I'm trying to connect a vector of connector to a vector of expandable connector. Here is the sample code to reproduce the issues. I explore 3 ways to do the connections, through blocks Adapter One to Three.
What am I doing wrong ?
Tested with OME v1.23.1 (64bits) and Dymola 2024 refresh1 (windows 64bits)
package Test
expandable connector Bus
end Bus;
connector IntegerOutput = output Integer;
block Source
IntegerOutput y=1;
end Source;
block AdapterOne
parameter Integer numberOfItems = 2;
Bus engineBus[numberOfItems];
Source source[numberOfItems](each y=3);
equation
connect(source.y, engineBus.value);
end AdapterOne;
block AdapterTwo
parameter Integer numberOfItems = 2;
Bus engineBus[numberOfItems];
Source source[numberOfItems](each y=3);
equation
connect(source[1].y, engineBus[1].level);
connect(source[2].y, engineBus[2].level);
end AdapterTwo;
model AdapterThree
parameter Integer numberOfItems = 2;
Bus engineBus[numberOfItems];
Source source[numberOfItems](each y=3);
equation
for i in 1:numberOfItems loop
connect(source[i].y, engineBus[i].level);
end for;
end AdapterThree;
end Test;
The code is correct (unless I missed something), and all cases will work in the next release of Dymola. A work-around for Dymola is to use the following:
block AdapterTwoAndHalf
parameter Integer numberOfItems = 2;
Bus engineBus[numberOfItems];
Source source[numberOfItems](each y=3);
equation
connect(source[1:numberOfItems].y, engineBus[1:numberOfItems].level);
end AdapterTwoAndHalf;