s/event/message/ re: ASOS messages

This commit is contained in:
XANTRONIX Industrial 2025-02-19 23:27:35 -05:00
parent d4c2585ec2
commit 33ac8386b1

View file

@ -142,7 +142,9 @@ class AFOSMessage(DatabaseTable):
@staticmethod
def parse(text: str) -> Self:
event = AFOSMessage()
message = AFOSMessage()
message.text = text
state = AFOSMessageParserState.SERIAL
for line in text.split('\n'):
@ -152,7 +154,7 @@ class AFOSMessage(DatabaseTable):
match = RE_ID.match(line)
if match is not None:
event.serial = int(match[1])
message.serial = int(match[1])
state = AFOSMessageParserState.ISSUANCE
elif state == AFOSMessageParserState.ISSUANCE:
match = RE_ISSUANCE.match(line)
@ -163,7 +165,7 @@ class AFOSMessage(DatabaseTable):
match = RE_PRODUCT.match(line)
if match is not None:
event.product = match['product']
message.product = match['product']
state = AFOSMessageParserState.BODY
elif state == AFOSMessageParserState.BODY:
@ -173,15 +175,15 @@ class AFOSMessage(DatabaseTable):
vtec = VTECEvent.parse(line)
if vtec is not None:
event.timestamp_start = vtec.timestamp_start
event.timestamp_end = vtec.timestamp_end
message.timestamp_start = vtec.timestamp_start
message.timestamp_end = vtec.timestamp_end
event.vtec_type = vtec.typeof
event.actions = vtec.actions
event.wfo = vtec.wfo
event.phenom = vtec.phenom
event.sig = vtec.sig
event.etn = vtec.etn
message.vtec_type = vtec.typeof
message.actions = vtec.actions
message.wfo = vtec.wfo
message.phenom = vtec.phenom
message.sig = vtec.sig
message.etn = vtec.etn
elif line == '&&':
state = AFOSMessageParserState.TAGS
elif state == AFOSMessageParserState.TAGS:
@ -191,19 +193,19 @@ class AFOSMessage(DatabaseTable):
match = RE_POLY.match(line)
if match is not None:
event.poly = parse_shape(match['coords'])
message.poly = parse_shape(match['coords'])
match = RE_MOTION.match(line)
if match is not None:
event.azimuth = int(match['azimuth'])
event.speed = int(match['speed'])
event.location = parse_location(match['lon'], match['lat'])
message.azimuth = int(match['azimuth'])
message.speed = int(match['speed'])
message.location = parse_location(match['lon'], match['lat'])
elif state == AFOSMessageParserState.FOOTER:
if line != '':
event.forecaster = line
message.forecaster = line
return event
return message
def is_watch(self):
return self.sig is not None and self.sig == 'A'