impure functionLogDisplayMessages

Writes the k last messages of a payload of the display link in the simulation log, one line each, and returns k - to be assigned to a variable, so that the call survives the initialization

Information

Shared by the displays (Peripherals.Display, Internal.Devices.PartialTextDisplay), at initial() as well as at each change(displayLink.seq).

Why a function with an output: in a when {initial(), change(...)}, OpenModelica (checked with 1.24.4 and 1.27.1) keeps the assignments of the initial() branch but drops a bare call to Modelica.Utilities.Streams.print (a call without result); a message written by the program before its first sleep() (t = 0, first sync point, during the initialization) was then missing from the log. Assigning the result keeps the call.

Inputs

TypeNameDefaultDescription
IntegerkNumber of messages to log, the last ones of payload
StringprefixStart of each log line
Stringpayload

Outputs

TypeNameDefaultDescription
Integerloggedk