1 function [retVal, flaRea, simTimRea, dblValRea ] = ...
2 exchangeDoublesWithSocket(
sockfd, flaWri, nDblRea, simTimWri, dblValWri)
3 % EXCHANGEDOUBLESWITHSOCKET - Exchanges data with the BCVTB
6 %
sockfd, flaWri, nDblRea, simTimWri, dblValWri);
7 % exchanges data with the BCVTB.
9 % The input arguments
are:
10 %
sockfd - Socket file descripter
11 % flaWri - Communication flag to write to the socket stream. Set to zero
12 % for normal operation, or to a negative value to stop
14 % nDblRea - Number of
double values to read.
15 % simTimWri - Current simulation time in seconds to write to the BCVTB.
16 % dblValWri - Vector of
double values to write to the BCVTB.
18 % The return values
are:
19 % retVal - A non-negative value if the data exchange was successfull,
20 % or a negative value if an error occured.
21 % flaRea - Communication flag read from the socket stream.
22 % flaRea < 0 indicates that the BCVTB will stop due to an error
23 % and not send any more data.
24 % flaRea == 0 is for normal operation.
25 % flaRea == 1 indicates that the final simulation time has
26 % been reached and no more data wil be exchanged.
27 % simTimRea - Current simulation time in seconds read from the socket.
28 % dblValRea - Vector of double values read from the socket.
33 % 2009-06-26 MWetter@lbl.gov: First version, based on code of
34 % Charles Corbin, UC Boulder
36 % Maximum number of double values. See defines.h for how to change it.
39 % Ensure that we will not attempt to read too many
double values
41 msg=['Attempted to read ', int2str(nDblRea), ...
42 ' double values which is above the limit of ', ...
43 int2str(NDBLMAX), '.'];
44 ME = MException(
'BCVTB:ConfigurationError', ...
50 % Get pointer of arguments
66 retVal = calllib(getBCVTBLibName(),
'exchangedoubleswithsocket',
sockfd, ...
77 % Ensure that we read as many
double values as expected
79 msg=['Read ', int2str(nDblReceived), ...
80 ' double values but expected to read ', int2str(nDblRea), '.'];
81 ME = MException(
'BCVTB:ConfigurationError', ...
87 % Get
return values from pointers
exchanges data with the BCVTB The input arguments are
end Get pointer of arguments INT32PTR
end Get return values from pointers flaRea
static void XMLCALL end(void *data, const char *el)
Call back functions that will be used by the expat xml parser.
#define NDBLMAX
Maximum number of double values that can be exchanged by Simulink.