Exemple #1
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            bool found = false;
            int  cnt;

            lock (TagInfoList)
            {
                string EPC       = info.epc.ToString();
                string LogStatus = "";
                string T1Status  = "";
                string T2Status  = "";
                string BStatus   = "";

                switch (info.Bank2Data[4] & 0x03)
                {
                case 0:
                case 2:
                    LogStatus = "Stop";
                    break;

                case 1:
                    LogStatus = "Recording";
                    break;

                case 3:
                    LogStatus = "Error";
                    break;
                }

                //if ((tagdata[e.info.pc.EPCLength + 10] & 0x02) != 0)
                if ((info.Bank2Data[8] & 0x02) != 0)
                {
                    T1Status = "Fail";
                }
                else
                {
                    T1Status = "OK";
                }

                if ((info.Bank2Data[8] & 0x04) != 0)
                {
                    T2Status = "Fail";
                }
                else
                {
                    T2Status = "OK";
                }

                if ((info.Bank2Data[0] & 0x8000) != 0)
                {
                    BStatus = "Fail";
                }
                else
                {
                    BStatus = "OK";
                }

                for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                {
                    if (TagInfoList[cnt].EPC == EPC)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    TagInfoList[cnt].LogStatus = LogStatus;
                    TagInfoList[cnt].T1        = T1Status;
                    TagInfoList[cnt].T2        = T2Status;
                    TagInfoList[cnt].B         = BStatus;
                }
                else
                {
                    MacduraTagInfoViewModel item = new MacduraTagInfoViewModel();

                    item.EPC       = EPC;
                    item.LogStatus = LogStatus;
                    item.T1        = T1Status;
                    item.T2        = T2Status;
                    item.B         = BStatus;

                    TagInfoList.Insert(0, item);
                }
            }
        }
Exemple #2
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;
                int cnt;

                if (BleMvxApplication._rfMicro_Power == 4 && BleMvxApplication._config.RFID_PowerSequencing_NumberofPower != 0)
                {
                    currentPower = (BleMvxApplication._config.RFID_PowerSequencing_Level[info.antennaPort] / 10).ToString("0.0") + "dB";
                    RaisePropertyChanged(() => currentPower);
                }

                lock (TagInfoList)
                {
                    UInt16 ocRSSI;
                    UInt16 sensorCode;
                    UInt16 temp;

                    sensorCode = (UInt16)(info.Bank1Data[0] & 0x1ff); // address c
                    ocRSSI     = info.Bank1Data[1];                   // address d
                    temp       = info.Bank1Data[2];                   // address e

                    for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                    {
                        if (TagInfoList[cnt].EPC == info.epc.ToString())
                        {
                            TagInfoList[cnt].OCRSSI    = ocRSSI;
                            TagInfoList[cnt].RSSIColor = "Black";

                            if (ocRSSI >= BleMvxApplication._rfMicro_minOCRSSI && ocRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
                            {
                                TagInfoList[cnt].GOODOCRSSI = ocRSSI.ToString();

                                //BleMvxApplication._rfMicro_SensorType // 0 = Sensor code, 1 = Temp
                                //BleMvxApplication._rfMicro_SensorUnit // 0=code, 1=f, 2=c, 3=%

                                switch (BleMvxApplication._rfMicro_SensorType)
                                {
                                case 0:
                                    if (BleMvxApplication._rfMicro_TagType == 1 && sensorCode >= 5 && sensorCode <= 490)
                                    {
                                        double SensorAvgValue;
                                        TagInfoList[cnt].SucessCount++;

                                        SensorAvgValue = sensorCode;

                                        switch (BleMvxApplication._rfMicro_SensorUnit)
                                        {
                                        case 1:         // RAW
                                            {
                                                TagInfoList[cnt].SensorAvgValue = sensorCode.ToString();
                                            }
                                            break;

                                        case 4:         // Range Allocation
                                            {
                                                if (sensorCode >= BleMvxApplication._rfMicro_WetDryThresholdValue)
                                                {
                                                    TagInfoList[cnt].SensorAvgValue = "Dry";
                                                }
                                                else
                                                {
                                                    TagInfoList[cnt].SensorAvgValue = "Wet";
                                                }
                                            }
                                            break;
                                        }

                                        if (TagInfoList[cnt].SucessCount >= 3)
                                        {
                                            switch (BleMvxApplication._rfMicro_thresholdComparison)
                                            {
                                            case 0:         // >
                                                if (SensorAvgValue > BleMvxApplication._rfMicro_thresholdValue)
                                                {
                                                    TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
                                                }
                                                else
                                                {
                                                    TagInfoList[cnt].valueColor = "Green";
                                                }
                                                break;

                                            default:         // <
                                                if (SensorAvgValue < BleMvxApplication._rfMicro_thresholdValue)
                                                {
                                                    TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
                                                }
                                                else
                                                {
                                                    TagInfoList[cnt].valueColor = "Green";
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    break;

                                default:
                                    if (temp >= 1300 && temp <= 3500)
                                    {
                                        double SensorAvgValue;
                                        TagInfoList[cnt].SucessCount++;
                                        UInt64 caldata = (UInt64)(((UInt64)info.Bank2Data[0] << 48) | ((UInt64)info.Bank2Data[1] << 32) | ((UInt64)info.Bank2Data[2] << 16) | ((UInt64)info.Bank2Data[3]));

                                        if (caldata == 0)
                                        {
                                            TagInfoList[cnt].SensorAvgValue = "NoCalData";
                                        }
                                        else
                                        {
                                            switch (BleMvxApplication._rfMicro_SensorUnit)
                                            {
                                            case 0:         // code
                                                TagInfoList[cnt]._sensorValueSum += temp;
                                                SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
                                                TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
                                                break;

                                            case 2:         // F
                                                TagInfoList[cnt]._sensorValueSum += getTempF(temp, caldata);
                                                SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
                                                TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
                                                break;

                                            default:         // C
                                                TagInfoList[cnt]._sensorValueSum += getTempC(temp, caldata);
                                                SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
                                                TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
                                                break;
                                            }

                                            if (TagInfoList[cnt].SucessCount >= 3)
                                            {
                                                switch (BleMvxApplication._rfMicro_thresholdComparison)
                                                {
                                                case 0:         // >
                                                    if (SensorAvgValue > BleMvxApplication._rfMicro_thresholdValue)
                                                    {
                                                        TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
                                                    }
                                                    else
                                                    {
                                                        TagInfoList[cnt].valueColor = "Green";
                                                    }
                                                    break;

                                                default:         // <
                                                    if (SensorAvgValue < BleMvxApplication._rfMicro_thresholdValue)
                                                    {
                                                        TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
                                                    }
                                                    else
                                                    {
                                                        TagInfoList[cnt].valueColor = "Green";
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                TagInfoList[cnt].RSSIColor = "Red";
                            }

                            found = true;
                            break;
                        }
                    }

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

                        item.EPC      = info.epc.ToString();
                        item.NickName = GetNickName(item.EPC);
                        if (item.NickName != "")
                        {
                            item.DisplayName = item.NickName;
                        }
                        else
                        {
                            item.DisplayName = item.EPC;
                        }
                        item.OCRSSI          = ocRSSI;
                        item.SucessCount     = 0;
                        item._sensorValueSum = 0;
                        item.SensorAvgValue  = "";
                        item.GOODOCRSSI      = "";
                        item.RSSIColor       = "Black";
                        item.valueColor      = "Black";

                        if (ocRSSI >= BleMvxApplication._rfMicro_minOCRSSI && ocRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
                        {
                            item.GOODOCRSSI = ocRSSI.ToString();

                            //BleMvxApplication._rfMicro_SensorType // 0 = Sensor code, 1 = Temp
                            //BleMvxApplication._rfMicro_SensorUnit //0=code, 1=f, 2=c, 3=%

                            switch (BleMvxApplication._rfMicro_SensorType)
                            {
                            case 0:
                                if (sensorCode >= 5 && sensorCode <= 490)
                                {
                                    item.SucessCount++;

                                    switch (BleMvxApplication._rfMicro_SensorUnit)
                                    {
                                    case 1:
                                        item.SensorAvgValue = sensorCode.ToString();
                                        break;

                                    default:
                                        if (sensorCode >= BleMvxApplication._rfMicro_WetDryThresholdValue)
                                        {
                                            item.SensorAvgValue = "Dry";
                                        }
                                        else
                                        {
                                            item.SensorAvgValue = "Wet";
                                        }
                                        break;
                                    }
                                }
                                break;

                            default:
                                if (temp >= 1300 && temp <= 3500)
                                {
                                    item.SucessCount++;
                                    UInt64 caldata = (UInt64)(((UInt64)info.Bank2Data[0] << 48) | ((UInt64)info.Bank2Data[1] << 32) | ((UInt64)info.Bank2Data[2] << 16) | ((UInt64)info.Bank2Data[3]));

                                    if (caldata == 0)
                                    {
                                        item.SensorAvgValue = "NoCalData";
                                    }
                                    else
                                    {
                                        switch (BleMvxApplication._rfMicro_SensorUnit)
                                        {
                                        case 0:         // code
                                            item._sensorValueSum = temp;
                                            item.SensorAvgValue  = item._sensorValueSum.ToString();
                                            break;

                                        case 2:         // F
                                            item._sensorValueSum = getTempF(temp, caldata);
                                            item.SensorAvgValue  = Math.Round(item._sensorValueSum, 2).ToString();
                                            break;

                                        default:         // C
                                            item._sensorValueSum = getTempC(temp, caldata);
                                            item.SensorAvgValue  = Math.Round(item._sensorValueSum, 2).ToString();
                                            break;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        else
                        {
                            item.RSSIColor = "Red";
                        }

                        TagInfoList.Insert(0, item);

                        _newTagFound = true;

                        Trace.Message("EPC Data = {0}", item.EPC);
                    }
                }
            });
        }
Exemple #3
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
                        }
                    }
                }
            });
        }
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            bool found = false;
            int  cnt;

            if (info.Bank1Data == null)
            {
                return;
            }

            if (info.Bank1Data.Length != 4)
            {
                return;
            }

            if (((info.Bank1Data[0] >> 12) != 0x0f) || ((info.Bank1Data[1] >> 12) != 0x0f))
            {
                return;
            }

            lock (TagInfoList)
            {
                //string EPC = info.epc.ToString().Substring(0, 16);
                string EPC      = info.epc.ToString();
                UInt16 version  = (UInt16)((info.Bank1Data[3] >> 12) & 0x0f);
                int    SEN_DATA = ((info.Bank1Data[0] & 0xfff) << 12) | (info.Bank1Data[1] & 0xfff);

                for (cnt = 0; cnt < TagInfoList.Count; cnt++)
                {
                    if (TagInfoList[cnt].EPC.Substring(0, 16) == EPC.Substring(0, 16))
                    {
                        found = true;
                        TagInfoList[cnt].EPC  = EPC;
                        TagInfoList[cnt].RSSI = info.rssi.ToString("#");
                        if (version == 0x00 || version == 0x01)
                        {
                            TagInfoList[cnt].Temp = "0.00";
                            TagInfoList[cnt].Temp = LTU1Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString("#.##");
                            //TagInfoList[cnt].Temp = LTU1Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString();
                        }
                        else if (version == 0x02)
                        {
                            TagInfoList[cnt].Temp = LTU2Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString("#.##");
                            //TagInfoList[cnt].Temp = LTU2Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString();
                        }
                        else
                        {
                            TagInfoList[cnt].Temp = "ERR";
                        }
                        break;
                    }
                }

                if (!found)
                {
                    var sensorValue = info.epc.ToUshorts();
                    CTESIUSTempTagInfoViewModel item = new CTESIUSTempTagInfoViewModel();

                    item.EPC  = EPC;
                    item.RSSI = info.rssi.ToString("#");
                    if (version == 0x00 || version == 0x01)
                    {
                        item.Temp = LTU1Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString("#.##");
                    }
                    else if (version == 0x02)
                    {
                        item.Temp = LTU2Temp(SEN_DATA, (Int16)(info.Bank1Data[2])).ToString("#.##");
                    }
                    else
                    {
                        item.Temp = "ERR";
                    }

                    TagInfoList.Insert(0, item);
                }
            }
        }