Table of Contents
Log Message
Logs messages to the model log file, if any has been specified.
Library
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Sinks/To Host')Description
QUARC provides a logging facility in which information about each run of a model may be logged to a file on the host. The Log Message block allows user-defined messages to be added to this log file. It formatted text to the log, much like the C language fprintf function prints to a file. Messages are appended to the log. For an overview of model logging, refer to the Model Logging section of the documentation.
For a description of the format strings, refer to Format Strings for Printing .
This block formats its inputs according to the given format string and then writes the formatted textual result to the log. The date and time are automatically prefixed to the message and a newline is appended at the end. For example, suppose the format string is:
"This is my message. Value of my signal is: [%lg]"
and the input is a 3-vector. Then the log entry might look like:
2010-07-16 11:05:56: This is my message. Value of my signal is: [0.5, 3.1415, 2.71828]
The format string may not contain the %n
format specifier, because it would
require an output port and the Log Message block does not provide any outputs (being like
a Scope).
The Log Message block is available in the External Mode Control Panel just like a Scope. As such, it responds to the same triggering options as Scopes. Messages are only written to the log while the Log Message block has been selected in the Signals & Triggering dialog and the trigger is armed.
The name of the log file is determined by the MEX-file arguments.. For convenience, the Log Message block provides a button, shown as "...", next to the Current log file name field. Clicking on the button opens the Set Model Log File dialog, which allows the log filename to be specified for the model. Model logging may also be enabled for all models via the Logging tab of the QUARC Preferences dialog. The current log file name, after format specifiers have been substituted, is displayed in the Current log file name field.
If automatic logging is enabled, then the default log filename is displayed in the
Current log file name parameter. If a different filename for the log has been
specified in the Set Model Log File dialog than the default recorded in the QUARC Preferences dialog
then logging will be enabled for the current model only. The log filename in this case is stored in
the MEX-file arguments, not in the block itself. Hence, deleting all Log Message blocks in the model will not disable
logging if a different filename than the default had been specified before deleting the block.
A warning is issued in this case when the last Log Message block is deleted from the model, giving
the option of turning off model logging or leaving it enabled.
Refer to MEX-file arguments.
for details on how the log filename is specified for a model. Note also that the log filename
is configuration dependent. A different log filename may be specified for each model configuration,
although the availability of the %t
format specifier in the log filename generally obviates
the need for a different log filename for each configuration.
Input Ports
...
The input ports contain the data to be formatted. The number of input ports is determined
by the number of format specifiers, such as %lg
, in the specified format
string. The %n
format specifier is not supported. All other valid format specifiers cause
corresponding input ports to be created. Variable-sized field widths, precisions
and code unit specifiers also cause input ports to be created in order to specify
the field width, precision or maximum number of code units. Inputs corresponding to string or
variable dimension format specifiers may be variable-size signals. See
Variable-Size Signals
for more information on variable-size signals.
Output Ports
This block has no output ports.
Data Type Support
For scalar quantities, the Log Message block accepts signals of any of the built-in Simulink data types at its data inputs. Fixed point is not currently supported.
For array quantities, as indicated by a dimension specifier in the format string, the Log Message block only accepts signals of the data type corresponding to the format specifier at that port.
Parameters and Dialog Box
Current log file name (tunable offline)
The filename of the log file, after format specifiers have been substituted. This field cannot be edited directly because the log file is actually a parameter of the model configuration and is not specific to the individual block. It is stored in the MEX-file arguments.. Use the button labelled "..." next to the Current log file name field to open the Set Model Log File dialog and change the log file name. If no file name is listed then no log will be generated and the Log Message block does nothing. A default log file name for all models may be specified via the QUARC Preferences dialog. If a default log file has been specified then this field will show the default log filename that has been assigned, after substituting for format specifiers.
This parameter is shared by all the Log Message blocks in the model. A separate log file cannot be created for each Log Message block. To make multiple files use a To Host File instead. |
This parameter is configuration-dependent. Changing the active model configuration will change the value of this parameter if a filename other than the default has been specified.
Format string
The format string used to format the data. Refer to the Format Strings for Printing page for a description of the format string. This parameter is treated as a string literal. It is not evaluated. Hence, do not enclose the format string in quotes unless you wish the quotes to appear in the output.
Maximum number of code units to print (tunable offline)
This parameter restricts the total number of code units written to the log. This limit is a hard limit. The total number of code units written to the log will never exceed this limit, even if the output for an input port is truncated or all the input ports have not been included in the output.
Sample time
The sample time of the block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.
A sample time of -1 indicates that the block inherits its sample time from the input. The block inherits the sample time by default.
To set the sample time to the fundamental sampling time of the model, use the qc_get_step_size function, which is a QUARC function that returns the fundamental sampling time of the model. The fundamental sampling time of the model is the sampling time entered in the Fixed step size field of the Solver pane of the Configuration parameters dialog.
Active during normal simulation (tunable offline)
Indicates whether this block should execute during normal simulation. If this option is not checked then the block will not write to the log during normal simulation. This parameter has no effect on generated code.
Targets
Target Name |
Compatible* |
Model Referencing |
Comments |
---|---|---|---|
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
Last fully supported in QUARC 2018. |
|
Rapid Simulation (RSIM) Target |
Yes |
Yes |
Logging is only supported for QUARC targets, not RSIM. |
S-Function Target |
No |
N/A |
Old technology. Use model referencing instead. |
Normal simulation |
Yes |
Yes |
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.