/// <summary> /// Handles the InventoryStreamEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.InventoryStreamEventArgs" /> instance containing the event data.</param> private void hNur_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { try { NurApi hNur = sender as NurApi; if (e.data.tagsAdded > 0) { totalReads += e.data.tagsAdded; NurApi.TagStorage inventoriedTags = hNur.GetTagStorage(); int numberOfNewTag = tagListBox.UpdateTagList(inventoriedTags); beeperInventory.Beep(numberOfNewTag); WriteLogToFile(inventoriedTags); UpdateStatistics(inventoriedTags); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Program.appName); } // Restart if stopped by TimeLimit if (e.data.stopped && continueInventory) { StartInventory(hNur); } //Keepd device alive HHUtils.KeepDeviceAlive(); }
// Inventory stream event, this is called when there's tags available in NurApi tag storage void hNur_InventoryStreamReady(object sender, NurApi.InventoryStreamEventArgs e) { // Get NurApi object that generated the event NurApi hNur = sender as NurApi; try { // Copy tags from NurApi internal tag storage to application tag storage NurApi.TagStorage intTagStorage = hNur.GetTagStorage(); lock (intTagStorage) { SendMessage(string.Format("Reader: {0}, Tags: {1}", hNur.GetReaderInfo().altSerial, intTagStorage.Count)); // Clear NurApi internal tag storage hNur.ClearTags(); } if (e.data.stopped) { // Start streaming again if stopped hNur.StartInventoryStream(); } } catch (Exception ex) { // Handle error SendMessage(ex.Message); } }
private static void HNur_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { try { if (e.data.tagsAdded > 0) { NurApi.TagStorage tags = hNur.GetTagStorage(); foreach (NurApi.Tag tag in tags) { //have we seen this tag yet? if (!inventoryResults.Contains(tag.GetEpcString())) { inventoryResults.Add(tag.GetEpcString()); if (client != null) { client.PublishMessage("nurapisample/epc", System.Text.Encoding.ASCII.GetBytes(tag.GetEpcString())); } } } } //if streaming stopped, restart it if (e.data.stopped) { hNur.StartInventoryStream(); } } catch (Exception ex) { Console.WriteLine("Something went wrong during inventory stream event [" + ex.Message + "]"); } }
/// <summary> /// Handles the InventoryStreamEvent event of the hNur control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.InventoryStreamEventArgs"/> instance containing the event data.</param> void hNur_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { try { NurApi hNur = sender as NurApi; if (e.data.tagsAdded > 0) { NurApi.TagStorage inventoriedTags = hNur.GetTagStorage(); int numberOfNewTag = nxpTagListView.UpdateTagList(inventoriedTags); //beeperInventory.Beep(numberOfNewTag); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Program.appName); } // Restart if stopped by TimeLimit if (e.data.stopped && continueInventory) { StartPsfInventory(); } //Keepd device alive HHUtils.KeepDeviceAlive(); }
// Inventory stream event, this is called when there's tags available in NurApi tag storage void hNur_InventoryStreamReady(object sender, NurApi.InventoryStreamEventArgs e) { try { // Copy tags from NurApi internal tag storage to application tag storage foreach (NurApi.Tag tag in hNur.GetTagStorage()) { if (tags.AddTag(tag)) { // New unique tag added listBox1.Items.Add(tag.GetEpcString()); } } // Clear NurApi internal tag storage hNur.ClearTags(); if (e.data.stopped && running) { // Start streaming again if stopped hNur.StartInventoryStream(); } } catch (Exception ex) { // Handle error listBox1.Items.Add(ex.Message); } }
void hNur_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { NurApi hNur = sender as NurApi; string eventString = string.Format("{0:N0}: InvStream: Tags {1}, Rounds {2}, Q {3}", e.timestamp, e.data.tagsAdded, e.data.roundsDone, e.data.Q ); AddToEventList(eventString); }
// This gets called when new tags arrives void nur_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { AddTagsToList(nur.GetTagStorage()); if (e.data.stopped && streaming) { // Restart streaming try { nur.StartInventoryStream(); } catch { } // Ignore error.. } }
private void NurApi_InventoryStreamEvent(object sender, NurApi.InventoryStreamEventArgs e) { // Update stats UpdateStats(e.data); // Update unique tags if (UpdateInventoriedTags()) { // New tag(s) found. set time mTagsFoundInTime = ((double)mInventoryStart.ElapsedMilliseconds / 1000.0); } // Restart stream if needed if (mStreamRunning && e.data.stopped) { App.NurApi.StartInventoryStream(); } }
// Inventory stream event, this is called when there's tags available in NurApi tag storage void hNur_InventoryStreamReady(object sender, NurApi.InventoryStreamEventArgs e) { try { // Copy tags from NurApi internal tag storage to application tag storage NurApi.TagStorage intTagStorage = hNur.GetTagStorage(); lock (intTagStorage) { for (int i = 0; i < intTagStorage.Count; i++) { NurApi.Tag tag; if (tags.AddTag(intTagStorage[i], out tag)) { // Add new unique tag added int index = listBox1.Items.Add(string.Format("EPC: {0}, ANT: {1}, RSSI: {2}", tag.GetEpcString(), tag.antennaId, tag.rssi)); tag.userData = index; } else { // Update current tag int index = (int)tag.userData; listBox1.Items[index] = string.Format("EPC: {0}, ANT: {1}, RSSI: {2}", tag.GetEpcString(), tag.antennaId, tag.rssi); } } // Clear NurApi internal tag storage hNur.ClearTags(); } if (e.data.stopped && running) { // Start streaming again if stopped hNur.StartInventoryStream(); } } catch (Exception ex) { // Handle error listBox1.Items.Add(ex.Message); } }
private void InventoryStreamEventHandler(object sender, NurApi.InventoryStreamEventArgs e) { try { //Only what we do here is to take count of readed tags. //Real app do much more... tags = myNur.GetTagStorage(); tagCount = tags.Count; totalInvRounds++; myNur.ClearTags(); if (e.data.stopped) { //Start again if stopped. myNur.StartInventoryStream(); } } catch { //Some problems. Stop all and exit from this thread. Stop(); } }