forked from modelscript/modelscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_doc.sysml
More file actions
370 lines (291 loc) · 10.3 KB
/
Copy pathtest_doc.sysml
File metadata and controls
370 lines (291 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// ═══════════════════════════════════════════════════════════════════════
// SysML v2 Kitchen Sink — comprehensive demonstration of SysML2 features
// ═══════════════════════════════════════════════════════════════════════
// ── STRUCTURAL DEFINITIONS ──────────────────────────────────────────
package VehicleSystem {
// ---------- Port Definitions ----------
port def TorquePort {
attribute torqueValue : Real;
}
port def ElectricalPort {
attribute voltage : Real;
attribute current : Real;
}
port def FuelPort {
attribute flowRate : Real;
}
// ---------- Part Definitions ----------
part def Engine {
attribute horsePower : Real;
attribute displacement : Real;
attribute fuelType : String;
port torqueOut : TorquePort;
port fuelIn : FuelPort;
}
part def Transmission {
attribute gearRatio : Real;
attribute numberOfGears : Integer;
port torqueIn : TorquePort;
port torqueOut : TorquePort;
}
part def Battery {
attribute capacity : Real;
attribute voltage : Real;
port electricalOut : ElectricalPort;
}
part def ElectricMotor {
attribute peakPower : Real;
attribute efficiency : Real;
port electricalIn : ElectricalPort;
port torqueOut : TorquePort;
}
part def BrakeSystem {
attribute maxBrakingForce : Real;
attribute absEnabled : Boolean;
}
part def Wheel {
attribute diameter : Real;
attribute tirePressure : Real;
}
part def FuelTank {
attribute capacity : Real;
port fuelOut : FuelPort;
}
// ---------- Top-Level Vehicle Definition ----------
part def Vehicle {
attribute mass : Real;
attribute topSpeed : Real;
attribute vin : String;
part engine : Engine;
part transmission : Transmission;
part battery : Battery;
part motor : ElectricMotor;
part brakes : BrakeSystem;
part frontLeft : Wheel;
part frontRight : Wheel;
part rearLeft : Wheel;
part rearRight : Wheel;
part fuelTank : FuelTank;
// Structural connections
connect engine.torqueOut to transmission.torqueIn;
connect battery.electricalOut to motor.electricalIn;
connect fuelTank.fuelOut to engine.fuelIn;
}
// ── Actors & Use Cases ──
part def Driver {
doc /* Primary operator of the vehicle. */
}
part def Mechanic {
doc /* Service technician responsible for maintenance. */
}
part def FleetManager {
doc /* Oversees a fleet of vehicles remotely. */
}
part def Passenger {
doc /* Rides the vehicle and adjusts convenience settings. */
}
part def ChargingStation {
doc /* Provides electrical power to recharge the battery. */
}
part def Pedestrian {
doc /* External actor interacting with vehicle safety systems. */
}
use case def DriveVehicle {
doc /* The driver operates the vehicle for daily commute. */
subject vehicle : Vehicle;
actor driver : Driver;
include use case startUp : StartVehicle;
include use case navigate : NavigateRoute;
}
use case def StartVehicle {
doc /* The driver starts the engine and checks dashboard. */
subject vehicle : Vehicle;
actor driver : Driver;
}
use case def NavigateRoute {
doc /* The driver follows turn-by-turn directions. */
subject vehicle : Vehicle;
actor driver : Driver;
}
use case def PerformMaintenance {
doc /* The mechanic performs scheduled service. */
subject vehicle : Vehicle;
actor mechanic : Mechanic;
}
use case def MonitorFleet {
doc /* The fleet manager monitors vehicle telemetry. */
actor manager : FleetManager;
}
use case def ChargeVehicle {
doc /* The driver connects the vehicle to a charging station. */
subject vehicle : Vehicle;
actor driver : Driver;
actor station : ChargingStation;
}
use case def UpdateSoftware {
doc /* The mechanic updates the vehicle system software. */
subject vehicle : Vehicle;
actor mechanic : Mechanic;
}
use case def AdjustClimateControl {
doc /* The passenger adjusts the cabin temperature and airflow. */
subject vehicle : Vehicle;
actor passenger : Passenger;
}
use case def DetectObstacle {
doc /* The vehicle detects a pedestrian and alerts the driver. */
subject vehicle : Vehicle;
actor pedestrian : Pedestrian;
actor driver : Driver;
}
}
// ── BEHAVIORAL DEFINITIONS ──────────────────────────────────────────
package VehicleBehavior {
// ---------- Action Definitions ----------
action def StartEngine {
in ignitionSignal : Boolean;
out engineRunning : Boolean;
}
action def Accelerate {
in throttlePosition : Real;
in currentSpeed : Real;
out newSpeed : Real;
}
action def Brake {
in brakeForce : Real;
in currentSpeed : Real;
out newSpeed : Real;
}
action def ShiftGear {
in targetGear : Integer;
out gearEngaged : Integer;
}
// ---------- State Definitions ----------
state def VehicleStates {
state off;
state idle;
state driving;
state charging;
state emergency;
transition off_to_idle
first off
then idle;
transition idle_to_driving
first idle
then driving;
transition driving_to_idle
first driving
then idle;
transition idle_to_off
first idle
then off;
transition any_to_emergency
first driving
then emergency;
}
// ---------- Composite Behavior ----------
action def DriveCycle {
action start : StartEngine;
action accel : Accelerate;
action shift : ShiftGear;
action brake : Brake;
succession start then accel;
succession accel then shift;
succession shift then brake;
}
}
// ── REQUIREMENTS ────────────────────────────────────────────────────
package VehicleRequirements {
requirement def MassRequirement {
doc /* The total vehicle mass shall not exceed 2000 kg. */
attribute maxMass : Real;
}
requirement def PerformanceRequirement {
doc /* The vehicle shall accelerate 0–100 km/h in under 6 seconds. */
attribute targetTime : Real;
}
requirement def SafetyRequirement {
doc /* The vehicle shall pass NCAP 5-star crash test rating. */
attribute minRating : Integer;
}
requirement def RangeRequirement {
doc /* The electric range shall be at least 50 km. */
attribute minRange : Real;
}
requirement def EmissionRequirement {
doc /* CO2 emissions shall be below 120 g/km. */
attribute maxEmission : Real;
}
requirement def ReliabilityRequirement {
doc /* MTBF shall be at least 200,000 km. */
attribute mtbf : Real;
}
}
// ── VERIFICATION & ANALYSIS ─────────────────────────────────────────
package VehicleVerification {
verification def MassVerificationCase {
doc /* Weigh the assembled vehicle on a certified scale. */
verify VehicleRequirements::MassRequirement;
}
verification def PerformanceVerificationCase {
doc /* Run acceleration test on a dynamometer. */
verify VehicleRequirements::PerformanceRequirement;
}
verification def SafetyVerificationCase {
doc /* Execute full NCAP crash test suite. */
verify VehicleRequirements::SafetyRequirement;
}
verification def EmissionVerificationCase {
doc /* Perform WLTP emission cycle measurement. */
verify VehicleRequirements::EmissionRequirement;
}
}
// ── CALCULATIONS & CONSTRAINTS ──────────────────────────────────────
package VehicleAnalysis {
calc def TotalMass {
in bodyMass : Real;
in drivetrainMass : Real;
in batteryMass : Real;
in cargoMass : Real;
return : Real;
bodyMass + drivetrainMass + batteryMass + cargoMass
}
calc def BrakingDistance {
in speed : Real;
in friction : Real;
return : Real;
speed ** 2 / (2 * friction * 9.81)
}
calc def PowerToWeight {
in power : Real;
in mass : Real;
return : Real;
power / mass
}
constraint def MaxMassConstraint {
1500 + 200 + 150 + 100 <= 2000
}
constraint def PowerFloorConstraint {
250 * 2 >= 400
}
constraint def RangeConstraint {
60 >= 50
}
}
// ── INTEGRATION & ALLOCATION ────────────────────────────────────────
package VehicleIntegration {
// Instantiate the vehicle
part vehicle : VehicleSystem::Vehicle;
// Satisfy requirements
satisfy VehicleRequirements::MassRequirement by vehicle;
satisfy VehicleRequirements::SafetyRequirement by vehicle;
satisfy VehicleRequirements::PerformanceRequirement by vehicle;
satisfy VehicleRequirements::RangeRequirement by vehicle;
// Allocate behavior to structure
allocation def BehaviorAllocation {
part source : VehicleBehavior::DriveCycle;
part target : VehicleSystem::Vehicle;
}
}
part badArray [2] : Integer = (1, 2, 3);
part errorBound [5..1];