def update(self, ppoints): previous_value = self.history[-1]["value"] if len(self.history) >= 2 else None if previous_value is not None and previous_value == ppoints: # remove redundant data point self.history.pop() now = EDTime.ms_epoch_now() self.history.append({"timestamp": now, "value": ppoints})
def add_subsystem(self, subsystem): if not subsystem: return canonical = EDVehicleFactory.normalize_module_name(subsystem) now = EDTime.ms_epoch_now() self.timestamp = now self.outfit_probably_changed() config = edrconfig.EDR_CONFIG self.subsystems[canonical] = edrhitppoints.EDRHitPPoints( config.hpp_history_max_points(), config.hpp_history_max_span(), config.hpp_trend_span()) self.subsystems[canonical].update(None)
def subsystem_health(self, subsystem, health): if subsystem is None: return canonical = EDVehicleFactory.normalize_module_name(subsystem) now = EDTime.ms_epoch_now() self.timestamp = now if canonical not in self.subsystems: config = edrconfig.EDR_CONFIG self.subsystems[canonical] = edrhitppoints.EDRHitPPoints( config.hpp_history_max_points(), config.hpp_history_max_span(), config.hpp_trend_span()) self.subsystems[canonical].update(health)
def __init__(self): self.type = None self.size = None self.name = None self.id = None self.identity = None self.rebuy = None self._value = None self.hot = False now = EDTime.py_epoch_now() now_ms = EDTime.ms_epoch_now() config = edrconfig.EDR_CONFIG self._hull_health = edrhitppoints.EDRHitPPoints( config.hpp_history_max_points(), config.hpp_history_max_span(), config.hpp_trend_span()) self._shield_health = edrhitppoints.EDRHitPPoints( config.hpp_history_max_points(), config.hpp_history_max_span(), config.hpp_trend_span()) self.shield_up = True self.subsystems = {} self.timestamp = now self.fight = {u"value": False, "large": False, u"timestamp": now} self._hardpoints_deployed = {u"value": False, u"timestamp": now} self._attacked = {u"value": False, u"timestamp": now} self.heat_damaged = {u"value": False, u"timestamp": now} self._in_danger = {u"value": False, u"timestamp": now} self._low_fuel = {u"value": False, u"timestamp": now} self.fight_staleness_threshold = config.instance_fight_staleness_threshold( ) self.danger_staleness_threshold = config.instance_danger_staleness_threshold( ) self.seats = 1 self.fuel_capacity = None self.fuel_level = None self.attitude = EDVehicleAttitude() self.module_info_timestamp = None self.slots_timestamp = None self.slots = {} self.modules = None self.power_capacity = None self.cargo_capacity = 0 self.cargo = edcargo.EDCargo()