-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New EventCode API #32
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move `sameold::message::event` → `sameold::message::phenomenon` Move SignificanceLevel and errors to `sameold::message::significance` These moves do not impact the external API.
cbs228
added
enhancement
New feature or request
sameold
Applies to sameold library
samedec
Applies to samedec binary
labels
Feb 18, 2024
cbs228
force-pushed
the
feature/new_events
branch
from
February 22, 2024 01:42
c6a1d8e
to
5007830
Compare
* Drop enum variant `WeatherService`, which was previously emitted if sameold could not determine if the originator was the NWS or Environment Canda. It's actually easy to tell: in Canada, SAME is only ever transmitted on Weatherradio stations. This means the station callsign will be an `EC/…` station. * Rename `Originator::as_str()` to `Originator::as_code_str()` for clarity * Support the "alternate" format code. * Originator is no longer `From<&str>`. Instead, it should be constructed via `Originator::from_org_and_call()`. * Originator now implements Default This is API-BREAKING for sameold. The samedec executable only reports the Display value, which is largely unchanged, but a `$SAMEDEC_ORIGINATOR` of "National Weather Service" will now be emitted instead of "Weather Service."
* `SignificanceLevel::from()` constructs directly from significance code str. The conversion is infallible. A new `SignificanceLevel::Unknown` variant is returned when a significance level cannot be determined. It sorts higher than `Warning`. * The conversion from `str` to `SignificanceLevel` is now infallible. A new `SignificanceLevel::Unknown` variant, which is the new Default, represents cases when the significance level cannot be determined. * The UnknownSignificanceLevel is no longer required and is removed. * Renamed `SignificanceLevel::as_str()` → `SignificanceLevel::as_code_str()`. This method returns a one-character significance code. * The Unknown variant is the new Default. This is an API-BREAKING change.
cbs228
force-pushed
the
feature/new_events
branch
from
February 22, 2024 03:09
5007830
to
1996c30
Compare
* The `EventCode` is now a struct which represents the combination of a `Phenomenon` and a `SignificanceLevel`. * The enum of all the SAME events is renamed to `Phenomenon`. * Phenomenon previously de-normalized into significance levels, like `TornadoWatch` and `TornadoWarning`, are represented as a single enum entry like `Tornado`. * Phenomenon from the 2022 revision of NWSI 10-1712 and more Canadian codes are added: * EAN: Renamed to National Emergency Message * NAT: National Audible Test * NST: National Silent Test * FSW: Flash Freeze Warning * FZW: Freeze Warning * HLS: Hurricane Local Statement * SQW: Snow Squall Warning * The alternate formatter for `EventCode` now displays only the phenomenon, like `Tornado`, without the significance level * The conversion of `EventCode` from str is now infallible. Drop the `UnrecognizedEventCode` error. * The `EventCodeIter` is not required and is dropped from the public API. * Fix bad code entry for ADR (Administrative Message) * Add dependency on `phf` This is an API-BREAKING change.
The new API is simpler and doesn't require matches for errors. The integration tests are also updated.
cbs228
force-pushed
the
feature/new_events
branch
from
February 23, 2024 02:18
1996c30
to
ec9f691
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
samedec
Applies to samedec binary
sameold
Applies to sameold library
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous versions of the
EventCode
API had two problems:The conversion from
MessageHeader
→EventCode
was fallible, even though messages with unrecognized event codes should still be played.Since each SAME event code was its own
EventCode
, it was not possible to separate the phenomenon from the severity.This PR is a major overhaul of all enums used to decode SAME event codes.
Originator
Improved detection of National Weather Service vs Environment Canada. The
WeatherService
enum variant is dropped.Rename
Originator::as_str()
toOriginator::as_code_str()
for claritySupport the "alternate" format code.
Originator is no longer
From<&str>
. Instead, it should be constructed viaOriginator::from_org_and_call()
.SignificanceLevel
SignificanceLevel::from()
constructs directly from significance code str. The conversion is now infallible.A new
SignificanceLevel::Unknown
variant is returned when a significance level cannot be determined. It sorts higher thanWarning
.The UnknownSignificanceLevel is no longer required and is removed.
Renamed
SignificanceLevel::as_str()
→SignificanceLevel::as_code_str()
. This method returns a one-character significance code.The following messages are upgraded to
Statement
:Phenomenon
The enum of all the SAME events is renamed to
Phenomenon
.Phenomenon previously de-normalized into significance levels, like
TornadoWatch
andTornadoWarning
, are represented as a single enum entry likeTornado
.Phenomenon from the 2022 revision of NWSI 10-1712 and more Canadian codes are added:
Add basic categories of Phenomenon
Fix bad code entry for ADR (Administrative Message)
EventCode
The
EventCode
is now a struct which represents the combination of aPhenomenon
and aSignificanceLevel
.EventCode
no longer convert directly to static str. Formatting requires eitherDisplay
orto_string()
. The human-readable string output for each SAME event code is largely unchanged. RemoveEventCode::as_display_str()
and replace withas_display_string()
.The alternate formatter for
EventCode
now displays only the phenomenon, likeTornado
, without the significance levelEventCode
are now Ord by their significance levelsEventCode
no longer convert back to their original SAME event code string. UseMessageHeader::event_str()
instead.This is an API-BREAKING change.