Interactive.src.CServer

Communication functions

Information

CServer package

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:

        

Package Content

Name Description
Interactive.src.CServer.startCserver startCserver Start the C server
Interactive.src.CServer.shutdownConnection shutdownConnection Shutdown connection
Interactive.src.CServer.getVarValues getVarValues Function that gets information from the view
Interactive.src.CServer.sendOutput sendOutput Function that sends information to the view
Interactive.src.CServer.startNClientCserver startNClientCserver Start the server for nClients
Interactive.src.CServer.sendChalk sendChalk The client receives the chalk that allows to perform changes

Interactive.src.CServer.startCserver

Start the C server

Inputs

NameDescription
nPortPort number

Outputs

NameDescription
fdSocket descriptor

Interactive.src.CServer.shutdownConnection

Shutdown connection

Inputs

NameDescription
fdSocket descriptor

Outputs

NameDescription
sdStatusStatus of the connection

Interactive.src.CServer.getVarValues

Function that gets information from the view

Inputs

NameDescription
fdSocket descriptor
lenCKILenght of the arrays CK/I

Outputs

NameDescription
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

Interactive.src.CServer.sendOutput

Function that sends information to the view

Inputs

NameDescription
fdSocket descriptor
lenLength of array O
O[len]Array containing the value of the interactive graphic properties sent to the view
intLenLength of the array intO
intO[intLen]Array containing the value of the interactive colors sent to the view
numNumber that identifies the component sending the values

Outputs

NameDescription
out=1 if the main window of the view has been closed

Interactive.src.CServer.startNClientCserver

Start the server for nClients

Inputs

NameDescription
nPortPort number
nClientsNumber of clients to be connected
launchView0/1 not/yes launch the view

Outputs

NameDescription
nCNumber of clients actually connected
fd[nClients]Socket descriptor

Interactive.src.CServer.sendChalk

The client receives the chalk that allows to perform changes

Inputs

NameDescription
fdSocket descriptor
chalkDeliver or not (1/0) then chalk

Outputs

NameDescription
out=1 if the main window of the view has been closed
Automatically generated Thu Apr 28 12:24:24 2022.