Пример #1
0
 public void Initialize(Device429 device429)//初始化通道
 {
     for (int i = 0; i < 16; i++)
     {
         Channe429Receive ch = (Channe429Receive)device429.GetSpecificItem(i);//遍历dic,获取信息
         var channel         = new ChannelInfoUiReceive();
         channel.Name      = ch.Name;
         channel.ChannelID = ch.ChannelID;
         if (ch.Parity == 1)
         {
             channel.Parity = BaudRate.偶校验.ToString();
         }
         else if (ch.Parity == 0)
         {
             channel.Parity = BaudRate.奇校验.ToString();
         }
         else
         {
             channel.Parity = BaudRate.校验.ToString();
         }
         channel.Enabled     = ch.Enabled;
         channel.BaudRate    = ch.BaudRate;
         channel.IsFilter    = ch.isFilter;
         channel.ReceiveType = ch.receiveType;
         channel.DeepCount   = ch.deepCount;
         channel.TimeCount   = ch.timeCount;
         _channels.Add(channel);
         SetGatherParam(ch);
     }
 }
Пример #2
0
        public void UpdataDevice(Device429 device429)
        {
            for (int i = 0; i < 16; i++)
            {
                Channe429Receive     channel       = (Channe429Receive)device429.GetSpecificItem(i);
                ChannelInfoUiReceive channelInfoUi = _channels[i];
                channel.AliasName = channelInfoUi.Name;
                if (channelInfoUi.Parity == BaudRate.偶校验.ToString())
                {
                    channel.Parity = 1;
                }
                else if (channelInfoUi.Parity == BaudRate.奇校验.ToString())
                {
                    channel.Parity = 0;
                }
                else
                {
                    channel.Parity = 2;
                }
                channel.Enabled     = channelInfoUi.Enabled;
                channel.BaudRate    = channelInfoUi.BaudRate;
                channel.isFilter    = channelInfoUi.IsFilter;
                channel.receiveType = channelInfoUi.ReceiveType;
                channel.deepCount   = channelInfoUi.DeepCount;
                channel.timeCount   = channelInfoUi.TimeCount;

                ChannelParamA429 paramA429 = new ChannelParamA429()
                {
                    work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE
                };
                if (channel.Parity == 0)
                {
                    paramA429.par = ParityA429.BHT_L1_A429_PARITY_ODD;
                }
                else if (channel.Parity == 1)
                {
                    paramA429.par = ParityA429.BHT_L1_A429_PARITY_EVEN;
                }
                else
                {
                    paramA429.par = ParityA429.BHT_L1_A429_PARITY_NONE;
                }
                if (channelInfoUi.BaudRate == 12500)
                {
                    paramA429.baud = BaudA429.BHT_L1_A429_BAUD_12_5K;
                }
                else if (channelInfoUi.BaudRate == 50000)
                {
                    paramA429.baud = BaudA429.BHT_L1_A429_BAUD_50K;
                }
                else if (channelInfoUi.BaudRate == 100000)
                {
                    paramA429.baud = BaudA429.BHT_L1_A429_BAUD_100K;
                }
                uint ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelParamRx(ref paramA429,
                                                                                        ParamOptionA429.BHT_L1_PARAM_OPT_SET);
                if (ret != 0)
                {
                    RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret));
                }
                SetGatherParam(channel);
            }
        }