Promotic

Connect - method of the tvTrend object

Description:
Connection of the tvTrend object to data source (to the data extension ExtTrend into the PmaTrendGroup object).
Syntax:
Boolean Connect(Long nType, Variant vServer, Variant vGroup, Variant vItem, String sParam, [Variant vUser], [Variant vPassword])
Parameters:
nType(Long) Connection type
0 - vServer, vGroup, vItem parameters are not taken into account and instead of of them the connection is made according to setting the properties: ConnectionType, ConnectionServer, ConnectionGroup, ConnectionItem, ConnectionUser, ConnectionPassword.
1 - Local connection, the connection to the trend server in the same running PROMOTIC application. All parameters of the method are valid.
2 - Remote connection by the HTTP protocol, the data are sent in the XML format. All parameters of the method are valid.
vServer(Variant) Remote data source - server.
If nType=0, then the parameter is not taken into account.
If nType=1, then the value of this parameter must be set to the string "local".
If nType=2, then it is the URL address and the value of this parameter must be set by the following text: "http://computer/trend", where:
- computer is usually the name of the remote computer
- trend is the value of the "PmaWebFolder > WebFolder > Web component identifier" configurator or of the "PmaTrendGroup > Web server > Web component identifier" configurator in the application on the computer computer.
vGroup(Variant) Group in the remote data source - trends server (the ID of this group).
If nType=0, then the parameter is not taken into account.
If nType=1, then the value of this parameter needs to be set, for example, to the string "group1", where group1 is the value on the server in the "PmaTrendGroup > Trend > Trend group identifier" configurator.
If nType=2 and at the same time the trend item in the vServer parameter is:
- value of the "PmaWebFolder > WebFolder > Web component identifier" configurator,
then the value of this parameter needs to be set, for example, to the string "group1", where group1 is value of the "PmaTrendGroup > Trend > Trend group identifier" configurator.
- value of the "PmaTrendGroup > Web server > Web component identifier" configurator,
then the value of this parameter needs to be set to the empty string "".
vItem(Variant) Name of the variable in the group of the trends server. See variable names on the "PmaTrendGroup > Data" tab.
sParam(String) Connection parameters.
The "iniread=xxx" string is entered, where xxx string is any of min, max, unit, color, name strings, or combination separated by comma. For example "iniread=min,max,color".
These values are transferred by calling a method from data extension ExtTrend and set to the viewer.
If the parameter is not used, then it is necessary to set an empty string "".
vUser[optional] (Variant) User name.
It is entered only if the trends server requires checking the access by the user and the password, see setting the user and the password in the "Trends" configuration window.
The vUser parameter needn't be entered if parameter nType=1 or 0 and property ConnetionType=1, i.e. the Connect method is connected to the local server.
vPassword[optional] (Variant) User password.
It is entered only if the trends server requires checking the access by the user and the password, see setting the user and the password in the trends server - the configuration in the "Trends" configuration window.
The vPassword parameter needn't be entered if the parameter nType=1 or 0 and the property ConnetionType=1, i.e. the Connect method is connected to the local server.
Return value:
true - Connection passed successfully
false - Error in the connection
Note:
This method is also functional in Web panels.
 
It is possible to connect it to the local trend server that runs in the same application in which the viewer runs - in this case the access to the server is always guaranteed and the vUser, vPassword parameters are not used.
It is possible to connect to the remote PROMOTIC trend server. The access to the remote server can be checked, see the "Trends" configuration window and the vUser, vPassword parameters can be used.

After the method successfully completed, any move on the time axis or the explicit calling the PmgTrendViewer.ReadData method results in sending the request for the data to the connected server.
The connection is valid until the next calling the Connect method or to deleting the tvTrend object or to closing the viewer.
Example1:
Server does NOT require the permissions checking:
JavaScriptVBScriptSelect and copy to clipboard

var bTrend = oTrend.Connect(nType, vServer, vGroup, vItem, sParam);
Server require the permissions checking:
JavaScriptVBScriptSelect and copy to clipboard

var bTrend = oTrend.Connect(nType, vServer, vGroup, vItem, sParam, vUser, vPassword);
Example2:
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var oTrend = oTView.Trends("t1");
if (oTrend)
{
var bConnect = oTrend.Connect(1, "local", "group1", "a1", "");
if (bConnect)
{
// OK
}
}
Example3:
Connection to the trends server, to the PmaWebFolder object in this server.
The trends text (in the URL "http://computer/trends") is the identifier of the Web component on the "WebFolder" tab.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var oTrend = oTView.Trends("t1");
if (oTrend)
{
var bConnect = oTrend.Connect(2, "http://computer/trends", "group1", "a1", "");
if (bConnect)
{
// OK
}
}
Example4:
Connection to the trends server, to the PmaTrendGroup object in this server.
The historical1 text (in the URL "http://computer/historical1") is the identifier of the Web component on the "Web server" tab.
JavaScriptVBScriptSelect and copy to clipboard

var oTView = pMe.Items("../TrendView");
var oTrend = oTView.Trends("t1");
if (oTrend)
{
var bConnect = oTrend.Connect(2, "http://computer/historical1", "", "a1", "");
if (bConnect)
{
// OK
}
}
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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