def test_unscaling(self): point_analog = \ PointManager().find_point("setpoint").readonly_object point_scaled = \ PointManager().find_point("setpoint_scaled").readwrite_object point_scaled.value = 44.0 self.assertEqual(point_analog.value, 87.0)
def test_scaling(self): point_analog = \ PointManager().find_point("temperature_source").readwrite_object point_scaled = \ PointManager().find_point("test_scaled_point").readonly_object point_analog.value = 44.0 print(point_scaled.value) self.assertEqual(point_scaled.value, 22.5)
def test_cmd_01(modbus_server): ''' Test read COIL status command. Read 3 coils, starting at address 3. Note that only coils 3 and 5 are populated. The routine should return a 0 bit for the unpopulated coil. ''' pd1 = PointManager().get_point_test('point_discrete_1') pd2 = PointManager().get_point_test('point_discrete_2') pd1.value = True pd2.value = True data_array = [] # MBAP header # transaction ID = 0x12 0x34 # protocol identifier = 0x00 0x00 # length = 0x00 0x06 # Unit identifier = 01 data_array = [0x12, 0x34, 0x00, 0x00, 0x00, 0x06, 0x01] # MBAP header # read 3 coils starting at address 03 # command = 0x01 # starting address = 0x00 0x03 # coils to read = 0x00 0x03 data_array += [0x01, 0x00, 0x03, 0x00, 0x03] data = bytearray(data_array) del data_array return_data = modbus_server.process_request(data) del data # return command 1, one byte, both discretes on expected_responce = [0x12, 0x34, 0x00, 0x00, 0x00, 0x04, 0x01] # MBAP expected_responce += [0x01, 0x01, 0x05] expected_responce = bytearray(expected_responce) assert return_data == expected_responce