Beispiel #1
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            //InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
                    string epcstr = info.epc.ToString();

                    try
                    {
                        TagInfoListSpeedup.Add(epcstr, TagInfoList.Count);

                        TagInfoViewModel item = new TagInfoViewModel();

                        item.timeOfRead = DateTime.Now;
                        item.EPC        = info.epc.ToString();
                        item.Bank1Data  = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data  = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI       = info.rssi;
                        //item.Phase = info.phase;
                        //item.Channel = (byte)info.freqChannel;
                        item.PC = info.pc.ToUshorts()[0];

                        //TagInfoList.Add(item);
                        TagInfoList.Insert(0, item);

                        _newtagCount4BeepSound++;
                        _newtagCount4Vibration++;

                        Trace.Message("EPC Data = {0}", item.EPC);

                        //_newTag = true;
                    }
                    catch (Exception ex)
                    {
                        int index;

                        if (TagInfoListSpeedup.TryGetValue(epcstr, out index))
                        {
                            index = TagInfoList.Count - index;
                            index--;

                            TagInfoList[index].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[index].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[index].RSSI      = info.rssi;
                        }
                        else
                        {
                            // error found epc
                        }
                    }
                }
            }//);
        }
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
                    for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                    {
                        if (TagInfoList[cnt].EPC == info.epc.ToString())
                        {
                            if (BleMvxApplication._reader.rfid.Options.TagRanging.multibanks >= 1 && TagInfoList[cnt].Bank1Data != CSLibrary.Tools.Hex.ToString(info.Bank1Data))
                            {
                                continue;
                            }

                            if (BleMvxApplication._reader.rfid.Options.TagRanging.multibanks == 2 && TagInfoList[cnt].Bank2Data != CSLibrary.Tools.Hex.ToString(info.Bank2Data))
                            {
                                continue;
                            }

                            TagInfoList[cnt].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[cnt].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[cnt].RSSI      = info.rssi;

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        TagInfoViewModel item = new TagInfoViewModel();

                        item.EPC       = info.epc.ToString();
                        item.Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI      = info.rssi;
                        item.PC        = info.pc.ToUshorts()[0];

                        TagInfoList.Insert(0, item);

                        _newTagFound = true;

                        Trace.Message("EPC Data = {0}", item.EPC);

                        _newTag = true;
                    }
                }
            });
        }
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
                    for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                    {
                        if (TagInfoList[cnt].EPC == info.epc.ToString())
                        {
                            TagInfoList[cnt].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[cnt].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[cnt].RSSI      = info.rssi;
                            TagInfoList[cnt].Phase     = info.phase;
                            TagInfoList[cnt].Channel   = ActiveFrequencyList[(byte)info.freqChannel].ToString();

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        TagInfoViewModel item = new TagInfoViewModel();

                        item.EPC       = info.epc.ToString();
                        item.Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI      = info.rssi;
                        item.Phase     = info.phase;
                        if (info.freqChannel < ActiveFrequencyList.Length)
                        {
                            item.Channel = ActiveFrequencyList[(byte)info.freqChannel].ToString();
                        }
                        item.PC = info.pc.ToUshorts()[0];

                        //TagInfoList.Add(item);
                        TagInfoList.Insert(0, item);

                        _newTagFound = true;

                        Trace.Message("EPC Data = {0}", item.EPC);

                        _newTag = true;
                    }
                }
            });
        }
Beispiel #4
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
#if not_binarysearch
                    for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                    {
                        if (TagInfoList[cnt].EPC == info.epc.ToString())
                        {
                            TagInfoList[cnt].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[cnt].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[cnt].RSSI      = info.rssi;
                            //TagInfoList[cnt].Phase = info.phase;
                            //TagInfoList[cnt].Channel = (byte)info.freqChannel;

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        TagInfoViewModel item = new TagInfoViewModel();

                        item.timeOfRead = DateTime.Now;
                        item.EPC        = info.epc.ToString();
                        item.Bank1Data  = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data  = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI       = info.rssi;
                        //item.Phase = info.phase;
                        //item.Channel = (byte)info.freqChannel;
                        item.PC = info.pc.ToUshorts()[0];

                        //TagInfoList.Add(item);
                        TagInfoList.Insert(0, item);

                        _newTagFound = true;

                        Trace.Message("EPC Data = {0}", item.EPC);

                        _newTag = true;
                    }
#else
                    string epcstr = info.epc.ToString();

                    try
                    {
                        TagInfoListSpeedup.Add(epcstr, TagInfoList.Count);

                        RFMicroTagInfoViewModel item = new RFMicroTagInfoViewModel();
                        item.RSSIColor      = "Black";
                        item.valueColor     = "Black";
                        item.DisplayName    = info.epc.ToString();
                        item.SensorAvgValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                        item.OCRSSI         = info.Bank2Data[3];
                        item.SucessCount    = 1;

                        item.EPC        = "";
                        item.GOODOCRSSI = "";
                        item.NickName   = "";

                        TagInfoList.Insert(0, item);

                        _newtagCount4BeepSound++;
                        _newtagCount4Vibration++;
                        _newTagPerSecond++;

                        Trace.Message("EPC Data = {0}", item.EPC);
                    }
                    catch (Exception ex)
                    {
                        int index;

                        if (TagInfoListSpeedup.TryGetValue(epcstr, out index))
                        {
                            index = TagInfoList.Count - index;
                            index--;

                            TagInfoList[index].SensorAvgValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                            TagInfoList[index].OCRSSI         = info.Bank2Data[3];
                            TagInfoList[index].SucessCount++;
                        }
                        else
                        {
                            // error found epc
                        }
                    }
#endif
                }
            });
        }
Beispiel #5
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
                    string epcstr = info.epc.ToString();

                    try
                    {
                        TagInfoListSpeedup.Add(epcstr, TagInfoList.Count);

                        TagInfoViewModel item = new TagInfoViewModel();

                        item.timeOfRead = DateTime.Now;
                        item.EPC        = info.epc.ToString();
                        item.Bank1Data  = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data  = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI       = info.rssi;
                        //item.Phase = info.phase;
                        //item.Channel = (byte)info.freqChannel;
                        item.PC = info.pc.ToUshorts()[0];

                        //TagInfoList.Add(item);
                        TagInfoList.Insert(0, item);
                        var dto = this.fromServer.Where(e => e.RfId.Equals(item.EPC, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                        if (dto != null)
                        {
                            this.Items.Add(dto);
                        }


                        _newtagCount4BeepSound++;
                        _newtagCount4Vibration++;
                        _newTagPerSecond++;



                        //_newTag = true;
                    }
                    catch (Exception ex)
                    {
                        int index;

                        if (TagInfoListSpeedup.TryGetValue(epcstr, out index))
                        {
                            index = TagInfoList.Count - index;
                            index--;

                            TagInfoList[index].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[index].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[index].RSSI      = info.rssi;
                        }
                        else
                        {
                            // error found epc
                        }
                    }
                }
            });
        }