From a1511889651f63bcdac39ee75ba267fd4501d1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pleva=C4=8D?= Date: Mon, 2 Oct 2023 08:46:47 +0200 Subject: [PATCH] Added support for priority planing --- station/config.py | 2 +- station/planner.py | 35 ++++++++++++++++++++++++++++------- web/API/stations.php | 5 +++-- web/DAL/transmitter.php | 6 +++--- web/seeds.php | 4 ++++ web/wsos | 2 +- 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/station/config.py b/station/config.py index cae5a3f..d4600a0 100644 --- a/station/config.py +++ b/station/config.py @@ -1,4 +1,4 @@ masterUrl = "http://10.0.0.8" +apiKey = "2c4d64c8-e73c-4111-8e71-40097c7318ef" pullInterval = 120 # in sec -apiKey = "672bccda-6eb3-4cae-bcbf-ed398e9d3dd9" planInterval = 1200 # in sec \ No newline at end of file diff --git a/station/planner.py b/station/planner.py index 9a9caef..554bc34 100644 --- a/station/planner.py +++ b/station/planner.py @@ -1,12 +1,14 @@ from pyorbital.orbital import Orbital from datetime import datetime, timedelta import time +from operator import itemgetter import puller -def plan(lat, lon, alt, tle, transmitter, receiver, name, delta = timedelta(seconds=1800), predictH = 24, horizon = 0): +def plan(lat, lon, alt, tle, transmitter, receiver, priority, name, delta = timedelta(seconds=1800), predictH = 12, horizon = 5): #prevent plan same obsevation last = datetime.utcnow() + plans = [] for ob in puller.watingJobs: last = max(ob["start"], last) @@ -27,24 +29,43 @@ def plan(lat, lon, alt, tle, transmitter, receiver, name, delta = timedelta(seco start = ob[0] end = ob[1] - if start < last: + if start <= last: print(f"[INFO] alredy planed {name} at {start}") continue - print(f"[INFO] planed {name} at {start}") - - puller.plan(transmitter, receiver, start, end) + plans.append({ + "transmitter": transmitter, + "receiver": receiver, + "start": start, + "end": end, + "priority": priority + }) def planAll(location): planeble = puller.getPlaneble() + plans = [] for transmitter in planeble: - plan( + plans += plan( location["lat"], location["lon"], location["alt"], transmitter["locator"]["tle"], transmitter["transmitter"], transmitter["receiver"], + transmitter["priority"] transmitter["name"] - ) \ No newline at end of file + ) + + plans = sorted(plans, key=itemgetter('start')) + + i = 0 + while i + 1 < len(plans): + if plan[i]["end"] < plan[i + 1]["start"]: + puller.plan(plan[i]["transmitter"], plan[i]["receiver"], plan[i]["start"], plan[i]["end"]) + i += 1 + + elif plan[i]["priority"] > plan[i + 1]["priority"]: + plan.pop(i + 1) + else: + i += 1 \ No newline at end of file diff --git a/web/API/stations.php b/web/API/stations.php index 5b41603..b8a981d 100644 --- a/web/API/stations.php +++ b/web/API/stations.php @@ -25,12 +25,13 @@ $transmitter->id->set($targetId); $transmitter->fetch(); - //get locator and nano and transmitter + //get locator and name and transmitter $res[] = [ "name" => $transmitter->target->get()->name->get(), "locator" => $transmitter->target->get()->locator->get(), "transmitter" => $transmitter->id->get(), - "receiver" => $receiver->id->get() + "receiver" => $receiver->id->get(), + "priority" => $transmitter->priority->get() ]; } } diff --git a/web/DAL/transmitter.php b/web/DAL/transmitter.php index 459a67a..9907d45 100644 --- a/web/DAL/transmitter.php +++ b/web/DAL/transmitter.php @@ -9,7 +9,7 @@ public \wsos\database\types\reference $processPipe; // process pipe for transmitter public \wsos\database\types\integer $centerFrequency; // in Hz public \wsos\database\types\integer $bandwidth; // in Hz - public \wsos\database\types\boolean $autoPlan; // can be events autoplaned? + public \wsos\database\types\integer $priority; // priority of transmitter function __construct( $id = null, @@ -19,7 +19,7 @@ $dataType = null, $centerFrequency = 0, $bandwidth = 0, - $autoPlan = false, + $priority = 0, $processPipe = null ) { parent::__construct($id); @@ -31,7 +31,7 @@ $this->centerFrequency = new \wsos\database\types\integer($centerFrequency); $this->bandwidth = new \wsos\database\types\integer($bandwidth); - $this->autoPlan = new \wsos\database\types\boolean($autoPlan); + $this->priority = new \wsos\database\types\integer($priority); } } ?> \ No newline at end of file diff --git a/web/seeds.php b/web/seeds.php index 1e94c51..56fafe7 100644 --- a/web/seeds.php +++ b/web/seeds.php @@ -143,6 +143,7 @@ $noaa19APT->centerFrequency->set(137100000); $noaa19APT->modulation->set($apt); $noaa19APT->antenna->set($qfh); + $noaa19APT->priority->set(2); $noaa19APT->processPipe->set($aptPipe); $noaa19APT->commit(); @@ -186,6 +187,7 @@ $noaa18APT->centerFrequency->set(137912500); $noaa18APT->modulation->set($apt); $noaa18APT->antenna->set($qfh); + $noaa18APT->priority->set(1); $noaa18APT->processPipe->set($aptPipe); $noaa18APT->commit(); @@ -229,6 +231,7 @@ $noaa15APT->centerFrequency->set(137500000); $noaa15APT->modulation->set($apt); $noaa15APT->antenna->set($qfh); + $noaa15APT->priority->set(0); $noaa15APT->processPipe->set($aptPipe); $noaa15APT->commit(); @@ -269,6 +272,7 @@ $meteor23LRPT1->centerFrequency->set(137900000); $meteor23LRPT1->modulation->set($lrpt); $meteor23LRPT1->antenna->set($qfh); + $meteor23LRPT1->priority->set(3); $meteor23LRPT1->processPipe->set($lrptPipe); $meteor23LRPT1->commit(); diff --git a/web/wsos b/web/wsos index 467e468..1b376bf 160000 --- a/web/wsos +++ b/web/wsos @@ -1 +1 @@ -Subproject commit 467e468efd3ef05bf9c6ec884fa79235cfcd04dd +Subproject commit 1b376bf6467101a1f3262f74d23118e2b19bd3ba