Update cookies preferences
Promotic

LoadCfg - method of the PmgTrendViewer object

Description:
Loading configuration data to 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, [Function onComplete])
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 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, regardless of whether 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:/config.tg". See Example3.
"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/cfg.tg" must be entered in the parameter. See Example4.
"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 the 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.
onComplete[optional] (Function) The event function in the form function onComplete(ev) {};. The function will be called after loading the configuration file (asynchronous operation).
Parameters:
ev(Object) Reference to an object describing detailed information about the specific event.
Result - Result of executed operation.
true - successful loading
false - failed loading
Return value:
true - successful loading
false - failed loading
Note:
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.
Example1:
Reading the configuration from the file on the server. Opens a window with a list of saved configuration files. After confirming the selection, a window is displayed with the option to add to or replace the existing configuration.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
oTView.LoadCfg("input:#cfg:", 27, onLoadCfg);
function onLoadCfg(ev)
{
if (ev.Result)
{
oTView.ReadData();
oTView.Draw();
oTView.CursorTime = Pm.Time;
}
}
Example2:
Reading the configuration from the file on the server. Before calling the method, 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;
oTView.LoadCfg("serverfile.tg:mycfg.tg", 11, onLoadCfg);
function onLoadCfg(ev)
{
if (ev.Result)
{
oTView.ReadData();
oTView.Draw();
}
}
Example3:
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;
oTView.LoadCfg("file:c:/mycfg.tg", 11, onLoadCfg);
function onLoadCfg(ev)
{
if (ev.Result)
{
oTView.ReadData();
oTView.Draw();
}
}
Example4:
Reading the configuration from HTTP address. The trend viewer displays the trends from PROMOTIC application AP1. This trend viewer is either contained in another PROMOTIC application panel or in the Web panel displayed in the Web browser. It is necessary to load the configuration saved, for example in the cfg1.tg 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/cfg1.tg". Then the configuration can be loaded to the viewer:
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe;
oTView.LoadCfg("http://computerAP1/dir3/cfg1.tg", 11, onLoadCfg);
function onLoadCfg(ev)
{
if (ev.Result)
{
oTView.ReadData();
oTView.Draw();
}
}

History:
Pm9.00.26: New onComplete parameter with the result of the asynchronous operation.
Pm8.00.12: returns the true value even if "http:"
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

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