53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
from ScEpTIC.exceptions import ConfigurationException
|
|
|
|
|
|
class CustomDevice:
|
|
"""
|
|
Custom device skeleton
|
|
"""
|
|
|
|
name = 'GENERIC_CUSTOM_DEVICE'
|
|
|
|
def setup(self, system_model):
|
|
"""
|
|
Sets up the custom device. Note that this is a callback called by the system model
|
|
:param system_model: the system model
|
|
"""
|
|
from ScEpTIC.emulator.energy.system_energy_model import SystemEnergyModel
|
|
|
|
if not isinstance(system_model, SystemEnergyModel):
|
|
raise ConfigurationException(f"Invalid class {system_model.__class__.__name__} for system_model. SystemEnergyModel required!")
|
|
|
|
self.system_model = system_model
|
|
|
|
|
|
def run_logic(self):
|
|
"""
|
|
Runs the logic of the custom device
|
|
:return: the number of clock cycles executed by the MCU during custom device operations
|
|
"""
|
|
raise NotImplementedError(f"{self.__class__.__name__} must implement run_logic()")
|
|
|
|
|
|
def init(self, print_enabled=True):
|
|
"""
|
|
Initializes the device
|
|
:param print_enabled: enables/disables print messages
|
|
:return: the number of clock cycles executed by the MCU during custom device operations
|
|
"""
|
|
raise NotImplementedError(f"{self.__class__.__name__} must implement init()")
|
|
|
|
|
|
def get_signals_strings(self):
|
|
"""
|
|
:return: a list with the names of the signals that may be collected from this device
|
|
"""
|
|
raise NotImplementedError(f"{self.__class__.__name__} must implement get_signals_strings()")
|
|
|
|
|
|
def get_signals(self):
|
|
"""
|
|
:return: a list with the signals collected from this device
|
|
"""
|
|
raise NotImplementedError(f"{self.__class__.__name__} must implement get_signals()")
|