Beispiel #1
0
        ///// 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;
            }
        }
Beispiel #2
0
 // Helper method to connect Reader to MainForm
 public void HandleTagReceived(MyTag tag)
 {
     if (tag == null)
     {
         // todo - some gui display thing
         //AppendToMainTextBox("No Tags Seen");
     }
     else if (IsInventoryRunning())  // if reader is running
     {
         handleTags.HandleTagReceived(tag);
         channel_index = Convert.ToInt32(tag.GetFrequency());
         if (channel_index == last_channel_index)
         {
             tagInfo.rssi[channel_index - 1] = tagInfo.rssi[channel_index - 1] + Convert.ToInt32(tag.GetRSSI());
             channel_counter = channel_counter + 1;
         }
         else
         {
             if (channel_counter != 0)
             {
                 tagInfo.rssi[last_channel_index - 1] = tagInfo.rssi[last_channel_index - 1] / channel_counter;
                 tagInfo.rssi[channel_index - 1]      = Convert.ToInt32(tag.GetRSSI());
                 channel_counter    = 1;
                 last_channel_index = channel_index;
             }
             else
             {
                 tagInfo.rssi[channel_index - 1] = Convert.ToInt32(tag.GetRSSI());
                 channel_counter    = 1;
                 last_channel_index = channel_index;
             }
         }
     }
 }
Beispiel #3
0
 // Adds a new element to the FIFO
 public void AddLast(MyTag data)
 {
     if(data != null)
     {
        if(dataQ.Count >= this.maxSize)
        {
            dataQ.Dequeue();
        }
         dataQ.Enqueue(data);
     }
 }
Beispiel #4
0
 // Helper method to connect Reader to MainForm
 public void HandleTagReceived(MyTag tag)
 {
     if (tag == null)
     {
         // todo - some gui display thing
         //AppendToMainTextBox("No Tags Seen");
     }
     else if (IsInventoryRunning())  // if reader is running
     {
         handleTags.HandleTagReceived(tag);
     }
 }
 // Helper method to connect Reader to MainForm
 public void HandleTagReceived(MyTag tag) 
 {
     if (tag == null)
     {
         // todo - some gui display thing
         //AppendToMainTextBox("No Tags Seen");
     }
     else if (IsInventoryRunning())  // if reader is running
     {
         handleTags.HandleTagReceived(tag);
     }
 }
Beispiel #6
0
        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;
        }
Beispiel #7
0
 private void HandleTagStats(MyTag t)
 {
     tagCount += t.GetCount();
     lock (newTags)
     {
         newTags.Add(t);
     }
 }
Beispiel #8
0
        private void HandleSOCTag(MyTag tag)
        {
            tag.SetSOCVersion(SOCVersion);

            int[] SOCValues = tag.GetSOCData();
            // store current value
            if (SOCValues.Length > 0)
                SOCValue = SOCValues[0];
            // add all the new values to the graph.
            for (int i = 0; i < SOCValues.Length; i++)
            {
                SOCFilteredValue = SOCFilteredValue * SOCFilterAlpha + SOCValues[i] * (1 - SOCFilterAlpha);
            }

            SOCTemperature = Math.Round(SOCFilteredValue * SOCSlope + SOCIntercept, 3);
            
            double valToPlot;
            if (socPlotTemp) valToPlot = SOCTemperature;
            else valToPlot = SOCFilteredValue;

            lock (SOCData)
            {
                // add new point to the graph.
                SOCData.Add(new PointPair(SOCReportNumber++, valToPlot));

                // keep graph data from getting too big, or performance degrades.
                if (SOCData.Count > 1000)
                    SOCData.RemoveAt(0);
            }

            tag.socFilteredValue = SOCFilteredValue; // for logging, etc.
            tag.socFilteredTemperature = SOCTemperature;
        }
Beispiel #9
0
 private void HandleCommercialTag(MyTag tag)
 {
     // Assume commercial tag is intended for bink-bonk application
     if (binkBonkCallback.isBinkBonkOpen())
     {
         binkBonkCallback.handleEPC(tag.GetEpcID());
     }
 }
Beispiel #10
0
 private void HandleTemperatureTag(MyTag t)
 {
     temperatureCelsius = t.GetTemperature();
     temperatureSource = t.GetTemperatureSensor();
     hasNewTempData = true;
 }
Beispiel #11
0
        private void HandleAccelTagStats(MyTag tag)
        {
            double alpha = accelInfo.alpha;
            // Get value from filter

            // todo this causes exception

            
            if (accelInfo.filterChkd)
            {
                //alpha = tbarLPFilter.Value;
                alpha = alpha / 100.0;
                if (alpha > 1 || alpha < 0)
                {
                    alpha = 0.2;
                    Trace.WriteLine("alpha out of bounds");
                }
            }
            else
            {
                alpha = 0.0;
            }
             

            double xac, yac, zac;
            // First work with the scaled values
            xac = tag.GetAccel("x");
            yac = tag.GetAccel("y");
            zac = tag.GetAccel("z");

            currentX = currentX * alpha + xac * (1 - alpha);
            currentY = currentY * alpha + yac * (1 - alpha);
            currentZ = currentZ * alpha + zac * (1 - alpha);

            // Now work with the raw adc values
            xac = tag.GetRawAccel("x");
            yac = tag.GetRawAccel("y");
            zac = tag.GetRawAccel("z");

            if (xac > xMax) xMax = xac;
            if (yac > yMax) yMax = yac;
            if (zac > zMax) zMax = zac;

            if (xac < xMin) xMin = xac;
            if (yac < yMin) yMin = yac;
            if (zac < zMin) zMin = zac;

            deltaX = xMax - xMin;
            deltaY = yMax - yMin;
            deltaZ = zMax - zMin;
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 // Helper method to connect Reader to MainForm
 public void HandleTagReceived(MyTag tag)
 {
     if (tag == null)
     {
         // todo - some gui display thing
         //AppendToMainTextBox("No Tags Seen");
     }
     else if (IsInventoryRunning())  // if reader is running
     {
         handleTags.HandleTagReceived(tag);
         channel_index = Convert.ToInt32(tag.GetFrequency());
         if (channel_index == last_channel_index)
         {
             tagInfo.rssi[channel_index - 1] = tagInfo.rssi[channel_index - 1] + Convert.ToInt32(tag.GetRSSI());
             channel_counter = channel_counter + 1;
         }
         else {
             if (channel_counter != 0)
             {
                 tagInfo.rssi[last_channel_index - 1] = tagInfo.rssi[last_channel_index - 1] / channel_counter;
                 tagInfo.rssi[channel_index - 1] = Convert.ToInt32(tag.GetRSSI());
                 channel_counter = 1;
                 last_channel_index = channel_index;
             }
             else {
                 tagInfo.rssi[channel_index - 1] = Convert.ToInt32(tag.GetRSSI());
                 channel_counter = 1;
                 last_channel_index = channel_index;
             }
         }
     }
 }
 public void HandleTagReceived(MyTag t)
 {
     tagCount += t.GetCount();
 }
Beispiel #15
0
        private string ParseTag(MSG_RO_ACCESS_REPORT msg, string result, int i)
        {
            if (msg.TagReportData[i].EPCParameter.Count > 0)
            {
                string epcInfo = "";
                Type   t       = msg.TagReportData[i].EPCParameter[0].GetType();
                if (t.Name == "PARAM_EPC_96")
                {
                    epcInfo = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                }
                else if (t.Name == "PARAM_EPCData")
                {
                    epcInfo = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                }
                else
                {
                    throw new Exception("ParseTag method couldn't resolve EPC type");
                }

                string time         = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string count        = (msg.TagReportData[i].TagSeenCount).ToString();
                string accessSpecID = (msg.TagReportData[i].AccessSpecID).ToString();
                string firstSeen    = (msg.TagReportData[i].FirstSeenTimestampUTC).ToString();
                string lastSeen     = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string rssi         = (msg.TagReportData[i].PeakRSSI).ToString();
                string freq         = (msg.TagReportData[i].ChannelIndex).ToString();
                string mode         = readerMgr.GetReaderConfigMode();

                result = null;
                //Tag newTag = BuildTag(epcInfo);

                // extract information
                count = getRelevantInfoFromXML(count, 1);
                //accessSpecID = getRelevantInfoFromXML(accessSpecID, 1);
                time = getRelevantInfoFromXML(time, 1);
                rssi = getRelevantInfoFromXML(rssi, 1);
                freq = getRelevantInfoFromXML(freq, 1);

                string accessResultData = "";
                if (accessSpecID != "0")
                {
                    for (int j = 0; j < msg.TagReportData[i].AccessCommandOpSpecResult.Length; j++)
                    {
                        result = msg.TagReportData[i].AccessCommandOpSpecResult[0].ToString();
                        // MessageBox.Show(result); - evil - just keeps popping up!
                        // extract access result
                        if (result != null && result.Contains("Success"))
                        {
                            Type t2 = msg.TagReportData[i].AccessCommandOpSpecResult[0].GetType();
                            if (t2.Name == "PARAM_C1G2ReadOpSpecResult")
                            {
                                PARAM_C1G2ReadOpSpecResult accessResult;
                                accessResult = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[i].AccessCommandOpSpecResult[0]));
                                string marker = "<ReadData>";
                                int    start  = result.IndexOf(marker);
                                int    end    = result.IndexOf("<", start + 1);
                                accessResultData = result.Substring(start + marker.Length, end - marker.Length - start);
                            }
                        }
                    }
                }

                // Pass all this information to the GUI in a MyTag object.
                MyTag newTag = new MyTag(epcInfo, time, count, firstSeen, lastSeen, accessResultData, rssi, freq, mode);
                readerMgr.HandleTagReceived(newTag);
            }
            return(result);
        }
Beispiel #16
0
        private string ParseTag(MSG_RO_ACCESS_REPORT msg, string result, int i)
        {
            if (msg.TagReportData[i].EPCParameter.Count > 0)
            {
                string epcInfo = "";
                Type t = msg.TagReportData[i].EPCParameter[0].GetType();
                if (t.Name == "PARAM_EPC_96")
                    epcInfo = ((PARAM_EPC_96)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                else if (t.Name == "PARAM_EPCData")
                    epcInfo = ((PARAM_EPCData)(msg.TagReportData[i].EPCParameter[0])).EPC.ToHexString();
                else
                    throw new Exception("ParseTag method couldn't resolve EPC type");
 
                string time = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string count = (msg.TagReportData[i].TagSeenCount).ToString();
                string accessSpecID = (msg.TagReportData[i].AccessSpecID).ToString();
                string firstSeen = (msg.TagReportData[i].FirstSeenTimestampUTC).ToString();
                string lastSeen = (msg.TagReportData[i].LastSeenTimestampUTC).ToString();
                string rssi = (msg.TagReportData[i].PeakRSSI).ToString();
                string freq = (msg.TagReportData[i].ChannelIndex).ToString();

                result = null;
                //Tag newTag = BuildTag(epcInfo);

                // extract information
                count = getRelevantInfoFromXML(count, 1);
                //accessSpecID = getRelevantInfoFromXML(accessSpecID, 1);
                time = getRelevantInfoFromXML(time, 1);
                rssi = getRelevantInfoFromXML(rssi, 1);
                freq = getRelevantInfoFromXML(freq, 1);
                
                string accessResultData = "";
                if (accessSpecID != "0")
                {
                    for (int j = 0; j < msg.TagReportData[i].AccessCommandOpSpecResult.Length; j++)
                    {
                        result = msg.TagReportData[i].AccessCommandOpSpecResult[0].ToString();
                        // MessageBox.Show(result); - evil - just keeps popping up!
                        // extract access result
                        if (result != null && result.Contains("Success"))
                        {
                            Type t2 = msg.TagReportData[i].AccessCommandOpSpecResult[0].GetType();
                            if (t2.Name == "PARAM_C1G2ReadOpSpecResult")
                            {
                                PARAM_C1G2ReadOpSpecResult accessResult;
                                accessResult = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[i].AccessCommandOpSpecResult[0]));
                                string marker = "<ReadData>";
                                int start = result.IndexOf(marker);
                                int end = result.IndexOf("<", start + 1);
                                accessResultData = result.Substring(start + marker.Length, end - marker.Length - start);
                            }
                        }
                    }
                }

                // Pass all this information to the GUI in a MyTag object.
                MyTag newTag = new MyTag(epcInfo, time, count, firstSeen, lastSeen, accessResultData, rssi, freq);
                readerMgr.HandleTagReceived(newTag);

            }
            return result;
        }