/// <summary> /// Set Parameters, it will initialize the connection /// </summary> /// <param name="cfg"></param> public void SetParameters(DeviceConfig cfg) { if (cfg.UsingComPort) // use tcp ip only { throw new Exception("Wrong Configuration Data"); } bool portOpen = IsOpen; if (portOpen) { Close(); } mIp = cfg.Network.IPAddress; mPort = cfg.Network.NetworkPort; if (portOpen) { Open(); } }
/// <summary> /// Set Parameters, it will initialize the connection /// </summary> /// <param name="cfg"></param> public void SetParameters(DeviceConfig cfg) { if (!cfg.UsingComPort) { throw new Exception("Wrong Configuration Data"); } bool portOpen = IsOpen; if (portOpen) { Close(); } mPort.PortName = cfg.PortData.portName; mPort.BaudRate = cfg.PortData.baudRate; if (portOpen) { Open(); } }
/// <summary> /// Set Parameters, it will initialize the connection /// </summary> /// <param name="cfg"></param> public void SetParameters(DeviceConfig cfg) { if (mCom != null) { mCom.Close(); } if (cfg.UsingComPort) { mCom = new ComPortWrapper(); } else { mCom = new TcpWrapper(); } mCom.SetParameters(cfg); mCom.OnConnectStatusChange += new UpdateMessageHandler(OnConnectionStatusChanged); }
public DeviceConfig Clone() { DeviceConfig cfg = new DeviceConfig(); cfg.PortData.baudRate = PortData.baudRate; cfg.PortData.portName = PortData.portName; cfg.Network.IPAddress = Network.IPAddress; cfg.Network.NetworkPort = Network.NetworkPort; cfg.UsingComPort = UsingComPort; return cfg; }