From fed902d45e49c7ecb35a1324fa2029abc3e6120e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pleva=C4=8D?= Date: Sun, 1 Oct 2023 11:46:20 +0200 Subject: [PATCH] Station position from YAGS server --- station/config.py | 8 +++++--- station/puller.py | 16 ++++++++++++++++ station/recorder.py | 2 +- web/API/main.php | 1 + web/API/stations.php | 11 +++++++++++ web/CONTROLLERS/dashboard.php | 6 +++--- web/seeds.php | 7 +++++++ 7 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 web/API/stations.php diff --git a/station/config.py b/station/config.py index 6cd335a..dacd5f2 100644 --- a/station/config.py +++ b/station/config.py @@ -1,8 +1,10 @@ masterUrl = "http://10.0.3.41:8000" pullInterval = 10 # in sec apiKey = "7b105947-65d6-40ba-bb4c-50b95a3ec1c8" + +# do not edit station = { - "lat": 49.2397383, - "lon": 16.5684175, - "alt": 0.277 #KM + "lat": 0, + "lon": 0, + "alt": 0 #KM } \ No newline at end of file diff --git a/station/puller.py b/station/puller.py index f5fc6aa..846d6da 100644 --- a/station/puller.py +++ b/station/puller.py @@ -14,6 +14,11 @@ def getNewJobs(): data_json = json.loads(response.read()) return data_json +def getInfo(): + response = urlopen(config.masterUrl + "/api/station/APIinfo?key=" + config.apiKey) + data_json = json.loads(response.read()) + return data_json + def apiSend(url, data, files=None): r = requests.post(url=config.masterUrl + url, data=data, files=files) return r.text @@ -65,6 +70,17 @@ def parseNewJobs(jobs): watingJobs.append(job) +def parseInfo(info): + if "gps" in info: + config.lat = info["gps"]["lat"] + config.lon = info["gps"]["lon"] + config.alt = info["gps"]["alt"] / 1000 + + print(f"[INFO] loaded locator from YAGS server LAT: {config.lat}, LON: {config.lon}, ALT: {config.alt}") + def pull(): + #get station info + info = getInfo() + parseInfo(info) jobs = getNewJobs() parseNewJobs(jobs) \ No newline at end of file diff --git a/station/recorder.py b/station/recorder.py index aa70192..153328d 100644 --- a/station/recorder.py +++ b/station/recorder.py @@ -41,7 +41,7 @@ class recorder(threading.Thread): # find supported FS for sample in self.job["receiver"]["params"]["fs"]: - if (sample > (int(self.job['transmitter']['bandwidth']) * 2)) and (sample < fs): + if (sample > int(self.job['transmitter']['bandwidth'])) and (sample < fs): fs = sample time.sleep(50) diff --git a/web/API/main.php b/web/API/main.php index 5a098f1..977203c 100644 --- a/web/API/main.php +++ b/web/API/main.php @@ -12,6 +12,7 @@ //register API functions include_once(__DIR__ . "/observations.php"); + include_once(__DIR__ . "/stations.php"); //init API $api->serve($router->getArgs()); \ No newline at end of file diff --git a/web/API/stations.php b/web/API/stations.php new file mode 100644 index 0000000..74ee8cb --- /dev/null +++ b/web/API/stations.php @@ -0,0 +1,11 @@ +find("apiKey", $params["key"]) + + return ["id" => $station->id->get(), "name" => $station->name->get(), "locator" => $station->locator->get()]; + } \ No newline at end of file diff --git a/web/CONTROLLERS/dashboard.php b/web/CONTROLLERS/dashboard.php index 948fb68..7d66fd4 100644 --- a/web/CONTROLLERS/dashboard.php +++ b/web/CONTROLLERS/dashboard.php @@ -56,9 +56,9 @@ /** * Get used size */ - $context["usedSize"] = round(foldersize(__DIR__ . "/../artefacts/") / 1000000); - $context["imagesSize"] = round(foldersize(__DIR__ . "/../artefacts/", "png") / 1000000); - $context["basebandSize"] = round(foldersize(__DIR__ . "/../artefacts/", "s8") / 1000000); + $context["usedSize"] = round(foldersize(__DIR__ . "/../ARTEFACTS/") / 1000000); + $context["imagesSize"] = round(foldersize(__DIR__ . "/../ARTEFACTS/", "png") / 1000000); + $context["basebandSize"] = round(foldersize(__DIR__ . "/../ARTEFACTS/", "s8") / 1000000); $context["otherSize"] = $context["usedSize"] - $context["imagesSize"] + $context["basebandSize"]; $context["freeSize"] = $context["artefactsSpace"] - $context["usedSize"]; diff --git a/web/seeds.php b/web/seeds.php index 3165863..fc6946f 100644 --- a/web/seeds.php +++ b/web/seeds.php @@ -38,6 +38,13 @@ */ $myStation = new \DAL\station(); $myStation->name->set("default"); + $myStation->locator->set([ + "gps" => [ + "lat" => 49.2397383, + "lon" => 16.5684175, + "alt" => 277 + ] + ]); $myStation->commit(); $myStation137 = new \DAL\receiver();