Promotic
WikipediaLinkedInYoutubeTwitterFacebook

GetCfg - method of object PmgTrendViewer

Description:
Returns current values of configuration data of the viewer and displayed treds.
Syntax:
String GetCfg(String sFilter, String sCfgTitle)
Calling:
sCfg = oTView.GetCfg(sFilter, 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 the tvTrend objects without data points
"TrendsNoConnect;" - Save only the configuration of the tvTrend objects without data points and parameters of the 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 the 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 length of viewer time axis.
sCfgTitle(String) User-defined configuration name. Saves into read data (tag <cfgtitle>). If the configuration is displayed in configuration list (by LoadCfg), then the user-defined configuration name is also displayed. Empty string ("") means that the configuration has no user-defined name.
Return Values:
The method returns String containing the complete requested configuration. The configuration data is saved as XML. It can be edited by any text editor and re-read into the viewer by the LoadCfg method.
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 activated 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.9 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice