from ScEpTIC.emulator.energy.energy_source import EnergySourceModel class SyntheticEnergySource(EnergySourceModel): """ Model of a synthetic energy source that supply energy only when the device is powered off """ def __init__(self, full_recharge_voltage): super().__init__() # Default time: 1ms self.default_time = 0.001 # On power failure during energy simulation -> full recharge self.power_off_full_recharge = True # Power off full recharge voltage self.full_recharge_voltage = full_recharge_voltage def set_voltage(self, voltage): """ Sets the recharge voltage :param voltage: the voltage """ self.voltage = voltage def get_current_sample_remaining_time(self): """ :return: the remaining time of the current trace sample """ return self.default_time def get_voltage_intervals(self, t): """ Returns the voltage of the energy harvester :param t: elapsed time :return: a list of (voltage, elapsed_time) """ self.elapsed_time += t return [(0.0, 0.0, t)] def get_voltage(self): """ :return: energy source current voltage """ return 0.0