An example Simulink model is provided, in example.mdl.
Hint: The server works particularly well if you use it with Leonardo Daga’s Real-Time blockset (http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=3175&objectType=file), to slow the model simulation down to real-time, which makes the server more responsive and means that the client is getting real-time data.
First, edit the example config file (io_config.cfg) to define the lists of input and output signals you want to use. When you refresh the model (ctrl-d), the inputs and outputs should be updated from the config file.
The s-function parameters should be defined in the following format:
Where the first parameter is the TCP port you want the server to bind to (usually port 80 for an HTTP server).
The second parameter is the path of the config file, in single quotes.
The third parameter is always ‘gcb’, so that the s-function knows the ident of the block it has been associated with – so it can update the signal names of the i/o ports.
If you start the simulation running, you should see the following messages in the Matlab command window:
SimServer: Starting webserver thread
SimServer: ServerThread: Starting webserver on port 80
The server is now serving data on port 80.
To prove it, you can open your web-browser and go to the following URL: http://localhost
Other URLs of interest include:
stats, where you’ll get an XML report of the server status.
An example Python script has been provided which shows how the XML-RPC interface can be used to Get and Set data in a running Simulink model.
The XML-RPC API supports the following methods.