Skip to content

Assignment of external objects not conform with MLS #54

@tbeu

Description

@tbeu

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 😒

  1. External objects in connectors are not legal since the connect statement is equivalent to an assignment equation.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions