Example #1
0
    def test_update(self):
        protocol = create_autospec(Protocol)
        protocol.query.side_effect = [
            b'\x12\x34\x00\x00\x00\x00\x00\x00\x56\x78'
        ]
        muster = Muster(protocol)
        vars = [
            variable.create('CommonScaleForAcVolts'),
            variable.create('CommonScaleForTemperature'),
        ]

        muster.update(vars)

        self.assertEqual(2, len(vars))
        self.assertEqual('CommonScaleForAcVolts', vars[0].get_name())
        self.assertEqual('CommonScaleForTemperature', vars[1].get_name())
        self.assertEqual(b'\x12\x34', vars[0].bytes)
        self.assertEqual(b'\x56\x78', vars[1].bytes)
        self.assertEqual(1, len(protocol.query.call_args_list))
        self.assertEqual(call(Range(41000, 5)),
                         protocol.query.call_args_list[0])
Example #2
0
 def __init__(self):
     self.__muster = Muster()
     self.__scale_variables = [
         variable.create('CommonScaleForAcVolts'),
         variable.create('CommonScaleForAcCurrent'),
         variable.create('CommonScaleForDcVolts'),
         variable.create('CommonScaleForDcCurrent'),
         variable.create('CommonScaleForTemperature'),
         variable.create('CommonScaleForInternalVoltages'),
     ]
     self.__variables = [
         variable.create('CombinedKacoAcPowerHiRes'),
         variable.create('LoadAcPower'),
         variable.create('ACLoadkWhTotalAcc'),
         variable.create('BatteryVolts'),
         variable.create('DCBatteryPower'),
         variable.create('Shunt1Name'),
         variable.create('Shunt1Power'),
         variable.create('Shunt2Name'),
         variable.create('Shunt2Power'),
         variable.create('Heatsink1Temp'),
         variable.create('Heatsink2Temp'),
         variable.create('ControlBoardTemp'),
         variable.create('BatteryTemperature'),
         variable.create('TransformerTemp'),
         variable.create('InletTemp'),
         variable.create('FanSpeed'),
         variable.create('BattOutToday'),
         variable.create('BattInToday'),
         variable.create('BattNetToday'),
         variable.create('BattInYesterday'),
         variable.create('BattOutYesterday'),
         variable.create('absorb'),
         variable.create('bulk'),
         variable.create('float'),
         variable.create('BattSocPercent'),
         variable.create('LoadAccumulatedToday'),
         variable.create('PercentageSolarOutput')
     ]
     self.__scales = None
Example #3
0
 def __init__(self):
     self.__muster = Muster()
     self.__scale_variables = [
         variable.create('CommonScaleForAcVolts'),
         variable.create('CommonScaleForAcCurrent'),
         variable.create('CommonScaleForDcVolts'),
         variable.create('CommonScaleForDcCurrent'),
         variable.create('CommonScaleForTemperature'),
         variable.create('CommonScaleForInternalVoltages'),
     ]
     self.__variables = [
         variable.create('CombinedKacoAcPowerHiRes'),
         variable.create('Shunt1Name'),
         variable.create('Shunt1Power'),
         variable.create('Shunt2Name'),
         variable.create('Shunt2Power'),
         variable.create('BatteryVolts'),
         variable.create('BatteryTemperature'),
         variable.create('LoadAcPower'),
         variable.create('DCBatteryPower'),
         variable.create('ACLoadkWhTotalAcc'),
         variable.create('BattOutkWhPreviousAcc'),
         variable.create('BattSocPercent'),
     ]
     self.__scales = None
Example #4
0
 def test_get_value_errors(self):
     var = variable.create(0xcafe)
     with self.assertRaises(Exception) as context:
         var.get_value([])
     self.assertEqual('Can not convert value for unknown variable type',
                      context.exception.args[0])
Example #5
0
 def test_bytes(self, arg, bytes, value):
     var = variable.create(arg)
     var.bytes = bytes
     self.assertEqual(value, var.get_value(scales))
     self.assertEqual(bytes, var.bytes)
Example #6
0
 def test_get_type(self, arg, type):
     self.assertEqual(type, variable.create(arg).get_type())
Example #7
0
 def test_range(self, arg, range):
     self.assertEqual(range, variable.create(arg).range)
Example #8
0
 def test_create(self, arg, name, address):
     var = variable.create(arg)
     self.assertIsInstance(var, Variable)
     self.assertEqual(address, var.range.address)
     self.assertEqual(name, var.get_name())