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 additional ON/OFF functionality for EPS and other subsystems #80

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
76 changes: 75 additions & 1 deletion EPS/eps_subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
'WatchdogResetTime': 24.0, # in hours
}

default_subsystem_state = {
'ADCS': False,
'Deployables': False,
'DFGM': False,
'GPS': False,
'IRIS': False,
'UHF': False
}

class EPSSubsystem: #pylint:disable=too-few-public-methods disable=too-many-instance-attributes
"""Holds the state of the EPS subsystem.

Expand All @@ -66,14 +75,79 @@ def __init__(self):
}
self.updatable_parameters = ['WatchdogResetTime']

self.subsystems = {
'ADCS': False,
'Deployables': False,
'DFGM': False,
'GPS': False,
'IRIS': False,
'UHF': False
Comment on lines +78 to +84
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great. Could also add in additional fields for 'GPIO' pins representing burn wires for antennas and UHF specifically.

}

self.eps_on = True

# Changing executable command tuples to dictionaries to point to fxns
self.executable_commands = {
'ResetDevice': self.reset_device,
'ResetSubsystems': self.reset_subsystems_state,
'SubsystemOn': self.subsystem_on,
'SubsystemOff': self.subsystem_off

}

def turn_on_eps(self):
"""Turn on the EPS subsystem"""
self.eps_on = True
print("EPS turned ON\n")
def turn_off_eps(self):
"""Turn off the EPS subsystem"""
self.eps_on = False
print("EPS turned OFF\n")
def reset_device(self):
"""Reset the device to default state, which is defined at the top of this file. """
"""Reset the device to default state, which is defined at the top of this file."""
if self.eps_on is False:
print("ERROR: EPS turned off. Please turn on EPS to execute command\n")
self.set_state_dict(default_eps_state)
print("EPS printed to default state\n")
def reset_subsystems_state(self):
"""Reset the subsystems to default state, which is defined at the top of this file."""
if self.eps_on is False:
print("ERROR: EPS turned off. Please turn on EPS to execute command\n")
self.subsystems = default_subsystem_state.copy()
print("Subsystems printed to default state\n")

def subsystem_on(self, subsystem_name):
"""
Turn off the specified subsystem.

Args:
subsystem_name (str): The name of the subsystem to turn off.

prints:
str: A message indicating the result of the operation.
"""
if self.eps_on is False:
print("ERROR: EPS turned off. Please turn on EPS to execute command\n")
if subsystem_name in self.subsystems:
self.subsystems[subsystem_name] = True
print(f"{subsystem_name} turned ON\n")
print(f"ERROR: {subsystem_name} is not a valid subsystem\n")
def subsystem_off(self, subsystem_name):
"""
Turn off the specified subsystem.

Args:
subsystem_name (str): The name of the subsystem to turn off.

prints:
str: A message indicating the result of the operation.
"""
if self.eps_on is False:
print("ERROR: EPS turned off. Please turn on EPS to execute command\n")
if subsystem_name in self.subsystems:
self.subsystems[subsystem_name] = False
print(f"{subsystem_name} turned OFF\n")
print(f"ERROR: {subsystem_name} is not a valid subsystem\n")


def set_state_dict(self, new_state_dict):
Expand Down
Loading