//获取当前选中的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)); } } } }
public SendLabelUi(SendLabel429 label429) { IsSelected = label429.IsSelected; Interval = label429.Interval; ActualValue = label429.ActualValue; Label = label429.Label; SDI = label429.SDI; Data = label429.Data; SymbolState = label429.SymbolState; Parity = label429.Parity; Name = label429.Name; isAutoIncrement = label429.isAutoIncrement; }
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); } } }
//前台数据跟新到后台 private void UpdataUiToChannel() { for (int index = 0; index < LabelList.Count; index++) { string labelName = _labelNameList[index]; SendLabel429 label = _curSelectedChannel.GetSpecificItem(labelName) as SendLabel429; if (label == null) { label = new SendLabel429(labelName) { ActualValue = LabelList[index].ActualValue, Label = LabelList[index].Label, SDI = LabelList[index].SDI, Data = LabelList[index].Data, SymbolState = LabelList[index].SymbolState, Parity = LabelList[index].Parity, IsSelected = LabelList[index].IsSelected, Interval = LabelList[index].Interval, isAutoIncrement = LabelList[index].isAutoIncrement }; _curSelectedChannel.Add(label); } else { label.ActualValue = LabelList[index].ActualValue; label.Label = LabelList[index].Label; label.SDI = LabelList[index].SDI; label.Data = LabelList[index].Data; label.SymbolState = LabelList[index].SymbolState; label.Parity = LabelList[index].Parity; label.IsSelected = LabelList[index].IsSelected; label.Interval = LabelList[index].Interval; label.isAutoIncrement = LabelList[index].isAutoIncrement; } } }
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); } }