Skip to content

Commit

Permalink
added reset functionality by adding default state values
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisheknaik96 committed Sep 1, 2023
1 parent d01fe7b commit bf87d98
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions IRIS/iris_subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +34,12 @@

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
}


class IRISSubsystem: # pylint: disable=too-many-instance-attributes
Expand All @@ -41,29 +48,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'],
'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.executable_commands = {
'TakeImage': self.take_image,
'SetTime': self.set_time
'SetTime': self.set_time,
'Reset': self.reset
}

def take_image(self):
Expand All @@ -75,6 +75,12 @@ 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__":
# If there is no arg, port is default otherwise use the arg
Expand Down

1 comment on commit bf87d98

@abhisheknaik96
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses (4) of #16.

Please sign in to comment.