Open javiarrobas opened 4 years ago
This is a duplicate of https://github.com/ibpsa/project1-boptest/issues/116, raised by @SenHuang19, who has also thought about it. I don't have an immediate solution and need to think on it.
Consider the following example:
model test_model
IBPSA.Controls.Continuous.SignalRanker sigRan(nin=3);
Modelica.Blocks.Sources.Sine sine(freqHz=1/86400);
Modelica.Blocks.Sources.Sine sine1(freqHz=1/36400);
Modelica.Blocks.Sources.Sine sine2(freqHz=1/56400);
IBPSA.Utilities.IO.SignalExchange.Overwrite overwrite[3];
IBPSA.Utilities.IO.SignalExchange.Read read[3];
equation
connect(sine.y, sigRan.u[1]);
connect(sine1.y, sigRan.u[2]);
connect(sine2.y, sigRan.u[3]);
connect(sigRan.y, overwrite.u);
connect(sigRan.u, read.u);
end test_model;
If we resolve the syntax error as @JavierArroyoBastida mentioned, we can generate a wrapper model as below:
model wrapped "Wrapped model"
// Input overwrite
Modelica.Blocks.Interfaces.RealInput u[3] "Signal for overwrite blocks";
Modelica.Blocks.Interfaces.BooleanInput u_activate[3] "Activation for overwrite blocks";
// Out read
Modelica.Blocks.Interfaces.RealOutput y[3] = mod.read.y "Measured signal";
// Original model
test_model mod(overwrite(uExt(y=u),activate(y=u_activate))) "Original model with overwrites";
end wrapped;
This wrapper model can be compiled with no error.
However, when one tries to do
model wrapped "Wrapped model"
// Input overwrite
Modelica.Blocks.Interfaces.RealInput u1 "Signal for overwrite block 1";
Modelica.Blocks.Interfaces.BooleanInput u_activate1 "Activation for overwrite block 1";
Modelica.Blocks.Interfaces.RealInput u2 "Signal for overwrite block 2";
Modelica.Blocks.Interfaces.BooleanInput u_activate2 "Activation for overwrite block 2";
Modelica.Blocks.Interfaces.RealInput u3 "Signal for overwrite block 3";
Modelica.Blocks.Interfaces.BooleanInput u_activate3 "Activation for overwrite block 3";
// Out read
Modelica.Blocks.Interfaces.RealOutput y[3] = mod.read.y "Measured signal";
// Original model
test_model mod(overwrite[1](uExt(y=u1),activate(y=u_activate1)),overwrite[2](uExt(y=u2),activate(y=u_activate2)),overwrite[3](uExt(y=u3),activate(y=u_activate3))) "Original model with overwrites";
end wrapped;
an error throws out
Error: Modifiers of specific array elements are not allowed
One solution to this is to do
model wrapped "Wrapped model"
// Input overwrite
Modelica.Blocks.Interfaces.RealInput u1 "Signal for overwrite block 1";
Modelica.Blocks.Interfaces.BooleanInput u_activate1 "Activation for overwrite block 1";
Modelica.Blocks.Interfaces.RealInput u2 "Signal for overwrite block 2";
Modelica.Blocks.Interfaces.BooleanInput u_activate2 "Activation for overwrite block 2";
Modelica.Blocks.Interfaces.RealInput u3 "Signal for overwrite block 3";
Modelica.Blocks.Interfaces.BooleanInput u_activate3 "Activation for overwrite block 3";
// Out read
Modelica.Blocks.Interfaces.RealOutput y[3] = mod.read.y "Measured signal";
// Original model
test_model mod(overwrite(uExt(y={u1,u2,u3}),activate(y={u_activate1,u_activate2,u_activate3}))) "Original model with overwrites";
end wrapped;
For some cases it may be very useful to instantiate the
Read
andOverwrite
blocks of the IBPSA library as arrays, particularly for large buildings like the commercial multi-zone hydronic testcase. Right now that is not possible because the parser builds the input-output names of the wrapped model based on the names of theRead
andOverwrite
blocks appending_u
and_y
in the end, which leads to a name that is not allowed because of the use of brackets within the resulting name.The name can be easily modified by identifying the brackets in the block name and substituting them by any string like
_index{i}
in:https://github.com/ibpsa/project1-boptest/blob/95221ca256798efe8acc368f3aaf1c9b31276ee2/parsing/parser.py#L226
However, changig the "// Original model" section of the
wrapped.mo
is not that easy as it's possible to get:Error: Modifiers of specific array elements are not allowed
@dhblum can you think of a workaround for that?
also @icupeiro FYI.