modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
466 stars 166 forks source link

Shorten names of sensor models #2460

Open tobolar opened 6 years ago

tobolar commented 6 years ago

Sensor models spread across the library don't need to contain the word "sensor" in their name when collected in packages called "Sensors". Applying this rule, the sensor models' names can be shortened significantly. I suppose the 'Sensor' in the name is hangover from former library versions to simplify naming of sensor instances. But using defaultComponentName consequently can make it as well. This applies to

In contrast, the rule is already applied to Modelica.Fluid.Sensors. Despite no defaultComponentName is applied.

See also discussion in #2301.

HansOlsson commented 6 years ago

Hmm.... I agree with this change and removing the need for defaultComponentName for the classes. The shorter name removes redundant information when looking for the class. I feel that defaultComponentName is easily over-used and is non-intuitive for users, since we build up the expectation that the class-name is used as component-name, and then in some cases some other name is used.

tobolar commented 6 years ago

I don't know how much this also concerns to sensors. The motivation is simply to not repeat the name of the package in the classes contained. But in my opinion it is helpful to reflect "sensor" in the instance name.

I guess a broad agreement within MAP-LIB is needed to solve this issue.

christiankral commented 5 years ago

My opinion is that it does not make sense to have the word Sensor twice in the full qualified class name, e.g. Modelica.Electrical.Polyphase.Sensors.VoltageSensor. It yet makes sense to have sensor in the instance name.

Example

image

We rename Sensors.VoltageSensor to Sensors.Voltage and change the defaultComponentName to voltageSensor. In this case a user used to MSL 3.X may even not notice that the sensor class names changed, if instance names are still same as before.

christiankral commented 5 years ago

@tobolar Do you think a formal broad agreement within MAP-LIB is needed here? Shall we make a poll instead using :+1: and :-1: on this comment?

:+1: Remove Sensor from class name, keep sensor in defaultComponentName :-1: Keep it as it is

tobolar commented 5 years ago

Do you think a formal broad agreement within MAP-LIB is needed here?

This could be reasonable if we want to establish this as a common rule for developers. Imagine how this could simplify e.g. the following path: Modelica.Electrical.Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet to Modelica.Electrical.Machines.Basic.Synchronous.SM_PermanentMagnet. ;-)

@hansolsson

I feel that defaultComponentName is easily over-used and is non-intuitive for users...

I'm afraid to use defaultComponentName would be then necessary since the instance name shall in that case reflect more then just the component name. Otherwise it could be even more confusing:

model useTranslationalComponents
  Modelica.Mechanics.Translational.Sensors.Position position;
  Modelica.Mechanics.Translational.Sources.Position position1;
end useTranslationalComponents;
tobolar commented 4 years ago

Due to missing further discussion we'll not be able to fix this by feature freeze.