DisplayMessage
Class¶
-
class
metlinkpid.
DisplayMessage
(pages)¶ A
DisplayMessage
object 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).DisplayMessage
objects 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
DisplayMessage
object 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 aPage
object, as accepted byPage.from_str()
, and is separated from otherPage
representations by|
.For reference, such a string can also be obtained by converting an existing
DisplayMessage
object 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
animate
ordelay
value, these defaults will be applied:Animate.VSCROLL
&delay=40
for the first page; andAnimate.HSCROLL
&delay=0
for 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 equivalentDisplayMessage
object to this one.
DisplayMessage.from_bytes()
Class Method¶
-
classmethod
DisplayMessage.
from_bytes
(bytes_in: bytes) → metlinkpid.DisplayMessage¶ Construct a
DisplayMessage
object 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
DisplayMessage
as understood by the display (not including the CRC-checksumming and packet-framing required for transmission).