Merge pull request #7 from GWES-EAS-Relay-Network/main

Small updates, nothing major.
This commit is contained in:
April Wormwood
2022-11-26 15:33:10 -07:00
committed by GitHub
3 changed files with 55 additions and 106 deletions

View File

@ -20,9 +20,9 @@ This software handles data collection and processing for The Weather Channel's I
- [ ] WMRecord - Marine Forecast - [ ] WMRecord - Marine Forecast
# Usage instructions # Usage instructions
[Download a release](https://github.com/the5dcrew/i2MessageEncoder-Rewrite/releases) for the most stable version, or clone the repository. [Download a release](https://github.com/Open-Telecom/i2MessageEncoder-Rewrite/releases) for the most stable version, or clone the repository.
``git clone https://github.com/the5dcrew/i2MessageEncoder-Rewrite`` ``git clone https://github.com/Open-Telecom/i2MessageEncoder-Rewrite``
*(If downloading this as a zip, extract to the directory of your choosing.)* *(If downloading this as a zip, extract to the directory of your choosing.)*

View File

@ -4,28 +4,22 @@ from radar import TWCRadarCollector
from datetime import datetime from datetime import datetime
""" 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.
"""
async def updateMosaicTask(): async def updateMosaicTask():
mosaicUpdateIntervals = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55] mosaicUpdateIntervals = [i+1 for i in range(0, 60, 5)]
while True: while True:
# Server takes ~15 - 35 seconds to fully generate a frame, so use 40 seconds to ensure it's fully generated. # Mosaic intervals are 5+1 minutes, so instead of waiting 40 seconds and running "Datetime.now()" twice, We run it once and wait for 60.
if datetime.now().minute in mosaicUpdateIntervals and datetime.now().second == 40: if datetime.now().minute in mosaicUpdateIntervals:
await TWCRadarCollector.collect("radarmosaic") await TWCRadarCollector.collect("radarmosaic")
await asyncio.sleep(1) await asyncio.sleep(1)
async def updateSatradTask(): async def updateSatradTask():
satradUpdateIntervals = [0, 10, 20, 30, 40, 50] satradUpdateIntervals = [i+1 for i in range(0, 60, 10)]
while True: while True:
# Server takes ~15 - 35 seconds to fully generate a frame, so use 40 seconds to ensure it's fully generated. #Satrad intervals are 10+1 minutes, so instead of waiting 40 seconds and running "Datetime.now()" twice, We run it once and wait for 60.
if datetime.now().minute in satradUpdateIntervals and datetime.now().second == 40: if datetime.now().minute in satradUpdateIntervals:
await TWCRadarCollector.collect("satrad") await TWCRadarCollector.collect("satrad")
await asyncio.sleep(1) await asyncio.sleep(1)
@ -94,4 +88,4 @@ async def tTask():
async def wnTask(): async def wnTask():
while True: while True:
await WateringNeeds.makeRecord() await WateringNeeds.makeRecord()
await asyncio.sleep(60 * 60) await asyncio.sleep(60 * 60)

137
lo8s.py
View File

@ -1,42 +1,21 @@
import py2Lib.bit as bit import py2Lib.bit as bit
import time from time import sleep
from datetime import datetime,timedelta from datetime import datetime, timedelta
import random from random import choice
import secrets
theNow = datetime.now()
currentHour = theNow.strftime('%H')
def runLo8s(flavor, duration, LDL, logo = None, LDLColor = None, EmergencyLFCancel = None): def runLo8s(flavor, duration, LDL, logo = None, LDLColor = None, EmergencyLFCancel = None):
Id = ''.join(random.choice('ABCDEF0123456789') for i in range(16)) Id = ''.join(random.choice('ABCDEF0123456789') for i in range(16))
nowUTC = datetime.utcnow() nowUTC = datetime.utcnow()
now = datetime.now() now = datetime.now()
friendlyRunTime = now + timedelta(seconds=30).strftime('%m/%d/%Y %I:%M:%S %p')
currentHour = nowUTC.strftime('%H')
friendlyRunTime = now + timedelta(seconds=30)
runTime = nowUTC + timedelta(seconds=30) runTime = nowUTC + timedelta(seconds=30)
ldlCancelTime = runTime.strftime('%m/%d/%Y %H:%M:%S:02')
runTimeLDL = nowUTC + timedelta(seconds=30) lo8sRunTime = runTime.strftime('%m/%d/%Y %H:%M:%S:00')
ldlCancelTime = runTimeLDL.strftime('%m/%d/%Y %H:%M:%S'+':02')
lo8sRunTime = runTime.strftime('%m/%d/%Y %H:%M:%S'+':00')
friendlyLo8sRunTime = friendlyRunTime.strftime('%m/%d/%Y %I:%M:%S %p')
if flavor == 'Z': if flavor == 'Z':
nextLDLRunTime = runTime + timedelta(seconds=91) nextLDLRunTime = runTime + timedelta(seconds=91)
else: else:
nextLDLRunTime = runTime + timedelta(seconds=65) nextLDLRunTime = runTime + timedelta(seconds=65)
nextLDLRun = nextLDLRunTime.strftime('%m/%d/%Y %H:%M:%S:02')
nextLDLRun = nextLDLRunTime.strftime('%m/%d/%Y %H:%M:%S'+':02')
if duration == '60': if duration == '60':
duration = '1800' duration = '1800'
elif duration == '65': elif duration == '65':
@ -46,66 +25,45 @@ def runLo8s(flavor, duration, LDL, logo = None, LDLColor = None, EmergencyLFCanc
elif duration == '120': elif duration == '120':
duration = '3600' duration = '3600'
else: else:
print('Invalid Duration specified. Please specifiy length of the local forecast in seconds. 60 for 1 minute, 65 for 1 minute 5 seconds, 90 for 1 minute 30 seconds, 120 for 2 minutes.\n\nScript will now terminate...') print('Invalid Duration specified. Please specifiy length of the local forecast in seconds.\n60 for 1 minute, 65 for 1 minute 5 seconds, 90 for 1 minute 30 seconds, 120 for 2 minutes.\n\nScript will now terminate...')
exit() exit()
nextLDLRun = nextLDLRunTime.strftime('%m/%d/%Y %H:%M:%S'+':02')
if EmergencyLFCancel == 1: if EmergencyLFCancel == 1:
print('Emergency Local On The 8s Kill Switch is Activated. No Local On The 8s Will Air. Maybe b3atdropp3r Hacked An i2 Again???\n' + friendlyLo8sRunTime) print(f'Emergency Local On The 8s Kill Switch is Activated. No Local On The 8s Will Air. Maybe b3atdropp3r Hacked An i2 Again???\n{friendlyLo8sRunTime}')
time.sleep(27) sleep(27)
elif logo != '': elif logo != '':
print('Sending Load Command To All Stars. The Local On The 8s is expected to start at ' + friendlyLo8sRunTime + ' ...') print(f'Sending Load Command To All Stars. The Local On The 8s is expected to start at {friendlyLo8sRunTime} ...')
bit.sendCommand(['<MSG><Exec workRequest="loadPres(File={0},VideoBehind=000,Logo=domesticAds/TAG'+ logo +',Flavor=domestic/'+flavor+',Duration='+duration+',PresentationId='+Id+')" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="loadPres(File={0},VideoBehind=000,Logo=domesticAds/TAG{logo},Flavor=domestic/{flavor},Duration={duration},PresentationId={Id})" /></MSG>'], 1)
time.sleep(27) sleep(27)
else: else:
print('Sending Load Command To All Stars. The Local On The 8s is expected to start at ' + friendlyLo8sRunTime + ' ...') print(f'Sending Load Command To All Stars. The Local On The 8s is expected to start at {friendlyLo8sRunTime} ...')
bit.sendCommand(['<MSG><Exec workRequest="loadPres(File={0},VideoBehind=000,Flavor=domestic/'+flavor+',Duration='+duration+',PresentationId='+Id+')" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="loadPres(File={0},VideoBehind=000,Flavor=domestic/{flavor},Duration={duration},PresentationId={Id})" /></MSG>'], 1)
time.sleep(27) sleep(27)
#Cancel LDL
print('\nCanceling LDL...') print('\nCanceling LDL...')
bit.sendCommand(['<MSG><Exec workRequest="cancelPres(File={0},PresentationId=LDL,StartTime='+ldlCancelTime+')" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="cancelPres(File={0},PresentationId=LDL,StartTime={ldlCancelTime})" /></MSG>'], 1)
#time.sleep(1)
if EmergencyLFCancel == 1: if EmergencyLFCancel == 1:
print('Not Airing Local On The 8s Due To Kill Switch Activated. Will Reload LDL After National DBS Forecast Finishes...') print('Not Airing Local On The 8s Due To Kill Switch Activated. Will Reload LDL After National DBS Forecast Finishes...')
time.sleep(53) sleep(53)
else: else:
#Run Local On The 8s
print('\nSending The Run Command. Stand By For Your Local Forecast...') print('\nSending The Run Command. Stand By For Your Local Forecast...')
bit.sendCommand(['<MSG><Exec workRequest="runPres(File={0},PresentationId='+Id+',StartTime='+lo8sRunTime+')" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="runPres(File={0},PresentationId={Id},StartTime={lo8sRunTime})" /></MSG>'], 1)
time.sleep(53) sleep(53)
if EmergencyLFCancel == 1: if EmergencyLFCancel == 1:
#color = None
#if LDLColor == 0:
#color = 'E'
#elif LDLColor == 1:
#color = 'F'
#else:
#color = 'E'
print("\nGetting The LDL Ready So It'll Cue After The National DBS Local Forecast") print("\nGetting The LDL Ready So It'll Cue After The National DBS Local Forecast")
bit.sendCommand(['<MSG><Exec workRequest="loadPres(File={0},Flavor=domestic/ldl'+LDLColor+',Duration=72000,PresentationId=LDL1)" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="loadPres(File={0},Flavor=domestic/ldl{LDLColor},Duration=72000,PresentationId=LDL1)" /></MSG>'], 1)
time.sleep(10) time.sleep(10)
print("\nSending The Run Command For The LDL...") print("\nSending The Run Command For The LDL...")
bit.sendCommand(['<MSG><Exec workRequest="runPres(File={0},PresentationId=LDL1,StartTime='+nextLDLRun+')" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="runPres(File={0},PresentationId=LDL1,StartTime={nextLDLRun})" /></MSG>'], 1)
elif LDL == 1: elif LDL == 1:
#color = None
#if LDLColor == 0:
#color = 'E'
#elif LDLColor == 1:
#color = 'F'
#else:
#color = 'E'
#Load LDL
print("\nGetting The LDL Ready So It'll Cue After This Local Forecast...") print("\nGetting The LDL Ready So It'll Cue After This Local Forecast...")
bit.sendCommand(['<MSG><Exec workRequest="loadPres(File={0},Flavor=domestic/ldl'+LDLColor+',PresentationId=LDL1)" /></MSG>'], 1) bit.sendCommand([f'<MSG><Exec workRequest="loadPres(File={0},Flavor=domestic/ldl{LDLColor},PresentationId=LDL1)" /></MSG>'], 1)
time.sleep(10) time.sleep(10)
#Run LDL print('\nSending The Run Command For The LDL. As Dave Schwartz Would Say... "That\'s a Wrap!"')
print('''\nSending The Run Command For The LDL. As Dave Schwartz Would Say... "That's a Wrap!"''') bit.sendCommand([f'<MSG><Exec workRequest="runPres(File={0},PresentationId=LDL1,StartTime={nextLDLRun})" /></MSG>'], 1)
bit.sendCommand(['<MSG><Exec workRequest="runPres(File={0},PresentationId=LDL1,StartTime='+nextLDLRun+')" /></MSG>'], 1)
else: else:
time.sleep(10) time.sleep(10)
print('''That's It Folks. As Dave Schwartz Would Say... "That's a Wrap!"''') print('That\'s It Folks. As Dave Schwartz Would Say... "That\'s a Wrap!"')
#----- SET BACKGROUNDS HERE ----------------------# #----- SET BACKGROUNDS HERE ----------------------#
BGCatastrophic = ['3094', '3095', '3103', '3115'] BGCatastrophic = ['3094', '3095', '3103', '3115']
@ -114,8 +72,6 @@ BGAlert = ['3094', '3095', '3103', '3115']
#BGNight = ['3091', '3092', '3102', '3114', '3191'] #BGNight = ['3091', '3092', '3102', '3114', '3191']
BGNorm = ['3091', '3092', '3102', '3114'] BGNorm = ['3091', '3092', '3102', '3114']
#------------------------------------------------------------------------
#------ BG RULES SECTION ------------------------# #------ BG RULES SECTION ------------------------#
if BGCatastrophic: if BGCatastrophic:
@ -137,29 +93,28 @@ else:
brandedNormal = '' brandedNormal = ''
#---------------------------------------------- #----------------------------------------------
i = 0 while True:
while i == 0: mode = input('Please specify mode.\n0 - "Unbranded"\n1 - "Normal"\n2 - "Alert"\n3 - "Storm Mode"\n4 - "Catastrophic"\n5 - "Tag"\n9 - Exit LOT8\n==>')
mode = input('\nPlease specify mode. 1 for "Normal", 2 for "Alert", 3 for "Storm Mode", 4 for "Catastrophic", 5 for "Tag" or 0 for "Unbranded"\n') if mode == '0':
if mode == '5': runLo8s('V', '65', 1, '', 'E')
ad = input('Please specify Tag Number.\n') elif mode == '1':
flavor = input("Flavor Overide? Default is 'V'.\nEnter flavor letter or enter to bypass...") runLo8s('V', '65', 1, brandedNormal, 'E')
elif mode == '2':
runLo8s('V', '65', 1, brandedAlert, 'E')
elif mode == '3':
runLo8s('V1', '65', 1, brandedStorm, 'STORM')
elif mode == '4':
runLo8s('V2', '65', 1, brandedCatastrophic, 'F')
elif mode == '5':
ad = input('Please specify Tag Number.\n==>')
flavor = input("Flavor Overide? Default is 'V'.\nEnter flavor letter, or press enter to bypass.\n==>")
if flavor == '': if flavor == '':
runLo8s('V', '65', 1, ad, 'E') runLo8s('V', '65', 1, ad, 'E')
else: else:
runLo8s(flavor, '65', 1, ad, 'E') runLo8s(flavor, '65', 1, ad, 'E')
elif mode == '4': elif mode == '9':
runLo8s('V2', '65', 1, brandedCatastrophic, 'F') print("\n\nGoodbye.\n\n")
elif mode == '3': exit()
runLo8s('V1', '65', 1, brandedStorm, 'STORM')
elif mode == '2':
runLo8s('V', '65', 1, brandedAlert, 'E')
elif mode == '1':
runLo8s('V', '65', 1, brandedNormal, 'E')
elif mode == '0':
runLo8s('V', '65', 1, '', 'E')
else: else:
print("An invalid mode was specified. This is not allowed! Will now shutdown...\n") print("Not a valid selection.\n\n")
time.sleep(5) time.sleep(1)
i = 1
#runLo8s('V', '65', 1, brandedNormal, 'E')