/// <summary>
        /// Modbus RTU master factory method.
        /// </summary>
        public static ModbusSerialMaster CreateRtu(ISerialResource serialResource)
        {
            if (serialResource == null)
                throw new ArgumentNullException("serialResource");

            InitializeTimeouts(serialResource);
            return new ModbusSerialMaster(new ModbusRtuTransport(serialResource));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ModbusSerialTransport"/> class.
        /// </summary>
        /// <param name="serialResource">The serial resource.</param>
        internal ModbusSerialTransport(ISerialResource serialResource)
        {
            if (serialResource == null)
            {
                throw new ArgumentNullException("serialResource");
            }

            _serialResource = serialResource;
        }
示例#3
0
        /// <summary>
        /// Modbus RTU master factory method.
        /// </summary>
        public static ModbusSerialMaster CreateRtu(ISerialResource serialResource)
        {
            if (serialResource == null)
            {
                throw new ArgumentNullException("serialResource");
            }

            InitializeTimeouts(serialResource);
            return(new ModbusSerialMaster(new ModbusRtuTransport(serialResource)));
        }
示例#4
0
 internal ModbusAsciiTransport(ISerialResource serialResource)
     : base(serialResource)
 {
     serialResource.NewLine = Environment.NewLine;
 }
示例#5
0
 public ModbusRtuTransport(ISerialResource serialResource)
     : base(serialResource)
 {
 }
示例#6
0
 /// <summary>
 /// Initializes serial port read write timeouts to default value if they have not been overridden already.
 /// </summary>
 internal static void InitializeTimeouts(ISerialResource serialResource)
 {
     serialResource.WriteTimeout = serialResource.WriteTimeout == serialResource.InfiniteTimeout ? Modbus.DefaultTimeout : serialResource.WriteTimeout;
     serialResource.ReadTimeout  = serialResource.ReadTimeout == serialResource.InfiniteTimeout ? Modbus.DefaultTimeout : serialResource.ReadTimeout;
 }
 /// <summary>
 /// Initializes serial port read write timeouts to default value if they have not been overridden already.
 /// </summary>
 internal static void InitializeTimeouts(ISerialResource serialResource)
 {
     serialResource.WriteTimeout = serialResource.WriteTimeout == serialResource.InfiniteTimeout ? Modbus.DefaultTimeout : serialResource.WriteTimeout;
     serialResource.ReadTimeout = serialResource.ReadTimeout == serialResource.InfiniteTimeout ? Modbus.DefaultTimeout : serialResource.ReadTimeout;
 }