modelBCVTB

Block that exchanges data with the Building Controls Virtual Test Bed

Extends from Modelica.Blocks.Interfaces.DiscreteBlock (Base class of discrete control blocks).

Information

Block that exchanges data with the Building Controls Virtual Test Bed (BCVTB).

At the start of the simulation, this block establishes a socket connection using the Berkeley Software Distribution socket (BSD socket). At each sampling interval, data are exchanged between Modelica and the BCVTB. When Dymola terminates, a signal is sent to the BCVTB so that it can terminate gracefully.

For each element in the input vector uR[nDblWri], the value of the flag flaDblWri[nDblWri] determines whether the current value, the average over the sampling interval or the integral over the sampling interval is sent to the BCVTB. The following three options are allowed:

flaDblWri[i] Value sent to the BCVTB
0 Current value of uR[i]
1 Average value of uR[i] over the sampling interval
2 Integral of uR[i] over the sampling interval

For the first call to the BCVTB interface, the value of the parameter uStart[nDblWri] will be used instead of uR[nDblWri]. This avoids an algebraic loop when determining the initial conditions. If uR[nDblWri] were to be used, then computing the initial conditions may require an iterative solution in which the function exchangeWithSocket may be called multiple times. Unfortunately, it does not seem possible to use a parameter that would give a user the option to either select uR[i] or uStart[i] in the first data exchange. The reason is that the symbolic solver does not evaluate the test that picks uR[i] or uStart[i], and hence there would be an algebraic loop.

If the parameter activateInterface is set to false, then no data is exchanged with the BCVTB. The output of this block is then equal to the value of the parameter yRFixed[nDblRea]. This option can be helpful during debugging. Since during model translation, the functions are still linked to the C library, the header files and libraries need to be present in the current working directory even if activateInterface=false.

Parameters

TypeNameDefaultDescription
SI.TimesamplePeriod (from DiscreteBlock)Sample period of component
SI.TimestartTime (from DiscreteBlock)0First sample time instant
BooleanactivateInterfacetrueSet to false to deactivate interface and use instead yFixed as output
Modelica.Units.SI.TimetimeStepTime step used for the synchronization
StringxmlFileName"socket.cfg"Name of the file that is generated by the BCVTB and that contains the socket information
IntegernDblWriNumber of double values to write to the BCVTB
IntegernDblReaNumber of double values to be read from the BCVTB
Integer[nDblWri]flaDblWrizeros(nDblWri)Flag for double values (0: use current value, 1: use average over interval, 2: use integral over interval)
Real[nDblWri]uStartInitial input signal, used during first data transfer with BCVTB
Real[nDblRea]yRFixedzeros(nDblRea)Fixed output, used if activateInterface=false

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealInput[nDblWri]uRReal inputs to be sent to the BCVTB
Modelica.Blocks.Interfaces.RealOutput[nDblRea]yRReal outputs received from the BCVTB

Components

TypeNameDefaultDescription
IntegerflaReaFlag received from BCVTB
Modelica.Units.SI.TimesimTimReaCurrent simulation time received from the BCVTB
IntegerretValReturn value from the BSD socket data exchange
Real[nDblWri]uRWriValue to be sent to the interface

Revisions

  • July 19, 2012, by Michael Wetter:
    Added a call to Buildings.Utilities.IO.BCVTB.BaseClasses.exchangeReals in the initial algorithm section. This is needed to propagate the initial condition to the server. It also leads to one more data exchange, which is correct and avoids the warning message in Ptolemy that says that the simulation reached its stop time one time step prior to the final time.
  • January 19, 2010, by Michael Wetter:
    Introduced parameter to set initial value to be sent to the BCVTB. In the prior implementation, if a variable was in an algebraic loop, then zero was sent for this variable.
  • May 14, 2009, by Michael Wetter:
    First implementation.