Opened 11 years ago

Closed 10 years ago

#2727 closed defect (fixed)

Inherited modifications are lost when redeclaring a component.

Reported by: Peter Aronsson Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

Consider the following models:

package Bug
  model M1
    replaceable Modelica.Blocks.Sources.Clock clock;
  end M1;

  model M2
    extends M1(clock.offset = 10, clock.startTime = 20);
  end M2;

  model M3
    extends M2(redeclare Modelica.Blocks.Sources.ExpSine clock);
  end M3;
end Bug;

Instantiate Bug.M2 (correct result):

class Bug.M2
  output Real clock.y \"Connector of Real output signal\";
  parameter Real clock.offset(quantity = \"Time\", unit = \"s\") = 10.0 \"Offset of output signal\";
  parameter Real clock.startTime(quantity = \"Time\", unit = \"s\") = 20.0 \"Output = offset for time < startTime\";
equation
  clock.y = clock.offset + (if time < clock.startTime then 0.0 else time - clock.startTime);
end Bug.M2;

Instantiate Bug.M3 (the modification clock.startTime=10 and clock.startTime=20 that should have been inherited from Bug.M2 are lost):

class Bug.M3
  output Real clock.y \"Connector of Real output signal\";
  parameter Real clock.amplitude = 1.0 \"Amplitude of sine wave\";
  parameter Real clock.freqHz(quantity = \"Frequency\", unit = \"Hz\", start = 2.0) \"Frequency of sine wave\";
  parameter Real clock.phase(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = 0.0 \"Phase of sine wave\";
  parameter Real clock.damping(quantity = \"DampingCoefficient\", unit = \"s-1\", start = 1.0) \"Damping coefficient of sine wave\";
  parameter Real clock.offset = 0.0 \"Offset of output signal\";
  parameter Real clock.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Output = offset for time < startTime\";
  protected constant Real clock.pi = 3.141592653589793;
equation
  clock.y = clock.offset + (if time < clock.startTime then 0.0 else clock.amplitude * exp((clock.startTime - time) * clock.damping) * sin(6.283185307179586 * clock.freqHz * (time - clock.startTime) + clock.phase));
end Bug.M3

Change History (2)

comment:1 by Adrian Pop, 11 years ago

Owner: changed from somebody to Adrian Pop
Status: newaccepted

comment:2 by Adrian Pop, 10 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r22600 (well, earlier but now there are tests for it).

Note: See TracTickets for help on using tickets.