modelBCVTB
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
| Type | Name | Default | Description |
|---|---|---|---|
| SI.Time | samplePeriod (from DiscreteBlock) | Sample period of component | |
| SI.Time | startTime (from DiscreteBlock) | 0 | First sample time instant |
| Boolean | activateInterface | true | Set to false to deactivate interface and use instead yFixed as output |
| Modelica.Units.SI.Time | timeStep | Time step used for the synchronization | |
| String | xmlFileName | "socket.cfg" | Name of the file that is generated by the BCVTB and that contains the socket information |
| Integer | nDblWri | Number of double values to write to the BCVTB | |
| Integer | nDblRea | Number of double values to be read from the BCVTB | |
| Integer[nDblWri] | flaDblWri | zeros(nDblWri) | Flag for double values (0: use current value, 1: use average over interval, 2: use integral over interval) |
| Real[nDblWri] | uStart | Initial input signal, used during first data transfer with BCVTB | |
| Real[nDblRea] | yRFixed | zeros(nDblRea) | Fixed output, used if activateInterface=false |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Blocks.Interfaces.RealInput[nDblWri] | uR | Real inputs to be sent to the BCVTB | |
| Modelica.Blocks.Interfaces.RealOutput[nDblRea] | yR | Real outputs received from the BCVTB |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | flaRea | Flag received from BCVTB | |
| Modelica.Units.SI.Time | simTimRea | Current simulation time received from the BCVTB | |
| Integer | retVal | Return value from the BSD socket data exchange | |
| Real[nDblWri] | uRWri | Value to be sent to the interface |
Revisions
-
July 19, 2012, by Michael Wetter:
Added a call toBuildings.Utilities.IO.BCVTB.BaseClasses.exchangeRealsin theinitial algorithmsection. 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.