From e629222c1577c8641909ac931f3a73cc4e5ea22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pleva=C4=8D?= Date: Sun, 1 Oct 2023 17:44:54 +0200 Subject: [PATCH] Added support for autoplan --- station/recorder.py | 6 +++--- web/API/stations.php | 30 +++++++++++++++++++++++++++++- web/API/targets.php | 14 ++++++++++++++ web/DAL/receiver.php | 5 ++++- web/DAL/station.php | 4 ++-- web/seeds.php | 12 +++++++++++- 6 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 web/API/targets.php diff --git a/station/recorder.py b/station/recorder.py index 153328d..bcc38cb 100644 --- a/station/recorder.py +++ b/station/recorder.py @@ -21,9 +21,10 @@ def del_folder(path): path.rmdir() class recorder(threading.Thread): - def __init__(self, job): + def __init__(self, job, location): threading.Thread.__init__(self) self.job = job + self.location = location def run(self): print(f"Recorder for job {self.job['target']['name']} started") @@ -32,7 +33,7 @@ class recorder(threading.Thread): #init rotator rotatorDriver = simplecom("/dev/ttyUSB0") - rotatorCTR = rotator(rotatorDriver, self.job, config.station) + rotatorCTR = rotator(rotatorDriver, self.job, self.location) rotatorCTR.start() baseband = f"records/{self.job['id']}" @@ -48,7 +49,6 @@ class recorder(threading.Thread): os.system(f"satdump record {baseband} --source {self.job['receiver']['params']['radio']} --samplerate {fs} --frequency {self.job['transmitter']['centerFrequency']} --gain {self.job['receiver']['params']['gain']} --baseband_format s8 --timeout {recordTime}") - print(f"Recorder for job {self.job['target']['name']} stoped") puller.setRecorded(self.job["id"]) diff --git a/web/API/stations.php b/web/API/stations.php index 185eb25..5b41603 100644 --- a/web/API/stations.php +++ b/web/API/stations.php @@ -7,7 +7,35 @@ $station->find("apiKey", $params["key"]); - return ["id" => $station->id->get(), "name" => $station->name->get(), "locator" => $station->locator->get()]; + return [ + "id" => $station->id->get(), + "name" => $station->name->get(), + "locator" => $station->locator->get() + ]; + } + + function autoPlanable($params) { + + $receivers = new \wsos\database\core\table(\DAL\receiver::class); + + $res = []; + foreach ($receivers->query("station.apiKey==?", [$params["key"]])->values as $receiver) { + foreach ($receiver->autoPlan->get() as $targetId) { + $transmitter = new \DAL\transmitter(); + $transmitter->id->set($targetId); + $transmitter->fetch(); + + //get locator and nano and transmitter + $res[] = [ + "name" => $transmitter->target->get()->name->get(), + "locator" => $transmitter->target->get()->locator->get(), + "transmitter" => $transmitter->id->get(), + "receiver" => $receiver->id->get() + ]; + } + } + + return $res; } function keys($params) { diff --git a/web/API/targets.php b/web/API/targets.php new file mode 100644 index 0000000..5e913aa --- /dev/null +++ b/web/API/targets.php @@ -0,0 +1,14 @@ +id->set($params["id"]); + + return [ + "id" => $target->id->get(), + "name" => $target->name->get(), + "locator" => $target->locator->get() + ]; + } diff --git a/web/DAL/receiver.php b/web/DAL/receiver.php index 6a9d286..600d578 100644 --- a/web/DAL/receiver.php +++ b/web/DAL/receiver.php @@ -8,6 +8,7 @@ public \wsos\database\types\integer $bandwidth; // in Hz public \wsos\database\types\json $params; // params for use public \wsos\database\types\integer $gain; // gain of reciver setup + public \wsos\database\types\json $autoPlan; // IDs of autoplan transmitters function __construct( $id = null, @@ -16,7 +17,8 @@ $centerFrequency = 0, $bandwidth = 0, $params = [], - $gain = 0 + $gain = 0, + $autoPlan = [] ) { parent::__construct($id); $this->station = new \wsos\database\types\reference($station, \DAL\station::class); @@ -26,6 +28,7 @@ $this->bandwidth = new \wsos\database\types\integer($bandwidth); $this->params = new \wsos\database\types\json($params); $this->gain = new \wsos\database\types\integer($gain); + $this->autoPlan = new \wsos\database\types\json($autoPlan); } } ?> \ No newline at end of file diff --git a/web/DAL/station.php b/web/DAL/station.php index 86b361f..643cbcd 100644 --- a/web/DAL/station.php +++ b/web/DAL/station.php @@ -6,9 +6,9 @@ public \wsos\database\types\uuid $apiKey; // access key public \wsos\database\types\timestamp $lastSeen; public \wsos\database\types\text $description; - public \wsos\database\types\json $locator; + public \wsos\database\types\json $locator; - function __construct($id = null, $name = "", $apiKey = null, $lastSeen = 0, $description = "", $locator = []) { + function __construct($id = null, $name = "", $apiKey = null, $lastSeen = 0, $description = "", $locator = [], $autoPlan = []) { parent::__construct($id); $this->name = new \wsos\database\types\text($name); $this->description = new \wsos\database\types\text($description); diff --git a/web/seeds.php b/web/seeds.php index fc6946f..1e94c51 100644 --- a/web/seeds.php +++ b/web/seeds.php @@ -289,4 +289,14 @@ $meteor23HRPT->centerFrequency->set(1700000000); $meteor23HRPT->modulation->set($hrpt); $meteor23HRPT->antenna->set($qfh); - $meteor23HRPT->commit(); \ No newline at end of file + $meteor23HRPT->commit(); + + // add autoplas + $myStation137->autoPlan->set([ + $noaa15APT->id->get(), + $noaa18APT->id->get(), + $noaa19APT->id->get(), + $meteor23LRPT1->id->get() + ]); + + $myStation137->commit(); \ No newline at end of file