Added support for autoplan

This commit is contained in:
Lukáš Plevač 2023-10-01 17:44:54 +02:00
parent 42e624a3d4
commit e629222c15
6 changed files with 63 additions and 8 deletions

View File

@ -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"])

View File

@ -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) {

14
web/API/targets.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace API\target;
function info($params) {
$target = new \DAL\target();
$target->id->set($params["id"]);
return [
"id" => $target->id->get(),
"name" => $target->name->get(),
"locator" => $target->locator->get()
];
}

View File

@ -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);
}
}
?>

View File

@ -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);

View File

@ -289,4 +289,14 @@
$meteor23HRPT->centerFrequency->set(1700000000);
$meteor23HRPT->modulation->set($hrpt);
$meteor23HRPT->antenna->set($qfh);
$meteor23HRPT->commit();
$meteor23HRPT->commit();
// add autoplas
$myStation137->autoPlan->set([
$noaa15APT->id->get(),
$noaa18APT->id->get(),
$noaa19APT->id->get(),
$meteor23LRPT1->id->get()
]);
$myStation137->commit();