DisplayMessage Class¶
-
class
metlinkpid.DisplayMessage(pages)¶ A
DisplayMessageobject represents a single, cohesive set of information displayed over a sequence ofPages. Once the sequence is exhausted, it repeats indefinitely until a new message is sent to the display (or the display times out & clears, which can be avoided byping()-ing the display).DisplayMessageobjects are typically built from a string usingDisplayMessage.from_str()rather than constructed directly.
DisplayMessage.from_str() Class Method¶
-
classmethod
DisplayMessage.from_str(string: str) → metlinkpid.DisplayMessage¶ Construct a
DisplayMessageobject from a string representation.- Parameters
string –
a string in one of the following formats:
<page_str><page_str>|<page_str><page_str>|<page_str>|<page_str>(etc.)
where each
<page_str>is a string representation of aPageobject, as accepted byPage.from_str(), and is separated from otherPagerepresentations by|.For reference, such a string can also be obtained by converting an existing
DisplayMessageobject to a string usingstr():>>> page1 = Page(animate=PageAnimate.VSCROLL, delay=40, text='12:34 FUNKYTOWN~5_Limited Express') >>> page2 = Page(animate=PageAnimate.HSCROLL, delay=0, text='_Stops all stations except East Richard') >>> str(DisplayMessage([page1, page2])) 'V40^12:34 FUNKYTOWN~5_Limited Express|H0^_Stops all stations except East Richard'
Where any page string fails to specify an
animateordelayvalue, these defaults will be applied:Animate.VSCROLL&delay=40for the first page; andAnimate.HSCROLL&delay=0for subsequent pages.
- Raises
ValueError – if the text of any page contains unusable characters, or if a valid Animate value is not given, or if the delay is outside the permissible range.
__str__() Method¶
-
DisplayMessage.__str__() → str¶ The string representation of this object.
Passing this string to
DisplayMessage.from_str()will yield an equivalentDisplayMessageobject to this one.
DisplayMessage.from_bytes() Class Method¶
-
classmethod
DisplayMessage.from_bytes(bytes_in: bytes) → metlinkpid.DisplayMessage¶ Construct a
DisplayMessageobject from a raw byte representation (not including the CRC-checksumming and packet-framing required for transmission).- Parameters
bytes_in – the raw byte representation.
- Raises
ValueError – if the bytes could not be understood.
to_bytes() Method¶
-
DisplayMessage.to_bytes() → bytes¶ The raw byte representation of the
DisplayMessageas understood by the display (not including the CRC-checksumming and packet-framing required for transmission).