Managing Events
The Application can register for one or more events so as to be notified of the same when it occurs. There are basically two main events.
ReadNotify– Notifies whenever read tag event occurs with read tag data as argument. By default, the event comes with tag data. If not required, we can disable using property AttachTagDataWithReadEvent.
StatusNotify– Notifies whenever status event occurs with status event data as argument.
| Event | Description |
|---|---|
| GPI_EVENT | A GPI event (state change from high to low, or low to high) has occurred on a GPI port. When this event is signaled, StatusEventData contains GPI Port and GPI Event that has occurred. |
| BUFFER_FULL_WARNING_EVENT | When the internal buffers are 90% full, this event will be signaled. |
| ANTENNA_EVENT | A particular Antenna has been Connected/Disconnected. When this event is signaled, StatusEventData contains Antenna and the Connection Status that has occurred. |
| INVENTORY_START_EVENT | Inventory Operation has started. In case of periodic trigger this event will be triggered for each period. |
| INVENTORY_STOP_EVENT | Inventory Operation has stopped. In case of periodic trigger this event will be triggered for each period. |
| ACCESS_START_EVENT | Access Operation has started. |
| ACCESS_STOP_EVENT | Access Operation has stopped. |
| DISCONNECTION_EVENT | Event notifying disconnection from the Reader. The Application can call Reconnect method periodically to attempt reconnection or call Disconnect method to cleanup and exit. |
| BUFFER_FULL_EVENT | When the internal buffers are 100% full, this event will be signaled and tags are discarded in FIFO manner. |
| NXP_EAS_ALARM_EVENT | This Event is generated when Reader finds a(NXP)tag with it's EAS System bit still set to true. |
| READER_EXCEPTION_EVENT | Event notifying that an exception has occurred in the Reader. When this event is signaled, StatusEventData.ReaderExceptionEventData.ReaderExceptionEventType can be called to know the reason for the exception which is coming as part of Events.StatusEventArgs. The Application can continue to use the connection if the reader renders is usable. |
| TEMPERATURE_ALARM_EVENT | When Temperature reaches Threshold level, this event will be generated. The event data contains source name (PA/Ambient), current Temperature and alarm Level (Low, High or Critical) |
// registering for read tag data notification
rfidApi.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
// ReadNotify Event comes without tag data
rfidApi.Events.AttachTagDataWithReadEvent = false;
// Read Notify handler
public void Events_ReadNotify(object sender, Events.ReadEventArgs e)
{
// fetch tags from the Dll by specifying the number of expected tags
Symbol.rfidApi.TagData[] myTags =
rfidApi.Actions.GetReadTags(100);
if (myTags != null)
{
for (int nIndex = 0; nIndex < myTags.Length; nIndex++)
{
if (myTags[nIndex].OpCode ==
ACCESS_OPERATION_CODE.ACCESS_OPERATION_NONE ||
(myTags[nIndex].OpCode ==
ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&
myTags[nIndex].OpStatus ==
ACCESS_OPERATION_STATUS.ACCESS_SUCCESS))
{
Console.WriteLine(myTags[nIndex].TagID);
if (myTags[nIndex].MemoryBankData != String.Empty)
Console.WriteLine(myTags[nIndex].MemoryBank.ToString() +
" : " + myTags[nIndex].MemoryBankData);
}
}
}
}
// Unregistering for read tag data notification
rfidApi.Events.ReadNotify -= new Events.ReadNotifyHandler(Events_ReadNotify);
// registering for status notification
rfidApi.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
// Subscribe required status notification
rfidApi.Events.NotifyInventoryStartEvent = true;
rfidApi.Events.NotifyInventoryStopEvent = true;
rfidApi.Events.NotifyGPIEvent = true;
rfidApi.Events.NotifyAntennaEvent = true;
rfidApi.Events.NotifyReaderDisconnectEvent = true;
// Status Notify handler
public void Events_StatusNotify(object sender, Events.StatusEventArgs e)
{
Console.WriteLine(e.StatusEventData.StatusEventType);
}
// Unregistering for status notification
rfidApi.Events.StatusNotify -= new Events.StatusNotifyHandler(Events_StatusNotify);