Exemple #1
0
 private void Reader_OnMessageNotificationReceived(AbstractReader reader, IReaderMessage msg)
 {
     if (msg.Status == MsgStatus.Success || msg is MsgActiveTagActive || msg is MsgActiveTagSleep)
     {
         if (msg is MsgTagInventory)
         {
             if (isStart_AutoPowerConfig && !isPause_AutoPowerConfig)
             {
                 if (this.OnAutoPowerConfigInventoryReceived != null)
                 {
                     MsgTagInventory msgTagInventory = msg as MsgTagInventory;
                     if (IsEnableAntenna || IsEnableRSSI)
                     {
                         msgTagInventory.ReceivedMessage.setAntennaAndRSSI(IsEnableAntenna, IsEnableRSSI);
                     }
                     this.OnAutoPowerConfigInventoryReceived(reader.ReaderName, msgTagInventory.ReceivedMessage.TagData);
                 }
             }
             else if (this.OnInventoryReceived != null)
             {
                 MsgTagInventory msgTagInventory2 = msg as MsgTagInventory;
                 if (msgTagInventory2.isRS485)
                 {
                     RS485Item[] rS485Items = RS485Items;
                     foreach (RS485Item rS485Item in rS485Items)
                     {
                         if (rS485Item.Address == msgTagInventory2.address)
                         {
                             if (rS485Item.IsEnableAntenna || rS485Item.IsEnableRSSI)
                             {
                                 msgTagInventory2.ReceivedMessage.setAntennaAndRSSI(IsEnableAntenna, IsEnableRSSI);
                             }
                             break;
                         }
                     }
                 }
                 else if (IsEnableAntenna || IsEnableRSSI)
                 {
                     msgTagInventory2.ReceivedMessage.setAntennaAndRSSI(IsEnableAntenna, IsEnableRSSI);
                 }
                 this.OnInventoryReceived(reader.ReaderName, msgTagInventory2.ReceivedMessage.TagData);
             }
         }
         if (msg is MsgTagRead && this.OnInventoryReceived != null)
         {
             MsgTagRead msgTagRead = msg as MsgTagRead;
             if (msgTagRead.isRS485)
             {
                 RS485Item[] rS485Items2 = RS485Items;
                 foreach (RS485Item rS485Item2 in rS485Items2)
                 {
                     if (rS485Item2.Address == msgTagRead.address)
                     {
                         if (rS485Item2.IsEnableAntenna || rS485Item2.IsEnableRSSI)
                         {
                             msgTagRead.ReceivedMessage.setAntennaAndRSSI(IsEnableAntenna, IsEnableRSSI);
                         }
                         break;
                     }
                 }
             }
             else if (IsEnableAntenna || IsEnableRSSI)
             {
                 msgTagRead.ReceivedMessage.setAntennaAndRSSI(IsEnableAntenna, IsEnableRSSI);
             }
             this.OnInventoryReceived(reader.ReaderName, msgTagRead.ReceivedMessage.TagData);
         }
         if (msg is MsgAlarmInfo_AccessControl && this.OnMsgAlarmInfo_AccessControl != null)
         {
             MsgAlarmInfo_AccessControl msgAlarmInfo_AccessControl = msg as MsgAlarmInfo_AccessControl;
             this.OnMsgAlarmInfo_AccessControl(reader.ReaderName, msgAlarmInfo_AccessControl.ReceivedMessage.TagData);
         }
         if (msg is MsgActiveTagInventory && this.OnActiveTagInventoryReceived != null)
         {
             MsgActiveTagInventory msgActiveTagInventory = msg as MsgActiveTagInventory;
             this.OnActiveTagInventoryReceived(reader.ReaderName, msgActiveTagInventory.ReceivedMessage.ActiveTagList);
         }
         if (msg is MsgActiveTagInventory2 && this.OnActiveTagInventoryReceived != null)
         {
             MsgActiveTagInventory2 msgActiveTagInventory2 = msg as MsgActiveTagInventory2;
             this.OnActiveTagInventoryReceived(reader.ReaderName, msgActiveTagInventory2.ReceivedMessage.ActiveTagList);
         }
         if (msg is MsgActiveTagActive && this.OnMsgActiveTagActiveReceivedHandle != null)
         {
             MsgActiveTagActive msg2 = msg as MsgActiveTagActive;
             this.OnMsgActiveTagActiveReceivedHandle(reader.ReaderName, msg2);
         }
         if (msg is MsgActiveTagSleep && this.OnMsgActiveTagSleepReceivedHandle != null)
         {
             MsgActiveTagSleep msg3 = msg as MsgActiveTagSleep;
             this.OnMsgActiveTagSleepReceivedHandle(reader.ReaderName, msg3);
         }
         if (msg is MsgFirmwareOnlineUpgrade && this.OnFirmwareOnlineUpgradeReceived != null)
         {
             MsgFirmwareOnlineUpgrade msgFirmwareOnlineUpgrade = msg as MsgFirmwareOnlineUpgrade;
             uint   frameAddress = msgFirmwareOnlineUpgrade.ReceivedMessage.FrameAddress;
             ushort total        = (ushort)(frameAddress >> 16);
             ushort rate         = (ushort)frameAddress;
             this.OnFirmwareOnlineUpgradeReceived(total, rate);
         }
         if (msg is MsgAppFirmwareOnlineUpgrade && this.OnFirmwareOnlineUpgradeReceived != null)
         {
             MsgAppFirmwareOnlineUpgrade msgAppFirmwareOnlineUpgrade = msg as MsgAppFirmwareOnlineUpgrade;
             uint   frameAddress2 = msgAppFirmwareOnlineUpgrade.ReceivedMessage.FrameAddress;
             ushort total2        = (ushort)(frameAddress2 >> 16);
             ushort rate2         = (ushort)frameAddress2;
             this.OnAppFirmwareOnlineUpgradeReceived(total2, rate2);
         }
         if (msg is MsgCtrlUpdata_YC001 && this.OnCtrlUpdata_YC001 != null)
         {
             MsgCtrlUpdata_YC001 msgCtrlUpdata_YC = msg as MsgCtrlUpdata_YC001;
             byte             ctrlBoardNO         = msgCtrlUpdata_YC.ReceivedMessage.CtrlBoardNO;
             IrTrigger[]      irStates            = msgCtrlUpdata_YC.ReceivedMessage.IrStates;
             SenssorTrigger[] senssorStates       = msgCtrlUpdata_YC.ReceivedMessage.SenssorStates;
             this.OnCtrlUpdata_YC001(ctrlBoardNO, irStates, senssorStates);
         }
         if (msg is MsgKeepAlive_YC001 && this.OnKeepAlive_YC001 != null)
         {
             this.OnKeepAlive_YC001();
         }
         if (msg is MsgKeepAlive)
         {
             if (keepAliveInterval == 0)
             {
                 MsgKeepAliveConfig msgKeepAliveConfig = new MsgKeepAliveConfig();
                 if (Send(msgKeepAliveConfig, 2000))
                 {
                     isEnableKeepAlive = msgKeepAliveConfig.ReceivedMessage.IsEnable;
                     keepAliveInterval = msgKeepAliveConfig.ReceivedMessage.Interval;
                 }
             }
             if (threadKeepAlive == null || !threadKeepAlive.IsAlive)
             {
                 threadKeepAlive = new Thread(threadKeepAliveMethod);
                 threadKeepAlive.Start();
             }
             dtKeepAlive = DateTime.Now;
         }
         if (msg is MsgSearchIp)
         {
             MsgSearchIp info = msg as MsgSearchIp;
             if (this.OnUdpSearchIpReceived != null)
             {
                 this.OnUdpSearchIpReceived(ReaderName, info);
             }
         }
     }
 }
Exemple #2
0
        private bool process(out string err)
        {
            bool flag = false;

            IsStop = false;
            err    = "";
            if (reader != null)
            {
                reader.isStart_AutoPowerConfig = true;
            }
            int  num   = 4;
            int  num2  = 4;
            byte power = scanPower;

            for (int i = 0; i < 3; i++)
            {
                MsgHubAntennaInfoConfig msgHubAntennaInfoConfig = new MsgHubAntennaInfoConfig();
                if (reader.Send(msgHubAntennaInfoConfig))
                {
                    num  = msgHubAntennaInfoConfig.ReceivedMessage.LayerAntennaCount;
                    flag = true;
                    break;
                }
                flag = false;
                err  = "获取每层天线数失败:" + msgHubAntennaInfoConfig.ErrorInfo.ErrMsg;
            }
            HabAntennaStatus habAntennaStatus = null;

            for (int j = 0; j < 3; j++)
            {
                MsgHubAntennaConfig msgHubAntennaConfig = new MsgHubAntennaConfig(curAntNO);
                if (reader.Send(msgHubAntennaConfig))
                {
                    habAntennaStatus = msgHubAntennaConfig.ReceivedMessage.PortInfo;
                    flag             = true;
                    break;
                }
                flag = false;
                err  = "获取天线启用状态失败:" + msgHubAntennaConfig.ErrorInfo.ErrMsg;
            }
            if (!flag)
            {
                return(false);
            }
            flag = false;
            for (int k = 0; k < 4; k++)
            {
                AntennaStatus[] antennas = habAntennaStatus.Antennas;
                foreach (AntennaStatus antennaStatus in antennas)
                {
                    if (antennaStatus.AntennaNO == k + 1 + (curLayerNO - 1) * 4)
                    {
                        antennaStatus.IsEnable = true;
                        break;
                    }
                }
            }
            for (int m = 0; m < 3; m++)
            {
                if (reader == null)
                {
                    break;
                }
                if (!reader.IsConnected)
                {
                    break;
                }
                MsgHubAntennaConfig msgHubAntennaConfig2 = new MsgHubAntennaConfig(habAntennaStatus);
                if (reader.Send(msgHubAntennaConfig2, 2000))
                {
                    flag = true;
                    break;
                }
                flag = false;
                err  = "设置天线启用状态失败:" + msgHubAntennaConfig2.ErrorInfo.ErrMsg;
            }
            if (flag)
            {
                flag = false;
                for (int n = 0; n < 3; n++)
                {
                    if (reader == null)
                    {
                        break;
                    }
                    if (!reader.IsConnected)
                    {
                        break;
                    }
                    MsgHubPowersConfig msgHubPowersConfig = new MsgHubPowersConfig(curAntNO, curLayerNO, preScanPower);
                    msgHubPowersConfig.msgBody[0] = 2;
                    if (reader.Send(msgHubPowersConfig, 2000))
                    {
                        flag = true;
                        if (err != "")
                        {
                            err = "";
                        }
                        break;
                    }
                    err  = "设置预读取功率错误: " + msgHubPowersConfig.ErrorInfo.ErrMsg;
                    flag = false;
                    if (PauseMethod(isSendMsg: false))
                    {
                        return(false);
                    }
                }
            }
            if (PauseMethod(isSendMsg: false))
            {
                return(false);
            }
            if (flag)
            {
                flag = false;
                MsgHubAntennaPortDwellTimeConfig msgHubAntennaPortDwellTimeConfig = new MsgHubAntennaPortDwellTimeConfig(curAntNO, (ushort)(preScanTime * 100 / num));
                for (int num3 = 0; num3 < 3; num3++)
                {
                    if (reader == null)
                    {
                        break;
                    }
                    if (!reader.IsConnected)
                    {
                        break;
                    }
                    if (reader.Send(msgHubAntennaPortDwellTimeConfig, 2000))
                    {
                        flag = true;
                        if (err != "")
                        {
                            err = "";
                        }
                        break;
                    }
                    err  = "设置预读驻留时间错误: " + msgHubAntennaPortDwellTimeConfig.ErrorInfo.ErrMsg;
                    flag = false;
                    if (PauseMethod(isSendMsg: false))
                    {
                        return(false);
                    }
                }
                if (PauseMethod(isSendMsg: true))
                {
                    return(false);
                }
                if (!flag)
                {
                    return(false);
                }
                flag = false;
                for (int num4 = 0; num4 < 3; num4++)
                {
                    if (reader == null)
                    {
                        break;
                    }
                    if (!reader.IsConnected)
                    {
                        break;
                    }
                    MsgTagInventory msgTagInventory = new MsgTagInventory();
                    msgTagInventory.isAutoPowerConft = true;
                    if (reader.Send(msgTagInventory))
                    {
                        flag = true;
                        if (err != "")
                        {
                            err = "";
                        }
                        break;
                    }
                    err  = "发送预读盘存指令错误: " + msgTagInventory.ErrorInfo.ErrMsg;
                    flag = false;
                }
                if (flag)
                {
                    for (int num5 = 0; num5 < preScanTime; num5++)
                    {
                        Thread.Sleep(100);
                        if (reader == null || reader.isPause_AutoPowerConfig)
                        {
                            break;
                        }
                    }
                    Thread.Sleep(150);
                    for (int num6 = 0; num6 < 3; num6++)
                    {
                        if (reader == null)
                        {
                            break;
                        }
                        if (!reader.IsConnected)
                        {
                            break;
                        }
                        MsgPowerOff msgPowerOff = new MsgPowerOff();
                        if (reader.Send(msgPowerOff))
                        {
                            flag = true;
                            if (err != "")
                            {
                                err = "";
                            }
                            break;
                        }
                        err  = "发送预读停止指令错误: " + msgPowerOff.ErrorInfo.ErrMsg;
                        flag = false;
                    }
                    for (int num7 = 0; num7 < 5; num7++)
                    {
                        Thread.Sleep(100);
                        if (reader == null || reader.isPause_AutoPowerConfig)
                        {
                            break;
                        }
                    }
                    MsgHubAntennaPortDwellTimeConfig msgHubAntennaPortDwellTimeConfig2 = new MsgHubAntennaPortDwellTimeConfig(curAntNO, 0);
                    for (int num8 = 0; num8 < 3; num8++)
                    {
                        if (reader == null)
                        {
                            break;
                        }
                        if (!reader.IsConnected)
                        {
                            break;
                        }
                        if (reader.Send(msgHubAntennaPortDwellTimeConfig2, 2000))
                        {
                            flag = true;
                            if (err != "")
                            {
                                err = "";
                            }
                            break;
                        }
                        err  = "设置驻留时间(0)错误: " + msgHubAntennaPortDwellTimeConfig2.ErrorInfo.ErrMsg;
                        flag = false;
                        if (PauseMethod(isSendMsg: true))
                        {
                            return(false);
                        }
                    }
                    switch (flag)
                    {
                    case false:
                        return(false);

                    default:
                    {
                        flag = false;
                        bool flag2 = false;
                        for (int num9 = 0; num9 < 4; num9++)
                        {
                            byte b = (byte)((curLayerNO - 1) * 4 + (num9 + 1));
                            if (!preReadPort.Contains(b))
                            {
                                AntennaStatus[] antennas2 = habAntennaStatus.Antennas;
                                foreach (AntennaStatus antennaStatus2 in antennas2)
                                {
                                    if (antennaStatus2.AntennaNO == b)
                                    {
                                        antennaStatus2.IsEnable = false;
                                        num2--;
                                        flag2 = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (flag2)
                        {
                            for (int num11 = 0; num11 < 3; num11++)
                            {
                                if (reader == null)
                                {
                                    break;
                                }
                                if (!reader.IsConnected)
                                {
                                    break;
                                }
                                MsgHubAntennaConfig msgHubAntennaConfig3 = new MsgHubAntennaConfig(habAntennaStatus);
                                if (reader.Send(msgHubAntennaConfig3, 2000))
                                {
                                    flag = true;
                                    break;
                                }
                                flag = false;
                                err  = "设置天线启用状态失败:" + msgHubAntennaConfig3.ErrorInfo.ErrMsg;
                            }
                        }
                        else
                        {
                            flag = true;
                        }
                        if (!flag)
                        {
                            return(false);
                        }
                        flag = false;
                        for (int num12 = 0; num12 < 3; num12++)
                        {
                            if (reader == null)
                            {
                                break;
                            }
                            if (!reader.IsConnected)
                            {
                                break;
                            }
                            MsgHubPowersConfig msgHubPowersConfig2 = new MsgHubPowersConfig(curAntNO, curLayerNO, power);
                            msgHubPowersConfig2.msgBody[0] = 2;
                            if (reader.Send(msgHubPowersConfig2, 2000))
                            {
                                flag = true;
                                if (err != "")
                                {
                                    err = "";
                                }
                                break;
                            }
                            err  = "设置参考功率错误: " + msgHubPowersConfig2.ErrorInfo.ErrMsg;
                            flag = false;
                            if (PauseMethod(isSendMsg: false))
                            {
                                return(false);
                            }
                        }
                        if (PauseMethod(isSendMsg: false))
                        {
                            return(false);
                        }
                        if (flag && num2 > 0)
                        {
                            flag = false;
                            for (int num13 = 0; num13 < 3; num13++)
                            {
                                if (reader == null)
                                {
                                    break;
                                }
                                if (!reader.IsConnected)
                                {
                                    break;
                                }
                                MsgHubAntennaPortDwellTimeConfig msgHubAntennaPortDwellTimeConfig3 = new MsgHubAntennaPortDwellTimeConfig(curAntNO, (ushort)(ScanTime * 100 / num));
                                if (reader.Send(msgHubAntennaPortDwellTimeConfig3, 2000))
                                {
                                    flag = true;
                                    if (err != "")
                                    {
                                        err = "";
                                    }
                                    break;
                                }
                                err  = "设置驻留时间错误: " + msgHubAntennaPortDwellTimeConfig3.ErrorInfo.ErrMsg;
                                flag = false;
                                if (PauseMethod(isSendMsg: false))
                                {
                                    return(false);
                                }
                            }
                            if (PauseMethod(isSendMsg: true))
                            {
                                return(false);
                            }
                            if (!flag)
                            {
                                return(false);
                            }
                            flag = false;
                            for (int num14 = 0; num14 < 3; num14++)
                            {
                                if (reader == null)
                                {
                                    break;
                                }
                                if (!reader.IsConnected)
                                {
                                    break;
                                }
                                MsgTagInventory msgTagInventory2 = new MsgTagInventory();
                                msgTagInventory2.isAutoPowerConft = true;
                                if (reader.Send(msgTagInventory2))
                                {
                                    flag = true;
                                    if (err != "")
                                    {
                                        err = "";
                                    }
                                    break;
                                }
                                err  = "发送盘存指令错误: " + msgTagInventory2.ErrorInfo.ErrMsg;
                                flag = false;
                            }
                            if (!flag)
                            {
                                return(false);
                            }
                            int num15 = ScanTime * num2 / 4;
                            if (ScanTime * num2 % 4 != 0)
                            {
                                num15++;
                            }
                            for (int num16 = 0; num16 < num15; num16++)
                            {
                                Thread.Sleep(100);
                                if (reader == null || reader.isPause_AutoPowerConfig)
                                {
                                    break;
                                }
                            }
                            Thread.Sleep(150);
                            for (int num17 = 0; num17 < 3; num17++)
                            {
                                if (reader == null)
                                {
                                    break;
                                }
                                if (!reader.IsConnected)
                                {
                                    break;
                                }
                                MsgPowerOff msgPowerOff2 = new MsgPowerOff();
                                if (reader.Send(msgPowerOff2))
                                {
                                    flag = true;
                                    if (err != "")
                                    {
                                        err = "";
                                    }
                                    break;
                                }
                                err  = "发送停止指令错误: " + msgPowerOff2.ErrorInfo.ErrMsg;
                                flag = false;
                            }
                            for (int num18 = 0; num18 < 5; num18++)
                            {
                                Thread.Sleep(100);
                                if (reader == null || reader.isPause_AutoPowerConfig)
                                {
                                    break;
                                }
                            }
                            for (int num19 = 0; num19 < 3; num19++)
                            {
                                if (reader == null)
                                {
                                    break;
                                }
                                if (!reader.IsConnected)
                                {
                                    break;
                                }
                                MsgHubAntennaPortDwellTimeConfig msgHubAntennaPortDwellTimeConfig4 = new MsgHubAntennaPortDwellTimeConfig(curAntNO, 0);
                                if (reader.Send(msgHubAntennaPortDwellTimeConfig4, 2000))
                                {
                                    flag = true;
                                    if (err != "")
                                    {
                                        err = "";
                                    }
                                    break;
                                }
                                err  = "设置驻留时间(0)错误: " + msgHubAntennaPortDwellTimeConfig4.ErrorInfo.ErrMsg;
                                flag = false;
                                if (PauseMethod(isSendMsg: true))
                                {
                                    return(false);
                                }
                            }
                        }
                        else if (!flag)
                        {
                            return(false);
                        }
                        if (!flag)
                        {
                            return(false);
                        }
                        power = getPowerValue();
                        if (!flag)
                        {
                            return(false);
                        }
                        flag = false;
                        for (int num20 = 0; num20 < 3; num20++)
                        {
                            if (reader == null)
                            {
                                break;
                            }
                            if (!reader.IsConnected)
                            {
                                break;
                            }
                            MsgHubPowersConfig msgHubPowersConfig3 = new MsgHubPowersConfig(curAntNO, curLayerNO, power);
                            if (reader.Send(msgHubPowersConfig3, 2000))
                            {
                                flag = true;
                                if (err != "")
                                {
                                    err = "";
                                }
                                if (this.OnAutoPowerConfig != null)
                                {
                                    this.OnAutoPowerConfig(curAntNO, curLayerNO, tagList.Count, power);
                                }
                                break;
                            }
                            err  = "设置参考功率错误: " + msgHubPowersConfig3.ErrorInfo.ErrMsg;
                            flag = false;
                            if (PauseMethod(isSendMsg: false))
                            {
                                return(false);
                            }
                        }
                        return(flag);
                    }
                    }
                }
                return(false);
            }
            return(false);

IL_07d5:
            bool flag3 = false;

            return(flag3);
        }