sysmlpy 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sysmlpy/__init__.py +226 -0
- sysmlpy/__main__.py +75 -0
- sysmlpy/antlr/README.md +146 -0
- sysmlpy/antlr/SysMLv2Lexer.interp +695 -0
- sysmlpy/antlr/SysMLv2Lexer.py +1123 -0
- sysmlpy/antlr/SysMLv2Lexer.tokens +444 -0
- sysmlpy/antlr/SysMLv2Parser.interp +960 -0
- sysmlpy/antlr/SysMLv2Parser.py +40750 -0
- sysmlpy/antlr/SysMLv2Parser.tokens +444 -0
- sysmlpy/antlr/SysMLv2ParserListener.py +4485 -0
- sysmlpy/antlr/SysMLv2ParserVisitor.py +2498 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
- sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
- sysmlpy/antlr_parser.py +185 -0
- sysmlpy/antlr_visitor.py +10864 -0
- sysmlpy/definition.py +1115 -0
- sysmlpy/examples/attribute_values.py +161 -0
- sysmlpy/examples/part_attributes.py +139 -0
- sysmlpy/examples/tuples_sequences.py +231 -0
- sysmlpy/formatting.py +47 -0
- sysmlpy/grammar/antlr4/README.md +30 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.g4 +931 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
- sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.g4 +2432 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.interp +960 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.py +40750 -0
- sysmlpy/grammar/antlr4/SysMLv2Parser.tokens +444 -0
- sysmlpy/grammar/antlr4/SysMLv2ParserListener.py +4485 -0
- sysmlpy/grammar/antlr4/SysMLv2ParserVisitor.py +2498 -0
- sysmlpy/grammar/antlr4/desc.xml +7 -0
- sysmlpy/grammar/antlr4/examples/camera.sysml +14 -0
- sysmlpy/grammar/antlr4/examples/toaster-system.sysml +193 -0
- sysmlpy/grammar/antlr4/examples/vehicle-model.sysml +118 -0
- sysmlpy/grammar/antlr4/pom.xml +59 -0
- sysmlpy/grammar/classes.py +8610 -0
- sysmlpy/library/LICENSE +165 -0
- sysmlpy/library/README.md +52 -0
- sysmlpy/library/__init__.py +0 -0
- sysmlpy/library/domain/Analysis/AnalysisTooling.sysml +34 -0
- sysmlpy/library/domain/Analysis/SampledFunctions.sysml +119 -0
- sysmlpy/library/domain/Analysis/StateSpaceRepresentation.sysml +143 -0
- sysmlpy/library/domain/Analysis/TradeStudies.sysml +171 -0
- sysmlpy/library/domain/Cause and Effect/CausationConnections.sysml +83 -0
- sysmlpy/library/domain/Cause and Effect/CauseAndEffect.sysml +81 -0
- sysmlpy/library/domain/Geometry/ShapeItems.sysml +899 -0
- sysmlpy/library/domain/Geometry/SpatialItems.sysml +168 -0
- sysmlpy/library/domain/Metadata/ImageMetadata.sysml +78 -0
- sysmlpy/library/domain/Metadata/ModelingMetadata.sysml +143 -0
- sysmlpy/library/domain/Metadata/ParametersOfInterestMetadata.sysml +39 -0
- sysmlpy/library/domain/Metadata/RiskMetadata.sysml +100 -0
- sysmlpy/library/domain/Quantities and Units/ISQ.sysml +42 -0
- sysmlpy/library/domain/Quantities and Units/ISQAcoustics.sysml +439 -0
- sysmlpy/library/domain/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
- sysmlpy/library/domain/Quantities and Units/ISQBase.sysml +206 -0
- sysmlpy/library/domain/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
- sysmlpy/library/domain/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
- sysmlpy/library/domain/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
- sysmlpy/library/domain/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
- sysmlpy/library/domain/Quantities and Units/ISQInformation.sysml +958 -0
- sysmlpy/library/domain/Quantities and Units/ISQLight.sysml +1537 -0
- sysmlpy/library/domain/Quantities and Units/ISQMechanics.sysml +1564 -0
- sysmlpy/library/domain/Quantities and Units/ISQSpaceTime.sysml +1169 -0
- sysmlpy/library/domain/Quantities and Units/ISQThermodynamics.sysml +1256 -0
- sysmlpy/library/domain/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
- sysmlpy/library/domain/Quantities and Units/MeasurementReferences.sysml +526 -0
- sysmlpy/library/domain/Quantities and Units/Quantities.sysml +107 -0
- sysmlpy/library/domain/Quantities and Units/QuantityCalculations.sysml +70 -0
- sysmlpy/library/domain/Quantities and Units/SI.sysml +378 -0
- sysmlpy/library/domain/Quantities and Units/SIPrefixes.sysml +48 -0
- sysmlpy/library/domain/Quantities and Units/TensorCalculations.sysml +50 -0
- sysmlpy/library/domain/Quantities and Units/Time.sysml +274 -0
- sysmlpy/library/domain/Quantities and Units/USCustomaryUnits.sysml +260 -0
- sysmlpy/library/domain/Quantities and Units/VectorCalculations.sysml +62 -0
- sysmlpy/library/domain/Requirement Derivation/DerivationConnections.sysml +63 -0
- sysmlpy/library/domain/Requirement Derivation/RequirementDerivation.sysml +39 -0
- sysmlpy/library/kernel/Base.kerml +95 -0
- sysmlpy/library/kernel/BaseFunctions.kerml +80 -0
- sysmlpy/library/kernel/BooleanFunctions.kerml +22 -0
- sysmlpy/library/kernel/Clocks.kerml +156 -0
- sysmlpy/library/kernel/CollectionFunctions.kerml +68 -0
- sysmlpy/library/kernel/Collections.kerml +147 -0
- sysmlpy/library/kernel/ComplexFunctions.kerml +47 -0
- sysmlpy/library/kernel/ControlFunctions.kerml +117 -0
- sysmlpy/library/kernel/ControlPerformances.kerml +135 -0
- sysmlpy/library/kernel/DataFunctions.kerml +43 -0
- sysmlpy/library/kernel/FeatureReferencingPerformances.kerml +190 -0
- sysmlpy/library/kernel/IntegerFunctions.kerml +43 -0
- sysmlpy/library/kernel/KerML.kerml +483 -0
- sysmlpy/library/kernel/Links.kerml +67 -0
- sysmlpy/library/kernel/Metaobjects.kerml +58 -0
- sysmlpy/library/kernel/NaturalFunctions.kerml +27 -0
- sysmlpy/library/kernel/NumericalFunctions.kerml +43 -0
- sysmlpy/library/kernel/Objects.kerml +212 -0
- sysmlpy/library/kernel/Observation.kerml +161 -0
- sysmlpy/library/kernel/OccurrenceFunctions.kerml +154 -0
- sysmlpy/library/kernel/Occurrences.kerml +992 -0
- sysmlpy/library/kernel/Performances.kerml +293 -0
- sysmlpy/library/kernel/RationalFunctions.kerml +49 -0
- sysmlpy/library/kernel/RealFunctions.kerml +56 -0
- sysmlpy/library/kernel/ScalarFunctions.kerml +33 -0
- sysmlpy/library/kernel/ScalarValues.kerml +23 -0
- sysmlpy/library/kernel/SequenceFunctions.kerml +111 -0
- sysmlpy/library/kernel/SpatialFrames.kerml +197 -0
- sysmlpy/library/kernel/StatePerformances.kerml +145 -0
- sysmlpy/library/kernel/StringFunctions.kerml +25 -0
- sysmlpy/library/kernel/Transfers.kerml +281 -0
- sysmlpy/library/kernel/TransitionPerformances.kerml +66 -0
- sysmlpy/library/kernel/TrigFunctions.kerml +35 -0
- sysmlpy/library/kernel/Triggers.kerml +188 -0
- sysmlpy/library/kernel/VectorFunctions.kerml +273 -0
- sysmlpy/library/kernel/VectorValues.kerml +64 -0
- sysmlpy/library/systems/Actions.sysml +552 -0
- sysmlpy/library/systems/Allocations.sysml +29 -0
- sysmlpy/library/systems/AnalysisCases.sysml +38 -0
- sysmlpy/library/systems/Attributes.sysml +25 -0
- sysmlpy/library/systems/Calculations.sysml +37 -0
- sysmlpy/library/systems/Cases.sysml +71 -0
- sysmlpy/library/systems/Connections.sysml +60 -0
- sysmlpy/library/systems/Constraints.sysml +44 -0
- sysmlpy/library/systems/Flows.sysml +126 -0
- sysmlpy/library/systems/Interfaces.sysml +89 -0
- sysmlpy/library/systems/Items.sysml +153 -0
- sysmlpy/library/systems/Metadata.sysml +32 -0
- sysmlpy/library/systems/Parts.sysml +81 -0
- sysmlpy/library/systems/Ports.sysml +54 -0
- sysmlpy/library/systems/Requirements.sysml +194 -0
- sysmlpy/library/systems/StandardViewDefinitions.sysml +123 -0
- sysmlpy/library/systems/States.sysml +103 -0
- sysmlpy/library/systems/SysML.sysml +539 -0
- sysmlpy/library/systems/UseCases.sysml +57 -0
- sysmlpy/library/systems/VerificationCases.sysml +103 -0
- sysmlpy/library/systems/Views.sysml +164 -0
- sysmlpy/navigate.py +272 -0
- sysmlpy/store.py +547 -0
- sysmlpy/usage.py +2978 -0
- sysmlpy-0.1.0.dist-info/METADATA +230 -0
- sysmlpy-0.1.0.dist-info/RECORD +143 -0
- sysmlpy-0.1.0.dist-info/WHEEL +4 -0
- sysmlpy-0.1.0.dist-info/entry_points.txt +3 -0
- sysmlpy-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
standard library package TransitionPerformances {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package contains a library model of the semantics of conditional transitions between occurrences,
|
|
5
|
+
* including the performance of specified Behaviors when the transition occurs.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
private import ScalarValues::Boolean;
|
|
9
|
+
private import ScalarValues::Natural;
|
|
10
|
+
private import SequenceFunctions::isEmpty;
|
|
11
|
+
private import Occurrences::Occurrence;
|
|
12
|
+
private import Occurrences::HappensBefore;
|
|
13
|
+
private import Performances::Performance;
|
|
14
|
+
private import Performances::Evaluation;
|
|
15
|
+
private import Transfers::MessageTransfer;
|
|
16
|
+
private import Transfers::AcceptPerformance;
|
|
17
|
+
private import Transfers::acceptPerformances;
|
|
18
|
+
private import ControlFunctions::allTrue;
|
|
19
|
+
private import SequenceFunctions::size;
|
|
20
|
+
|
|
21
|
+
abstract behavior TransitionPerformance {
|
|
22
|
+
in feature transitionLinkSource: Performance[1];
|
|
23
|
+
|
|
24
|
+
feature trigger: MessageTransfer[*];
|
|
25
|
+
bool guard[*] subsets enclosedPerformances;
|
|
26
|
+
step effect[*] subsets enclosedPerformances;
|
|
27
|
+
|
|
28
|
+
feature triggerTarget : Occurrence [1] default this;
|
|
29
|
+
feature transitionLink: HappensBefore[0..1];
|
|
30
|
+
|
|
31
|
+
private binding [0..1] transitionLink.earlierOccurrence = [1] transitionLinkSource;
|
|
32
|
+
private succession [1] transitionLinkSource then [*] effect;
|
|
33
|
+
private succession [*] effect then [1] transitionLink.laterOccurrence;
|
|
34
|
+
|
|
35
|
+
private connector [0..1] transitionLink to [1..*] trigger;
|
|
36
|
+
private connector all guardConstraint: TPCGuardConstraint[*]
|
|
37
|
+
from [0..1] transitionLink to [*] guard;
|
|
38
|
+
|
|
39
|
+
private succession all [*] trigger then [*] guard;
|
|
40
|
+
private succession all [*] guard then [*] effect;
|
|
41
|
+
|
|
42
|
+
feature accNum: Natural [1] = if isEmpty(trigger) ? 0 else 1;
|
|
43
|
+
step accept: AcceptPerformance[accNum] subsets timeEnclosedOccurrences, acceptPerformances {
|
|
44
|
+
feature redefines acceptedTransfer = trigger;
|
|
45
|
+
}
|
|
46
|
+
binding accept.receiver = triggerTarget;
|
|
47
|
+
|
|
48
|
+
private succession [*] guard then [accNum] accept;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
behavior NonStateTransitionPerformance specializes TransitionPerformance {
|
|
52
|
+
feature isTriggerAfter: Boolean default true;
|
|
53
|
+
private succession [1] transitionLinkSource then [1] Performance::self;
|
|
54
|
+
private feature taNum: Natural [1] = if isTriggerAfter ? size(trigger) else 0;
|
|
55
|
+
private succession triggerAfter [taNum] first [0..1] transitionLinkSource then [*] trigger.endShot;
|
|
56
|
+
|
|
57
|
+
private succession all [*] guard then [0..1] transitionLink.laterOccurrence;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
assoc struct TPCGuardConstraint {
|
|
61
|
+
end guardedLink [0..1] feature constrainedHBLink: HappensBefore;
|
|
62
|
+
end bool constrainedGuard;
|
|
63
|
+
|
|
64
|
+
private inv { allTrue(constrainedGuard()) }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
standard library package TrigFunctions {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines basic trigonometric functions on real numbers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
public import ScalarValues::Real;
|
|
8
|
+
|
|
9
|
+
feature pi : Real;
|
|
10
|
+
inv piPrecision { RealFunctions::round(pi * 1E20) == 314159265358979323846.0 }
|
|
11
|
+
|
|
12
|
+
function deg { in theta_rad : Real[1];
|
|
13
|
+
return : Real[1] = theta_rad * 180 / pi;
|
|
14
|
+
}
|
|
15
|
+
function rad { in theta_deg : Real;
|
|
16
|
+
return : Real[1] = theta_deg * pi / 180;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
datatype UnitBoundedReal :> Real {
|
|
20
|
+
inv unitBound { -1.0 <= that & that <= 1.0 }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function sin { in theta : Real[1]; return : UnitBoundedReal[1]; }
|
|
24
|
+
function cos { in theta : Real[1]; return : UnitBoundedReal[1]; }
|
|
25
|
+
function tan { in theta : Real[1];
|
|
26
|
+
return : Real = sin(theta) / cos(theta);
|
|
27
|
+
}
|
|
28
|
+
function cot { in theta : Real;
|
|
29
|
+
return : Real = cos(theta) / sin(theta);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function arcsin { in x : UnitBoundedReal[1]; return : Real[1]; }
|
|
33
|
+
function arccos { in x : UnitBoundedReal[1]; return : Real[1]; }
|
|
34
|
+
function arctan { in x : Real[1]; return : Real[1]; }
|
|
35
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
standard library package Triggers {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package contains functions that return ChangeSignals for triggering
|
|
5
|
+
* when a Boolean condition changes from false to true, at a specific time
|
|
6
|
+
* or after a specific time delay.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
private import ScalarValues::Boolean;
|
|
10
|
+
private import ScalarValues::NumericalValue;
|
|
11
|
+
private import Occurrences::Occurrence;
|
|
12
|
+
|
|
13
|
+
public import Clocks::*;
|
|
14
|
+
public import Observation::*;
|
|
15
|
+
|
|
16
|
+
struct TimeSignal :> ChangeSignal {
|
|
17
|
+
doc
|
|
18
|
+
/*
|
|
19
|
+
* A TimeSignal is a ChangeSignal whose condition is the currentTime
|
|
20
|
+
* of a given Clock reaching a specific signalTime.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
feature signalTime : NumericalValue[1] {
|
|
24
|
+
doc
|
|
25
|
+
/*
|
|
26
|
+
* The time at which the TimeSignal should be sent.
|
|
27
|
+
*/
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
feature signalClock : Clock[1] {
|
|
31
|
+
doc
|
|
32
|
+
/*
|
|
33
|
+
* The Clock whose currentTime is being monitored.
|
|
34
|
+
*/
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private bool :>> signalCondition {
|
|
38
|
+
doc
|
|
39
|
+
/*
|
|
40
|
+
* The Boolean condition of the currentTime of the signalClock being
|
|
41
|
+
* equal to the signalTime.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
signalClock.currentTime == signalTime
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function TriggerWhen {
|
|
49
|
+
doc
|
|
50
|
+
/*
|
|
51
|
+
* TriggerWhen returns a monitored ChangeSignal for a given condition,
|
|
52
|
+
* to be sent to a given receiver when the condition occurs.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
in bool condition[1] {
|
|
56
|
+
doc
|
|
57
|
+
/*
|
|
58
|
+
* The BooleanExpression to be monitored for changing from
|
|
59
|
+
* false to true.
|
|
60
|
+
*/
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
in feature receiver : Occurrence [1] {
|
|
64
|
+
doc
|
|
65
|
+
/*
|
|
66
|
+
* The Occurrence to which the ChangeSignal is to be sent.
|
|
67
|
+
*/
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
in feature monitor : ChangeMonitor[1] default defaultMonitor {
|
|
71
|
+
doc
|
|
72
|
+
/*
|
|
73
|
+
* The ChangeMonitor to be used to monitor the ChangeSignal condition.
|
|
74
|
+
* The default is the Observation::defaultMonitor.
|
|
75
|
+
*/
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return feature changeSignal : ChangeSignal[1] = new ChangeSignal(condition, monitor) {
|
|
79
|
+
doc
|
|
80
|
+
/*
|
|
81
|
+
* The ChangeSignal for the condition, as monitored by the monitor.
|
|
82
|
+
*/
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
step :> monitor.startObservation {
|
|
86
|
+
in observer = receiver;
|
|
87
|
+
in signal = changeSignal;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function TriggerAt {
|
|
92
|
+
doc
|
|
93
|
+
/*
|
|
94
|
+
* TriggerAt returns a monitored TimeSignal to be sent to a receiver when
|
|
95
|
+
* the currentTime of a given Clock reaches a specific timeInstant.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
in feature timeInstant : NumericalValue[1] {
|
|
99
|
+
doc
|
|
100
|
+
/*
|
|
101
|
+
* The time instant, relative to the clock, at which the TimeSignal should be sent.
|
|
102
|
+
*/
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
in feature receiver : Occurrence[1] {
|
|
106
|
+
doc
|
|
107
|
+
/*
|
|
108
|
+
* The Occurrence to which the TimeSignal is to be sent.
|
|
109
|
+
*/
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
in feature clock : Clock[1] default localClock {
|
|
113
|
+
doc
|
|
114
|
+
/*
|
|
115
|
+
* The Clock to be used as the reference for the timeInstant. The default is
|
|
116
|
+
* the localClock, which will be bound when the function is invoked.
|
|
117
|
+
*/
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
in feature monitor : ChangeMonitor[1] default defaultMonitor {
|
|
121
|
+
doc
|
|
122
|
+
/*
|
|
123
|
+
* The ChangeMonitor to be used to monitor the TimeSignal condition.
|
|
124
|
+
* The default is the Observation::defaultMonitor.
|
|
125
|
+
*/
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return feature timeSignal : TimeSignal[1] = new TimeSignal(timeInstant, clock, monitor) {
|
|
129
|
+
doc
|
|
130
|
+
/*
|
|
131
|
+
* The TimeSignal for the given timeInstant, as monitored by the monitor.
|
|
132
|
+
*/
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
step :> monitor.startObservation {
|
|
136
|
+
in observer = receiver;
|
|
137
|
+
in signal = timeSignal;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function TriggerAfter {
|
|
142
|
+
doc
|
|
143
|
+
/*
|
|
144
|
+
* TriggerAfter returns a monitored TimeSignal to be sent to a receiver after
|
|
145
|
+
* a certain time delay relative to a given Clock.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
in feature delay : NumericalValue[1] {
|
|
149
|
+
doc
|
|
150
|
+
/*
|
|
151
|
+
* The time duration, relative to the clock, after which the TimeSignal is sent.
|
|
152
|
+
*/
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
in feature receiver : Occurrence[1] {
|
|
156
|
+
doc
|
|
157
|
+
/*
|
|
158
|
+
* The Occurrence to which the TimeSignal is to be sent.
|
|
159
|
+
*/
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
in feature clock : Clock[1] default localClock {
|
|
163
|
+
doc
|
|
164
|
+
/*
|
|
165
|
+
* The Clock to be used as the reference for the time delay. The default is
|
|
166
|
+
* the localClock, which will be bound when the function is invoked.
|
|
167
|
+
*/
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
in feature monitor : ChangeMonitor[1] default defaultMonitor {
|
|
171
|
+
doc
|
|
172
|
+
/*
|
|
173
|
+
* The ChangeMonitor to be used to monitor the TimeSignal condition.
|
|
174
|
+
* The default is the Observation::defaultMonitor.
|
|
175
|
+
*/
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return signal : TimeSignal[1] =
|
|
179
|
+
TriggerAt(clock.currentTime + delay, receiver, clock, monitor) {
|
|
180
|
+
doc
|
|
181
|
+
/*
|
|
182
|
+
* The TimeSignal for the currentTime of the clock when the function is invoked
|
|
183
|
+
* plus the given time delay, as monitored by the monitor.
|
|
184
|
+
*/
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
standard library package VectorFunctions {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package defines abstract functions on VectorValues corresponding to the algebraic operations
|
|
5
|
+
* provided by a vector space with inner product. It also includes concrete implementations of these
|
|
6
|
+
* functions specifically for CartesianVectorValues.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
private import ScalarValues::NumericalValue;
|
|
10
|
+
private import ScalarValues::Positive;
|
|
11
|
+
private import ScalarValues::Real;
|
|
12
|
+
private import ScalarValues::Boolean;
|
|
13
|
+
private import NumericalFunctions::*;
|
|
14
|
+
private import RealFunctions::sqrt;
|
|
15
|
+
private import TrigFunctions::arccos;
|
|
16
|
+
private import SequenceFunctions::size;
|
|
17
|
+
private import ControlFunctions::*;
|
|
18
|
+
|
|
19
|
+
public import VectorValues::*;
|
|
20
|
+
|
|
21
|
+
/* Generic arithmetic functions for all VectorValues. */
|
|
22
|
+
|
|
23
|
+
abstract function isZeroVector {
|
|
24
|
+
doc
|
|
25
|
+
/*
|
|
26
|
+
* Return whether a VectorValue is a zero vector.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
in v: VectorValue[1];
|
|
30
|
+
return : Boolean[1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
abstract function '+' specializes DataFunctions::'+' {
|
|
34
|
+
doc
|
|
35
|
+
/*
|
|
36
|
+
* With two arguments, returns the sum of two VectorValues. With one argument, returns that VectorValue.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
in v: VectorValue[1];
|
|
40
|
+
in w: VectorValue[0..1];
|
|
41
|
+
return u: VectorValue[1];
|
|
42
|
+
inv zeroAddition { w == null or isZeroVector(w) implies u == w }
|
|
43
|
+
inv commutivity { w != null implies u == w + v }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
abstract function '-' specializes DataFunctions::'-' {
|
|
47
|
+
doc
|
|
48
|
+
/*
|
|
49
|
+
* With two arguments, returns the difference of two VectorValues. With one arguments, returns the inverse
|
|
50
|
+
* of the given VectorValue, that is, the VectorValue that, when added to the original VectorValue, results in
|
|
51
|
+
* the zeroVector.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
in v: VectorValue[1];
|
|
55
|
+
in w: VectorValue[0..1];
|
|
56
|
+
return u: VectorValue[1];
|
|
57
|
+
inv negation { w == null implies isZeroVector(v + u) }
|
|
58
|
+
inv difference { w != null implies v + u == w }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
abstract function sum0 {
|
|
62
|
+
doc
|
|
63
|
+
/*
|
|
64
|
+
* Return the sum of a collection of VectorValues. If the collection is empty, return a given zero vector.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
in coll: VectorValue[*] nonunique;
|
|
68
|
+
in zero: VectorValue[1];
|
|
69
|
+
inv precondition { isZeroVector(zero) }
|
|
70
|
+
return s: VectorValue[1] = coll->reduce '+' ?? zero;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Functions specific to NumericalVectorValues. */
|
|
74
|
+
|
|
75
|
+
function VectorOf {
|
|
76
|
+
doc
|
|
77
|
+
/*
|
|
78
|
+
* Construct a NumericalVectorValue whose elements are a non-empty list of component NumericalValues.
|
|
79
|
+
* The dimension of the NumericalVectorValue is equal to the number of components.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
in components: NumericalValue[1..*] ordered nonunique;
|
|
83
|
+
return : NumericalVectorValue[1] {
|
|
84
|
+
:>> dimension = size(components);
|
|
85
|
+
:>> elements = components;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
abstract function scalarVectorMult specializes DataFunctions::'*' {
|
|
90
|
+
doc
|
|
91
|
+
/*
|
|
92
|
+
* Scalar product of a NumericalValue and a NumericalVectorValue.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
in x: NumericalValue[1];
|
|
96
|
+
in v: NumericalVectorValue[1];
|
|
97
|
+
return w: NumericalVectorValue[1];
|
|
98
|
+
inv scaling { norm(w) == x * norm(v) }
|
|
99
|
+
inv zeroLength { isZeroVector(w) implies isZero(norm(w))}
|
|
100
|
+
}
|
|
101
|
+
alias '*' for scalarVectorMult;
|
|
102
|
+
|
|
103
|
+
abstract function vectorScalarMult specializes DataFunctions::'*' {
|
|
104
|
+
doc
|
|
105
|
+
/*
|
|
106
|
+
* Scalar product of a NumericalVectorValue and a NumericalValue, which has the same value as the scalar product of the
|
|
107
|
+
* NumericalValue and the NumericalVectorValue.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
in v: NumericalVectorValue[1];
|
|
111
|
+
in x: NumericalValue[1];
|
|
112
|
+
return w: NumericalVectorValue[1] default scalarVectorMult(x, v);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
abstract function vectorScalarDiv specializes DataFunctions::'/' {
|
|
116
|
+
doc
|
|
117
|
+
/*
|
|
118
|
+
* Scalar quotient of a NumericalVectorValue and a NumericalValue, defined as the scalar product of the inverse of the
|
|
119
|
+
* NumericalValue and the NumericalVectorValue.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
in v: NumericalVectorValue[1];
|
|
123
|
+
in x: NumericalValue[1];
|
|
124
|
+
return w: NumericalVectorValue[1] = scalarVectorMult(1.0 / x, v);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
abstract function inner specializes DataFunctions::'*' {
|
|
128
|
+
doc
|
|
129
|
+
/*
|
|
130
|
+
* Inner product of two NumericalVectorValues.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
in v: NumericalVectorValue[1];
|
|
134
|
+
in w: NumericalVectorValue[1];
|
|
135
|
+
return x: NumericalValue[1];
|
|
136
|
+
inv commmutivity { x == inner(w, v) }
|
|
137
|
+
inv zeroInner { isZeroVector(v) or isZeroVector(w) implies isZero(x)}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
abstract function norm {
|
|
141
|
+
doc
|
|
142
|
+
/*
|
|
143
|
+
* The norm (magnitude) of a NumericalVectorValue, as a NumericalValue.
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
in v: NumericalVectorValue[1];
|
|
147
|
+
return l : NumericalValue[1];
|
|
148
|
+
inv squareNorm { l * l == inner(v,v) }
|
|
149
|
+
inv lengthZero { isZero(l) == isZeroVector(v) }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
abstract function angle {
|
|
153
|
+
doc
|
|
154
|
+
/*
|
|
155
|
+
* The angle between two NumericalVectorValues, as a NumericalValue.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
in v: NumericalVectorValue[1];
|
|
159
|
+
in w: NumericalVectorValue[1];
|
|
160
|
+
return theta: NumericalValue[1];
|
|
161
|
+
inv commutivity { theta == angle(w, v) }
|
|
162
|
+
inv lengthInsensitive { theta == angle(w / norm(w), v / norm(v)) }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Specialized functions with concrete definitions for CartesianVectorValues. */
|
|
166
|
+
|
|
167
|
+
function CartesianVectorOf {
|
|
168
|
+
doc
|
|
169
|
+
/*
|
|
170
|
+
* Construct a CartesianVectorValue whose elements are a non-empty list of Real components.
|
|
171
|
+
* The dimension of the NumericalVectorValue is equal to the number of components.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
in components: Real[*] ordered nonunique;
|
|
175
|
+
return : CartesianVectorValue[1] {
|
|
176
|
+
:>> dimension = size(components);
|
|
177
|
+
:>> elements = components;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function CartesianThreeVectorOf specializes CartesianVectorOf {
|
|
181
|
+
in components: Real[3] ordered nonunique;
|
|
182
|
+
return : CartesianThreeVectorValue[1] {
|
|
183
|
+
feature :>> CartesianVectorOf::result::dimension, CartesianThreeVectorValue::dimension;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
feature cartesianZeroVector: CartesianVectorValue[3] =
|
|
188
|
+
(
|
|
189
|
+
CartesianVectorOf(0.0),
|
|
190
|
+
CartesianVectorOf((0.0, 0.0)),
|
|
191
|
+
CartesianThreeVectorOf((0.0, 0.0, 0.0))
|
|
192
|
+
) {
|
|
193
|
+
doc
|
|
194
|
+
/*
|
|
195
|
+
* Cartesian zero vectors of 1, 2 and 3 dimensions.
|
|
196
|
+
*/
|
|
197
|
+
}
|
|
198
|
+
feature cartesian3DZeroVector: CartesianThreeVectorValue[1] =
|
|
199
|
+
cartesianZeroVector#(3);
|
|
200
|
+
|
|
201
|
+
function isCartesianZeroVector specializes isZeroVector {
|
|
202
|
+
doc
|
|
203
|
+
/*
|
|
204
|
+
* A CartesianVectorValue is a zero vector if all its elements are zero.
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
in v: CartesianVectorValue[1];
|
|
208
|
+
return : Boolean[1] = v.elements->forAll{in x; x == 0.0};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function 'cartesian+' specializes '+' {
|
|
212
|
+
in v: CartesianVectorValue[1];
|
|
213
|
+
in w: CartesianVectorValue[0..1];
|
|
214
|
+
inv precondition { w != null implies v.dimension == w.dimension }
|
|
215
|
+
return u: CartesianVectorValue[1] =
|
|
216
|
+
if w == null? v
|
|
217
|
+
else CartesianVectorOf(
|
|
218
|
+
(1..w.dimension)->collect{in i : Positive; v#(i) + w#(i)}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function 'cartesian-' specializes '-' {
|
|
223
|
+
in v: CartesianVectorValue[1];
|
|
224
|
+
in w: CartesianVectorValue[0..1];
|
|
225
|
+
inv precondition { w != null implies v.dimension == w.dimension }
|
|
226
|
+
return u: CartesianVectorValue[1] =
|
|
227
|
+
CartesianVectorOf(
|
|
228
|
+
if w == null? CartesianVectorOf(v.elements->collect{in x : Real; -x})
|
|
229
|
+
else CartesianVectorOf(
|
|
230
|
+
(1..v.dimension)->collect{in i : Positive; v#(i) - w#(i)}
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function cartesianScalarVectorMult specializes scalarVectorMult {
|
|
236
|
+
in x: Real[1];
|
|
237
|
+
in v: CartesianVectorValue[1];
|
|
238
|
+
return w: CartesianVectorValue[1] =
|
|
239
|
+
CartesianVectorOf(
|
|
240
|
+
v.elements->collect{in y : Real; x * y}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
function cartesianVectorScalarMult specializes vectorScalarMult {
|
|
244
|
+
in v: CartesianVectorValue[1];
|
|
245
|
+
in x: Real[1];
|
|
246
|
+
return w: CartesianVectorValue[1] = cartesianScalarVectorMult(x, v);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function cartesianInner specializes inner {
|
|
250
|
+
in v: CartesianVectorValue[1];
|
|
251
|
+
in w : CartesianVectorValue[1];
|
|
252
|
+
inv precondition { v.dimension == w.dimension }
|
|
253
|
+
return x: Real[1] =
|
|
254
|
+
(1..v.dimension)->collect{in i : Positive; v#(i) * w#(i)}->reduce RealFunctions::'+';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function cartesianNorm specializes norm {
|
|
258
|
+
in v: CartesianVectorValue[1];
|
|
259
|
+
return l : NumericalValue[1] = sqrt(cartesianInner(v, v));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function cartesianAngle specializes angle {
|
|
263
|
+
in v: CartesianVectorValue[1]; in w: CartesianVectorValue[1];
|
|
264
|
+
inv precondition { v.dimension == w.dimension }
|
|
265
|
+
return theta: Real[1] = arccos(cartesianInner(v, w) / (norm(v) * norm(w)));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function sum {
|
|
269
|
+
in coll: CartesianThreeVectorValue[*];
|
|
270
|
+
return : CartesianThreeVectorValue[1] = sum0(coll, cartesian3DZeroVector);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
standard library package VectorValues {
|
|
2
|
+
doc
|
|
3
|
+
/*
|
|
4
|
+
* This package provides a basic model of abstract vectors as well as concrete vectors
|
|
5
|
+
* whose components are numerical values. The package VectorFunctions defines the
|
|
6
|
+
* corresponding vector-space functions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
private import ScalarValues::NumericalValue;
|
|
10
|
+
private import ScalarValues::Real;
|
|
11
|
+
private import Collections::Array;
|
|
12
|
+
|
|
13
|
+
abstract datatype VectorValue {
|
|
14
|
+
doc
|
|
15
|
+
/*
|
|
16
|
+
* A VectorValue is an abstract data type whose values may be operated on using
|
|
17
|
+
* VectorFunctions.
|
|
18
|
+
*/
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
datatype NumericalVectorValue :> VectorValue, Array intersects VectorValue, Array {
|
|
22
|
+
doc
|
|
23
|
+
/*
|
|
24
|
+
* A NumericalVectorValue is a kind of VectorValue that is specifically represented
|
|
25
|
+
* as a one-dimensional array of NumericalValues. The dimension is allowed to be empty,
|
|
26
|
+
* permitting a NumericalVectorValue of rank 0, which is essentially isomorphic to a
|
|
27
|
+
* scalar NumericalValue.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
feature dimension[0..1] :>> dimensions;
|
|
31
|
+
feature :>> elements : NumericalValue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
datatype CartesianVectorValue :> NumericalVectorValue {
|
|
35
|
+
doc
|
|
36
|
+
/*
|
|
37
|
+
* CartesianVectorValue is a specialization Numerical VectorValue for which there are
|
|
38
|
+
* specific implementations in VectorFunctions of the abstract vector-space functions.
|
|
39
|
+
*
|
|
40
|
+
* Note: The restriction of the element type to Real is to facilitate
|
|
41
|
+
* the complete definition of these functions.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
feature :>> elements : Real;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
datatype ThreeVectorValue :> NumericalVectorValue {
|
|
48
|
+
doc
|
|
49
|
+
/*
|
|
50
|
+
* A ThreeVectorValue is a NumericalVectorValue that has dimension 3.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
feature :>> dimension = 3;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
datatype CartesianThreeVectorValue :> CartesianVectorValue, ThreeVectorValue
|
|
57
|
+
intersects CartesianVectorValue, ThreeVectorValue {
|
|
58
|
+
doc
|
|
59
|
+
/*
|
|
60
|
+
* A CartesianThreeVectorValue is a NumericalVectorValue that is both Cartesian and
|
|
61
|
+
* has dimension 3.
|
|
62
|
+
*/
|
|
63
|
+
}
|
|
64
|
+
}
|