//--------------------------------------------------------------------------- private IDataLinkLayer CreateConnection(InterfaceType type, TransmissionMode mode) { IDataLinkLayer result; switch (type) { case InterfaceType.SerialPort: { switch (mode) { case TransmissionMode.RTU: { String[] ports = System.IO.Ports.SerialPort.GetPortNames(); if (ports.Length != 0) { RTU.SerialPort.ComPort comport = new RTU.SerialPort.ComPort(ports[0], 19200, System.IO.Ports.Parity.Even, 8, System.IO.Ports.StopBits.One, 1000, 200, false, Diagnostics.TypeOfMessageLog.Warning | Diagnostics.TypeOfMessageLog.Information | Diagnostics.TypeOfMessageLog.Error, String.Empty); result = (IDataLinkLayer)comport; } else { RTU.SerialPort.ComPort comport = new RTU.SerialPort.ComPort(String.Empty, 19200, System.IO.Ports.Parity.Even, 8, System.IO.Ports.StopBits.One, 1000, 200, false, Diagnostics.TypeOfMessageLog.Warning | Diagnostics.TypeOfMessageLog.Information | Diagnostics.TypeOfMessageLog.Error, String.Empty); result = (IDataLinkLayer)comport; } break; } case TransmissionMode.ASCII: { result = null; break; } default: { throw new NotImplementedException(); } } break; } case InterfaceType.TCPIP: { result = null; break; } default: { throw new NotImplementedException(); } } return result; }
//--------------------------------------------------------------------------- private IDataLinkLayer CreateConnection(InterfaceType type, TransmissionMode mode) { IDataLinkLayer result; switch (type) { case InterfaceType.SerialPort: { switch (mode) { case TransmissionMode.RTU: { String[] ports = System.IO.Ports.SerialPort.GetPortNames(); if (ports.Length != 0) { RTU.SerialPort.ComPort comport = new RTU.SerialPort.ComPort(ports[0], 19200, System.IO.Ports.Parity.Even, 8, System.IO.Ports.StopBits.One, 1000, 200, false, Diagnostics.TypeOfMessageLog.Warning | Diagnostics.TypeOfMessageLog.Information | Diagnostics.TypeOfMessageLog.Error, String.Empty); result = (IDataLinkLayer)comport; } else { RTU.SerialPort.ComPort comport = new RTU.SerialPort.ComPort(String.Empty, 19200, System.IO.Ports.Parity.Even, 8, System.IO.Ports.StopBits.One, 1000, 200, false, Diagnostics.TypeOfMessageLog.Warning | Diagnostics.TypeOfMessageLog.Information | Diagnostics.TypeOfMessageLog.Error, String.Empty); result = (IDataLinkLayer)comport; } break; } case TransmissionMode.ASCII: { result = null; break; } default: { throw new NotImplementedException(); } } break; } case InterfaceType.TCPIP: { result = null; break; } default: { throw new NotImplementedException(); } } return(result); }