Exemplo n.º 1
0
 def set(self, counter_state: CounterState):
     try:
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/voltages",
             counter_state.voltages, 2)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/currents",
             counter_state.currents, 2)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/powers",
             counter_state.powers, 2)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/power_factors",
             counter_state.power_factors, 2)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/imported",
             counter_state.imported)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/exported",
             counter_state.exported)
         pub_to_broker("openWB/set/counter/" + str(self.num) + "/get/power",
                       counter_state.power)
         pub_to_broker(
             "openWB/set/counter/" + str(self.num) + "/get/frequency",
             counter_state.frequency)
     except Exception as e:
         process_error(e)
Exemplo n.º 2
0
 def set(self, bat_state: BatState):
     try:
         files.battery.power.write(bat_state.power)
         files.battery.soc.write(bat_state.soc)
         files.battery.energy_imported.write(bat_state.imported)
         files.battery.energy_exported.write(bat_state.exported)
     except Exception as e:
         process_error(e)
Exemplo n.º 3
0
def pub_to_broker(topic: str, value, digits: Union[int, None] = None) -> None:
    rounding = get_rounding_function_by_digits(digits)
    try:
        if isinstance(value, list):
            Pub().pub(topic, [rounding(v) for v in value])
        else:
            Pub().pub(topic, rounding(value))
    except Exception as e:
        process_error(e)
Exemplo n.º 4
0
 def set(self, counter_state: CounterState):
     try:
         files.evu.voltages.write(counter_state.voltages)
         files.evu.currents.write(counter_state.currents)
         files.evu.powers_import.write(counter_state.powers)
         files.evu.power_factors.write(counter_state.power_factors)
         files.evu.energy_import.write(counter_state.imported)
         files.evu.energy_export.write(counter_state.exported)
         files.evu.power_import.write(counter_state.power)
         files.evu.frequency.write(counter_state.frequency)
     except Exception as e:
         process_error(e)
Exemplo n.º 5
0
 def set(self, bat_state: BatState):
     try:
         pub_to_broker("openWB/set/bat/" + str(self.num) + "/get/power",
                       bat_state.power, 2)
         pub_to_broker("openWB/set/bat/" + str(self.num) + "/get/soc",
                       bat_state.soc, 0)
         pub_to_broker("openWB/set/bat/" + str(self.num) + "/get/imported",
                       bat_state.imported, 2)
         pub_to_broker("openWB/set/bat/" + str(self.num) + "/get/exported",
                       bat_state.exported, 2)
     except Exception as e:
         process_error(e)
Exemplo n.º 6
0
 def set(self, counter_state: CounterState):
     try:
         files.evu.voltages.write(counter_state.voltages)
         files.evu.currents.write(counter_state.currents)
         files.evu.powers_import.write(counter_state.powers)
         files.evu.power_factors.write(counter_state.power_factors)
         files.evu.energy_import.write(counter_state.imported)
         files.evu.energy_export.write(counter_state.exported)
         files.evu.power_import.write(counter_state.power)
         files.evu.frequency.write(counter_state.frequency)
         log.MainLogger().info('EVU Watt: ' + str(counter_state.power))
         log.MainLogger().info('EVU Bezug: ' + str(counter_state.imported))
         log.MainLogger().info('EVU Einspeisung: ' +
                               str(counter_state.exported))
     except Exception as e:
         process_error(e)
Exemplo n.º 7
0
def ramdisk_write(file: str, value, digits: Optional[int] = None) -> None:
    try:
        (RAMDISK_PATH / file).write_text(
            str(get_rounding_function_by_digits(digits)(value)))
    except Exception as e:
        process_error(e)