Esempio n. 1
0
        public async Task TestFloat()
        {
            var           factory = new ModbusFactory();
            IModbusMaster modbus  = factory.CreateMaster(_client);
            await _client.ConnectAsync(MODBUS_IP, MODBUS_PORT);

            float?data = await modbus.ReadFloatAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            await modbus.WriteFloatAsync(MODBUS_SLAVE, 0, 1.234F);

            data = await modbus.ReadFloatAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            Assert.Equal(1.234F, data);
            await modbus.WriteFloatAsync(MODBUS_SLAVE, 0, 0);

            data = await modbus.ReadFloatAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
            Assert.Equal(0, data);
            data = await modbus.ReadOnlyFloatAsync(MODBUS_SLAVE, 0);

            Assert.NotNull(data);
        }