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); } }
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); } } }