ingests GET/SET/EXE commands
This commit is contained in:
parent
41356f5922
commit
9b58ca7528
|
@ -1,5 +1,7 @@
|
|||
import numpy as np
|
||||
from sensor_module import gamma_sensor
|
||||
from gamma import gamma_sensor
|
||||
from heartbeat import heartbeat_module
|
||||
from location import location_module
|
||||
from time import sleep
|
||||
from astropy.coordinates import SkyCoord as sc
|
||||
from os import system
|
||||
|
@ -12,51 +14,52 @@ DOWNLINK_FILESTORE = "../store/data"
|
|||
|
||||
class sat:
|
||||
def __init__(self):
|
||||
self.location = self.get_loc()
|
||||
self.attitude = sc(0,0, unit='deg', frame='icrs')
|
||||
self.battery = 100.00
|
||||
self.MTE = 0
|
||||
self.kill = False
|
||||
self.maneuver_q = []
|
||||
self.maneuver_TTC = 0 #time to completion
|
||||
self.gyro_saturation = 0
|
||||
self.modules = [gamma_sensor(),gamma_sensor()]
|
||||
|
||||
def get_loc(self):
|
||||
"""
|
||||
retrieve location from orbit sim
|
||||
"""
|
||||
return (10,10,10)
|
||||
|
||||
def get_status(self, command="null"):
|
||||
status_string = ""
|
||||
self.modules = {
|
||||
"heartbeat" : heartbeat_module(),
|
||||
"location" : location_module(),
|
||||
#"power" : power_manager(),
|
||||
#"attitude" : attitude_module(),
|
||||
"gamma_sensor" : gamma_sensor()
|
||||
}
|
||||
|
||||
def check_command_q(self):
|
||||
cur_batch = []
|
||||
with open("test_q","r") as q:
|
||||
com_q = q.read().splitlines()
|
||||
for com in com_q:
|
||||
if int(com.split(":")[0]) == self.MTE:
|
||||
if int(com.split(":")[0]) == self.modules["heartbeat"].mod_get("MTE")[0]:
|
||||
cur_batch.append(com)
|
||||
return cur_batch
|
||||
|
||||
|
||||
def spin(self):
|
||||
while True:
|
||||
for m in self.modules:
|
||||
m.mod_update()
|
||||
print(m.mod_get("detections"))
|
||||
if self.MTE % 10 == 0:
|
||||
m.mod_set("flush", 1)
|
||||
MTE = self.modules["heartbeat"].mod_get("MTE")[0]
|
||||
print(MTE)
|
||||
batch = self.check_command_q()
|
||||
print("MTE:", self.MTE)
|
||||
print("COMS:", batch)
|
||||
if self.MTE == 5:
|
||||
self.kill = False
|
||||
if self.kill:
|
||||
|
||||
for c in batch:
|
||||
print(c)
|
||||
com = c.split(":")
|
||||
if com[1] == "GET" and len(com) == 4:
|
||||
res = self.modules[com[2]].mod_get(com[3])
|
||||
elif com[1] == "SET" and len(com) == 5:
|
||||
res = self.modules[com[2]].mod_set(com[3],com[4])
|
||||
elif com[1] == "EXE" and len(com) == 5:
|
||||
res = self.modules[com[2]].mod_exe(com[3],com[4])
|
||||
else:
|
||||
res = (-1, "BAD COMMAND: " + c)
|
||||
print(res)
|
||||
|
||||
for m in self.modules:
|
||||
self.modules[m].mod_update()
|
||||
if self.modules["heartbeat"].mod_get("kill")[0] == 1:
|
||||
print("heading to bed")
|
||||
return
|
||||
self.MTE += 1
|
||||
sleep(1)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue