Communication functions
CServer package package includes Modelica functions encapsulating external C-functions.
The goal of these external C-functions is to communicate the simulation of the model and
the graphic user interface (C++ program automatically generated during the initialization process).
The communication is based on a client-server architecture.
The C++ view and the simulation of the model are the client and the server respectively.
The communication is performed using TCP sockets.
The external C-functions perform the following communication tasks:
| Name | Description |
|---|---|
| Start the C server | |
| Shutdown connection | |
| Function that gets information from the view | |
| Function that sends information to the view | |
| Start the server for nClients | |
| The client receives the chalk that allows to perform changes |
Start the C server
| Name | Description |
|---|---|
| nPort | Port number |
| Name | Description |
|---|---|
| fd | Socket descriptor |
Shutdown connection
| Name | Description |
|---|---|
| fd | Socket descriptor |
| Name | Description |
|---|---|
| sdStatus | Status of the connection |
Function that gets information from the view
| Name | Description |
|---|---|
| fd | Socket descriptor |
| lenCKI | Lenght of the arrays CK/I |
| Name | Description |
|---|---|
| out | |
| CK[lenCKI] | CK[i]=1 implies that the variable associated to the interactive control identified by the number i has changed its value |
| I[lenCKI] | Vector with the new values of the interactive variables modified due to a user action |
Function that sends information to the view
| Name | Description |
|---|---|
| fd | Socket descriptor |
| len | Length of array O |
| O[len] | Array containing the value of the interactive graphic properties sent to the view |
| intLen | Length of the array intO |
| intO[intLen] | Array containing the value of the interactive colors sent to the view |
| num | Number that identifies the component sending the values |
| Name | Description |
|---|---|
| out | =1 if the main window of the view has been closed |
Start the server for nClients
| Name | Description |
|---|---|
| nPort | Port number |
| nClients | Number of clients to be connected |
| launchView | 0/1 not/yes launch the view |
| Name | Description |
|---|---|
| nC | Number of clients actually connected |
| fd[nClients] | Socket descriptor |
The client receives the chalk that allows to perform changes
| Name | Description |
|---|---|
| fd | Socket descriptor |
| chalk | Deliver or not (1/0) then chalk |
| Name | Description |
|---|---|
| out | =1 if the main window of the view has been closed |