Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a 'factory reset' feature to the IRIS subsystem #29

Merged
merged 4 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 25 additions & 22 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,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
Expand All @@ -41,39 +49,34 @@ 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):
"""Simulates taking a picture using the IRIS camera."""
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__":
Expand Down