Opened 10 years ago
Last modified 10 years ago
#3285 closed defect
Errnoeus pathnames created by Omedit — at Initial Version
Reported by: | massimo ceraolo | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | high | Milestone: | 1.9.3 |
Component: | OMEdit | Version: | trunk |
Keywords: | Cc: |
Description
Consider the following simple package BugDrag, containing MSL's sine and integrator:
encapsulated package BugDrag import Modelica; block Sine "Generate sine signal" parameter Real amplitude = 1 "Amplitude of sine wave"; parameter Modelica.SIunits.Frequency freqHz(start = 1) "Frequency of sine wave"; parameter Modelica.SIunits.Angle phase = 0 "Phase of sine wave"; parameter Real offset = 0 "Offset of output signal"; parameter Modelica.SIunits.Time startTime = 0 "Output = offset for time < startTime"; extends Modelica.Blocks.Interfaces.SO; protected constant Real pi = Modelica.Constants.pi; equation y = offset + (if time < startTime then 0 else amplitude * Modelica.Math.sin(2 * pi * freqHz * (time - startTime) + phase)); annotation(Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Line(points = {{-80, 68}, {-80, -80}}, color = {192, 192, 192}), Polygon(points = {{-80, 90}, {-88, 68}, {-72, 68}, {-80, 90}}, lineColor = {192, 192, 192}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid), Line(points = {{-90, 0}, {68, 0}}, color = {192, 192, 192}), Polygon(points = {{90, 0}, {68, 8}, {68, -8}, {90, 0}}, lineColor = {192, 192, 192}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid), Line(points = {{-80, 0}, {-68.7, 34.2}, {-61.5, 53.1}, {-55.1, 66.4}, {-49.4, 74.6}, {-43.8, 79.1}, {-38.2, 79.8}, {-32.6, 76.6}, {-26.9, 69.7}, {-21.3, 59.4}, {-14.9, 44.1}, {-6.83, 21.2}, {10.1, -30.8}, {17.3, -50.2}, {23.7, -64.2}, {29.3, -73.1}, {35, -78.4}, {40.6, -80}, {46.2, -77.6}, {51.9, -71.5}, {57.5, -61.9}, {63.9, -47.2}, {72, -24.8}, {80, 0}}, color = {0, 0, 0}, smooth = Smooth.Bezier), Text(extent = {{-147, -152}, {153, -112}}, lineColor = {0, 0, 0}, textString = "freqHz=%freqHz")}), Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Line(points = {{-80, -90}, {-80, 84}}, color = {95, 95, 95}), Polygon(points = {{-80, 97}, {-84, 81}, {-76, 81}, {-80, 97}}, lineColor = {95, 95, 95}, fillColor = {95, 95, 95}, fillPattern = FillPattern.Solid), Line(points = {{-99, -40}, {85, -40}}, color = {95, 95, 95}), Polygon(points = {{97, -40}, {81, -36}, {81, -45}, {97, -40}}, lineColor = {95, 95, 95}, fillColor = {95, 95, 95}, fillPattern = FillPattern.Solid), Line(points = {{-41, -2}, {-31.6, 34.2}, {-26.1, 53.1}, {-21.3, 66.4}, {-17.1, 74.6}, {-12.9, 79.1}, {-8.64, 79.8}, {-4.42, 76.6}, {-0.201, 69.7}, {4.02, 59.4}, {8.84, 44.1}, {14.9, 21.2}, {27.5, -30.8}, {33, -50.2}, {37.8, -64.2}, {42, -73.1}, {46.2, -78.4}, {50.5, -80}, {54.7, -77.6}, {58.9, -71.5}, {63.1, -61.9}, {67.9, -47.2}, {74, -24.8}, {80, 0}}, color = {0, 0, 255}, thickness = 0.5, smooth = Smooth.Bezier), Line(points = {{-41, -2}, {-80, -2}}, color = {0, 0, 255}, thickness = 0.5), Text(extent = {{-87, 12}, {-40, 0}}, lineColor = {0, 0, 0}, textString = "offset"), Line(points = {{-41, -2}, {-41, -40}}, color = {95, 95, 95}), Text(extent = {{-60, -43}, {-14, -54}}, lineColor = {0, 0, 0}, textString = "startTime"), Text(extent = {{75, -47}, {100, -60}}, lineColor = {0, 0, 0}, textString = "time"), Text(extent = {{-80, 99}, {-40, 82}}, lineColor = {0, 0, 0}, textString = "y"), Line(points = {{-9, 80}, {43, 80}}, color = {95, 95, 95}), Line(points = {{-41, -2}, {50, -2}}, color = {95, 95, 95}), Polygon(points = {{33, 80}, {30, 67}, {36, 67}, {33, 80}}, lineColor = {95, 95, 95}, fillColor = {95, 95, 95}, fillPattern = FillPattern.Solid), Text(extent = {{37, 57}, {83, 39}}, lineColor = {0, 0, 0}, textString = "amplitude"), Polygon(points = {{33, -2}, {30, 11}, {36, 11}, {33, -2}, {33, -2}}, lineColor = {95, 95, 95}, fillColor = {95, 95, 95}, fillPattern = FillPattern.Solid), Line(points = {{33, 80}, {33, -2}}, color = {95, 95, 95})})); end Sine; block Integrator "Output the integral of the input signal" import Modelica.Blocks.Types.Init; parameter Real k(unit = "1") = 1 "Integrator gain"; parameter Modelica.Blocks.Types.Init initType = Modelica.Blocks.Types.Init.InitialState "Type of initialization (1: no init, 2: steady state, 3,4: initial output)" annotation(Evaluate = true, Dialog(group = "Initialization")); parameter Real y_start = 0 "Initial or guess value of output (= state)" annotation(Dialog(group = "Initialization")); extends Modelica.Blocks.Interfaces.SISO(y(start = y_start)); initial equation if initType == Init.SteadyState then der(y) = 0; elseif initType == Init.InitialState or initType == Init.InitialOutput then y = y_start; end if; equation der(y) = k * u; annotation(Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100.0, -100.0}, {100.0, 100.0}}, initialScale = 0.1), graphics = {Line(visible = true, points = {{-80.0, 78.0}, {-80.0, -90.0}}, color = {192, 192, 192}), Polygon(visible = true, lineColor = {192, 192, 192}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid, points = {{-80.0, 90.0}, {-88.0, 68.0}, {-72.0, 68.0}, {-80.0, 90.0}}), Line(visible = true, points = {{-90.0, -80.0}, {82.0, -80.0}}, color = {192, 192, 192}), Polygon(visible = true, lineColor = {192, 192, 192}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid, points = {{90.0, -80.0}, {68.0, -72.0}, {68.0, -88.0}, {90.0, -80.0}}), Text(visible = true, lineColor = {192, 192, 192}, extent = {{0.0, -70.0}, {60.0, -10.0}}, textString = "I"), Text(visible = true, extent = {{-150.0, -150.0}, {150.0, -110.0}}, textString = "k=%k"), Line(visible = true, points = {{-80.0, -80.0}, {80.0, 80.0}}, color = {0, 0, 127})}), Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Rectangle(extent = {{-60, 60}, {60, -60}}, lineColor = {0, 0, 255}), Line(points = {{-100, 0}, {-60, 0}}, color = {0, 0, 255}), Line(points = {{60, 0}, {100, 0}}, color = {0, 0, 255}), Text(extent = {{-36, 60}, {32, 2}}, lineColor = {0, 0, 0}, textString = "k"), Text(extent = {{-32, 0}, {36, -58}}, lineColor = {0, 0, 0}, textString = "s"), Line(points = {{-46, 0}, {46, 0}}, color = {0, 0, 0})})); end Integrator; annotation(uses(Modelica(version = "3.2.1"))); end BugDrag;
Imagine that we want, in OMEdit, create a new model, named MyModel, coat consistes on a sine and an integrator integrating the sine output.
Do the following:
1) drag sine in MyModel
2) drag Integrator into the model
3) connect the sine output with the Integrator input.
The following code is produced:
model MyModel BugDrag.sine sine1 annotation(Placement(visible = true, transformation(origin = {-54, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); BugDrag.Integrator integrator1 annotation(Placement(visible = true, transformation(origin = {-6, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation connect(integrator1.u, sine1.y) annotation(Line(points = {{-18, 0}, {-44, 0}, {-44, 0}, {-44, 0}, {-44, 0}}, color = {0, 0, 127})); annotation(Icon(coordinateSystem(extent = {{-100, -80}, {100, 80}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}))); end MyModel;
that does not check, because the substring "BugDrag."
If the package is not encapsulated the issue is not there.
I think we have here two issues:
1) the prefix containing the package name (here "BugDrag") should not be automatically added, at least for encapsulated packages
2) OMEdit shows these dragged models as being correct, even though they are not accessible. SInche their pathnames make them non-accessible, they should be displayed as red boxes.