Go back to using message number for alert bits
SpaceX has been using inconsistent field ordering when adding alerts, so field index cannot be used to consistently identify the specific alerts. Message number is more appropriate for that, anyway, but is not guaranteed to be a low enough number to fit into a bit field. Oh well, in the unlikely event that SpaceX switches to larger message numbers, they just won't show up in the alerts bit field (but will still show up in alert_detail). This does make the bit ordering in alerts inconsistent with prior versions of these tools, but I've never actually seen one of these alerts report true, so hopefully this doesn't impact anyone. The alerts are still sorted by index number in the alert_detail text output, which is a problem for CSV output, but I think ordering by message number instead would be pointlessly complex. alert_detail is not a great fit for CSV output anyway, due to its variable length, so just added a warning about that in the text script module doc.
This commit is contained in:
parent
203efaf84d
commit
55ba411db8
2 changed files with 11 additions and 3 deletions
|
@ -4,6 +4,11 @@
|
|||
This script pulls the current status info and/or metrics computed from the
|
||||
history data and prints them to stdout either once or in a periodic loop.
|
||||
By default, it will print the results in CSV format.
|
||||
|
||||
Note that using this script to record the alert_detail group mode as CSV
|
||||
data is not recommended, because the number of alerts and their relative
|
||||
order in the output can change with the dish software. Instead of using
|
||||
the alert_detail mode, you can use the alerts bitmask in the status group.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
|
|
@ -107,14 +107,16 @@ their nature, but the field names are pretty self-explanatory.
|
|||
|
||||
: **alert_motors_stuck** : Alert corresponding with bit 0 (bit mask 1) in
|
||||
*alerts*.
|
||||
: **alert_thermal_throttle** : Alert corresponding with bit 1 (bit mask 2) in
|
||||
: **alert_thermal_shutdown** : Alert corresponding with bit 1 (bit mask 2) in
|
||||
*alerts*.
|
||||
: **alert_thermal_shutdown** : Alert corresponding with bit 2 (bit mask 4) in
|
||||
: **alert_thermal_throttle** : Alert corresponding with bit 2 (bit mask 4) in
|
||||
*alerts*.
|
||||
: **alert_unexpected_location** : Alert corresponding with bit 3 (bit mask 8)
|
||||
in *alerts*.
|
||||
: **alert_mast_not_near_vertical** : Alert corresponding with bit 4 (bit mask
|
||||
16) in *alerts*.
|
||||
: **slow_ethernet_speeds** : Alert corresponding with bit 5 (bit mask 32) in
|
||||
*alerts*.
|
||||
|
||||
General history data
|
||||
--------------------
|
||||
|
@ -555,7 +557,8 @@ def status_data(context=None):
|
|||
for field in status.alerts.DESCRIPTOR.fields:
|
||||
value = getattr(status.alerts, field.name)
|
||||
alerts["alert_" + field.name] = value
|
||||
alert_bits |= (1 if value else 0) << (field.index)
|
||||
if field.number < 65:
|
||||
alert_bits |= (1 if value else 0) << (field.number - 1)
|
||||
|
||||
return {
|
||||
"id": status.device_info.id,
|
||||
|
|
Loading…
Reference in a new issue