Header image  

an open-source HTTP and XML-RPC server for Matlab Simulink



How to use it

Building from source

Javascript demo

How to use it

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.

Config file

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.

S-function parameters

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.

Running it

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.

  • jsdemo, where you’ll get an demo of a javascript client (with the source included in the ./webroot directory).

XML-RPC interface

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.

double getVal(string ‘signal_name’)

setVal (string ‘signal_name’,double value)

int getNumInputs()

int getNumOutputs()

string getInputName(int)

string getOutputName(int)

struct getAllInputs()

struct getAllOutputs()