Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Connect - method of object tvTrend

Description:
Connection of the tvTrend object to the data source (to a variable in the PmTrend object).
Syntax:
Connect(nType As Long, vServer As Variant, vGroup As Variant, vItem As Variant, sParam As String, [vUser As Variant], [vPassword As Variant]) As Boolean
Calling:
b = oTrend.Connect(nType, vServer, vGroup, vItem, sParam) 'Server does not require the permissions checking.
b = oTrend.Connect(nType, vServer, vGroup, vItem, sParam, vUser, vPassword) 'Server require the permissions checking.
Parameters:
nType(Long) Connection type
0 - vServer, vGroup, vItem parameters are not taken into account and instead of them the connection is made according to setting the ConnectionType, ConnectionServer, ConnectionGroup, ConnectionItem, ConnectionUser, ConnectionPassword properties.
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 http 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 configurator PmWebFolder > WebFolder > Web component identifier or the configurator PmTrend > Web Server > Web component identifier 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 server value in the configurator PmTrend > Trend > Group ID identifier.
If nType=2 and at the same time the trend item in the vServer parameter is:
- value of the configurator PmWebFolder > WebFolder > Web component identifier, then the value of this parameter needs to be set, for example, to the string "group1", where group1 is value of the configurator PmTrend > Trend > Group ID identifier.
- value of the configurator PmTrend > Web Server > Web component identifier, 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 in the page PmTrend > Data.
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". The meaning of these strings is minimum, maximum, unit, color and name respectively. These values are transfered by a method from the data item in the page PmTrend > Data and set for 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 when the trends server requires checking the access by the user and the password, see setting the user and the password in the page PmRoot > Trends.

The vUser parameter needn't be entered if the parameter nType=1 or 0 and the property ConnetionType=1, that is the Connect method is connected to the local server.

vPassword[optional] (Variant) User password. It is entered only when 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 on the page PmRoot > Trends.

The vPassword parameter needn't be entered if the parameter nType=1 or 0 and the property ConnetionType=1, that is the Connect method is connected to the local server.

Return Values:
true - Connection passed successfully
false - Error in the connection
Note:

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 page PmRoot > Trends and the vUser, vPassword parameters can be used.

After the method successfully completed, any move in the time axis or the explicit calling the TrendsView.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:
Connection to the trends server, the PmWebFolder object in this server, trends (on the address "http://computer/trends") is the identifier of ther Web component on the WebFolder page.
Dim bConnect, oTrend
Set oTrend = oTView.Trends("t1")
If Not oTrend Is Nothing Then
  bConnect = oTrend.Connect(2, "http://computer/trends", "group1", "a1", "")
  If bConnect Then
     'OK
  End If
End If
Example2:
Connection to the trends server, the PmTrend folder in this server, historical1 (on the address "http://computer/historical1") is the identifier of ther Web component on the Web Server page.
Dim bConnect, oTrend
Set oTrend = oTView.Trends("t1")
If Not oTrend Is Nothing Then
  bConnect = oTrend.Connect(2, "http://computer/historical1", "", "a1", "")
  If bConnect Then
     'OK
  End If
End If
Example3:
Dim bConnect, oTrend
Set oTrend = oTView.Trends("t1")
If Not oTrend Is Nothing Then
  bConnect = oTrend.Connect(1, "local", "group1", "a1", "")
  If bConnect Then
     'OK
  End If
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice