s/event/message/ re: ASOS messages
This commit is contained in:
parent
d4c2585ec2
commit
33ac8386b1
1 changed files with 19 additions and 17 deletions
|
@ -142,7 +142,9 @@ class AFOSMessage(DatabaseTable):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(text: str) -> Self:
|
def parse(text: str) -> Self:
|
||||||
event = AFOSMessage()
|
message = AFOSMessage()
|
||||||
|
message.text = text
|
||||||
|
|
||||||
state = AFOSMessageParserState.SERIAL
|
state = AFOSMessageParserState.SERIAL
|
||||||
|
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
|
@ -152,7 +154,7 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_ID.match(line)
|
match = RE_ID.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.serial = int(match[1])
|
message.serial = int(match[1])
|
||||||
state = AFOSMessageParserState.ISSUANCE
|
state = AFOSMessageParserState.ISSUANCE
|
||||||
elif state == AFOSMessageParserState.ISSUANCE:
|
elif state == AFOSMessageParserState.ISSUANCE:
|
||||||
match = RE_ISSUANCE.match(line)
|
match = RE_ISSUANCE.match(line)
|
||||||
|
@ -163,7 +165,7 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_PRODUCT.match(line)
|
match = RE_PRODUCT.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.product = match['product']
|
message.product = match['product']
|
||||||
|
|
||||||
state = AFOSMessageParserState.BODY
|
state = AFOSMessageParserState.BODY
|
||||||
elif state == AFOSMessageParserState.BODY:
|
elif state == AFOSMessageParserState.BODY:
|
||||||
|
@ -173,15 +175,15 @@ class AFOSMessage(DatabaseTable):
|
||||||
vtec = VTECEvent.parse(line)
|
vtec = VTECEvent.parse(line)
|
||||||
|
|
||||||
if vtec is not None:
|
if vtec is not None:
|
||||||
event.timestamp_start = vtec.timestamp_start
|
message.timestamp_start = vtec.timestamp_start
|
||||||
event.timestamp_end = vtec.timestamp_end
|
message.timestamp_end = vtec.timestamp_end
|
||||||
|
|
||||||
event.vtec_type = vtec.typeof
|
message.vtec_type = vtec.typeof
|
||||||
event.actions = vtec.actions
|
message.actions = vtec.actions
|
||||||
event.wfo = vtec.wfo
|
message.wfo = vtec.wfo
|
||||||
event.phenom = vtec.phenom
|
message.phenom = vtec.phenom
|
||||||
event.sig = vtec.sig
|
message.sig = vtec.sig
|
||||||
event.etn = vtec.etn
|
message.etn = vtec.etn
|
||||||
elif line == '&&':
|
elif line == '&&':
|
||||||
state = AFOSMessageParserState.TAGS
|
state = AFOSMessageParserState.TAGS
|
||||||
elif state == AFOSMessageParserState.TAGS:
|
elif state == AFOSMessageParserState.TAGS:
|
||||||
|
@ -191,19 +193,19 @@ class AFOSMessage(DatabaseTable):
|
||||||
match = RE_POLY.match(line)
|
match = RE_POLY.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.poly = parse_shape(match['coords'])
|
message.poly = parse_shape(match['coords'])
|
||||||
|
|
||||||
match = RE_MOTION.match(line)
|
match = RE_MOTION.match(line)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
event.azimuth = int(match['azimuth'])
|
message.azimuth = int(match['azimuth'])
|
||||||
event.speed = int(match['speed'])
|
message.speed = int(match['speed'])
|
||||||
event.location = parse_location(match['lon'], match['lat'])
|
message.location = parse_location(match['lon'], match['lat'])
|
||||||
elif state == AFOSMessageParserState.FOOTER:
|
elif state == AFOSMessageParserState.FOOTER:
|
||||||
if line != '':
|
if line != '':
|
||||||
event.forecaster = line
|
message.forecaster = line
|
||||||
|
|
||||||
return event
|
return message
|
||||||
|
|
||||||
def is_watch(self):
|
def is_watch(self):
|
||||||
return self.sig is not None and self.sig == 'A'
|
return self.sig is not None and self.sig == 'A'
|
||||||
|
|
Loading…
Add table
Reference in a new issue