Diagnostics Using a Client-Server Architecture
Diagnostic Messaging with Simulink Functions
Use Simulink® functions when you define a diagnostic service where callers pass an error code. The service tracks error codes for all errors that occur. One way to implement this service is to use an indexed Data Store Memory block. A diagnostic monitoring system can then periodically check for the occurrence of specific errors and modify system behavior accordingly.
You can use Simulink Function blocks and Function Caller blocks to model client-server architectures. Uses for this architecture include memory storage and diagnostics.
As an example, create a model of a simple distributed system consisting of multiple control applications (clients), each of which can report diagnostics throughout execution. Since client-server architectures are typically constructed in layers, add a service layer to model the diagnostic interface.
The services (servers), modeled using Simulink Function blocks, are in a separate model. Add the service model to your system model as a referenced model.
The control applications (clients) interact with the diagnostic interface using Function Caller blocks.
Application 1 reports a diagnostic condition by invoking the
reportDiagnostic interface within the service layer. The application
calls this function while passing in a diagnostic identifier.
The interval test determines when to create a diagnostic identifier.
The implementation of the function (Simulink Function 1) tracks the passed-in identifier by transferring the value to a graphical output of the function. A graphical output is a server-side signal that is not part of the server interface but facilitates communication between service functions through function arguments. The value of graphical outputs is held between function invocations.
reportDiagnostic function is an example of a modifier pattern.
This pattern helps to communication of data from the caller to the function and later
computations based on that data.
Application 2 invokes the
inspectDiagnostic interface within the
service layer to inspect whether diagnostics were reported.
The implementation of the function (Simulink Function) uses a graphical input
id) to observe the last reported diagnostic and transfer this value as
an output argument (
identifier) to the caller. A graphical input is a
server-side signal that is not part of the server interface.
inspectDiagnostic function is an example of an observer pattern.
This pattern helps to communication of data from the function to the caller.
Simulink Function | Argument Inport | Argument Outport | Function Caller | MATLAB Function