FCS.aadl.out 29.3 KB
Newer Older
Bechir Zalila's avatar
Bechir Zalila committed
1
2
3
4
------------------------------------------
---------- Ocarina LNT Generator ---------
------------------------------------------

5
Begin Thread
Bechir Zalila's avatar
Bechir Zalila committed
6
7
8
Begin Processor
Begin Types
Begin Main
9
10
% DEFAULT_MCL_LIBRARIES="standard.mcl"
"Main.bcg"=  divbranching reduction of "FLIGHTCONTROLSYSTEM_Main.lnt";
Bechir Zalila's avatar
Bechir Zalila committed
11
12
13
14
property PROPERTY_Deadlock is
   deadlock of "Main.bcg";
   expected FALSE;
end property;
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
property Scheduling_Test (ID)
   "Scheduling Test "is
"Main.bcg"|= with evaluator3
   NEVER ("ACTIVATION_$ID !T_Error");
   expected TRUE;
end property;
check Scheduling_Test ( 1);
check Scheduling_Test ( 2);
check Scheduling_Test ( 3);
check Scheduling_Test ( 4);
check Scheduling_Test ( 5);
check Scheduling_Test ( 6);
check Scheduling_Test ( 7);
property Connection (ID)
   "Connection Test "is
"Main.bcg"|= with evaluator3
   AFTER_1_INEVITABLE_2 ('SEND_$ID !*' , 'RECEIVE_$ID !*');
   expected TRUE;
end property;
property Is_Preempted (ID)
   "Is_Preempted Test "is
"Main.bcg"|= with evaluator3
   SOME (true* ."ACTIVATION_$ID !T_DISPATCH_PREEMPTION". true* . ("ACTIVATION_$ID !T_PREEMPTION")* . true* . "ACTIVATION_$ID !T_PREEMPTION_COMPLETION");
   expected TRUE;
end property;
check Is_Preempted ( 1);
check Is_Preempted ( 2);
check Is_Preempted ( 3);
check Is_Preempted ( 4);
check Is_Preempted ( 5);
check Is_Preempted ( 6);
check Is_Preempted ( 7);
property Data_Loss (ID)
   "Between two consecutive SEND_$ID actions, there is a RECEIVE_$ID" is
"Main.bcg"|= with evaluator3
   NEVER (true* ."SEND_$ID !AADLDATA". (not"RECEIVE_$ID !AADLDATA")* ."SEND_$ID !AADLDATA");
   expected TRUE;
end property;
property Transition (TH_NAME, Si, Sj)
   "Thread $TH_NAME, being in state $Si, the corresponding $Sj state is eventually reachable" is
"Main.bcg"|= with evaluator3
   AFTER_1_INEVITABLE_2 ("DISPLAY_STATE !$TH_NAME !$Si","DISPLAY_STATE !$TH_NAME !$Sj");
Bechir Zalila's avatar
Bechir Zalila committed
57
58
   expected TRUE;
end property;
59
60
Begin Port
module FLIGHTCONTROLSYSTEM_Threads (Types) is 
Bechir Zalila's avatar
Bechir Zalila committed
61
62
   process Thread_FF [
   ACTIVATION: LNT_Channel_Dispatch, 
63
64
   PORT_ANGLE_O: LNT_Channel_Port, 
   PORT_ANGLE: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
65
   is 
66
67
68
69
70
71
72
      var 
         ANGLE_O : LNT_Type_Data, 
         ANGLE : LNT_Type_Data
      in 
         ANGLE_O := AADLDATA; 
         ANGLE := EMPTY; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
73
            select 
74
75
76
77
78
79
80
81
82
83
84
85
86
87
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_ANGLE (?ANGLE)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ANGLE_O (ANGLE_O)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_ANGLE (?ANGLE); 
                  PORT_ANGLE_O (ANGLE_O)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
88
               []
89
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
90
               []
91
92
93
94
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
95
96
97
98
   end process 
   
   process Thread_NL [
   ACTIVATION: LNT_Channel_Dispatch, 
99
100
101
   PORT_POS_C: LNT_Channel_Port, 
   PORT_POS_O: LNT_Channel_Port, 
   PORT_ACC_C: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
102
   is 
103
104
105
106
107
108
109
110
111
      var 
         POS_C : LNT_Type_Data, 
         POS_O : LNT_Type_Data, 
         ACC_C : LNT_Type_Data
      in 
         POS_C := EMPTY; 
         POS_O := EMPTY; 
         ACC_C := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
112
            select 
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_POS_C (?POS_C); 
                  PORT_POS_O (?POS_O)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ACC_C (ACC_C)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_POS_C (?POS_C); 
                  PORT_POS_O (?POS_O); 
                  PORT_ACC_C (ACC_C)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
129
               []
130
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
131
               []
132
133
134
135
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
136
137
138
139
   end process 
   
   process Thread_NF [
   ACTIVATION: LNT_Channel_Dispatch, 
140
141
   PORT_POS_I: LNT_Channel_Port, 
   PORT_POS_O: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
142
   is 
143
144
145
146
147
148
149
      var 
         POS_I : LNT_Type_Data, 
         POS_O : LNT_Type_Data
      in 
         POS_I := EMPTY; 
         POS_O := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
150
            select 
151
152
153
154
155
156
157
158
159
160
161
162
163
164
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_POS_I (?POS_I)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_POS_O (POS_O)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_POS_I (?POS_I); 
                  PORT_POS_O (POS_O)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
165
               []
166
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
167
               []
168
169
170
171
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
172
173
174
175
   end process 
   
   process Thread_PL [
   ACTIVATION: LNT_Channel_Dispatch, 
176
177
178
   PORT_ACC_C: LNT_Channel_Port, 
   PORT_ACC_O: LNT_Channel_Port, 
   PORT_ANGLE_C: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
179
   is 
180
181
182
183
184
185
186
187
188
      var 
         ACC_C : LNT_Type_Data, 
         ACC_O : LNT_Type_Data, 
         ANGLE_C : LNT_Type_Data
      in 
         ACC_C := EMPTY; 
         ACC_O := EMPTY; 
         ANGLE_C := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
189
            select 
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_ACC_C (?ACC_C); 
                  PORT_ACC_O (?ACC_O)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ANGLE_C (ANGLE_C)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_ACC_C (?ACC_C); 
                  PORT_ACC_O (?ACC_O); 
                  PORT_ANGLE_C (ANGLE_C)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
206
               []
207
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
208
               []
209
210
211
212
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
213
214
215
216
   end process 
   
   process Thread_PF [
   ACTIVATION: LNT_Channel_Dispatch, 
217
218
   PORT_ACC_I: LNT_Channel_Port, 
   PORT_ACC_O: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
219
   is 
220
221
222
223
224
225
226
      var 
         ACC_I : LNT_Type_Data, 
         ACC_O : LNT_Type_Data
      in 
         ACC_I := EMPTY; 
         ACC_O := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
227
            select 
228
229
230
231
232
233
234
235
236
237
238
239
240
241
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_ACC_I (?ACC_I)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ACC_O (ACC_O)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_ACC_I (?ACC_I); 
                  PORT_ACC_O (ACC_O)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
242
               []
243
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
244
               []
245
246
247
248
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
249
250
251
252
   end process 
   
   process Thread_FL [
   ACTIVATION: LNT_Channel_Dispatch, 
253
254
255
   PORT_ANGLE_C: LNT_Channel_Port, 
   PORT_ANGLE_O: LNT_Channel_Port, 
   PORT_ORDER: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
256
   is 
257
258
259
260
261
262
263
264
265
      var 
         ANGLE_C : LNT_Type_Data, 
         ANGLE_O : LNT_Type_Data, 
         ORDER : LNT_Type_Data
      in 
         ANGLE_C := EMPTY; 
         ANGLE_O := EMPTY; 
         ORDER := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
266
            select 
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_ANGLE_C (?ANGLE_C); 
                  PORT_ANGLE_O (?ANGLE_O)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ORDER (ORDER)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_ANGLE_C (?ANGLE_C); 
                  PORT_ANGLE_O (?ANGLE_O); 
                  PORT_ORDER (ORDER)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
283
               []
284
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
285
               []
286
287
288
289
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
290
291
292
293
   end process 
   
   process Thread_AP [
   ACTIVATION: LNT_Channel_Dispatch, 
294
295
296
297
   PORT_POSITION: LNT_Channel_Port, 
   PORT_ACC: LNT_Channel_Port, 
   PORT_ACC_I: LNT_Channel_Port, 
   PORT_POS_I: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
298
   is 
299
300
301
302
303
304
305
306
307
308
309
      var 
         POSITION : LNT_Type_Data, 
         ACC : LNT_Type_Data, 
         ACC_I : LNT_Type_Data, 
         POS_I : LNT_Type_Data
      in 
         POSITION := EMPTY; 
         ACC := EMPTY; 
         ACC_I := AADLDATA; 
         POS_I := AADLDATA; 
         loop 
Bechir Zalila's avatar
Bechir Zalila committed
310
            select 
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
               select 
                  ACTIVATION (T_Dispatch_Preemption); 
                  PORT_POSITION (?POSITION); 
                  PORT_ACC (?ACC)
                  []
                  ACTIVATION (T_Preemption_Completion); 
                  PORT_ACC_I (ACC_I); 
                  PORT_POS_I (POS_I)
                  []
                  ACTIVATION (T_Dispatch_Completion); 
                  PORT_POSITION (?POSITION); 
                  PORT_ACC (?ACC); 
                  PORT_ACC_I (ACC_I); 
                  PORT_POS_I (POS_I)
                  []
                  ACTIVATION (T_Preemption)
               end select ; 
               ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
329
               []
330
               ACTIVATION (T_Error)
Bechir Zalila's avatar
Bechir Zalila committed
331
               []
332
333
334
335
               ACTIVATION (T_Stop)
            end select 
         end loop
      end var
Bechir Zalila's avatar
Bechir Zalila committed
336
337
338
   end process 
   
   process Device_Operator [
339
   PORT_POS_C: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
340
341
342
   is 
      loop 
         select 
343
            PORT_POS_C (AADLDATA)
Bechir Zalila's avatar
Bechir Zalila committed
344
345
346
347
348
349
350
            []
            null 
         end select 
      end loop
   end process 
   
   process Device_GPS [
351
   PORT_POSITION: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
352
353
354
   is 
      loop 
         select 
355
            PORT_POSITION (AADLDATA)
Bechir Zalila's avatar
Bechir Zalila committed
356
357
358
359
360
361
362
            []
            null 
         end select 
      end loop
   end process 
   
   process Device_IMU [
363
364
   PORT_ANGLE: LNT_Channel_Port, 
   PORT_ACC: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
365
366
367
   is 
      loop 
         select 
368
            PORT_ANGLE (AADLDATA)
Bechir Zalila's avatar
Bechir Zalila committed
369
            []
370
            PORT_ACC (AADLDATA)
Bechir Zalila's avatar
Bechir Zalila committed
371
372
373
374
375
         end select 
      end loop
   end process 
   
   process Device_Platform [
376
   PORT_ORDER: LNT_Channel_Port]
Bechir Zalila's avatar
Bechir Zalila committed
377
378
379
   is 
      loop 
         select 
380
            PORT_ORDER (AADLDATA)
Bechir Zalila's avatar
Bechir Zalila committed
381
382
383
384
385
386
387
            []
            null 
         end select 
      end loop
   end process 
   
end module 
388
module Types 
Bechir Zalila's avatar
Bechir Zalila committed
389
390
with "==",  "eq" , "<",  "lt" , "<=",  "le" , ">",  "gt" , ">=",  "ge" is 
   type LNT_Type_Data is 
391
      AADLDATA, EMPTY
Bechir Zalila's avatar
Bechir Zalila committed
392
393
   end type 
   
394
395
396
397
398
399
   type LNT_Type_Data_FIFO is 
      list of LNT_Type_Data
      with "==",  "eq" , "length" , "append" , "tail" , "head" , "<>",  "ne",  "!=" 
   end type 
   
   channel LNT_Channel_Port is 
Bechir Zalila's avatar
Bechir Zalila committed
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
      (LNT_Type_Data) 
   end channel
   type LNT_Type_Time_Constraint is 
      range 0 .. 240 of Nat
   end type 
   
   type LNT_Type_Thread is 
      array [0 .. 11 ]of LNT_Type_Time_Constraint
   end type 
   
   type LNT_Type_Thread_Array is 
      array [1 .. 7 ]of LNT_Type_Thread
   end type 
   
   type LNT_Type_Dispatch is 
415
      T_Dispatch_Preemption, T_Preemption_Completion, T_Dispatch_Completion, T_Preemption, T_Stop, T_Error, T_Complete
Bechir Zalila's avatar
Bechir Zalila committed
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
   end type 
   
   type LNT_Type_Event is 
      Incoming_Event, No_Event
   end type 
   
   channel LNT_Channel_Dispatch is 
      (LNT_Type_Dispatch) 
   end channel
   channel LNT_Channel_Event is 
      (LNT_Type_Event) 
   end channel
   function Thread_Number : Nat 
   is 
      return 7
   end function 
   
   function PPCM_THREAD : LNT_Type_Time_Constraint 
   is 
      return LNT_Type_Time_Constraint ( 120)
   end function 
   
   function _+_ (
      n1: LNT_Type_Time_Constraint, 
      n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint 
   is 
      return LNT_Type_Time_Constraint (Nat (n1) + Nat (n2) mod 240)
   end function 
   
   function _-_ (
      n1: LNT_Type_Time_Constraint, 
      n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint 
   is 
      if (n1 <  n2)
      then 
         return LNT_Type_Time_Constraint (((240 - Nat (n2))  + Nat (n1))  mod 240)
      else 
         return LNT_Type_Time_Constraint (Nat (n1) - Nat (n2) mod 240)
      end if
   end function 
   
   function _*_ (
      n1: LNT_Type_Time_Constraint, 
      n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint 
   is 
      return LNT_Type_Time_Constraint (Nat (n1) * Nat (n2) mod 240)
   end function 
   
end module 
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
module FLIGHTCONTROLSYSTEM_Main (Types, FLIGHTCONTROLSYSTEM_Processor, FLIGHTCONTROLSYSTEM_Threads, LNT_Generic_Process_For_Port_Connections) is 
   process Main [
   ACTIVATION_3: LNT_Channel_Dispatch, 
   SEND_V5: LNT_Channel_Port, 
   RECEIVE_V16: LNT_Channel_Port, 
   ACTIVATION_6: LNT_Channel_Dispatch, 
   RECEIVE_V13: LNT_Channel_Port, 
   RECEIVE_V3: LNT_Channel_Port, 
   SEND_V1: LNT_Channel_Port, 
   ACTIVATION_7: LNT_Channel_Dispatch, 
   RECEIVE_V7: LNT_Channel_Port, 
   SEND_V3: LNT_Channel_Port, 
   ACTIVATION_5: LNT_Channel_Dispatch, 
   RECEIVE_V1: LNT_Channel_Port, 
   RECEIVE_V4: LNT_Channel_Port, 
   SEND_V2: LNT_Channel_Port, 
   ACTIVATION_4: LNT_Channel_Dispatch, 
   RECEIVE_V6: LNT_Channel_Port, 
   SEND_V4: LNT_Channel_Port, 
   ACTIVATION_1: LNT_Channel_Dispatch, 
   RECEIVE_V2: LNT_Channel_Port, 
   RECEIVE_V5: LNT_Channel_Port, 
   SEND_V14: LNT_Channel_Port, 
   ACTIVATION_2: LNT_Channel_Dispatch, 
   RECEIVE_V15: LNT_Channel_Port, 
   RECEIVE_V17: LNT_Channel_Port, 
   SEND_V6: LNT_Channel_Port, 
   SEND_V7: LNT_Channel_Port, 
   SEND_V13: LNT_Channel_Port, 
   SEND_V15: LNT_Channel_Port, 
   SEND_V16: LNT_Channel_Port, 
   SEND_V17: LNT_Channel_Port, 
   RECEIVE_V14: LNT_Channel_Port]
   is 
      par 
         ACTIVATION_3 , SEND_V5 , SEND_V16 -> 
         par 
            SEND_V16 , RECEIVE_V16 -> 
            Event_Port_For_Periodic [SEND_V16, RECEIVE_V16] ( 3)
            ||
            ACTIVATION_3 , SEND_V5 , RECEIVE_V16 -> 
            Thread_FF [ACTIVATION_3, SEND_V5, RECEIVE_V16]
         end par 
         ||
         ACTIVATION_6 , SEND_V13 , SEND_V3 , SEND_V1 -> 
         par 
            SEND_V13 , RECEIVE_V13 -> 
            Event_Port_For_Periodic [SEND_V13, RECEIVE_V13] ( 3)
            ||
            SEND_V3 , RECEIVE_V3 -> 
            Event_Port_For_Periodic [SEND_V3, RECEIVE_V3] ( 3)
            ||
            ACTIVATION_6 , RECEIVE_V13 , RECEIVE_V3 , SEND_V1 -> 
            Thread_NL [ACTIVATION_6, RECEIVE_V13, RECEIVE_V3, SEND_V1]
         end par 
         ||
         ACTIVATION_7 , SEND_V7 , SEND_V3 -> 
         par 
            SEND_V7 , RECEIVE_V7 -> 
            Event_Port_For_Periodic [SEND_V7, RECEIVE_V7] ( 3)
            ||
            ACTIVATION_7 , RECEIVE_V7 , SEND_V3 -> 
            Thread_NF [ACTIVATION_7, RECEIVE_V7, SEND_V3]
         end par 
         ||
         ACTIVATION_5 , SEND_V1 , SEND_V4 , SEND_V2 -> 
         par 
            SEND_V1 , RECEIVE_V1 -> 
            Event_Port_For_Periodic [SEND_V1, RECEIVE_V1] ( 3)
            ||
            SEND_V4 , RECEIVE_V4 -> 
            Event_Port_For_Periodic [SEND_V4, RECEIVE_V4] ( 3)
            ||
            ACTIVATION_5 , RECEIVE_V1 , RECEIVE_V4 , SEND_V2 -> 
            Thread_PL [ACTIVATION_5, RECEIVE_V1, RECEIVE_V4, SEND_V2]
         end par 
         ||
         ACTIVATION_4 , SEND_V6 , SEND_V4 -> 
         par 
            SEND_V6 , RECEIVE_V6 -> 
            Event_Port_For_Periodic [SEND_V6, RECEIVE_V6] ( 3)
            ||
            ACTIVATION_4 , RECEIVE_V6 , SEND_V4 -> 
            Thread_PF [ACTIVATION_4, RECEIVE_V6, SEND_V4]
         end par 
         ||
         ACTIVATION_1 , SEND_V2 , SEND_V5 , SEND_V14 -> 
         par 
            SEND_V2 , RECEIVE_V2 -> 
            Event_Port_For_Periodic [SEND_V2, RECEIVE_V2] ( 3)
            ||
            SEND_V5 , RECEIVE_V5 -> 
            Event_Port_For_Periodic [SEND_V5, RECEIVE_V5] ( 3)
            ||
            ACTIVATION_1 , RECEIVE_V2 , RECEIVE_V5 , SEND_V14 -> 
            Thread_FL [ACTIVATION_1, RECEIVE_V2, RECEIVE_V5, SEND_V14]
         end par 
         ||
         ACTIVATION_2 , SEND_V15 , SEND_V17 , SEND_V6 , SEND_V7 -> 
         par 
            SEND_V15 , RECEIVE_V15 -> 
            Event_Port_For_Periodic [SEND_V15, RECEIVE_V15] ( 3)
            ||
            SEND_V17 , RECEIVE_V17 -> 
            Event_Port_For_Periodic [SEND_V17, RECEIVE_V17] ( 3)
            ||
            ACTIVATION_2 , RECEIVE_V15 , RECEIVE_V17 , SEND_V6 , SEND_V7 -> 
            Thread_AP [ACTIVATION_2, RECEIVE_V15, RECEIVE_V17, SEND_V6, SEND_V7]
         end par 
         ||
         SEND_V13 -> 
         Device_Operator [SEND_V13]
         ||
         SEND_V15 -> 
         Device_GPS [SEND_V15]
         ||
         SEND_V16 , SEND_V17 -> 
         Device_IMU [SEND_V16, SEND_V17]
         ||
         SEND_V14 -> 
         par 
            SEND_V14 , RECEIVE_V14 -> 
            Data_Port [SEND_V14, RECEIVE_V14]
            ||
            RECEIVE_V14 -> 
            Device_Platform [RECEIVE_V14]
         end par 
         ||
         ACTIVATION_1 , ACTIVATION_2 , ACTIVATION_3 , ACTIVATION_4 , ACTIVATION_5 , ACTIVATION_6 , ACTIVATION_7 -> 
         Processor [ACTIVATION_1, ACTIVATION_2, ACTIVATION_3, ACTIVATION_4, ACTIVATION_5, ACTIVATION_6, ACTIVATION_7]
      end par 
   end process 
   
end module 
module FLIGHTCONTROLSYSTEM_Processor (Types) is 
Bechir Zalila's avatar
Bechir Zalila committed
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
   function Assign (
      in var Threads: LNT_Type_Thread_Array, 
      I: Nat, 
      K: Nat, 
      Val: LNT_Type_Time_Constraint) : LNT_Type_Thread_Array 
   is 
      var 
         P : LNT_Type_Thread
      in 
         P := Threads[I]; 
         P[K] := Val; 
         Threads[I] := P
      end var; 
      return Threads
   end function 
   
   function Update_Thread (
      in var Aux_Threads: LNT_Type_Thread_Array, 
      I: Nat, 
      TODO: LNT_Type_Time_Constraint) : LNT_Type_Thread_Array 
   is 
      var 
         P : LNT_Type_Thread
      in 
         P := Aux_Threads[I]; 
         if (P[2] ==  LNT_Type_Time_Constraint (0))
         then 
            P[6] := LNT_Type_Time_Constraint (1)
         end if; 
         P[2] := P[2] + TODO; 
         P[8] := LNT_Type_Time_Constraint (1); 
631
         if (P[2] ==  P[0])
Bechir Zalila's avatar
Bechir Zalila committed
632
633
634
         then 
            P[7] := LNT_Type_Time_Constraint (1); 
            P[2] := LNT_Type_Time_Constraint (0); 
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
            case P[11] of LNT_Type_Time_Constraint in 
            
               LNT_Type_Time_Constraint (1) -> 
                  P[4] := P[5] ; 
                  P[5] := PPCM_THREAD ; 
                  P[10] := LNT_Type_Time_Constraint (0)
               | 
               LNT_Type_Time_Constraint (0) | LNT_Type_Time_Constraint (3) -> 
                  if ((P[3] + LNT_Type_Time_Constraint (1) * P[1] <=  PPCM_THREAD)  and  (P[4] + P[1] <=  PPCM_THREAD) )
                  then 
                     P[4] := P[3] * P[1]; 
                     P[3] := P[3] + LNT_Type_Time_Constraint (1); 
                     P[5] := P[3] * P[1]
                  else 
                     P[10] := LNT_Type_Time_Constraint (0)
                  end if
               | 
               LNT_Type_Time_Constraint (2) -> 
                  if ((P[4] + P[1] <=  PPCM_THREAD)  and  (P[5] + P[1] <=  PPCM_THREAD) )
                  then 
                     P[4] := P[4] + P[1]; 
                     P[5] := P[5] + P[1]
                  else 
                     P[10] := LNT_Type_Time_Constraint (0)
                  end if
               | 
               any  -> 
                  null 
            end case 
Bechir Zalila's avatar
Bechir Zalila committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
         end if; 
         Aux_Threads[I] := P
      end var; 
      return Aux_Threads
   end function 
   
   process Sporadic_Notif [
   INCOMING_EVENT_GATE: LNT_Channel_Event](
   in out Threads: LNT_Type_Thread_Array,
   k: Nat,
   Counter: LNT_Type_Time_Constraint,
   in out Is_Activated: bool) 
   is 
      select 
         INCOMING_EVENT_GATE (Incoming_Event); 
         Threads := Assign (Threads, K, 3, (Threads[k][3] + LNT_Type_Time_Constraint (1)) )
         []
         INCOMING_EVENT_GATE (No_Event)
      end select ; 
      if ((Counter >=  Threads[k][4])  and  (Threads[k][3] >  LNT_Type_Time_Constraint (0)) )
      then 
         Threads := Assign (Threads, k, 4, Counter); 
         Threads := Assign (Threads, k, 5, (Counter + Threads[k][1]) ); 
         Threads := Assign (Threads, k, 10, LNT_Type_Time_Constraint (1)); 
         Threads := Assign (Threads, K, 3, (Threads[k][3] - LNT_Type_Time_Constraint (1)) ); 
         Is_Activated := true
      end if
   end process 
   
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
   process Timed_Hybrid_Notif [
   INCOMING_EVENT_GATE: LNT_Channel_Event](
   in out Threads: LNT_Type_Thread_Array,
   k: Nat,
   Counter: LNT_Type_Time_Constraint,
   in out Is_Activated: bool) 
   is 
      select 
         INCOMING_EVENT_GATE (Incoming_Event); 
         Threads := Assign (Threads, k, 4, Counter); 
         Threads := Assign (Threads, k, 5, (Counter + Threads[k][1]) ); 
         Is_Activated := true
         []
         INCOMING_EVENT_GATE (No_Event)
      end select 
   end process 
   
   process Activate_K [
   ACTIVATION_1: LNT_Channel_Dispatch, 
   ACTIVATION_2: LNT_Channel_Dispatch, 
   ACTIVATION_3: LNT_Channel_Dispatch, 
   ACTIVATION_4: LNT_Channel_Dispatch, 
   ACTIVATION_5: LNT_Channel_Dispatch, 
   ACTIVATION_6: LNT_Channel_Dispatch, 
   ACTIVATION_7: LNT_Channel_Dispatch](
   in out Threads: LNT_Type_Thread_Array,
   K: Nat) 
   is 
      case k in 
      
          1 -> 
            Thread_Activation [ACTIVATION_1] (!?Threads,  1)
         | 
          2 -> 
            Thread_Activation [ACTIVATION_2] (!?Threads,  2)
         | 
          3 -> 
            Thread_Activation [ACTIVATION_3] (!?Threads,  3)
         | 
          4 -> 
            Thread_Activation [ACTIVATION_4] (!?Threads,  4)
         | 
          5 -> 
            Thread_Activation [ACTIVATION_5] (!?Threads,  5)
         | 
          6 -> 
            Thread_Activation [ACTIVATION_6] (!?Threads,  6)
         | 
          7 -> 
            Thread_Activation [ACTIVATION_7] (!?Threads,  7)
         | 
         any  -> 
            null 
      end case 
   end process 
   
Bechir Zalila's avatar
Bechir Zalila committed
749
750
751
752
753
754
755
756
757
   process Thread_Activation [
   ACTIVATION: LNT_Channel_Dispatch](
   in out Threads: LNT_Type_Thread_Array,
   K: Nat) 
   is 
      if (Threads[K][8] ==  LNT_Type_Time_Constraint (1))
      then 
         if ((Threads[K][6] ==  LNT_Type_Time_Constraint (1))  and  (Threads[K][7] ==  LNT_Type_Time_Constraint (1)) )
         then 
758
            ACTIVATION (T_Dispatch_Completion); 
Bechir Zalila's avatar
Bechir Zalila committed
759
760
761
762
763
            Threads := Assign (Threads, K, 6, LNT_Type_Time_Constraint (0)); 
            Threads := Assign (Threads, K, 7, LNT_Type_Time_Constraint (0))
         elsif (Threads[K][7] ==  LNT_Type_Time_Constraint (1))
         then 
         
764
            ACTIVATION (T_Preemption_Completion); 
Bechir Zalila's avatar
Bechir Zalila committed
765
766
767
768
            Threads := Assign (Threads, K, 7, LNT_Type_Time_Constraint (0))
         elsif (Threads[K][6] ==  LNT_Type_Time_Constraint (1))
         then 
         
769
            ACTIVATION (T_Dispatch_Preemption); 
Bechir Zalila's avatar
Bechir Zalila committed
770
771
            Threads := Assign (Threads, K, 6, LNT_Type_Time_Constraint (0))
         else 
772
            ACTIVATION (T_Preemption)
Bechir Zalila's avatar
Bechir Zalila committed
773
774
         end if; 
         Threads := Assign (Threads, K, 8, LNT_Type_Time_Constraint (0)); 
775
         ACTIVATION (T_Complete)
Bechir Zalila's avatar
Bechir Zalila committed
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
      elsif (Threads[K][9] ==  LNT_Type_Time_Constraint (0))
      then 
      
         ACTIVATION (T_ERROR)
      end if
   end process 
   
   process Processor [
   ACTIVATION_1: LNT_Channel_Dispatch, 
   ACTIVATION_2: LNT_Channel_Dispatch, 
   ACTIVATION_3: LNT_Channel_Dispatch, 
   ACTIVATION_4: LNT_Channel_Dispatch, 
   ACTIVATION_5: LNT_Channel_Dispatch, 
   ACTIVATION_6: LNT_Channel_Dispatch, 
   ACTIVATION_7: LNT_Channel_Dispatch]
   is 
      var 
         Threads : LNT_Type_Thread_Array, 
         Counter : LNT_Type_Time_Constraint, 
         I : Nat, 
         k : Nat, 
         Preempt : bool, 
         TODO : LNT_Type_Time_Constraint, 
         Nb_Active_Thread : Nat
      in 
         Counter := LNT_Type_Time_Constraint (0); 
         Threads := LNT_Type_Thread_Array (LNT_Type_Thread (LNT_Type_Time_Constraint (0))); 
         Threads[ 1] := LNT_Type_Thread (LNT_Type_Time_Constraint (2), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 2] := LNT_Type_Thread (LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 3] := LNT_Type_Thread (LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 4] := LNT_Type_Thread (LNT_Type_Time_Constraint (5), LNT_Type_Time_Constraint (40), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (40), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 5] := LNT_Type_Thread (LNT_Type_Time_Constraint (5), LNT_Type_Time_Constraint (40), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (40), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 6] := LNT_Type_Thread (LNT_Type_Time_Constraint (20), LNT_Type_Time_Constraint (120), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (120), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         Threads[ 7] := LNT_Type_Thread (LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (120), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (120), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0)); 
         loop 
811
812
813
814
815
816
817
818
            if (Counter <  PPCM_THREAD)
            then 
               Nb_Active_Thread := 0; 
               K := 1; 
               while (K <=  Thread_Number) loop
                  if ((Threads[K][10] ==  LNT_Type_Time_Constraint (1))  and  (Threads[K][9] ==  LNT_Type_Time_Constraint (1))  and  (Counter >=  Threads[K][4]) )
                  then 
                     if (Counter >=  Threads[K][5])
Bechir Zalila's avatar
Bechir Zalila committed
819
                     then 
820
821
822
823
                        Threads := Assign (Threads, K, 9, LNT_Type_Time_Constraint (0)); 
                        Activate_k [ACTIVATION_1, ACTIVATION_2, ACTIVATION_3, ACTIVATION_4, ACTIVATION_5, ACTIVATION_6, ACTIVATION_7] (!?Threads, k); 
                        k := k + 1
                     else 
Bechir Zalila's avatar
Bechir Zalila committed
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
                        Preempt := true; 
                        TODO := Threads[K][0] - Threads[K][2]; 
                        I := 1; 
                        while ((I <=  (K - 1) )  and  Preempt) loop
                           if ((Threads[I][10] ==  LNT_Type_Time_Constraint (1))  and  (Threads[I][9] ==  LNT_Type_Time_Constraint (1))  and  (Counter + TODO >  Threads[I][4]) )
                           then 
                              TODO := Threads[I][4] - Counter; 
                              Preempt := false
                           else 
                              I := I + 1
                           end if
                        end loop; 
                        Counter := Counter + TODO; 
                        Nb_Active_Thread := Nb_Active_Thread + 1; 
                        Threads := Update_Thread (Threads, K, TODO); 
839
840
841
842
843
844
845
                        Activate_k [ACTIVATION_1, ACTIVATION_2, ACTIVATION_3, ACTIVATION_4, ACTIVATION_5, ACTIVATION_6, ACTIVATION_7] (!?Threads, k); 
                        if (Preempt)
                        then 
                           k := I
                        else 
                           k := k + 1
                        end if
Bechir Zalila's avatar
Bechir Zalila committed
846
                     end if
847
848
                  else 
                     k := k + 1
Bechir Zalila's avatar
Bechir Zalila committed
849
                  end if
850
851
               end loop; 
               if (Nb_Active_Thread ==  0)
Bechir Zalila's avatar
Bechir Zalila committed
852
               then 
853
                  Counter := Counter + LNT_Type_Time_Constraint (1)
Bechir Zalila's avatar
Bechir Zalila committed
854
               end if
855
856
857
858
859
860
861
862
863
            else 
               ACTIVATION_1 (T_Stop); 
               ACTIVATION_2 (T_Stop); 
               ACTIVATION_3 (T_Stop); 
               ACTIVATION_4 (T_Stop); 
               ACTIVATION_5 (T_Stop); 
               ACTIVATION_6 (T_Stop); 
               ACTIVATION_7 (T_Stop)
            end if
Bechir Zalila's avatar
Bechir Zalila committed
864
865
866
867
868
         end loop
      end var
   end process 
   
end module