Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onDataReceive - event of object PmaCommGroup

Description:
The event is triggered 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 PmaData objects)" setting.

Parameters:
pMe(Object) Reference to the PmaComm object where the event rises.
pEvent(Object) Reference 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 PmaData objects)".

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

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

Then each item of this array represents the "variable object PmVar" that is defined in this PmaCommGroup object. Variables in other PmaData 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 triggered 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.
pEvent.Attr - (Long) Bit attribute.
1 - The first message was transmitted.
2 - The last message was transmitted. This signals that all communicated variables were received.
Note:
This event is not necessarily called (and usually is not 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 triggered and these 5 variables will be in pEvent.Items, and if another message is received with additional variables, then the event is triggered again, etc.

 
The event is triggered each time the communication message vith values is received.

Is triggered even if the whole communication procedure failed and no values were obtained - if so, then the pEvent.ErrorCount value will be the same as the number of items in pEvent.Items.

 
The value pEvent.Attr can be used to detect whether the message was the first or the last.

Example:

0 = This message is neither the first nor the last.
3 = This message transmitted all the variables at once so it is both the first and the last.
 
Calling this event can also be emulated in the INFO system when this object is being viewed and the "Actions" button is pressed. See "PmaRoot > Permissions > InfoEdit" permission.
Example:
The ""onDataReceive" event" configurator is set to "A = call for all registered variables (in this object and also in other PmaData objects)".

We will report following information about the received data items into the Debug_info item of the INFO system:

JavaScriptVBScriptSelect and copy to clipboard

var i;
var aItems = pEvent.Items;
var nItems = aItems.GetSize(1);
Pm.Debug("COMM onDataReceive: Size=" + nItems + ", ErrorCount=" + pEvent.ErrorCount);
for (i = 0; i < nItems; i++)
{
Pm.Debug("Name=" + aItems.GetItem(i).Var.Name);
Pm.Debug("Value=" + aItems.GetItem(i).Var.Value);
Pm.Debug("Quality=" + aItems.GetItem(i).Var.Quality);
Pm.Debug("ItemId=" + aItems.GetItem(i).ItemId);
}

History:
Pm9.00.02: New property pEvent.Attr that can be used to detect whether the message that triggered this event was the first or the last.
PROMOTIC 9.0.3 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice