Exemplo n.º 1
0
        //获取当前选中的label
        public void Select(string path)
        {
            _curSelectedChannel = null;
            CurSelectedLabel    = null;

            string[] pathParts = path.Split('_');
            if (pathParts.Length > 3)
            {
                string chName = pathParts[3];
                _curSelectedChannel = (Channe429Send)_device429.GetSpecificItem(chName);//这个方法是获取子组件
                if (pathParts.Length > 4)
                {
                    string lableName = pathParts[4];
                    CurSelectedLabel = (SendLabel429)_curSelectedChannel.GetSpecificItem(lableName);
                    //这里将数据初始化到周期发送里面
                    Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, _curSelectedChannel.ChannelID);
                    uint ret = driverTx.ChannelSendTx((uint)CurSelectedLabel.ActualValue, SendOptA429.BHT_L1_A429_OPT_PERIOD_SEND_UPDATE);
                    if (ret != 0)
                    {
                        RunningLog.Record(string.Format("return value is {0} when invoke ChannelSendTx Set Data", ret));
                    }
                    ret = driverTx.ChannelPeriodParamTx(CurSelectedLabel.Interval, ParamOptionA429.BHT_L1_PARAM_OPT_SET);
                    if (ret != 0)
                    {
                        RunningLog.Record(string.Format("return value is {0} when invoke ChannelPeriodParamTx", ret));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void OnLogin(object sender, EventArgs e)
        {
            //检测授权
            var activator = new KeyAuthorization(App.Instance.ConfigDirectory);

            if (!activator.Check())
            {
                MessageBox.Show(@"软件过期,请重新授权!", @"提示");
                return;
            }
            _newDeviceUi.Login();

#if Test
            Device429 device =
                ((Bus429)App.Instance.FlightBusManager.GetBus(BoardType.A429.ToString())).GetSpecificItem(0);
            if (device != null)
            {
                Channe429Receive   ch     = (Channe429Receive)device.GetSpecificItem(0);
                Channel429DriverRx driver = (Channel429DriverRx)ch.ChannelDriver;
                MibDataA429        mibDataA429;
                driver.ChannelMibGetRx(out mibDataA429);
                Console.WriteLine("mibDataA429:{0},{1}", mibDataA429.cnt, mibDataA429.err_cnt);
            }
#endif
            this.Close();
        }
Exemplo n.º 3
0
 public void Initialize(Device429 device429)
 {
     for (int i = 0; i < 16; i++)
     {
         Channe429Send ch      = (Channe429Send)device429.GetSpecificItem(i + 16);
         var           channel = new ChannelInfoUiSend();
         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.LoopEnable = ch.LoopEnable;
         _channels.Add(channel);
     }
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
        //获取当前选中的chanel
        public void Select(string path)
        {
            _curSelectedChannel = null;

            string[] pathParts = path.Split('_');
            if (pathParts.Length > 3)
            {
                string chName = pathParts[3];
                //_curSelectedChannel = (Channe429Receive)_device429.GetSpecificItem(chName);//这个方法是获取子组件
                SelectChannelClick = (Channe429Receive)_device429.GetSpecificItem(chName);
            }
        }
Exemplo n.º 6
0
        //private void UpdateTreeView2()
        //{
        //    for (int i = 0; i < 16; i++)
        //    {
        //        string childNode = "chanel_" + i.ToString();
        //        TreeNode treeNode = new TreeNode(childNode);
        //        treeNode.Checked = true;
        //        _treeView2.Nodes.Add(treeNode);
        //    }
        //    foreach (var item in _treeView2.Nodes)
        //    {
        //        int geWei = 0;
        //        int shiWei = 0;
        //        TreeNode treeNode = (TreeNode)item;
        //        for (int i = 0; i <= 377; i++)
        //        {
        //            geWei = i % 100 % 10;
        //            shiWei = i % 100 / 10;
        //            if (geWei > 7 || shiWei > 7)
        //            {
        //                continue;
        //            }
        //            string childNode = "label_" + i.ToString();
        //            TreeNode labelNode = new TreeNode(childNode);
        //            labelNode.Checked = true;
        //            for (int j = 0; j < 4; j++)
        //            {
        //                string SDILabel = string.Empty;
        //                switch (j)
        //                {
        //                    case 0: SDILabel = "SDI_00"; break;
        //                    case 1: SDILabel = "SDI_01"; break;
        //                    case 2: SDILabel = "SDI_10"; break;
        //                    case 3: SDILabel = "SDI_11"; break;
        //                }
        //                TreeNode SDINode = new TreeNode(SDILabel);
        //                for (int k = 0; k < 4; k++)
        //                {
        //                    string SSMLabel = string.Empty;
        //                    switch (k)
        //                    {
        //                        case 0: SSMLabel = "SSM_00"; break;
        //                        case 1: SSMLabel = "SSM_01"; break;
        //                        case 2: SSMLabel = "SSM_10"; break;
        //                        case 3: SSMLabel = "SSM_11"; break;
        //                    }
        //                    TreeNode SSMNode = new TreeNode(SSMLabel);
        //                    SSMNode.Checked = true;
        //                    SDINode.Nodes.Add(SSMNode);
        //                }
        //                SDINode.Checked = true;
        //                labelNode.Nodes.Add(SDINode);
        //            }
        //            treeNode.Nodes.Add(labelNode);

        //        }
        //    }
        //}
        public void UpdateTreeView1()
        {
            //设备里的信息的新信息添加到_treeView1中
            TreeNode node = _treeView1.TopNode;

            for (int i = 0; i < 16; i++)
            {
                Channe429Receive receiveCh = (Channe429Receive)_device429.GetSpecificItem(i);
                if (!receiveCh.Enabled)
                {
                    continue;
                }
                SimpleTreeNode chNode;
                if (!node.Nodes.ContainsKey(receiveCh.Name))
                {
                    chNode = new SimpleTreeNode()
                    {
                        Text = receiveCh.Name,
                        Name = receiveCh.Name,
                        Path = receiveCh.Path
                    };
                    node.Nodes.Add(chNode);
                }
                else
                {
                    chNode = (SimpleTreeNode)node.Nodes[receiveCh.Name];
                }

                int count = 0;
                while (true)
                {
                    AbstractLabel label429 = null;
                    label429 = receiveCh.GetSpecificItem(count++);

                    if (label429 == null)
                    {
                        break;
                    }

                    if (!chNode.Nodes.ContainsKey(label429.Name))
                    {
                        SimpleTreeNode labelNode = new SimpleTreeNode()
                        {
                            Text = label429.Name,
                            Name = label429.Name,
                            Path = label429.Path
                        };
                        chNode.AddChildNode(labelNode);
                    }
                    if (!((Label429)label429).IsSelected)
                    {
                        chNode.Nodes[label429.Name].ForeColor = Color.Gray;
                    }
                    else
                    {
                        chNode.Nodes[label429.Name].ForeColor = Color.Black;
                    }
                }
            }


            //去除Treeview中多余的条目
            TreeNode topNode = _treeView1.TopNode;

            for (int i = 0; i < topNode.Nodes.Count; i++)
            {
                SimpleTreeNode   channelNode      = (SimpleTreeNode)topNode.Nodes[i];
                string           name             = channelNode.Name;
                Channe429Receive channe429Receive = (Channe429Receive)_device429.GetSpecificItem(name);
                if (null == channe429Receive)
                {
                    topNode.Nodes.Remove(channelNode);
                    i--;
                }
                else
                {
                    for (int j = 0; j < channelNode.Nodes.Count; j++)
                    {
                        SimpleTreeNode labelNode = (SimpleTreeNode)channelNode.Nodes[j];
                        Label429       label     = (Label429)channe429Receive.GetSpecificItem(labelNode.Name);
                        if (null == label)
                        {
                            channelNode.Nodes.Remove(labelNode);
                            j--;
                        }
                    }
                }
            }

            node.ExpandAll();
        }
Exemplo n.º 7
0
 public void UpdataDevice(Device429 device429)
 {
     for (int i = 0; i < 16; i++)
     {
         Channe429Send     channel       = (Channe429Send)device429.GetSpecificItem(i + 16);//注意这里
         ChannelInfoUiSend 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.BaudRate   = channelInfoUi.BaudRate;
         channel.LoopEnable = channelInfoUi.LoopEnable;
         channel.Enabled    = channelInfoUi.Enabled;
         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 = ((Channel429DriverTx)(channel.ChannelDriver)).ChannelParamTx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET);
         if (ret != 0)
         {
             RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret));
         }
         if (channel.LoopEnable)
         {
             Channel429DriverTx driverTx = new Channel429DriverTx(device429.DevID, channel.ChannelID);
             ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_ENABLE);
         }
         else
         {
             Channel429DriverTx driverTx = new Channel429DriverTx(device429.DevID, channel.ChannelID);
             ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_DISABLE);
         }
     }
 }
Exemplo n.º 8
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);
            }
        }