AdsReadVarConnectEx
Creates a fixed connection between a Visual Basic variable and a data item from an ADS device.
object.AdsReadVarConnectEx(nIndexOffset As String,
nRefreshType As ADSOCXTRANSMODE,
nCycleTime As Long,
phConnect As Long
hUser As Variant
) As Long
Parameter
adsVarName
[in] Name of the ADS variable
nRefreshType
[in] Type of data exchange between VB variable and ADS variable (see the ADSOCXTRANSMODE data type)
nCycleTime
[in] Read cycle in ms
phConnect
[out] Contains a unique handle for the connection that has been established (this is not the handle of the ADS variable!).
hUser
[in] Optional: This value is passed when the AdsReadConnectUpdateEx() event is called.
Return value
See ADS error codes
Comments
If the connection to an ADS variable is no longer required, it should be released using the AdsDisconnectEx() method. If only certain specific values are required in a form, the connection should only be created when the form is loaded, and should be released again when the form is closed.
Note on PLC: Ensure that Symbol download is enabled in PLC Control under Project / Options / TwinCAT. You will find more detailed information in the PLC Control manual.
The method's first parameter is composed of the POE name and the PLC variable that is to be addressed. If, for instance, the variable 'SPSVar1' from the function 'Funk1' is to be accessed, then 'Funk1.SPSVar1' must be supplied as the first parameter. When global variables are being accessed, the POE name is omitted, as, for instance, in '.SPSGlobVar'. The parameter adsVarName does not distinguish between upper and lower case letters.
Note on NC: Symbol download must be enabled for each axis in the System Manager. This can be specified in the configuration dialog for the axis under General. The 'Create symbols' box must be checked. See System Manager manual.
The symbolic names of the individual NC parameters have a fixed specification, and can be found in the NC documentation.
Note for use under Borland Delphi: When calling the associated event function AdsReadConnectUpdateEx() the OleVariant parameters are not passed to the Delphi application correctly. The method AdsReadVarConnectEx2() with its associated event function AdsReadConnectUpdateEx2() provides the same functionality as the AdsReadVarConnectEx/AdsReadConnectUpdateEx method. Please use this method/event in Delphi applications. In Visual Basic applications both methods can be used.