Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (var item in _treeView2.Nodes)
     {
         TreeNode         node     = (TreeNode)item;
         uint             chanelId = Convert.ToUInt32(node.Text.Split('_')[1]);
         uint             ret;
         Channe429Receive channe429ReNow = null;
         //Channe429Receive channe429Re
         foreach (var itemOfRev in _device429.ReceiveComponents)
         {
             Channe429Receive channe429Re = (Channe429Receive)itemOfRev;
             if (channe429Re.ChannelID == chanelId)
             {
                 channe429ReNow = channe429Re;
             }
         }
         if (node.Checked == true)
         {
             Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, chanelId);
             ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_ENABLE);
             channe429ReNow.isLoop = false;
         }
         else
         {
             Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, chanelId);
             ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_DISABLE);
             channe429ReNow.isLoop = true;
         }
         if (ret != 0)
         {
             RunningLog.Record(string.Format("return value is {0} when invoke ChannelLoopTx", ret));
         }
     }
 }
 //清除数据
 private void ClearData(object sender, EventArgs e)
 {
     foreach (var item in _device429.ReceiveComponents)
     {
         Channe429Receive sendChanel = (Channe429Receive)item;
         sendChanel.count          = 0;
         sendChanel.errCount       = 0;
         sendChanel.DeviceCount    = 0;
         sendChanel.errDeviceCount = 0;
         for (int i = 0; i <= 377; i++)
         {
             ReceiveLabel429 label = (ReceiveLabel429)sendChanel.GetSpecificItem(i);
             if (label != null)
             {
                 sendChanel.Delete(label);
             }
         }
         Channel429DriverRx channel429DriverRx = new Channel429DriverRx(_device429.DevID, sendChanel.ChannelID);
         uint ret = channel429DriverRx.ChannelMibClearRx();
         if (ret != 0)
         {
             RunningLog.Record(string.Format("return value is {0} when clear receive data", ret));
         }
     }
 }
Beispiel #3
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();
        }
Beispiel #4
0
 public void ComboxChange()
 {
     if (!this.comboBox1.Text.Contains(chanelStr))
     {
         channelReceives = new List <Channe429Receive>();//清理所有元素
         uint channelId = Convert.ToUInt32(this.comboBox1.Text.Split('_')[1]) - 1;
         foreach (var item in _device429.ReceiveComponents)
         {
             Channe429Receive channe429Receive = (Channe429Receive)item;
             if (channe429Receive.ChannelID == channelId)
             {
                 channelReceives.Add(channe429Receive);
             }
         }
     }
     else
     {
         channelReceives = new List <Channe429Receive>();//清理所有元素
         foreach (var item in _device429.ReceiveComponents)
         {
             Channe429Receive channe429Receive = (Channe429Receive)item;
             channelReceives.Add(channe429Receive);
         }
     }
 }
 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);
     }
 }
Beispiel #6
0
 public void Stop()
 {
     foreach (var item in _device429.ReceiveComponents)
     {
         Channe429Receive chanelReceive = (Channe429Receive)item;
         chanelReceive.isSend = false;//将标识设置为false,就可以停用
     }
     MsgShow.ShowWarning("已经停止接收消息!");
 }
Beispiel #7
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);
            }
        }
Beispiel #8
0
 private void LoadData(object sender, EventArgs e)
 {
     list = new List <string>();
     foreach (var item in channelReceives)
     {
         Channe429Receive receive    = item;
         List <string>    listReturn = receive.DataAnalysis(scrollBarValue);
         list.AddRange(listReturn);
     }
     foreach (string item in list)
     {
         this.textBox1.Text += item + "\r\n";
     }
 }
        public ClickReceiveData(Channe429Receive channe429Receive)
        {
            this._channe429Receive = channe429Receive;

            textBox1            = new TextBox();
            textBox1.BackColor  = Color.LightYellow;
            textBox1.Dock       = DockStyle.Fill;
            textBox1.Multiline  = true;
            textBox1.ScrollBars = ScrollBars.Vertical;
            this.Controls.Add(textBox1);
            _thread.ThreadEvent += OnProcess;//创建一个新的线程来处理count

            this.FormClosed           += ClearThread;
            this.textBox1.TextChanged += TextChange;//始终显示最下面的
        }
        private void OnTreeViewAfterSelect(object sender, EventArgs e)
        {
            string selectedItemPath = ((SimpleTreeNode)_treeView1.SelectedNode).Path;

            _chVm.Select(selectedItemPath);
            bool isContained = selectedItemPath.Contains("Channel");

            if (isContained)
            {
                Channe429Receive chanel = _chVm.SelectChannelClick;
                var clickReceiveData    = new ClickReceiveData(chanel);
                clickReceiveData.Name = this.Name;
                clickReceiveData.Text = this.Name.Replace(TreeLocalHost.PathString + "_", "") + "_ReceiveSettingg";
                clickReceiveData.ShowSingleAtCenterParent(this.FindForm());
            }
        }
Beispiel #11
0
 public void Start()
 {
     MsgShow.ShowWarning("正在接收消息。。。");
     IsSelected = true;
     foreach (var item in _device429.ReceiveComponents)
     {
         Channe429Receive chanelReceive = (Channe429Receive)item;
         chanelReceive.IsFileSaveAllow = IsFileSaveAllow; //是否进行文件保存
         chanelReceive.isSend          = true;            //开始接收,为什么??因为在login的时候在后台多开了一个线程在不停的调用接收和发送,那么只需要将它的标识设置为true就ok了
         receiveLabelUi        = new ReceiveLabelUi(DateTime.Now);
         receiveLabelUi.chanel = chanelReceive;
         Labellist.Add(receiveLabelUi);            //将新的记录保存到ui中
         if (_curSelectedChannel == chanelReceive) //如果选中的chanel与这个chanel一样的话,执行下面的操作
         {
             Label = receiveLabelUi;
         }
     }
 }
        private void SetGatherParam(Channe429Receive channelInfoUi)
        {
            ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx();

            if (channelInfoUi.isFilter == true)    //过滤
            {
                gatherParamA429.gather_enable = 0;
            }
            else    //不过滤
            {
                gatherParamA429.gather_enable = 1;
            }
            if (channelInfoUi.receiveType == "队列")
            {
                gatherParamA429.recv_mode = RecvModeA429.BHT_L1_A429_RECV_MODE_LIST;
            }
            else
            {
                gatherParamA429.recv_mode = RecvModeA429.BHT_L1_A429_RECV_MODE_SAMPLE;
            }
            if (!string.IsNullOrEmpty(channelInfoUi.deepCount))
            {
                gatherParamA429.threshold_count = (ushort)Convert.ToInt32(channelInfoUi.deepCount);
            }
            if (!string.IsNullOrEmpty(channelInfoUi.timeCount))
            {
                gatherParamA429.threshold_time = (ushort)Convert.ToInt32(channelInfoUi.timeCount);
            }
            uint ret = ((Channel429DriverRx)(channelInfoUi.ChannelDriver)).ChannelGatherParam(ref gatherParamA429,
                                                                                              ParamOptionA429.BHT_L1_PARAM_OPT_SET);

            if (ret != 0)
            {
                RunningLog.Record(string.Format("return value is {0} when invoke ChannelGatherParam", ret));
            }
        }
        protected void OnProcess()
        {
            while (true)
            {
                int    countRe             = 0;
                int    totalError          = 0;
                uint   totalDviceCount     = 0;
                uint   totalDeviceErrCount = 0;
                string result = string.Empty;
                foreach (var ch in _device429.ReceiveComponents)
                {
                    uint             data    = 0;
                    Channe429Receive chennel = (Channe429Receive)ch;
                    countRe             += chennel.count;
                    totalError          += chennel.errCount;
                    totalDviceCount     += chennel.DeviceCount;
                    totalDeviceErrCount += chennel.errDeviceCount;
                    if (chennel.isSend == true)
                    {
                        if (chennel.rxpA429Result.data != 0)
                        {
                            data = chennel.rxpA429Result.data;
                        }
                        if (data != 0)
                        {
                            //对data进行解析
                            AnalysisLabel label = new AnalysisLabel();
                            label.ActualValue = (int)data;
                            ReceiveLabel429 receiveLabel = new ReceiveLabel429("label_" + label.Label.ToString());
                            receiveLabel.ActualValue = label.ActualValue;
                            ReceiveLabel429 receiveLabelExactHas = (ReceiveLabel429)chennel.GetSpecificItem("label_" + label.Label.ToString());
                            if (receiveLabelExactHas == null)
                            {
                                chennel.Add(receiveLabel);
                            }
                            result += DateTime.Now.ToString() + "\r\n" + "label:\n";
                            if (checkBox1.Checked == false)
                            {
                                result += data.ToString("x2");
                            }
                            else
                            {
                                result += data.ToString("x8");
                            }
                            //这里需要保存log
                            textBox1.Text += result + "\r\n";
                        }
                    }
                }
                if (!this.IsDisposed)//如果窗口没有释放,那么就不停的刷新tree,释放了就不在使用刷新这个方法
                {
                    UpdateTreeView1();
                }

                label_totalCount.Text = countRe.ToString();
                label_totalError.Text = totalError.ToString();
                label4.Text           = totalDviceCount.ToString();
                label6.Text           = totalDeviceErrCount.ToString();
                Thread.Sleep(500);
            }
        }
        //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();
        }
Beispiel #15
0
        }                                   //黑名单(true)与白名单(false)的状态

        public FilterModule(Channe429Receive receive429)
        {
            Owner       = receive429;
            _receive429 = receive429;
        }
Beispiel #16
0
 public SummaryModule(Channe429Receive receive429)
 {
     Owner       = receive429;
     _receive429 = receive429;
 }
Beispiel #17
0
        public void SaveSetting()
        {
            _deviceInfo.sendSet   = new List <SendSetting>();
            _deviceInfo.LoopSet   = new List <LoopTxSetting>();
            _deviceInfo.GatherSet = new List <GatherSetting>();
            _deviceInfo.devMsg    = new DeviceMessage();
            //_deviceInfo.FilterSet = new FilterSetting();
            //FilterSetting filterStr = new FilterSetting();
            //filterStr.filter = _device429.filterStr;
            DeviceMessage devMessage = new DeviceMessage();

            devMessage.BoardNo      = _device429.BoardNo;
            devMessage.BoardType    = _device429.BoardType;
            devMessage.ChannelCount = _device429.ChannelCount;
            devMessage.ChannelType  = _device429.ChannelType;
            devMessage.DevID        = _device429.DevID;
            devMessage.filter       = _device429.filterStr;
            _deviceInfo.devMsg      = devMessage;
            foreach (var item in _device429.SendComponents)
            {
                Channe429Send sendChanel = (Channe429Send)item;

                //赋值发送配置信息
                SendSetting sendSet = new SendSetting();
                sendSet.AliasName   = sendChanel.AliasName;
                sendSet.BaudRate    = sendChanel.BaudRate;
                sendSet.ChannelID   = sendChanel.ChannelID;
                sendSet.ChannelType = sendChanel.ChannelType;
                sendSet.Enabled     = sendChanel.Enabled;
                sendSet.labelInfos  = new List <LabelInfo>();
                for (int i = 0; i <= 377; i++)
                {
                    LabelInfo    label    = new LabelInfo();
                    SendLabel429 label429 = (SendLabel429)sendChanel.GetSpecificItem(i);
                    if (label429 != null)
                    {
                        label.Data        = label429.Data;
                        label.Label       = label429.Label;
                        label.Parity      = label429.Parity;
                        label.SDI         = label429.SDI;
                        label.SymbolState = label429.SymbolState;
                        sendSet.labelInfos.Add(label);
                    }
                }
                _deviceInfo.sendSet.Add(sendSet);//记录发送设置信息
            }
            //赋值接收配置信息
            _deviceInfo.RevSet = new List <ReceiveSetting>();
            //赋值接收配置信息
            foreach (var item in _device429.ReceiveComponents)
            {
                ReceiveSetting   RevSet    = new ReceiveSetting();
                Channe429Receive RevChanel = (Channe429Receive)item;
                RevSet.AliasName   = RevChanel.AliasName;
                RevSet.BaudRate    = RevChanel.BaudRate;
                RevSet.ChannelID   = RevChanel.ChannelID;
                RevSet.ChannelType = RevChanel.ChannelType;
                RevSet.Enabled     = RevChanel.Enabled;
                _deviceInfo.RevSet.Add(RevSet);

                GatherSetting            GatherSet       = new GatherSetting();
                ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx();
                uint ret = ((Channel429DriverRx)(RevChanel.ChannelDriver)).ChannelGatherParam(ref gatherParamA429,
                                                                                              ParamOptionA429.BHT_L1_PARAM_OPT_GET);
                GatherSet.chanelID       = RevChanel.ChannelID;
                GatherSet.gatherType     = gatherParamA429.recv_mode;
                GatherSet.isFilter       = gatherParamA429.gather_enable;
                GatherSet.ThresholdCount = gatherParamA429.threshold_count;
                GatherSet.ThresholdTime  = gatherParamA429.threshold_time;
                _deviceInfo.GatherSet.Add(GatherSet);

                LoopTxSetting loopTxSetting = new LoopTxSetting();
                loopTxSetting.chanelID = RevChanel.ChannelID;
                loopTxSetting.IsLoop   = RevChanel.isLoop;
                _deviceInfo.LoopSet.Add(loopTxSetting);
            }
        }
        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);
            }
        }