ScEpTIC.emulator.energy package

Subpackages

Submodules

ScEpTIC.emulator.energy.energy_utils module

ScEpTIC.emulator.energy.energy_utils.P_R_to_V(P, R)

Calculates the voltage from instantaneous power and equivalent resistance :param P: power :param R: resistance

ScEpTIC.emulator.energy.energy_utils.R_from_energy_t(V, e, t)

Calculates the instantaneous equivalent resistance given the energy consumption in an instant t under the voltage V :param V: Voltage (V) :param e: energy consumed in t :param t: time interval :return: the equivalent resistance

ScEpTIC.emulator.energy.energy_utils.R_from_parallel_r(R1, R2)

Calculates the equivalent resistance of two parallel resistors :param R1: resistor 1 :param R2: resistor 2 :return: the equivalent resistance

ScEpTIC.emulator.energy.energy_utils.energy_from_I_f(V, I, f)

Calculates the energy consumption of a clock cycle with frequency f :param V: voltage :param I: current draw :param f: clock frequency

ScEpTIC.emulator.energy.energy_utils.energy_from_I_t(V, I, t)

Calculates the energy consumption in the time interval t :param V: voltage :param I: current draw :param t: time interval

ScEpTIC.emulator.energy.energy_utils.energy_from_R_f(V, R, f)

Calculates the energy consumption of a clock cycle with frequency f :param V: voltage :param R: resistance :param f: clock frequency

ScEpTIC.emulator.energy.energy_utils.energy_from_R_t(V, R, t)

Calculates the energy consumption in the time interval t :param V: voltage :param R: resistance :param t: time interval

ScEpTIC.emulator.energy.energy_utils.equivalent_resistance(V, I)

Calculates the equivalent resistance of a given voltage and current draw :param V: Voltage (V) :param I: Current Draw (A)

ScEpTIC.emulator.energy.energy_utils.float_to_str(value, round_val=None, omit_dot_zero=False)
ScEpTIC.emulator.energy.energy_utils.str_add_vals(val1, val2)

Adds two values in str representation :param val1: first value (with unit multipliers) :param val2: second value (with unit multipliers) :return: the sum in textual representation (with unit multipliers)

ScEpTIC.emulator.energy.energy_utils.str_to_float(value)

Converts a string to a float, accounting for unit multipliers such as M/k/m/u

ScEpTIC.emulator.energy.energy_utils.str_to_int(value)

Converts a string to an int, accounting for unit multipliers such as M/k/m/u

ScEpTIC.emulator.energy.options module

class ScEpTIC.emulator.energy.options.ComponentVoltageSource(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum for specifying the voltage source where custom devices are attached

ENERGY_BUFFER = 1
VOLTAGE_REGULATOR = 2
class ScEpTIC.emulator.energy.options.OpModeName(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum for op_mode_name of system_model.run_step()

D2VFS_ISR = 'D2VFS_ISR'
DUMMY = 'DUMMY'
ENERGY_BUFFER_RECHARGE = 'ENERGY_BUFFER_RECHARGE'
EXTERNAL_NVM = 'EXTERNAL_NVM'
FBTC_ISR = 'FBTC_ISR'
LPM = 'LPM'
LPM_ENTER = 'LPM_ENTER'
LPM_EXIT = 'LPM_EXIT'
NVM_I2C = 'NVM_I2C'
NVM_SPI = 'NVM_SPI'
PROBE_ENERGY_BUFFER = 'PROBE_ENERGY_BUFFER'
PROGRAM_EXECUTION = 'PROGRAM_EXECUTION'
SIMULATE_ADC = 'SIMULATE_ADC'
SIMULATE_CYCLES = 'SIMULATE_CYCLES'
SIMULATE_RADIO = 'SIMULATE_RADIO'
SIMULATE_SENSOR = 'SIMULATE_SENSOR'
STATE_RESTORE = 'STATE_RESTORE'
STATE_SAVE = 'STATE_SAVE'
STATIC_SCALE_DOWN = 'STATIC_SCALE_DOWN'
STATIC_SCALE_UP = 'STATIC_SCALE_UP'
class ScEpTIC.emulator.energy.options.PowerOffCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum for specifying when the device will turn off

ENERGY_BUFFER_VOLTAGE_THRESHOLD = 2
POWER_STATE_EVENT = 1

ScEpTIC.emulator.energy.power_state_event module

class ScEpTIC.emulator.energy.power_state_event.PowerStateEvent(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum for power state events

ADC_OFF = 2
MCU_OFF = 1
NVM_OFF = 3

ScEpTIC.emulator.energy.system_energy_model module

class ScEpTIC.emulator.energy.system_energy_model.SystemEnergyModel

Bases: object

Class to model the system energy consumption

add_power_off_event(event)

Adds a PowerStateEvent to the list of events that will cause the system to power off :param event: a PowerStateEvent

attach_component(name, component, target)

Attaches an additional component to the energy buffer, the voltage regulator, or the MCU. :param name: component name for stats :param component: the component :param target: ComponentVoltageSource enum specifying the voltage source for the device

attach_custom_device(custom_device)

Attaches a custom device to the system model and initializes it. Note that a custom device consists in a model of an ad-hoc device, which may include multiple components and additional logic. :param custom_device: the custom device (must inherit from CustomDevice)

attach_energy_buffer(energy_buffer)

Attaches an energy buffer to the system model :param energy_buffer: the energy buffer (must inherit from EnergyBufferModel)

attach_energy_harvester(energy_harvester)

Attaches an energy harvester to the system model :param energy_harvester: the energy harvester

attach_energy_source_model(energy_source)

Attaches an energy source model to the system model :param energy_source: the energy source model

attach_mcu(mcu)

Attaches a MCU to the system model :param mcu: the MCU (must inherit from MCUEnergyModel)

attach_state_retention_model(state_retention)

Attaches a state retention model to the system model :param state_retention: the state retention model (must inherit from StateRetentionEnergyModel)

attach_timekeeper(timekeeper)

Attaches a timekeeper to the system model :param timekeeper: the timekeeper

attach_voltage_regulator(voltage_regulator)

Attaches a voltage regulator to the system model :param voltage_regulator: the voltage regulator (must inherit from VoltageRegulatorModel)

calculate_energy_draws(mcu_clock_action, elapsed_time)

Calculates the energy draw of the simulated circuit and returns it :param mcu_clock_action: Clock cycle action of the MCU :param elapsed_time: the time elapsed :return: a dictionary with all the energy draws types

circuit_equivalent_resistance(mcu_clock_action, energy_draws=None, elapsed_time=None)

Calculates the circuit equivalent resistance (excluding the energy harvester) :param mcu_clock_action: Clock cycle action of the MCU :param energy_draws: pre-computed energy draws :param elapsed_time: elapsed time in the pre-computed energy draws :return: the circuit equivalent resistance

disable_lpm_precise_ticks()

Revers LPM simulation of t = source_sample_time

disable_stats()

Disables statistics collection

enable_lpm_precise_ticks()

Enables LPM simulation of t = mcu tick

execute_full_recharge(mcu_clock_action, op_mode_name, v_target, v_supply)

Executes a full recharge of the energy buffer :param mcu_clock_action: Clock cycle action of the MCU :param op_mode_name: current operation identifier (string) for metrics identification :param v_target: target voltage :param v_supply: voltage of the power supply

get_collected_signals()
Returns:

the collected signals

get_component(name)
get_drained_energy()
Returns:

the used energy

get_elapsed_ticks()

Returns total elapsed clock ticks

get_elapsed_time()
Returns:

the time elapsed during a simulation tick / step

get_power_state_events()
Returns:

a list of the power state events occurred

get_simulation_time()

Returns total elapsed time in s

get_stats()
Returns:

the simulation statistics and the name of each label

get_used_energy()

Returns total used energy

init(custom_devices_print_enabled=True)

Initializes the MCU and custom devices :param custom_devices_print_enabled: enables/disables custom devices messages :return: the number of clock cycles executed by the MCU

init_custom_signals(data)

Set the strings and keys of custom signals collected during the simulation :param data: a list of tuples (key, string)

power_failure_occurred()
Returns:

if a power failure occurred during previous operations

power_failure_occurring(reset_cache=True)
Parameters:

reset_cache – reset the cache if a cached power failure occurred

Returns:

if the MCU needs to be shut down / a power failure is occurring

record_power_failure()

Records the occurrence of a power failure

reset(run_gc_collect=True)

Resets statistics :param run_gc_collect: runs the garbage collector after deleting the saved signals

reset_simulation_time()
reset_used_energy()

Resets the total energy usage

run_custom_devices_logic(skip_device=None)

Runs all custom device logic :param skip_device: device to skip :return: the number of clock cycles executed by the MCU during custom device operations

run_step(mcu_clock_action, op_mode_name, is_wait_cycle=False, from_custom_device=None, additional_op_mode_name=None)

Runs a simulation step :param mcu_clock_action: Clock cycle action of the MCU :param op_mode_name: current operation identifier (string) for metrics identification :param is_wait_cycle: specifies if the execution happens due to a wait cycle :param from_custom_device: name of the cust device that is triggering the step execution :param additional_op_mode_name: additional op_mode_name for metrics identification :return: the number of clock cycles executed by the MCU

set_custom_signal(name, val)

Set the custom signals collected during the simulation :param name: the signal name :param val: the signal value

set_power_failures_automatic_check(val)

Sets how power failures are controlled :param val: True/False

set_power_off_condition(power_off_condition)

Sets the power off condition for the MCU :param power_off_condition: a PowerOffCondition

set_power_off_voltage(voltage)

Sets the power off voltage (considered only when power off condition = PowerOffCondition.VOLTAGE_THRESHOLD) :param voltage: the power off voltage

ScEpTIC.emulator.energy.voltage_drawner module

class ScEpTIC.emulator.energy.voltage_drawner.VoltageDrawner

Bases: object

Generic component that consumes energy

attach_voltage_source(source)
Parameters:

source – a voltage source

get_drained_energy(t)

Calculates the energy consumed by the component. :param t: elapsed time :return: the consumed energy

voltage_source = None

ScEpTIC.emulator.energy.voltage_source module

class ScEpTIC.emulator.energy.voltage_source.VoltageSource

Bases: object

Generic voltage source

get_voltage()
Returns:

the output voltage of the element

Module contents