Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onDataReceive - event of object PmOpcClientData

Description:
The event fires after receiving the data from the OPC server.

The calling procedure of this event depends on the setup of "onDataReceive" event configurator. It is recommended to use the "A = call the event for all registered variables (in this object and also in other PmData objects)" setting.

Parameters:
pMe(Object) Reference to the Promotic object where the event rises.
pEvent(Object) A referrence to object describing detailed information about the specific event.
pEvent.Items - (Array) The property is set only if the "onDataReceive" event configurator is set to:
- "A = call the event for all registered variables (in this object and also in other PmData objects)".

Then each item of this array represents the "data extension ExtOpcClient object" of the variable that is defined either in this PmOpcClientData object or in another PmData object.

- "B = calling for the whole group of received variables - only for variables defined in this object (obsolete)".

Then each item of this array represents the "variable Var object" that is defined in this PmOpcClientData. Variables in other PmData objects (that have the ExtOpcClient data extension) are not processed here.

In both cases, if for example 10 data items are simultaneously received from the OPC server then the event is triggered only once and there are these 10 items in this array.

pEvent.VarName - (String) Data item name. The property is set only if the "onDataReceive" event configurator is set to "C = calling for each variable separately - only for variables defined in this object (obsolete)".

For example if 10 data items are received from the OPC server, then the event is fired for each item of the array and the name of the item is in pEvent.VarName.

pEvent.Reason - (Long) Reason of the receipt.
0 - Receipt from the automatic update. I.e. if the Update from server at server change configurator is set to.
1 - After calling the Read method.
2 - After calling the Refresh method.
Note:
Fireing of this event can even be emulated in the INFO system when the local menu is opened on the 1.page (by the right mouse button) while viewing this object. See permission PmRoot > Permissions > InfoEdit.
Example:
In the "onDataReceive" event configurator there is "A = call the event for all registered variables (in this object and also in other PmData objects)". We will report following information about the received data items into the Debug_info item of the INFO system:
Dim i,u
u = UBound(pEvent.Items)
Pm.Debug "OPC onDataReceive: Count=" & (u+1) & ", Reason=" & pEvent.Reason
For i=0 To u
  Pm.Debug " Name=" & pEvent.Items(i).Var.Name
  Pm.Debug " Value=" & pEvent.Items(i).Var.Value
  Pm.Debug " Quality=" & pEvent.Items(i).Var.Quality
  Pm.Debug " ItemId=" & pEvent.Items(i).ItemId
Next
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice