Skip to content

Commit 20831a2

Browse files
committed
Added example and training models.
- Added example models for cause/effect and requirements derivation. - Added training model for local clocks. - Made minor corrections to CollectionFunctions, TrigFunctions and VectorFunctions library models.
1 parent 2892101 commit 20831a2

9 files changed

Lines changed: 107 additions & 13 deletions

File tree

sysml.library/Kernel Libraries/Kernel Function Library/CollectionFunctions.kerml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ package CollectionFunctions {
5353
return : Anything[0..1] = (col.elements as Anything)[index];
5454
}
5555

56-
function 'array[' specializes '[' { in arr: Array[1]; in indexes: Positive[n] ordered nonunique;
57-
return : Anything[0..1];
58-
56+
function 'array[' specializes BaseFunctions::'[' { in arr: Array[1]; in indexes: Positive[n] ordered nonunique;
5957
private feature n : Natural[1] = arr.rank;
6058

6159
// Assumes row-major ordering for elements.

sysml.library/Kernel Libraries/Kernel Function Library/TrigFunctions.kerml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ package TrigFunctions {
1717
}
1818

1919
datatype UnitBoundedReal :> Real {
20-
private x :>> self;
21-
inv unitBound { -1.0 <= x & x <= 1.0 }
20+
inv unitBound { -1.0 <= that & that <= 1.0 }
2221
}
2322

2423
function sin { in theta : Real[1]; return : UnitBoundedReal[1]; }

sysml.library/Kernel Libraries/Kernel Function Library/VectorFunctions.kerml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ package VectorFunctions {
109109

110110
in v: NumericalVectorValue[1];
111111
in x: NumericalValue[1];
112-
return w: NumericalVectorValue[1];
113-
scalarVectorMult(x, v)
112+
return w: NumericalVectorValue[1] = scalarVectorMult(x, v);
114113
}
115114

116115
abstract function vectorScalarDiv specializes DataFunctions::'/' {
@@ -171,13 +170,14 @@ package VectorFunctions {
171170
* The dimension of the NumericalVectorValue is equal to the number of components.
172171
*/
173172

174-
in components: Real[*];
173+
in components: Real[*] ordered nonunique;
175174
return : CartesianVectorValue[1] {
176175
:>> dimension = size(components);
177176
:>> elements = components;
178177
}
179178
}
180-
function CartesianThreeVectorOf specializes CartesianVectorOf { in components: Real[3];
179+
function CartesianThreeVectorOf specializes CartesianVectorOf {
180+
in components: Real[3] ordered nonunique;
181181
return : CartesianThreeVectorValue[1];
182182
}
183183

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package MedicalDeviceFailure {
2+
import CauseAndEffect::*;
3+
4+
part medicalDevice {
5+
part battery {
6+
event occurrence depleted;
7+
event occurrence cannotBeCharged;
8+
}
9+
10+
event occurrence deviceFails;
11+
12+
ref patient {
13+
event occurrence therapyDelayed;
14+
}
15+
16+
#multicausation connection {
17+
end #cause :> battery.depleted;
18+
end #cause :> battery.cannotBeCharged;
19+
end #effect :> deviceFails;
20+
}
21+
22+
#causation connect deviceFails to patient.therapyDelayed;
23+
}
24+
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package VehicleRequirementDerivation {
2+
import RequirementDerivation::*;
3+
4+
part vehicle {
5+
attribute mass :> ISQ::mass;
6+
7+
part chassis {
8+
attribute mass :> ISQ::mass;
9+
}
10+
11+
part engine {
12+
attribute mass :> ISQ::mass;
13+
}
14+
}
15+
16+
requirement def MassRequirement {
17+
subject mass :> ISQ::mass;
18+
attribute massLimit :> ISQ::mass;
19+
require constraint { mass <= massLimit }
20+
}
21+
22+
requirement vehicleMassRequirement : MassRequirement {
23+
subject :>> mass = vehicle.mass;
24+
}
25+
26+
requirement chassisMassRequirement : MassRequirement {
27+
subject :>> mass = vehicle.chassis.mass;
28+
}
29+
30+
requirement engineMassRequirement : MassRequirement {
31+
subject :>> mass = vehicle.engine.mass;
32+
}
33+
34+
#derivation connection {
35+
end #original :> vehicleMassRequirement;
36+
end #derive :> chassisMassRequirement;
37+
end #derive :> engineMassRequirement;
38+
}
39+
40+
}

sysml/src/training/24. Transitions/Change and Time Triggers.sysml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package 'Change and Time Triggers' {
2121
in controller : VehicleController;
2222

2323
entry; then normal;
24-
do senseTemperature { out temp; }
24+
do senseTemperature;
2525

2626
state normal;
2727
accept at vehicle.maintenanceTime
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package 'Local Clock Example' {
2+
import ScalarValues::String;
3+
4+
item def Start;
5+
item def Request;
6+
7+
part def Server {
8+
part :>> localClock = Time::Clock();
9+
10+
attribute today : String;
11+
12+
port requestPort;
13+
14+
state ServerBehavior {
15+
entry; then off;
16+
17+
state off;
18+
accept Start via requestPort
19+
then waiting;
20+
21+
state waiting;
22+
accept request : Request via requestPort
23+
then responding;
24+
accept at Time::Iso8601DateTime(today + "11:59:00")
25+
then off;
26+
27+
state responding;
28+
accept after 5 [SI::min]
29+
then waiting;
30+
}
31+
}
32+
}

sysml/src/training/30. Constraints/Analytical Constraints.sysml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ package 'Analytical Constraints' {
1313

1414
attribute v_avg : SpeedValue = (v_i + v_f)/2;
1515

16-
a == Acceleration(p, m, v_avg) &
17-
v_f == Velocity(dt, v_i, a) &
16+
a == Acceleration(p, m, v_avg) and
17+
v_f == Velocity(dt, v_i, a) and
1818
x_f == Position(dt, x_i, v_avg)
1919
}
2020

sysml/src/training/30. Constraints/Derivation Constraints.sysml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package 'Derivation Constraints' {
1717
in deltaT : TimeValue;
1818
in force : ForceValue;
1919

20-
force * deltaT == mass * (finalSpeed - initialSpeed) &
20+
force * deltaT == mass * (finalSpeed - initialSpeed) and
2121
mass > 0[kg]
2222
}
2323

0 commit comments

Comments
 (0)