//获取当前选中的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 UpdataChannelToUi() { for (int i = 0; true; i++) { SendLabel429 label = _curSelectedChannel.GetSpecificItem(i) as SendLabel429; if (label == null) { break; } string labelName = label.Name; if (_labelNameList.Contains(labelName)) { int index = _labelNameList.IndexOf(labelName); LabelList[index] = new SendLabelUi(label); _labelNameList[index] = labelName; } else { LabelList.Add(new SendLabelUi(label)); _labelNameList.Add(labelName); } } }
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(); }