Ticket #91 (closed enhancement: wontfix)

Opened 6 months ago

Last modified 8 weeks ago

SignalType for Integer (Enumerations) / Boolean

Reported by: henrik.isernhagen@… Owned by: otter
Priority: normal Milestone: undecided
Component: *unspecified* Version: 3.0
Severity: normal Keywords:
Cc: Hide ticket: no

Description

For Real Signals it is possible to define a SignalType with an quantity and an display unit. In order to this, it is possible to describe the type of a signal.

Additionally, often Boolean Signals and also Integer Signals are used to describe a state and according to this a type of signal. An example is here the actual workaround for the Enumeration implementation as an Integer. Here, a quantity is normally added, too, e.g. "gear" and the according Integer represantation "-1, 0, 1, 2, ...".

If you use an Integer Signal as a representation of a state (e.g. http://www.modelica.org/events/modelica2008/Proceedings/sessions/session3c3.pdf) it should be possible to add the defined SignalType (the Enumeration with displayUnit) to the signal. In order to this it would be possible to plot a signal with label, e.g, "gear, transmission state, shifting type".

The same applies for a Boolean signal, because it is often used as a represenation of a state, e.g., "clutch open/close, ignition on/off".

Best regards,

Henrik

Attachments

Change History

Changed 6 months ago by otter

  • status changed from new to closed
  • resolution set to wontfix

In Modelica Standard Library 3.0, the definition of Real signals is changed to:

connector RealInput = input Real;

i.e., the SignalType was removed. The reason is that the previous definition

connector RealSignal
  replaceable type SignalType = Real;
  extends SignalType;
end RealSignal;
connector RealInput = input RealSignal;

is no longer allowed in Modelica 3, since "extending" from a "replaceable" class is forbidden (if a class is redeclared, the redeclared class could introduce elements that are already available and since the redeclared class is inherited, a name clash of the same elements could occur; in other words, redeclaration could fail).

Even if SignalType is not available, it is still possible to set all attributes of Real, Integer, Boolean signals (see p. 43 of the Modelica Language Specification version 3.0), although this is not so convenient. Example:

Integer gear(quantity="6-speed-gear");

Integer and Booleans have attributes "quantity, min, max, start, fixed", but they do not have "unit" or "displayUnit", because this does not make sense. In Dymola the "quantity" is not displayed in the GUI. However connections are only allowed, if the quantity attributes of the connected elements are identical (or one of them is the empty string) and this is checked in Dymola.

In Dymola 7.0 "real" enumerations are now supported. They are also used in MSL3.0 (and no longer emulated enumerations). It would therefore be best to use enumerations to your purpose, e.g., for a gear, since in principal the tool would have enough information to display this information also in the plot window. This is currently, however, not adviceable due to the following draw backs:

  1. When connectors with "enumerations" are used, then connections are only possible between identical enumerations. E.g., even if there is a generic block to work on Integer signals, this cannot be used with a connector that has enumerations. Therefore, all Integer blocks would have to be duplicated for every new enumeration connector (like "gear").
    The Modelica Assocation plans to fix this type of issues by introducing "type propagation" in one of the next versions. In such a case, Integer blocks could also be connected to enumeration connectors.
  2. Enumerations always start at 1. Dymola 7.0 displays not the enumeration value in the plot window but the Integer equivalent. For a gear, the plot result is therefore not so easy to interpret ("1" does not mean the first gear, but the rear-gear).

As a summary, enumerations should be currently only used for parameters and optional arguments of functions. For time varying enumerations, still the emulated enumerations (with package/constants) should be used.

Add/Change #91 (SignalType for Integer (Enumerations) / Boolean)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.