1 | package params
|
---|
2 |
|
---|
3 | import T = Modelica.Mechanics.Translational;
|
---|
4 |
|
---|
5 | model drivetrain
|
---|
6 |
|
---|
7 | type DirectionOfTravel = enumeration(Forward, Backward);
|
---|
8 |
|
---|
9 | T.Sources.ConstantForce forward_engine(f_constant=1);
|
---|
10 | T.Sources.ConstantForce reverse_engine(f_constant=-1);
|
---|
11 | T.Components.Fixed ground;
|
---|
12 | T.Components.Mass body(m=1, v.start=0, v.fixed=true, s.start=0, s.fixed=true);
|
---|
13 |
|
---|
14 | parameter DirectionOfTravel direction = DirectionOfTravel.Forward;
|
---|
15 |
|
---|
16 | equation
|
---|
17 | if direction == DirectionOfTravel.Forward then
|
---|
18 | connect(body.flange_a, forward_engine.flange);
|
---|
19 | connect(reverse_engine.flange, ground.flange);
|
---|
20 | elseif direction == DirectionOfTravel.Backward then
|
---|
21 | connect(body.flange_a, reverse_engine.flange);
|
---|
22 | connect(forward_engine.flange, ground.flange);
|
---|
23 | end if;
|
---|
24 |
|
---|
25 | end drivetrain;
|
---|
26 |
|
---|
27 | model backward
|
---|
28 | extends drivetrain(direction=drivetrain.DirectionOfTravel.Backward);
|
---|
29 | end backward;
|
---|
30 |
|
---|
31 | end params;
|
---|