def set(self, inverter_state: InverterState): try: pub_to_broker("openWB/set/pv/" + str(self.num) + "/get/power", inverter_state.power, 2) pub_to_broker("openWB/set/pv/" + str(self.num) + "/get/counter", inverter_state.counter, 3) pub_to_broker("openWB/set/pv/" + str(self.num) + "/get/currents", inverter_state.currents, 1) except Exception as e: raise FaultState.from_exception(e)
def __exit__(self, exception_type, exception, exception_traceback) -> bool: fault_state = FaultState.from_exception(exception) for component in self.__device_components: component_info = component.component_info if component_info not in self.__ignored_components: fault_state.store_error(component_info) delattr(MultiComponentUpdateContext.__thread_local, "active_context") return True
def set(self, inverter_state: InverterState): try: self.__pv.power.write(inverter_state.power) self.__pv.energy.write(inverter_state.exported) self.__pv.energy_k.write(inverter_state.exported / 1000) if inverter_state.currents: self.__pv.currents.write(inverter_state.currents) except Exception as e: raise FaultState.from_exception(e)
def set(self, inverter_state: InverterState): try: self.__pv.power.write(inverter_state.power) self.__pv.energy.write(inverter_state.counter) self.__pv.energy_k.write(inverter_state.counter / 1000) self.__pv.currents.write(inverter_state.currents) log.MainLogger().info('PV Watt: ' + str(inverter_state.power)) except Exception as e: raise FaultState.from_exception(e)
def override_subcomponent_state(component_info: ComponentInfo, exception): active_context = getattr( MultiComponentUpdateContext.__thread_local, "active_context", None) # type: Optional[MultiComponentUpdateContext] if active_context: # If a MultiComponentUpdateContext is active, we need make sure that it will not override # the value for the individual component active_context.ignore_subcomponent_state(component_info) fault_state = FaultState.from_exception(exception) fault_state.store_error(component_info)
def override_subcomponent_state(component_info: ComponentInfo, exception, update_always: bool): active_context = getattr( MultiComponentUpdateContext.__thread_local, "active_context", None) # type: Optional[MultiComponentUpdateContext] if active_context: # If a MultiComponentUpdateContext is active, we need make sure that it will not override # the value for the individual component active_context.ignore_subcomponent_state(component_info) if exception: fault_state = FaultState.from_exception(exception) else: # Fehlerstatus nicht überschreiben if update_always: fault_state = FaultState.no_error() else: return fault_state.store_error(component_info)
def __exit__(self, exception_type, exception, exception_traceback) -> bool: fault_state = FaultState.from_exception(exception) for component in self.__device_components: fault_state.store_error( self.__device_components[component].component_info) return True