Promotic

GetCfg - method of the PmgTrendViewer object

Description:
Returns current values of configuration data of the viewer and displayed trends.
Syntax:
String GetCfg(String sFilter, String sCfgTitle)
Parameters:
sFilter(String) Specifies which of the viewer properties are saved into the configuration data.
The individual values can be concatenated. Example: "View;Trends;TimeMinMax;".
"View;" - Save the viewer appearance apart the tvTrend objects and apart the time of the left and right edge of the viewer.
"Trends;" - Save only the configuration of tvTrend objects without data points
"TrendsNoConnect;" - Save only the configuration of tvTrend objects without data points and without parameters of connection. The connection parameters are specified by the ConnectionType, ConnectionServer, ConnectionGroup and ConnectionItem properties of the tvTrend object. This option is suitable for generating the configuration file for printing. Note! If some of the following trend properties (for example tvTrend.Name, tvTrend.Unit, tvTrend.ValueMin, tvTrend.ValueMax or tvGraph.Color), contains the $default flag indicating reading the value from server), then the flag will be replaced by the real value that was read (cannot be read without the connection).
"TrendsData;" - Save only data points currently read by the viewer of the tvTrend object without the configuration of this object. This option is suitable for generating the configuration file for printing.
"TimeMinMax;" - Save the time of the left and right edge of the viewer.
"TimeZoom;" - Save only the time axis length of the viewer.
sCfgTitle(String) User-defined configuration name. Saves into read data (<cfgtitle> tag). If the configuration is displayed in configuration list (by the LoadCfg method), then the user-defined configuration name is also displayed. Empty string ("") means that the configuration has no user-defined name.
Return value:
The method returns String containing the complete requested configuration. The configuration data is saved in the XML format. It can be edited by any text editor and re-read to the viewer by the LoadCfg method.
Note:
This method is also functional in Web panels.
Example:
The example of saving trend configuration from the viewer to the server. The trend viewer may run on local application (on the server) or on a Web browser type client (Chrome, Firefox, Edge, InternetExplorer ...), but the configuration is alway saved to the server (contrary to the SaveCfg method that saves the data locally).
The example is divided into:
- the script (JavaScript or VBScript) that is started in the panel from another Pmg object (e.g. PmgButton)
- the script on the server in designer's method of the panel named "SaveTrendCfg"
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../AxTrendsView");
var sCfg = oTView.GetCfg("Trends;TimeZoom;", "");
if (Pm.IsValid(sCfg))
{
if (pMe.PmPanel.Methods.SaveTrendCfg("SaveCfg.tg", sCfg))
{
Pm.MessageBox("Message OK", "Configuration file saved");
}
else
{
Pm.MessageBox("Message Error", "Configuration file NOT saved");
}
}
And the script in designer's method of the panel "SaveTrendCfg" with parameters sFile and sCfg (VBScript syntax). The user test for $ADMIN is a security measure that allows only the application administrator to save configurations to the server.
VBScriptSelect and copy to clipboard

If pContext.User.TestInGroup("$ADMIN") Then
pResult = Pm.FileTextWrite("#cfg:" & sFile, sCfg, "mode:new;charset:utf-8;")
Else
pResult = false
End If

History:
Pm8.02.11: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.