-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Customer asked for UDP support in SimulationX. Thus I tried to figure out why SerialPackager fails in SimulationX. The reason is that the external objects, i.e. there constructors are used in assignments which is illegal according to the MLS 3.3 (rev 1) section 12.9.7: "Only the constructor may return external objects and external object can only be bound in component declarations and neither modified later nor assigned to."
Thus the current design of the SerialPackager and the Communication package is bad in two ways 😒
- External objects in connectors are not legal since the connect statement is equivalent to an assignment equation.
- Constructing the external object in
when initial()is not legal at all.
Whereas SimulationX is tolerant with the first problem the second problem is a really bad design failure. I changed the construction of the external object from something like
model Packager
Interfaces.PackageOut pkgOut;
protected
Integer bufferSize;
equation
when initial() then
bufferSize = something;
pkgOut.pkg = SerialPackager(bufferSize); // create external object here
end when;
end Packager;to
model Packager
Interfaces.PackageOut pkgOut(pkg = SerialPackager(bufferSize));
protected
Integer bufferSize;
equation
when initial() then
bufferSize = something;
end when;
end Packager;which still violates the first problem but could fix the second one. However, this now reveals the bad design of the auto propagation of the buffer size. It is not clear which external object defines the auto buffer size and which external object uses the derived buffer size.
In the need for a quick fix for the second problem I would consider to either use a fixed buffer size or refer to some global parameters like e.g. Modelica.Mechanics.MultiBody.World of the MSL holds.
@bernhard-thiele, @MartinOtter What do you think? Can we find a workaround in order to get the customer project running soon? Do you have other ideas to fix the second problem (or even the first problem to make the library really standard conform)? I am willing to contribute of course.