So I have a modified script that monitors the level of an external tank via modbus TCP.
This works Great and creates the tank and posts in the data.
What id like to do is from the same script also feed data into another tank. Ie internal and also External. this is where im struggling . if anyone can help out that would be amassing.
This is the 2nd Tank id like to add
Reg_u16( 0xb203, '/ExtLevel', 1, '%.1f L')
################################################# #Modbus Tank Monitor ################################################# import logging import device import probe from register import * log = logging.getLogger() class Reg_ver(Reg, int): def __init__(self, base, name): Reg.__init__(self, base, 1, name) def __int__(self): v = self.value return v[0] << 16 | v[1] << 8 | v[2] def __str__(self): return '%d.%d.%d' % self.value def decode(self, values): v = values[0] return self.update((v >> 12, v >> 8 & 0xf, v & 0xff)) class DSE8610(device.Tank): FluidType = 0 default_role = 'tank' productid = 0x030 productname = 'DSE 8610Mk2 Fuel Tank' min_timeout = 0.5 name = 'DSE 8610Mk2 Fuel Tank' custom_name = 'Tank 1' def __init__(self, *args): super(DSE8610, self).__init__(*args) self.info_regs = Reg_ver( 0x0302, '/HardwareVersion' Reg_ver( 0x0302, '/FirmwareVersion' Reg_text(0x5000, 7, '/Serial'), def device_init(self): regs = [ Reg_u16( 0x0403, '/Level', 1, '%d L'), Reg_u16( 0x0403, '/Remaining', 250, '%.1f'), Reg_u16( 0xb203, '/ExtLevel', 1, '%.1f L'), ] self.data_regs = regs def dbus_write_register(self, reg, path, val): super(DSE8610, self).dbus_write_register(reg, path, val) self.sched_reinit() def get_ident(self): return 'dse%s' % self.info['/Serial'] models = { -32704: { 'model': 'DSE8610MK2', 'handler': DSE8610, }, 32832: { 'model': 'DSE8610Mk2', 'handler': DSE8610, }, } probe.add_handler(probe.ModelRegister(0x0301, models, methods=['tcp'], units=[1]))