Promotic
WikipediaLinkedInYoutubeTwitterFacebook

LoadCfg - method of the PmgTrendViewer object

Description:
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.

Syntax:
Boolean LoadCfg(String sCfg, Long nStyle)
Parameters:
sCfg(String) Source of the read configuration data.
"serverfile.tg:" - file on the server in the trend configuration folder (see the "Path to configuration groups" configurator), e.g. "serverfile.tg:config.tg".

Caution! The important fact is that this reference to the configuration file is valid for local application on the server 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 local application the file is read directly as file: and in the Web application as http:.

"file:" - Disk file, e.g. "file:c:/config.tg". 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:" - HTTP address, for example "http://computer/address/cfg.tg" must be entered in the parameter. See Example3.
"input:" - Selection from a 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 into the viewer. The viewer properties are always overwritten. The parameter specifies how to read the tvTrend objects in case 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
Note:

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 extension *.tg (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 the runtime mode 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.
Example1:
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("serverfile.tg:mycfg.tg", 11))
//.. configuration has been read
Example2:
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:/mycfg.tg", 11))
//.. configuration has been read
Example3:
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 "cfg1.tg". Let´s suppose that this file offers the application AP1 (this application is located on a network computer named "computerAP1") into the Web by the PmaWebDir object (Web component identifier of this object is "dir3") at HTTP address for example "http://computerAP1/dir3/cfg1.tg". Then the configuration can be loaded into the viewer:
JavaScriptVBScriptSelect and copy to clipboard

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

History:
Pm8.00.12: returns the true value even if "http:"
PROMOTIC 9.0.13 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