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); } }
//获取当前选中的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)); } } } }
private void UpdateTree() { foreach (var item in _device429.SendComponents) { Channe429Send chaneSend = (Channe429Send)item; string nodeName = "chanel_" + chaneSend.ChannelID.ToString(); TreeNode node = new TreeNode(nodeName); node.Checked = true; _treeView2.Nodes.Add(node); } }
//开始全部任务 public void StartAll() { MsgShow.ShowWarning("数据发送中。。。"); foreach (var item in _device429.SendComponents) { Channe429Send seletedItem = item as Channe429Send;//这里从iselect修改到了chanel429send if (seletedItem != null) { seletedItem.isSend = true; } } }
//停止所有的chanel,只需要将选中置为false就ok了,在chanel里面进行了选中判断 public void StopAll() { MsgShow.ShowWarning("停止数据发送!"); foreach (var item in _device429.SendComponents) { //IIsSelected seletedItem = item as IIsSelected; Channe429Send seletedItem = item as Channe429Send; if (seletedItem != null) { seletedItem.isSend = false; } } }
protected void OnProcess() { string selectedItemPath = ((SimpleTreeNode)_treeView1.SelectedNode).Text; while (true) { int count = 0; int errCount = 0; int devCount = 0; int devCountErr = 0; bool isContained429 = selectedItemPath.Contains("429"); bool isContainedChanel = selectedItemPath.Contains("Channel"); //string textValue = string.Empty; if (isContained429) { foreach (var ch in _device429.SendComponents) { Channe429Send chennel = (Channe429Send)ch; count += chennel.labelCount; errCount += chennel.errCount; devCount += (int)chennel.DeviceCount; devCountErr += (int)chennel.errDeviceCount; if (chennel.currentLabel != null && chennel.isSend != false) { if (isRadioBtn.Checked == false) { this.textBox_sendValue.Text += DateTime.Now.ToString() + ":\r\n" + chennel.ChannelID.ToString() + "\r\n" + chennel.currentLabel.ActualValue.ToString("x2") + "\r\n"; } else { this.textBox_sendValue.Text += DateTime.Now.ToString() + ":\r\n" + chennel.ChannelID.ToString() + "\r\n" + chennel.currentLabel.ActualValue.ToString("x8") + "\r\n"; } } } } else if (isContainedChanel) { Channe429Send chennel = ChVm._curSelectedChannel; count = chennel.labelCount; errCount = chennel.errCount; } this.label2.Text = count.ToString(); this.label4.Text = errCount.ToString(); this.label6.Text = devCount.ToString(); this.label8.Text = devCountErr.ToString(); //this.textBox_sendValue.Text = textValue; Thread.Sleep(500); } }
private void ClearData(object sender, EventArgs e) { foreach (var ch in _device429.SendComponents) { Channe429Send chennel = (Channe429Send)ch; chennel.labelCount = 0; chennel.errCount = 0; chennel.DeviceCount = 0; chennel.errDeviceCount = 0; this.textBox_sendValue.Text = ""; Channel429DriverTx channel429DriverRx = new Channel429DriverTx(_device429.DevID, chennel.ChannelID); uint ret = channel429DriverRx.ChannelMibClearTx(); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when clear send data", ret)); } } }
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 UpdateTreeView() { //设备里的信息的新信息添加到_treeView1中 TreeNode node = _treeView1.TopNode; foreach (var ch in _device429.SendComponents) { Channe429Send sendCh = (Channe429Send)ch; if (!sendCh.Enabled) { continue; } SimpleTreeNode chNode; if (!node.Nodes.ContainsKey(sendCh.Name)) { chNode = new SimpleTreeNode() { Text = sendCh.Name, Name = sendCh.Name, Path = sendCh.Path }; node.Nodes.Add(chNode); } else { chNode = (SimpleTreeNode)node.Nodes[sendCh.Name]; } int count = 0; while (true) { AbstractLabel label429 = null; label429 = sendCh.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; Channe429Send channe429Send = (Channe429Send)_device429.GetSpecificItem(name); if (null == channe429Send) { topNode.Nodes.Remove(channelNode); i--; } else { for (int j = 0; j < channelNode.Nodes.Count; j++) { SimpleTreeNode labelNode = (SimpleTreeNode)channelNode.Nodes[j]; Label429 label = (Label429)channe429Send.GetSpecificItem(labelNode.Name); if (null == label) { channelNode.Nodes.Remove(labelNode); j--; } } } } node.ExpandAll(); }
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); } } }