Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mustBeConnected based on cardinality assert (which is deleted) #210

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions PlanarMechanics/Interfaces/PartialTwoFrames.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ partial model PartialTwoFrames "Partial model with two frames"

Frame_a frame_a
"Coordinate system fixed to the component with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})));
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Frame_b frame_b
"Coordinate system fixed to the component with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{84,-16},{116,16}})));
annotation (Placement(transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");

protected
outer PlanarMechanics.PlanarWorld planarWorld "Planar world model";

equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of " + getInstanceName() + " is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of " + getInstanceName() + " is not connected");

annotation (Documentation(revisions="<html>
<p>
<img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\" alt=\"DLR logo\">
<strong>Developed 2010 at the DLR Institute of System Dynamics and Control</strong>
</p>
</html>", info="<html>
<p>This is a partial model with two planar frames. It can be inherited to build up models with 2 planar flanges.</p>
<p>
This is a partial model with two planar frames. It can be inherited to build up models
with two planar flanges.
</p>
<!--
This partial model provides two planar frame connectors, access to the world
object and an assert to check that both frame connectors are connected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ model BasicTransformAbsoluteVector

Interfaces.Frame_a frame_a
"Coordinate system from which absolute kinematic quantities are measured" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");

Interfaces.Frame_resolve frame_resolve
"Coordinate system in which vector is optionally resolved"
annotation (Placement(transformation(extent={{-16,-16},{16,16}},
origin={100,0}),
iconTransformation(extent={{-16,-16},{16,16}},
origin={100,0})));
origin={100,0})),
mustBeConnected="Connector frame_resolve should be connected",
mayOnlyConnectOnce="Connector frame_resolve must be connected exactly once");

Modelica.Blocks.Interfaces.RealInput r_in[3]
"Input vector resolved in frame defined by frame_r_in"
Expand All @@ -39,8 +42,6 @@ protected
"Orientation object from frame in which r_in is resolved to world frame";
Real r_temp[3] "Temporary vector in transformation calculation";
equation
assert(cardinality(frame_a) > 0, "Connector frame_a must be connected at least once");
assert(cardinality(frame_resolve) == 1, "Connector frame_resolve must be connected exactly once");
frame_a.fx = 0;
frame_a.fy = 0;
frame_a.t = 0;
Expand Down
9 changes: 5 additions & 4 deletions PlanarMechanics/Sensors/Internal/PartialAbsoluteBaseSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ model PartialAbsoluteBaseSensor

Interfaces.Frame_a frame_a
"Coordinate system from which kinematic quantities are measured" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");

Interfaces.Frame_resolve frame_resolve
"Coordinate system in which vector is optionally resolved"
Expand All @@ -14,11 +15,11 @@ model PartialAbsoluteBaseSensor
origin={0,-100}),
iconTransformation(extent={{-16,-16},{16,16}},
rotation=-90,
origin={0,-100})));
origin={0,-100})),
mustBeConnected="Connector frame_resolve should be connected",
mayOnlyConnectOnce="Connector frame_resolve must be connected exactly once");

equation
assert(cardinality(frame_a) > 0, "Connector frame_a must be connected at least once");
assert(cardinality(frame_resolve) == 1, "Connector frame_resolve must be connected exactly once");
frame_a.fx = 0;
frame_a.fy = 0;
frame_a.t = 0;
Expand Down
13 changes: 7 additions & 6 deletions PlanarMechanics/Sensors/Internal/PartialAbsoluteSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ partial model PartialAbsoluteSensor

Interfaces.Frame_a frame_a
"Coordinate system at which the kinematic quantities are measured"
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})));
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");

equation
assert(cardinality(frame_a) > 0, "Connector frame_a must be connected at least once");
annotation (Icon(coordinateSystem(preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
graphics={
Text(
extent={{-108,43},{-72,18}},
textColor={128,128,128},
textString="a"),
Line(points={{-70,0},{-96,0},{-96,0}})}));
Line(
points={{-70,0},{-96,0},{-96,0}})}));
end PartialAbsoluteSensor;
17 changes: 8 additions & 9 deletions PlanarMechanics/Sensors/Internal/PartialCutForceBaseSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ partial model PartialCutForceBaseSensor

extends Modelica.Icons.RoundSensor;
Interfaces.Frame_a frame_a "Coordinate system a" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b "Coordinate system b" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));
transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");
Interfaces.Frame_resolve frame_resolve
"The output vector is optionally resolved in this frame (cut-force/-torque are set to zero)"
"Output vector is optionally resolved in this frame (cut-force/-torque are set to zero)"
annotation (Placement(transformation(
origin={80,-100},
extent={{-16,-16},{16,16}},
rotation=270)));
rotation=270)),
mustBeConnected="Connector frame_resolve should be connected",
mayOnlyConnectOnce="Connector frame_resolve must be connected exactly once");

parameter Modelica.Mechanics.MultiBody.Types.ResolveInFrameA resolveInFrame=
Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_a
Expand All @@ -21,11 +25,6 @@ partial model PartialCutForceBaseSensor
protected
outer PlanarWorld planarWorld;
equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of cut-force/-torque sensor object is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of cut-force/-torque sensor object is not connected");

// frame_a and frame_b are identical
{frame_a.x, frame_a.y} = {frame_b.x, frame_b.y};
frame_a.phi = frame_b.phi;
Expand Down
16 changes: 7 additions & 9 deletions PlanarMechanics/Sensors/Internal/PartialCutForceSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@ partial model PartialCutForceSensor

extends Modelica.Icons.RoundSensor;
Interfaces.Frame_a frame_a "Coordinate system a" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b "Coordinate system b" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));
transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");
Interfaces.Frame_resolve frame_resolve
if resolveInFrame==Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_resolve
"Output vectors are optionally resolved in this frame (cut-force/-torque are set to zero)"
"Output vector are optionally resolved in this frame (cut-force/-torque are set to zero)"
annotation (Placement(transformation(
origin={80,-100},
extent={{-16,-16},{16,16}},
rotation=270)));
rotation=270)),
mustBeConnected="An enabled frame_resolve connector should be connected");

parameter Modelica.Mechanics.MultiBody.Types.ResolveInFrameA resolveInFrame=
Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_a
"Frame in which output vector(s) is/are resolved (1: world, 2: frame_a, 3: frame_resolve)";

protected
outer PlanarWorld planarWorld;
equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of cut-force/-torque sensor object is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of cut-force/-torque sensor object is not connected");

annotation (
Documentation(
Expand Down
18 changes: 9 additions & 9 deletions PlanarMechanics/Sensors/Internal/PartialCutTorqueBaseSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ partial model PartialCutTorqueBaseSensor

extends Modelica.Icons.RoundSensor;
Interfaces.Frame_a frame_a "Coordinate system a" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b "Coordinate system b" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));
transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");
// Interfaces.Frame_resolve frame_resolve
// "The output vector is optionally resolved in this frame (cut-force/-torque are set to zero)"
// annotation (Placement(transformation(
Expand All @@ -22,11 +24,6 @@ partial model PartialCutTorqueBaseSensor
protected
outer PlanarWorld planarWorld;
equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of cut-force/-torque sensor object is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of cut-force/-torque sensor object is not connected");

// frame_a and frame_b are identical
{frame_a.x, frame_a.y} = {frame_b.x, frame_b.y};
frame_a.phi = frame_b.phi;
Expand All @@ -51,10 +48,13 @@ cut-torque acting between the two frames and
to provide the measured signals as output for further processing
with the blocks of package Modelica.Blocks.
</p>
</html>"), Icon(coordinateSystem(
</html>"),
Icon(
coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
grid={2,2}), graphics={
grid={2,2}),
graphics={
Line(points={{-70,0},{-101,0}}),
Line(points={{70,0},{100,0}}),
Text(
Expand Down
11 changes: 4 additions & 7 deletions PlanarMechanics/Sensors/Internal/PartialCutTorqueSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ partial model PartialCutTorqueSensor

extends Modelica.Icons.RoundSensor;
Interfaces.Frame_a frame_a "Coordinate system a" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b "Coordinate system b" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));
transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");
// Interfaces.Frame_resolve frame_resolve if
// resolveInFrame==Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_resolve
// "Output vectors are optionally resolved in this frame (cut-force/-torque are set to zero)"
Expand All @@ -22,11 +24,6 @@ partial model PartialCutTorqueSensor

protected
outer PlanarWorld planarWorld;
equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of cut-force/-torque sensor object is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of cut-force/-torque sensor object is not connected");

annotation (
Documentation(revisions="<html>
Expand Down
38 changes: 20 additions & 18 deletions PlanarMechanics/Sensors/Internal/PartialRelativeBaseSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ model PartialRelativeBaseSensor

Interfaces.Frame_a frame_a
"Coordinate system a (measurement is between frame_a and frame_b)" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b
"Coordinate system b (measurement is between frame_a and frame_b)" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));

transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");
Interfaces.Frame_resolve frame_resolve
"Coordinate system in which vector is optionally resolved"
annotation (Placement(transformation(extent={{84,64},{116,96}}),
iconTransformation(extent={{84,65},{116,97}})));
iconTransformation(extent={{84,65},{116,97}})),
mustBeConnected="Connector frame_resolve should be connected",
mayOnlyConnectOnce="Connector frame_resolve must be connected exactly once");

equation
assert(cardinality(frame_a) > 0, "Connector frame_a must be connected at least once");
assert(cardinality(frame_b) > 0, "Connector frame_b must be connected at least once");
assert(cardinality(frame_resolve) == 1, "Connector frame_resolve must be connected exactly once");
frame_a.fx = 0;
frame_a.fy = 0;
frame_a.t = 0;
frame_b.fx = 0;
frame_b.fy = 0;
frame_b.t = 0;
frame_resolve.fx = 0;
frame_resolve.fy = 0;
frame_resolve.t = 0;
annotation (Icon(coordinateSystem(preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
frame_a.fx = 0;
frame_a.fy = 0;
frame_a.t = 0;
frame_b.fx = 0;
frame_b.fy = 0;
frame_b.t = 0;
frame_resolve.fx = 0;
frame_resolve.fy = 0;
frame_resolve.t = 0;

annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
graphics={
Text(
extent={{-108,43},{-72,18}},
textColor={128,128,128},
Expand Down
9 changes: 4 additions & 5 deletions PlanarMechanics/Sensors/Internal/PartialRelativeSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ partial model PartialRelativeSensor
extends Modelica.Icons.RoundSensor;

Interfaces.Frame_a frame_a "Coordinate system a" annotation (Placement(
transformation(extent={{-116,-16},{-84,16}})));
transformation(extent={{-116,-16},{-84,16}})),
mustBeConnected="Connector frame_a should be connected");
Interfaces.Frame_b frame_b "Coordinate system b" annotation (Placement(
transformation(extent={{84,-16},{116,16}})));
transformation(extent={{84,-16},{116,16}})),
mustBeConnected="Connector frame_b should be connected");

equation
assert(cardinality(frame_a) > 0, "Connector frame_a must be connected at least once");
assert(cardinality(frame_b) > 0, "Connector frame_b must be connected at least once");
annotation (Icon(coordinateSystem(preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Text(
Expand Down