LoadCfg - method of the PmgTrendViewer object

Reading configuration data of the viewer.
The configuration data are created in the XML format either by calling the SaveCfg method or by calling the GetCfg method or 'manually', for example in the text editor.
Boolean LoadCfg(String sCfg, Long nStyle)
sCfg(String) Source of the read configuration data.
"" - file on the server in the trend configuration folder (see the "Path to configuration groups" configurator), e.g. "".
Caution! The important fact is that this reference to the configuration file is valid on the server in the running application and also for the client in the Web application. Therefore it is possible to use the same way of reading the configuration file, regardles if the application is local or Web. In the running application the file is read directly as file: and in the Web application as http:.
"file:" - Disk file, e.g. "file:c:/". See Example2.
"string:" - The parameter contains the configuration data themselves - a string in the XML format.
The configuration is read even if the string: is omited at the beginning of the parameter, but it is recommended to use the string:.
"http:" - URL address. For example "http://computer/address/" must be entered in the parameter. See Example3.
"input:" - Selection from the list.
In the list there are filenames of configurations saved in the #cfg: folder. (e.g. input:#cfg:).
If the configuration server has been defined (by the AddServer method with sPurpose="cfg") parameter, then the configuration groups from this server are also included in this list.
In the Web client there are additional options available:
- The configuration files saved locally in Web browser temporary storage by the SaveCfg method.
- Configuration groups from the Web panel server.
nStyle(Long) Specifies how the data have to be read to the viewer. The viewer properties are always overwritten. The parameter specifies how to read the tvTrend objects if the viewer has already created some tvTrend objects (i.e. it views some graphs) before calling the method.
6 - Existing tvTrend objects in the viewer are overwritten by the configuration data. If they don't exist, then new ones are created and filled up.
10 - Existing tvTrend objects are kept. New tvTrend objects are created and added.
11 - Existing tvTrend objects are removed. Then new tvTrend objects are created and added.
27 - If the tvTrend objects already exist in the viewer, then at first the window with the question whether to Remove the viewer content first (i.e. all trends), is displayed. Then new tvTrend objects are created and added.
Return values:
true - successful loading
false - failed loading
This method is also functional in Web panels.
The configuration data are represented by viewer text data using the XML language syntax, if saved to disk, then it is necessary to use a target file with the .tg extension (the *.tg extension is known by the PROMOTIC system thus able to work with the data stored in such files).

If the configuration data contains tvTrend objects with the data specifying a connection to the data sources - trend servers, then in runtime of the viewer the trend objects are connected to the data sources (to servers) after reading.

Every calling the method sets the properties LastCfgSrc, LastCfgTitle. A user name of the configuration group is set in the LastCfgTitle property. The line with the user name isn't created automatically with creation of the configuration file by calling the SaveCfg method, it is necessary to add a line with this user configurable name into the content of the configuration file manually, see the description of the LastCfgTitle property.
Reading the configuration from the file on the server. Before the method is called, the existing tvTrend objects are deleted and the configuration is read from the file on the server.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
if (oTView.LoadCfg("", 11))
// .. configuration has been read
Reading the configuration from the disk file. Before calling the method existing tvTrend objects are removed, the configuration from the file is read afterwards.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
if (oTView.LoadCfg("file:c:/", 11))
// .. configuration has been read
Reading the configuration from HTTP address. The trend viewer displays the trends from PROMOTIC application AP1. This trend viewer is contained in another PROMOTIC application panel or in the Web panel displayed in the Web browser. It is necessary to load the configuration saved in a configuration file, for example in the file. Let´s suppose that this file offers the application AP1 (this application is located on the computer named "computerAP1") to the Web by the PmaWebDir object (Web component identifier of this object is "dir3") at HTTP address for example "http://computerAP1/dir3/". Then the configuration can be loaded to the viewer:
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
if (oTView.LoadCfg("http://computerAP1/dir3/", 11))
// .. configuration has been read

Pm8.00.12: returns the value true even if "http:"
PROMOTIC 9.0.24 SCADA system documentation MICROSYS, spol. s r.o.

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