Promotic

SaveCfg - method of the PmgTrendViewer object

Description:
Saving current configuration data of the viewer.
Syntax:
Boolean SaveCfg(String sCfg, Long nStyle, String sFilter)
Parameters:
sCfg(String) Location for saving the configuration data. It is either:
"input:" - Selection from the list. Before saving the list of existing configurations is displayed. This allows to select existing file or create new file.
- If the trend viewer is in local panel on the server:
The configurations list is read from the folder defined after the "input:" text. The selected file will be saved there..
- If the trend viewer is in the Web browser:
The configurations list is read from the temporary storage of the Web browser. The selected file is saved into this temporary storage. In this case the string defined after the "input:" text is ignored.

Example: "input:#cfg:", see Example1.
"file:" - File on the disk. The configuration data will be saved into the specified file, that is defined after the "file:" text.
- If the trend viewer is in local panel on the server:
The file name is displayed including the complete file path..
- If the trend viewer is in the Web browser:
This option currently is not functional for Web browsers.

Example: "file:#cfg:config.tg", see Example2.
"string:" - Text string. In this case, the parameter is of the input/output type and the output contains the specified configuration data - a XML formatted text.
The "string:" value is obsolete and it is better to use the GetCfg method.
nStyle(Long) Specifies how the data have to be saved.
0 - Save always.
1 - If the file already exists, then a question is displayed whether the existing file to overwrite (if the answer is NO, then the configuration is not saved).
2 - If the file already exists, then the configuration is not saved.
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.
Return value:
Returns the success rate of saving. The false value means failed saving.
Note:
This method is also functional in Web panels.
 
The configuration data are saved in the XML format and consequentially they can be modified by any text editor and read backwards to the viewer by the LoadCfg method.
 
This method saves the configuration always on the computer where the trends are being viewed. It means that if the trend viewer runs on the client (Web browser Chrome, Firefox, Edge, InternetExplorer ...), then the configuration is saved into the temporary storage of such Web browser and therefore are not accessible by other clients. This method cannot save configurations on the server because there are no limiting mechanisms for user testing (to prevent someone from saving to the server).
The GetCfg method is designed for storing configurations to the server.
Example1:
Before saving a list of existing configurations is displayed. It is possible to select an existing file or create new file. Only the configuration of tvTrend objects displayed in the viewer are saved.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
oTView.SaveCfg("input:#cfg:", 1, "Trends;");
Example2:
Saving into the file on the disk. Only the configuration of tvTrend objects displayed in the viewer are saved.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
oTView.SaveCfg("file:#cfg:mycfg.tg", 0, "Trends;");

History:
Pm8.02.11: The "string:" value is obsolete and it is better to use the GetCfg method.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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