mirror of
https://github.com/mewtek/i2ME-Legacy.git
synced 2025-05-11 00:57:31 -05:00
Make tasks for updating from the radar server
This commit is contained in:
parent
ce51e37e7f
commit
175ab43039
@ -1,12 +1,34 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from recordGenerators import Alerts,CurrentObservations,HourlyForecast,DailyForecast, AirQuality, AirportDelays, AchesAndPains, Breathing, HeatingAndCooling, MosquitoActivity, PollenForecast, TideForecast, WateringNeeds
|
from recordGenerators import Alerts,CurrentObservations,HourlyForecast,DailyForecast, AirQuality, AirportDelays, AchesAndPains, Breathing, HeatingAndCooling, MosquitoActivity, PollenForecast, TideForecast, WateringNeeds
|
||||||
from radar import TWCRadarCollector
|
from radar import TWCRadarCollector
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
""" This houses the tasks needed to update the data records concurrently
|
""" This houses the tasks needed to update the data records concurrently
|
||||||
I have no idea if this is a messy way to do things, but it will be worked upon if it is.
|
I have no idea if this is a messy way to do things, but it will be worked upon if it is.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
async def updateMosaicTask():
|
||||||
|
mosaicUpdateIntervals = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# Server takes ~15 - 35 seconds to fully generate a frame, so use 40 seconds to ensure it's fully generated.
|
||||||
|
if datetime.now().minute in mosaicUpdateIntervals and datetime.now().second == 40:
|
||||||
|
await TWCRadarCollector.collect("radarmosaic")
|
||||||
|
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
async def updateSatradTask():
|
||||||
|
satradUpdateIntervals = [0, 10, 20, 30, 40, 50]
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# Server takes ~15 - 35 seconds to fully generate a frame, so use 40 seconds to ensure it's fully generated.
|
||||||
|
if datetime.now().minute in satradUpdateIntervals and datetime.now().second == 40:
|
||||||
|
await TWCRadarCollector.collect("satrad")
|
||||||
|
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
async def alertsTask():
|
async def alertsTask():
|
||||||
while True:
|
while True:
|
||||||
await Alerts.makeRecord()
|
await Alerts.makeRecord()
|
||||||
|
6
main.py
6
main.py
@ -42,6 +42,8 @@ async def createTemp():
|
|||||||
async def main():
|
async def main():
|
||||||
await createTemp()
|
await createTemp()
|
||||||
|
|
||||||
|
mosaicTask = asyncio.create_task(RecordTasks.updateMosaicTask())
|
||||||
|
satradTask = asyncio.create_task(RecordTasks.updateSatradTask())
|
||||||
alertsTask = asyncio.create_task(RecordTasks.alertsTask())
|
alertsTask = asyncio.create_task(RecordTasks.alertsTask())
|
||||||
coTask = asyncio.create_task(RecordTasks.coTask())
|
coTask = asyncio.create_task(RecordTasks.coTask())
|
||||||
hfTask = asyncio.create_task(RecordTasks.hfTask())
|
hfTask = asyncio.create_task(RecordTasks.hfTask())
|
||||||
@ -71,5 +73,9 @@ async def main():
|
|||||||
await tTask
|
await tTask
|
||||||
await wnTask
|
await wnTask
|
||||||
|
|
||||||
|
if useRadarServer:
|
||||||
|
await mosaicTask
|
||||||
|
await satradTask
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
Loading…
x
Reference in New Issue
Block a user