From 9cb4e1f74c44165d844ebd1fd0d5d3848acb68dc Mon Sep 17 00:00:00 2001 From: Laika Date: Thu, 22 Apr 2021 19:45:15 -0400 Subject: [PATCH] Added periodic check of command queue --- satsim/satsim.py | 81 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 19 deletions(-) diff --git a/satsim/satsim.py b/satsim/satsim.py index 883cda1..d0daccd 100644 --- a/satsim/satsim.py +++ b/satsim/satsim.py @@ -1,6 +1,6 @@ import numpy as np import threading -import astropy.coordinates import SkyCoord as sc +from astropy.coordinates import SkyCoord as sc class Sat: def __init__(self): @@ -8,46 +8,89 @@ class Sat: self.attitude = sc(0,0, unit='deg', frame='icrs') self.saturation = 0 self.battery = 10000 - self.system_modes = - { - "opt_read": False - "opt_cool": False - "rad_mode": False - "grv_mode": False - "HGA_mode": "off" #off/rx/tx - "LGA_mode": "idle" #idle/dup/tx - "torquers": False - "gyro_del": False + self.MTE = 0 + self.kill = False + self.system_modes = { + "opt_read": False, + "opt_cool": False, + "rad_mode": False, + "grv_mode": False, + "HGA_mode": "off", #off/rx/tx + "LGA_mode": "idle", #idle/dup/tx, for power these modes will be automatic + "torquers": False, + "gyro_del": False, } - def inst_optical(): + def getLoc(self): + pass + + def inst_optical(self): """ Main Telescope """ pass - def inst_radiation(): + def inst_ultraviolet(self): + """ + UV band Telescope + """ + pass + + def inst_Hydrogen_line(self): + """ + hydrogen line radio telescope + """ + + + def inst_radiation(self): """ beta/gamma detector """ pass - def inst_gravitometer(): + def inst_gravitometer(self): """ local gravity and potential gravity waves (rare) """ pass - def inst_hg_antenna(): + def inst_hg_antenna(self): """ tight beam antenna for high speed up/downlink has to point at your ground station. """ pass - def check_command_q(): - pass + def check_command_q(self): + with open('test_q', 'r+') as q: + commands = q.readlines() + remainder = "" + for com in commands: + if int(com.split(":")[0]) == self.MTE: + print("got com -> ", com) + else: + remainder += com + q.truncate(0) + q.seek(0) + q.write(remainder) - def update(): - pass + def update(self): + self.check_command_q() + self.MTE += 1 + if not self.kill: + threading.Timer(1, self.update).start() + else: + print("heading to bed") + + +if __name__ == "__main__": + BoSLOO = Sat() + BoSLOO.update() + #while True: + # try: + # pass + # except KeyboardInterrupt: + # BoSLOO.kill = True + # print("Good night!") + # break