diff --git a/.gitignore b/.gitignore index 68bc17f..5df36e2 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# MacOS +.DS_Store diff --git a/IRIS/iris_subsystem.py b/IRIS/iris_subsystem.py index 2ad2a26..b4fbfef 100644 --- a/IRIS/iris_subsystem.py +++ b/IRIS/iris_subsystem.py @@ -24,6 +24,7 @@ Copyright 2023 [Abhishek Naik]. Licensed under the Apache License, Version 2.0 """ + import sys sys.path.append("../ex3_simulated_subsystems") from socket_stuff import create_socket_and_listen # pylint: disable=C0413 @@ -33,6 +34,13 @@ DEFAULT_HOST = '127.0.0.1' DEFAULT_PORT = 1821 +DEFAULT_STATE_VALUES = { # at some point, we should simulate temperature changes + 'PowerStatus': 1, # 1 means powered on, 0 means off + 'SensorStatus': 0, # 1 means sensors are on, 0 means off + 'NumImages': 0, # number of images + 'MaxNumImages': 20, # maximum images that can be stored + 'DateTime': '1694902684' # arbitrary value for now (time at which this was written) + } class IRISSubsystem: # pylint: disable=too-many-instance-attributes @@ -41,29 +49,22 @@ class IRISSubsystem: # pylint: disable=too-many-instance-attributes Tuples are provided that define the executable commands and updatable parameters. """ def __init__(self): - self.power_status = 1 # 1 means powered on, 0 means off - self.sensor_status = 0 # 1 means sensors are on, 0 means off - self.temp_vis = 25 # in degree Celsius - self.temp_nir = 25 # in degree Celsius - self.temp_flash = 25 # in degree Celsius - self.temp_gate = 25 # in degree Celsius - self.num_images = 5 # number of images - self.max_num_images = 20 # maximum images that can be stored - self.software_version = 1.0 self.state = { - 'PowerStatus': self.power_status, - 'SensorStatus': self.sensor_status, - 'TempVIS': self.temp_vis, - 'TempNIR': self.temp_nir, - 'TempFLASH': self.temp_flash, - 'TempGATE': self.temp_gate, - 'NumImages': self.num_images, - 'SoftwareVersion': self.software_version, + 'PowerStatus': DEFAULT_STATE_VALUES['PowerStatus'], + 'SensorStatus': DEFAULT_STATE_VALUES['SensorStatus'], + 'NumImages': DEFAULT_STATE_VALUES['NumImages'], + 'MaxNumImages': DEFAULT_STATE_VALUES['MaxNumImages'], + 'Time': DEFAULT_STATE_VALUES['DateTime'], + 'TempVIS': 25, # in degree Celsius + 'TempNIR': 25, # in degree Celsius + 'TempGATE': 25, # in degree Celsius + 'TempFLASH': 25, # in degree Celsius + 'SoftwareVersion': 1.0, } - self.updatable_parameters = ['PowerStatus', 'SensorStatus'] + self.updatable_parameters = ['PowerStatus', 'SensorStatus', 'Time'] self.executable_commands = { 'TakeImage': self.take_image, - 'SetTime': self.set_time + 'Reset': self.reset } def take_image(self): @@ -71,9 +72,11 @@ def take_image(self): self.state['NumImages'] += 1 print('Increased NumImages by 1') - def set_time(self): - """Simulates setting the time for the IRIS subsystem.""" - print('Not implemented yet') + def reset(self): + """Simulates a 'factory reset' of the IRIS subsystem.""" + for key, value in DEFAULT_STATE_VALUES.items(): + self.state[key] = value # temp is what the temp is, doesn't get reset + print('Factory reset performed.') if __name__ == "__main__":