This commit is contained in:
matteo porta 2022-07-12 15:30:30 +02:00
parent eb6b8ad49d
commit ebd80d3daf
2 changed files with 5 additions and 2 deletions

View File

@ -65,11 +65,11 @@ class ModbusComponent(Component):
return False return False
return True return True
def _decode(self, read, data_type, *args, **kwargs): def _decode(self, read, data_type="16bit_uint", *args, **kwargs):
decoder = BinaryPayloadDecoder.fromRegisters(read.registers, byteorder=self.byteorder, wordorder=self.wordorder) decoder = BinaryPayloadDecoder.fromRegisters(read.registers, byteorder=self.byteorder, wordorder=self.wordorder)
return getattr(decoder, f"decode_{data_type}")(*args, **kwargs) return getattr(decoder, f"decode_{data_type}")(*args, **kwargs)
def _encode(self, data, data_type, *args, **kwargs): def _encode(self, data, data_type="16bit_uint", *args, **kwargs):
builder = BinaryPayloadBuilder(byteorder=self.byteorder, wordorder=self.wordorder) builder = BinaryPayloadBuilder(byteorder=self.byteorder, wordorder=self.wordorder)
getattr(builder, f"add_{data_type}")(data, *args, **kwargs) getattr(builder, f"add_{data_type}")(data, *args, **kwargs)
return builder.build() return builder.build()

View File

@ -128,7 +128,10 @@ class TecnaMarpossProvasetT3(ModbusComponent):
def write_recipe(self, recipe, table=1): def write_recipe(self, recipe, table=1):
# "pressure_ramp": self.pressure_ramp_sb, # "pressure_ramp": self.pressure_ramp_sb,
# "stabilization_cycles": self.stabilization_cycles_sb, # "stabilization_cycles": self.stabilization_cycles_sb,
recipe_name = recipe.spec["part_number"][:16].encode("ascii")
recipe_name += b"\x00" * (16 - len(recipe_name))
recipe = { recipe = {
**{719 + i: (recipe_name[i * 2 + 1] << 8) + recipe_name[i * 2] for i in range(8)},
"Selection number of test table on which you intend to work": table, "Selection number of test table on which you intend to work": table,
"Type of test": "LEAK TEST", "Type of test": "LEAK TEST",
"Test flags": 0b0000000001010000, "Test flags": 0b0000000001010000,