public static bool?UserConfigureTcpModbusAddress(Guid uidGuid) { Array.Resize(ref ModbusControls, ModbusControls.Length + 1); ModbusControls[ModbusControls.Length - 1].UidGuid = uidGuid; ModbusControls[ModbusControls.Length - 1].ModbusTimers = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000), IsEnabled = false, Tag = uidGuid }; ModbusControls[ModbusControls.Length - 1].ModbusTimers.Tick += ModbusTimerOnTick; ModbusTimerId.Add(ModbusControls[ModbusControls.Length - 1].ModbusTimers, uidGuid); ModbusControls[ModbusControls.Length - 1].ModbusAddressList = new List <Tuple <bool, bool, bool, bool, int> >(); var index = GetIndex <CheckListItem>(uidGuid); var modbusSelection = new ModbusSelection { DeviceAddress = IpAddressTables[index].IpAddress.ToString(), DeviceName = IpAddressTables[index].IpAddress.ToString(), IsAbsolute = true }; return(modbusSelection.ShowDialog()); }
public static bool?UserConfigureSerialModbusAddresses(Guid uidGuid) { var index = GetIndex <SerialCommunication>(uidGuid); var port = new SerialPort { PortName = SerialCommunications[index].ComPort, BaudRate = (int)SerialCommunications[index].BaudRate, Parity = SerialCommunications[index].SerialParity, StopBits = SerialCommunications[index].SerialStopBits, DataBits = SerialCommunications[index].SerialBits, Handshake = SerialCommunications[index].FlowControl, RtsEnable = SerialCommunications[index].RtsEnable, ReadTimeout = SerialCommunications[index].ReadTimeout }; Array.Resize(ref ModbusControls, ModbusControls.Length + 1); ModbusControls[ModbusControls.Length - 1].UidGuid = uidGuid; ModbusControls[ModbusControls.Length - 1].ModbusTimers = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000), IsEnabled = false, Tag = uidGuid }; ModbusControls[ModbusControls.Length - 1].ModbusTimers.Tick += ModbusTimerOnTick; ModbusTimerId.Add(ModbusControls[ModbusControls.Length - 1].ModbusTimers, uidGuid); ModbusControls[ModbusControls.Length - 1].ModbusAddressList = new List <Tuple <bool, bool, bool, bool, int> >(); index = GetIndex <CheckListItem>(uidGuid); var modbusSelection = new ModbusSelection { DeviceAddress = port.PortName, DeviceName = AvailableModbusSerialPorts[index].ItemName, IsAbsolute = true }; return(modbusSelection.ShowDialog()); }