Exemplo n.º 1
0
        public void Add(TagReadData addData)
        {
            lock (new Object())
            {
                string key = null;

                if (chkbxUniqueByData)
                {
                    if (true == chkbxShowFailedDataReads)
                    {
                        //key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                        // When CHECKED - Add the entry to the database. This will result in
                        // potentially two entries for every tag: one with the requested data and one without.
                        if (addData.Data.Length > 0)
                        {
                            key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                        }
                        else
                        {
                            key = addData.EpcString + "";
                        }
                    }
                    else if ((false == chkbxShowFailedDataReads) && (addData.Data.Length == 0))
                    {
                        // When UNCHECKED (default) - If the embedded read data fails (data.length==0) then don't add the entry to
                        // the database, thus it won't be displayed.
                        return;
                    }
                    else
                    {
                        key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                    }
                }
                else
                {
                    key = addData.EpcString;     //if only keying on EPCID
                }

                UniqueTagCounts = 0;
                TotalTagCounts  = 0;

                if (!EpcIndex.ContainsKey(key))
                {
                    TagReadRecord value = new TagReadRecord(addData);
                    value.SerialNumber = (uint)EpcIndex.Count + 1;
                    _tagList.Add(value);
                    EpcIndex.Add(key, value);
                    //Call this method to calculate total tag reads and unique tag read counts
                    UpdateTagCountTextBox(EpcIndex);
                }
                else
                {
                    EpcIndex[key].Update(addData);
                    UpdateTagCountTextBox(EpcIndex);
                }
            }
        }
Exemplo n.º 2
0
 //Calculate total tag reads and unique tag reads.
 public void UpdateTagCountTextBox(Dictionary <string, TagReadRecord> EpcIndex)
 {
     UniqueTagCounts += EpcIndex.Count;
     TagReadRecord[] dataRecord = new TagReadRecord[EpcIndex.Count];
     EpcIndex.Values.CopyTo(dataRecord, 0);
     TotalTagCounts = 0;
     for (int i = 0; i < dataRecord.Length; i++)
     {
         TotalTagCounts += dataRecord[i].ReadCount;
     }
 }
Exemplo n.º 3
0
        public void Add(TagReadData addData)
        {
            lock (new Object())
            {
                string key = null;

                if (tagdbSensorType == SensorType.Johar_106 || tagdbSensorType == SensorType.Johar_101)
                {
                    key = addData.EpcString.Substring(0, 4);
                    //Console.WriteLine("*** tagdb add key=" + key);
                }
                else
                {
                    if (chkbxUniqueByData)
                    {
                        if (true == chkbxShowFailedDataReads)
                        {
                            //key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                            // When CHECKED - Add the entry to the database. This will result in
                            // potentially two entries for every tag: one with the requested data and one without.
                            if (addData.Data.Length > 0)
                            {
                                key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                            }
                            else
                            {
                                key = addData.EpcString + "";
                            }
                        }
                        else if ((false == chkbxShowFailedDataReads) && (addData.Data.Length == 0))
                        {
                            // When UNCHECKED (default) - If the embedded read data fails (data.length==0) then don't add the entry to
                            // the database, thus it won't be displayed.
                            return;
                        }
                        else
                        {
                            key = addData.EpcString + ByteFormat.ToHex(addData.Data, "", " ");
                        }
                    }
                    else
                    {
                        key = addData.EpcString; //if only keying on EPCID
                    }
                }
                //if (chkbxUniqueByAntenna)
                //{
                //    key += addData.Antenna.ToString();
                //}
                //if (chkbxUniqueByFrequency)
                //{
                //    key += addData.Frequency.ToString();
                //}

                UniqueTagCounts = 0;
                TotalTagCounts  = 0;

                if (!EpcIndex.ContainsKey(key))
                {
                    TagReadRecord value = new TagReadRecord(addData);
                    value.SerialNumber  = (uint)EpcIndex.Count + 1;
                    value.SensorType    = tagdbSensorType;
                    value.SensorSubType = tagdbSensorSubType;
                    Console.WriteLine(string.Format("Sensor={0}, Sub={1}", tagdbSensorType, tagdbSensorSubType));

                    _tagList.Add(value);
                    EpcIndex.Add(key, value);
                    //Call this method to calculate total tag reads and unique tag read counts
                    UpdateTagCountTextBox(EpcIndex);
                    Console.WriteLine("tagdb add [" + key + "]");
                }
                else
                {
                    EpcIndex[key].SensorSubType = tagdbSensorSubType;
                    if (tagdbSensorType == SensorType.VBL)
                    {
                        if (tagdbSensorSubType == SensorSubType.VBL_TUNE)
                        {
                            if (EpcIndex[key].TuneValue.Trim().Equals(""))
                            {
                                EpcIndex[key].TuneValue = ByteFormat.ToHex(addData.Data, "", "");
                            }
                        }
                        else if (tagdbSensorSubType == SensorSubType.VBL_NValue)
                        {
                            EpcIndex[key].TemperatureCode = ByteFormat.ToHex(addData.Data, "", "");
                        }
                    }
                    if (tagdbSensorType == SensorType.RFMicronMagnusS3)
                    {
                        if (tagdbSensorSubType == SensorSubType.RFMicroMagnusS3_CalibratedCode)
                        {
                            if (EpcIndex[key].TuneValue.Trim().Equals(""))
                            {
                                EpcIndex[key].TuneValue = ByteFormat.ToHex(addData.Data, "", "");
                            }
                            else if (tagdbSensorSubType == SensorSubType.RFMicroMagnusS3_TemperatureCode)
                            {
                                EpcIndex[key].TemperatureCode = ByteFormat.ToHex(addData.Data, "", "");
                            }
                        }
                    }

                    EpcIndex[key].Update(addData); //ToDo update temperature
                    UpdateTagCountTextBox(EpcIndex);
                }
            }
        }