onDataReceive - event of object PmCommData

The event fires after receipt of data from communication.

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

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 for various objects depending on "onDataReceive" event configurator setup:
- "A = call for all registered variables (in this object and also in other PmData objects)".

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

- "B = call only for variables defined in this object (obsolete)".

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

In both cases if 10 data items are received simultaneously from communication then the event is called only once and there are these 10 items in the array.

pEvent.ErrorCount - (Long) The number of data items in the array pEvent.Items, that do not have the Quality property set to Good.
This event is not necessarily called simultaneously for all communicated variables. It is called based on the communication progress - for example if a message is received, containing only 5 variables, then the event is called and these 5 variables will be in pEvent.Items, and then when another message is received with additional variables, the event is called again, etc.
This event is triggered each time the system tries to get the values of the variables. It is triggered even so the whole communication procedure failed and no values were obtained - if so, the pEvent.ErrorCount value will be the same as 1+UBound(pEvent.Items).
Fireing of this event can even be emulated in the INFO system when the local menu is opened on the (by the right mouse button) while viewing this object. See permission PmRoot > Permissions > InfoEdit.
In the "onDataReceive" event configurator there is "A = call 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 "COMM onDataReceive: Count=" & (u+1) & ", ErrorCount=" & pEvent.ErrorCount
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
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice