///// TAG HANDLER //// /// <summary> /// GUI Tag Handler for RFID Reader. /// Call for each tag seen. /// Pass in a null if no tags seen. /// </summary> /// <param name="appendToTop">A new tag. Null = no tags seen.</param> public void HandleTagReceived(MyTag tag) { string data = ""; if (tag.GetAccessResultData().Length > 0) data = " Data = " + tag.GetAccessResultData(); //AppendToMainTextBox("EPC = " + tag.GetEpcID() + " Count: " + tag.GetCount() + data); // Update Tag Stats HandleTagStats(tag); // Handle Atten Step Tester //if (readerMgr.getCurrentMode() == ReaderManager.GuiModes.AttenuatorTest) // HandleAttenTestStats(tag); // this is intentionally broke for now.... switch (tag.GetTagType()) { case TagType.WISP_ACCELEROMETER: HandleAccelTagStats(tag); break; case TagType.WISP_TEMPERATURE: HandleTemperatureTag(tag); break; case TagType.WISP_SOC: HandleSOCTag(tag); break; default: HandleCommercialTag(tag); // no action for now... // this could be commercial tags, etc. break; } }
private void ParseTag(MyTag tag) { bool foundTag = false; int id = -1; int count; int rowIdx; string idstr = ""; // Look for the tag for (rowIdx = 0; rowIdx < tagStatsDataGridView.Rows.Count; rowIdx++) { idstr = (string)(tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.SERIAL_NUM].Value); try { id = Convert.ToInt32(idstr); } catch(Exception e) { Trace.WriteLine("exception: " + e.ToString()); } if (tag != null && id == tag.GetSerialNumber()) { foundTag = true; break; } } // Update the info if (foundTag) { // Update Count count = Convert.ToInt32(tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.COUNT].Value); count += tag.GetCount(); tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.COUNT].Value = count; tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.SENSOR_TYPE].Value = tag.GetTagTypeName(); tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.LAST_SEEN].Value = System.DateTime.Now.ToString(); tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.TX_COUNTER].Value = tag.GetPacketCounter().ToString(); tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.EPC].Value = tag.GetEpcID().ToString(); tagStatsDataGridView.Rows[rowIdx].Cells[(int)StatColumnIdx.DATA].Value = tag.GetAccessResultData(); } else // add tag { string[] newRow = new string[(int)StatColumnIdx.ENUM_MAX_IDX]; newRow[(int)StatColumnIdx.SERIAL_NUM] = tag.GetSerialNumber().ToString(); newRow[(int)StatColumnIdx.HW_REV] = tag.GetHardwareRev(); newRow[(int)StatColumnIdx.SENSOR_TYPE] = tag.GetTagTypeName(); newRow[(int)StatColumnIdx.COUNT] = tag.GetCount().ToString(); newRow[(int)StatColumnIdx.LAST_SEEN] = System.DateTime.Now.ToString(); newRow[(int)StatColumnIdx.TX_COUNTER] = tag.GetPacketCounter().ToString(); newRow[(int)StatColumnIdx.EPC] = tag.GetEpcID().ToString(); newRow[(int)StatColumnIdx.DATA] = tag.GetAccessResultData().ToString(); tagStatsDataGridView.Rows.Add(newRow); Trace.WriteLine("Stats Added New Tag: " + tag.GetSerialNumber().ToString()); } // resize columns - this kills performance :( // button added instead. // tagStatsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }
private string WriteSensorData(MyTag tag) { string temp = ""; switch (tag.GetTagType()) { case TagType.WISP_ACCELEROMETER: temp = temp + ""; temp = temp + tag.GetAccel("x"); temp = temp + "\t"; temp = temp + tag.GetAccel("y"); temp = temp + "\t"; temp = temp + tag.GetAccel("z"); break; case TagType.WISP_TEMPERATURE: temp = temp + "Temp= "; temp = temp + tag.GetTemperature(); break; case TagType.WISP_SOC: if (tag.GetAccessResultData().Length > 0) { int[] data = tag.GetSOCData(); for (int i = 0; i < data.Length; i++) { temp = temp + "ADC,"; temp = temp + data[i] + ","; temp = temp + "temp,"; temp = temp + tag.socFilteredTemperature + ","; } } break; default: // no action for now... // this could be commercial tags, etc. break; } return temp; }