forked from IreneRosadi/UppaalModels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modelMitigation.xml
1962 lines (1885 loc) · 71.2 KB
/
modelMitigation.xml
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
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
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
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
631
632
633
634
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
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
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
<nta>
<declaration>// Place global declarations here.
//processes IDs
const int ID_SAI_INITIATOR = 0; //SAI initiator
const int ID_SAI_RESPONDER = 1; //SAI responder
const bool Initiator = true;
//signals ID
const int SIG_Sa_CONNECT_request=1;
const int SIG_Sa_CONNECT_confirm=2;
const int SIG_Sa_CONNECT_indication=3;
const int SIG_Sa_CONNECT_response=4;
const int SIG_Sa_DISCONNECT_request=5;
const int SIG_Sa_DISCONNECT_indication=6;
const int SIG_Sa_DATA_request=7;
const int SIG_Sa_DATA_indication=8;
//fixed constants
const int INT16_MAX = 32767; //max value for sn and SAI_CLOCK, according to UPPAL max integer assignment
const int N = 2; //number of operating devices
const int MTF_max = 6; //message type field max value
const int SN_max = 100; //sequence number max value
const int O_Start = 1; //message type field for OffsetStart message
const int O_Answ1 = 2; //message type field for OffsetAnsw1 message
const int O_Answ2 = 3; //message type field for OffsetAnsw2 message
const int O_Est = 4; //message type field for OffsetEst message
const int O_End = 5; //message type field for OffsetEnd message
const int App_Msg = 6; //message type field for Application message protected with TTS
//parameters to set
const int queue_size = 15; //max element number in sig_queue
const int N_max_lost_msg[N] = {2,2}; //SAI max lost msg number + 1 (N_max_lost_msg must be >=1)
const int N_max_succ_err[N] = {3,3}; //SAI max number of succesive errors + 1
const int msg_freq[N] = {8,8}; //SAI_User frequency for msg exchange
const int T_reply_max[N] = {3*msg_freq[0],3*msg_freq[1]};//SAI_User max time value without any reply
const int T_start_max[N] = {2,2}; //SAI_Conn max time value for answers in clock offset update procedure
const int T_conn_max = 4*T_start_max[ID_SAI_INITIATOR]; //SAI_User initiator max time value for responder connection confirm
const int T_off_max = 3; //SAI_Conn_Ini max difference between initiator min offset and responder max offset estimation
const int T_max[N] = {5,5}; //SAI max validity time of incoming msgs
const int offset_update_freq[N] = {500,500}; //SAI_Update_Req frequency for offset update procedure
const int T_extra_delay = 0; //extra delays due to the processing time of the application data in the sender sub-system (default 0)
const int T_commSystemCheck_min = 250; //Communication_System min waiting time for check
const int T_tryFaultInjection_min = 10; //FaultInjector min waiting time for fault injection
const double s_time = 0.0; //SAI_clock starting time
const double temporal_drift = 30000.0; //SAI_clock temporal drift
//parameters to set: rate
const double connRate = 1.0; //SAI_User initiator connection rate
const double msgDelayStandard[N] = {2.0,2.0}; //SAI standard msg delay
const double msgDelayInjected = 0.4*msgDelayStandard[0]; //SAI injected msg delay for transmission delay threat
const double commSystemCheckRate = 1.0; //Communication_System check rate
const double tryFaultInjectionRate = 1.0; //FaultInjector fault rate
const double connRelease = 100.0; //safe conn release rate
//parameters to set: weight
const int sendDataMsg = 99; //SAI_User weight for application data msg sending
const int stopConnMsg = 1; //SAI_User weight for safe connection release msg sending
const int safeConn = 99; //Euroradio_SL weight for safe connection maintenance
const int disruptiveConnRelease = 1; //Euroradio_SL weight for EuroradioSL failure
const int noEuroradioFailure = 99; //Euroradio_Env weight for no failure occurrance
const int euroradioFailure = 1; //Euroradio_Env weight for failure occurrance
const int noFault = 1; //FaultInjector weight for no fault injection
const int fault = 1; //FaultInjector weight for fault injection
const int transmissionDelay = 1; //Euroradio_Env weight for transmission delay threats
const int deletion = 1; //Euroradio_Env weight for msg deletion threats
const int resequencing = 1; //Euroradio_Env weight for msg resequencing threats
const int repetition = 1; //Euroradio_Env weight for msg repetition threats
//definitions
typedef int[0,N-1] id_t; //allowed values for SAI id
typedef int[0,SN_max] sn_t; //allowed values for Sequence Number
typedef int[0,MTF_max] mtf_t; //allowed values for Message Type Field
typedef struct
{
int min_offset; //min offset estimation
int max_offset; //max offset estimation
int check_field; //result of clock offset estimation check: 1 if clock offset estimation comparison is validated, 0 otherwise
} data_t; //user data structure
typedef struct
{
mtf_t mtf; //message type field
sn_t sn; //msg sequence number
int s_ts; //sender time stamp
int last_r_ts; //last received time stamp
int s_last_r_ts; //sender time stamp at last received msg
data_t user_data; //user data used in OffsetEst message during clock offset update procedure
} msg_t; //msg structure
typedef struct
{
int sig_id; //signal id
msg_t msg; //msg to exchange
} sig_t; //signal structure
//channels
broadcast chan
SAI_CONNECT_request[N], SAI_CONNECT_confirm[N], SAI_CONNECT_indication[N], SAI_CONNECT_response[N], //primitives for SAI_User - SAI entity connection communications
SAI_DATA_request[N], SAI_DATA_indication[N], //primitives for SAI_User - SAI entity message exchange communications
SAI_DISCONNECT_request[N], SAI_DISCONNECT_indication[N], //primitives for SAI_User - SAI entity disconnection communications
Sa_CONNECT_request[N], Sa_CONNECT_confirm[N], Sa_CONNECT_indication[N], Sa_CONNECT_response[N], //primitive for Euroradio_Env - SAI entity connection communications
Sa_DATA_request[N], Sa_DATA_indication[N], //primitive for Euroradio_Env - SAI entity message exchange communications
Sa_DISCONNECT_request[N], Sa_DISCONNECT_indication[N], //primitive for Euroradio_Env - SAI entity disconnection communications
tau_offset_update_request[N], tau_offset_update_answer[N], //tau SAI signals for offset update procedure request and answer
tau_safe_conn_release[N], //tau SAI signal for safe connection release communications
tau_error_notification[N], //SAI signals for error notification to SAI_User
tau_CommSystem_fault; //Communication_System signal for internal error communications to Euroradio_SL_Env
//constants
const data_t empty_user_data = {0, 0, 0}; //empty user data
const msg_t empty_msg = {0, 0, 0, 0, 0,empty_user_data}; //empty message
const sig_t empty_sig = {0,empty_msg}; //empty signal
//variables
sig_t sig_out = empty_sig; //variable for SAI entity - Euroradio_Env signal exchange
sig_t sig_queue[N][queue_size]; //SAI entity signal queue
bool isConnected[N] = {false,false}; //true if SAI entity is connected
bool isTTSInitializing = false; //true if TTS init is taking place
clock SAI_clock[N] = {s_time,s_time+temporal_drift}; //SAI clock
double msgDelay[N] = msgDelayStandard; //SAI msg delay variable
int sn[N] = {-1,-1}; //SAI msg sn (-1 if no msg has been sent yet)
int last_sn[N] = {-1,-1}; //SAI sn of last received and validated msg (-1 if no msg has been validated yet)
int last_received_ts[N] = {0,0}; //SAI last received time stamp
int last_msg_ts[N] = {0,0}; //SAI time stamp at last msg reception
int T_offset_max[N] = {0,0}; //SAI maximum offset estimations
int T_offset_min[N] = {0,0}; //SAI minimum offset estimations
//functions
bool allSAIConnected() //true if all N SAI are connected
{
return forall(i: id_t) isConnected[i];
}
bool isQueueEmpty(id_t SAI_id)
{
return sig_queue[SAI_id][queue_size-1]==empty_sig;
}
bool isQueueFull(int id)
{
return sig_queue[id][0]!=empty_sig;
}
void computeMinMaxOffsets(id_t SAI_id, sig_t sig)
{
T_offset_min[SAI_id]:=sig.msg.last_r_ts-sig.msg.s_last_r_ts;
T_offset_max[SAI_id]:=last_msg_ts[SAI_id]-last_received_ts[SAI_id];
}
void prepareSig(sig_t &sig, int sig_id)
{
sig.sig_id:=sig_id;
}
void prepareTTSSig(sig_t &sig, int sig_id, int msg_mtf, int msg_sn, int msg_s_ts, int msg_last_r_ts, int msg_s_last_r_ts)
{
sig.sig_id:=sig_id;
sig.msg.mtf:=msg_mtf;
sig.msg.sn:=msg_sn;
sig.msg.s_ts:=msg_s_ts;
sig.msg.last_r_ts:=msg_last_r_ts;
sig.msg.s_last_r_ts:=msg_s_last_r_ts;
}
void resetParams(id_t SAI_id)
{
last_sn[SAI_id]:=-1;
last_received_ts[SAI_id]:=0;
last_msg_ts[SAI_id]:=0;
T_offset_max[SAI_id]:=0;
T_offset_min[SAI_id]:=0;
}
</declaration>
<template>
<name>Fault_Injector</name>
<declaration>
clock t;
id_t id;
int n_pos_max;
sig_t sig:=empty_sig;
void shiftFirstSig(int id, int n_pos)
{
int i;
for (i:=0;i<queue_size;i++)
{
if(sig_queue[id][i]!=empty_sig)
{
int j:=i;
int pos_switch:=0;
sig_t tmp;
while (pos_switch<n_pos)
{
if (j == queue_size-1)
{
return;
}
tmp:=sig_queue[id][j+1];
sig_queue[id][j+1]:=sig_queue[id][j];
sig_queue[id][j]:=tmp;
pos_switch++;
j++;
}
}
}
}
void deleteFirstSig(int id)
{
int i;
for (i:=0;i<queue_size;i++)
{
if(sig_queue[id][i]!=empty_sig)
{
sig_queue[id][i]:=empty_sig;
return;
}
}
}
void repeatFirstSig(int id)
{
int i;
for (i:=0;i<queue_size;i++)
{
if(sig_queue[id][i]!=empty_sig)
{
if(i!=0)
{
sig_queue[id][i-1]:=sig_queue[id][i];
}
return;
}
}
}</declaration>
<location id="id0" x="-1122" y="-1513">
<name x="-1173" y="-1530">Wait</name>
<label kind="exponentialrate" x="-1284" y="-1513">tryFaultInjectionRate</label>
</location>
<location id="id1" x="-799" y="-1581">
<name x="-782" y="-1589">DoFault</name>
<committed/>
</location>
<branchpoint id="id2" x="-799" y="-1513">
</branchpoint>
<branchpoint id="id3" x="-799" y="-1649">
</branchpoint>
<init ref="id0"/>
<transition>
<source ref="id1"/>
<target ref="id3"/>
</transition>
<transition>
<source ref="id2"/>
<target ref="id0"/>
<label kind="assignment" x="-790" y="-1479">t:=0</label>
<label kind="probability" x="-790" y="-1496">noFault</label>
<nail x="-799" y="-1411"/>
<nail x="-1122" y="-1411"/>
</transition>
<transition>
<source ref="id2"/>
<target ref="id1"/>
<label kind="probability" x="-790" y="-1547">fault</label>
</transition>
<transition>
<source ref="id0"/>
<target ref="id2"/>
<label kind="select" x="-1088" y="-1513">SAI_id: int[0,N-1]</label>
<label kind="guard" x="-1088" y="-1496">t >= T_tryFaultInjection_min &&
!isQueueEmpty(SAI_id) &&
allSAIConnected()</label>
<label kind="assignment" x="-1088" y="-1445">id:=SAI_id</label>
</transition>
<transition>
<source ref="id3"/>
<target ref="id0"/>
<label kind="select" x="-918" y="-1785">n_pos: int[1,2]</label>
<label kind="assignment" x="-969" y="-1768">shiftFirstSig(id,n_pos),
t:=0</label>
<label kind="probability" x="-918" y="-1802">resequencing</label>
<nail x="-799" y="-1802"/>
<nail x="-1122" y="-1802"/>
</transition>
<transition>
<source ref="id3"/>
<target ref="id0"/>
<label kind="assignment" x="-935" y="-1632">deleteFirstSig(id),
t:=0</label>
<label kind="probability" x="-876" y="-1649">deletion</label>
<nail x="-1122" y="-1649"/>
</transition>
<transition>
<source ref="id3"/>
<target ref="id0"/>
<label kind="assignment" x="-935" y="-1700">repeatFirstSig(id),
t:=0</label>
<label kind="probability" x="-885" y="-1717">repetition</label>
<nail x="-799" y="-1717"/>
<nail x="-1122" y="-1717"/>
</transition>
<transition>
<source ref="id3"/>
<target ref="id0"/>
<label kind="assignment" x="-1054" y="-1844">msgDelay[id]:=msgDelayInjected,
t:=0</label>
<label kind="probability" x="-952" y="-1861">transmissionDelay</label>
<nail x="-799" y="-1861"/>
<nail x="-1122" y="-1861"/>
</transition>
</template>
<template>
<name>Communication_System</name>
<declaration>
clock t;
</declaration>
<location id="id4" x="-578" y="-374">
<name x="-629" y="-374">Wait</name>
<label kind="exponentialrate" x="-765" y="-391">commSystemCheckRate</label>
</location>
<location id="id5" x="-578" y="-459">
<name x="-612" y="-493">ConnRelease</name>
<committed/>
</location>
<branchpoint id="id6" x="-238" y="-374">
</branchpoint>
<init ref="id4"/>
<transition>
<source ref="id5"/>
<target ref="id4"/>
<label kind="synchronisation" x="-569" y="-442">tau_CommSystem_fault!</label>
<label kind="assignment" x="-569" y="-425">t:=0</label>
</transition>
<transition>
<source ref="id6"/>
<target ref="id4"/>
<label kind="assignment" x="-306" y="-297">t:=0</label>
<label kind="probability" x="-306" y="-314">safeConn</label>
<nail x="-238" y="-314"/>
<nail x="-578" y="-314"/>
</transition>
<transition>
<source ref="id6"/>
<target ref="id5"/>
<label kind="probability" x="-399" y="-476">disruptiveConnRelease</label>
<nail x="-238" y="-459"/>
</transition>
<transition>
<source ref="id4"/>
<target ref="id6"/>
<label kind="guard" x="-544" y="-374">t >=T_commSystemCheck_min &&
allSAIConnected()</label>
</transition>
</template>
<template>
<name>Euroradio_SL_Env</name>
<parameter>const id_t SAI_id, const id_t receiver</parameter>
<declaration>// Place local declarations here.
sig_t sig:=empty_sig;
void enqueueSignalQueue(int id)
{
int i;
for (i:=0;i<queue_size-1;i++)
{
sig_queue[id][i]:=sig_queue[id][i+1];
}
sig_queue[id][queue_size-1]:=sig;
}
sig_t dequeueSignalQueue(id_t SAI_id)
{
int i;
sig_t tmp;
for (i:=0;i<queue_size;i++)
{
if (sig_queue[SAI_id][i]!=empty_sig)
{
tmp:=sig_queue[SAI_id][i];
sig_queue[SAI_id][i]:=empty_sig;
return tmp;
}
}
return empty_sig;
}
</declaration>
<location id="id7" x="-1946" y="-1283">
<name x="-1929" y="-1309">Wait</name>
<label kind="invariant" x="-1929" y="-1326">sig_out==empty_sig</label>
<label kind="exponentialrate" x="-1929" y="-1343">msgDelay[SAI_id]</label>
</location>
<location id="id8" x="-1657" y="-1411">
<name x="-1708" y="-1445">EuroradioFailure</name>
<committed/>
</location>
<location id="id9" x="-1470" y="-1215">
<name x="-1462" y="-1241">CheckDelivery</name>
<committed/>
</location>
<location id="id10" x="-2303" y="-1283">
<name x="-2371" y="-1266">CheckIncomingSig</name>
<committed/>
</location>
<branchpoint id="id11" x="-1470" y="-1411">
</branchpoint>
<init ref="id7"/>
<transition>
<source ref="id10"/>
<target ref="id7"/>
<label kind="guard" x="-2278" y="-1598">sig.sig_id==SIG_Sa_DATA_indication</label>
<label kind="synchronisation" x="-2278" y="-1581">Sa_DATA_indication[SAI_id]!</label>
<label kind="assignment" x="-2278" y="-1564">sig_out:=sig,
sig:=empty_sig</label>
<nail x="-2303" y="-1598"/>
<nail x="-1946" y="-1598"/>
</transition>
<transition>
<source ref="id10"/>
<target ref="id7"/>
<label kind="guard" x="-2278" y="-1513">sig.sig_id==SIG_Sa_DISCONNECT_indication</label>
<label kind="synchronisation" x="-2278" y="-1496">Sa_DISCONNECT_indication[SAI_id]!</label>
<nail x="-2303" y="-1513"/>
<nail x="-1946" y="-1513"/>
</transition>
<transition>
<source ref="id10"/>
<target ref="id7"/>
<label kind="guard" x="-2278" y="-1436">sig.sig_id==SIG_Sa_CONNECT_confirm</label>
<label kind="synchronisation" x="-2278" y="-1419">Sa_CONNECT_confirm[SAI_id]!</label>
<nail x="-2303" y="-1436"/>
<nail x="-1946" y="-1437"/>
</transition>
<transition>
<source ref="id10"/>
<target ref="id7"/>
<label kind="guard" x="-2278" y="-1368">sig.sig_id==SIG_Sa_CONNECT_indication</label>
<label kind="synchronisation" x="-2278" y="-1351">Sa_CONNECT_indication[SAI_id]!</label>
<nail x="-2303" y="-1368"/>
<nail x="-1946" y="-1368"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id10"/>
<label kind="guard" x="-2142" y="-1283">!isQueueEmpty(SAI_id)</label>
<label kind="assignment" x="-2218" y="-1266">sig:=dequeueSignalQueue(SAI_id)</label>
</transition>
<transition>
<source ref="id9"/>
<target ref="id11"/>
<label kind="guard" x="-1462" y="-1368">!isQueueFull(receiver) && (
isConnected[receiver] ||
isTTSInitializing ||
sig.sig_id==SIG_Sa_CONNECT_indication ||
sig.sig_id==SIG_Sa_CONNECT_confirm)</label>
</transition>
<transition>
<source ref="id7"/>
<target ref="id8"/>
<label kind="synchronisation" x="-1912" y="-1283">tau_CommSystem_fault?</label>
<nail x="-1657" y="-1283"/>
</transition>
<transition>
<source ref="id11"/>
<target ref="id8"/>
<label kind="assignment" x="-1606" y="-1394">sig:=empty_sig</label>
<label kind="probability" x="-1606" y="-1411">euroradioFailure</label>
</transition>
<transition>
<source ref="id11"/>
<target ref="id7"/>
<label kind="assignment" x="-1461" y="-1479">enqueueSignalQueue(receiver),
sig:=empty_sig</label>
<label kind="probability" x="-1462" y="-1445">noEuroradioFailure</label>
<nail x="-1470" y="-1496"/>
<nail x="-1946" y="-1496"/>
</transition>
<transition>
<source ref="id8"/>
<target ref="id7"/>
<label kind="synchronisation" x="-1921" y="-1411">Sa_DISCONNECT_indication[SAI_id]!</label>
<nail x="-1946" y="-1411"/>
</transition>
<transition>
<source ref="id9"/>
<target ref="id7"/>
<label kind="guard" x="-1419" y="-1215">!(!isQueueFull(receiver) && (
isConnected[receiver] ||
isTTSInitializing ||
sig.sig_id==SIG_Sa_CONNECT_indication ||
sig.sig_id==SIG_Sa_CONNECT_confirm))</label>
<label kind="assignment" x="-1419" y="-1130">sig:=empty_sig</label>
<nail x="-1071" y="-1215"/>
<nail x="-1071" y="-1564"/>
<nail x="-1946" y="-1564"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id9"/>
<label kind="synchronisation" x="-1912" y="-961">Sa_DATA_request[SAI_id]?</label>
<label kind="assignment" x="-1912" y="-943">sig:=sig_out,
sig_out:=empty_sig,
sig.sig_id:=SIG_Sa_DATA_indication</label>
<nail x="-1946" y="-961"/>
<nail x="-1470" y="-960"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id9"/>
<label kind="synchronisation" x="-1912" y="-1046">Sa_DISCONNECT_request[SAI_id]?</label>
<label kind="assignment" x="-1912" y="-1029">sig:=sig_out,
sig_out:=empty_sig,
sig.sig_id:=SIG_Sa_DISCONNECT_indication</label>
<nail x="-1946" y="-1046"/>
<nail x="-1470" y="-1046"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id9"/>
<label kind="synchronisation" x="-1912" y="-1130">Sa_CONNECT_response[SAI_id]?</label>
<label kind="assignment" x="-1912" y="-1113">sig:=sig_out,
sig_out:=empty_sig,
sig.sig_id:=SIG_Sa_CONNECT_confirm</label>
<nail x="-1946" y="-1130"/>
<nail x="-1470" y="-1130"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id9"/>
<label kind="synchronisation" x="-1912" y="-1215">Sa_CONNECT_request[SAI_id]?</label>
<label kind="assignment" x="-1912" y="-1198">sig:=sig_out,
sig_out:=empty_sig,
sig.sig_id:=SIG_Sa_CONNECT_indication</label>
<nail x="-1946" y="-1215"/>
</transition>
</template>
<template>
<name>SAI_Conn_Ini</name>
<parameter>const id_t id</parameter>
<declaration>
sig_t sig:=empty_sig;</declaration>
<location id="id12" x="-25" y="-17">
<name x="-8" y="-17">WaitTTSAnswer</name>
<label kind="invariant" x="-8" y="-34">sig_out==empty_sig</label>
</location>
<location id="id13" x="-986" y="-17">
<name x="-1105" y="-25">Disconnected</name>
</location>
<location id="id14" x="-603" y="-17">
<name x="-773" y="-42">SendConnRequestSig</name>
<committed/>
</location>
<location id="id15" x="-289" y="-17">
<name x="-442" y="-42">WaitConnConfirmSig</name>
<label kind="invariant" x="-450" y="-59">sig_out==empty_sig</label>
</location>
<location id="id16" x="-603" y="110">
<name x="-671" y="127">DisconnectIndication</name>
<committed/>
</location>
<location id="id17" x="-25" y="-187">
<name x="-8" y="-195">Connected</name>
<label kind="invariant" x="-8" y="-212">sig_out==empty_sig</label>
</location>
<init ref="id13"/>
<transition>
<source ref="id17"/>
<target ref="id13"/>
<label kind="synchronisation" x="-305" y="-246">SAI_DISCONNECT_request[id]?</label>
<nail x="-25" y="-246"/>
<nail x="-986" y="-246"/>
</transition>
<transition>
<source ref="id17"/>
<target ref="id13"/>
<label kind="synchronisation" x="-305" y="-187">SAI_DISCONNECT_indication[id]?</label>
<nail x="-986" y="-187"/>
</transition>
<transition>
<source ref="id12"/>
<target ref="id13"/>
<label kind="synchronisation" x="-17" y="68">SAI_DISCONNECT_indication[id]?</label>
<label kind="assignment" x="-17" y="85">isTTSInitializing:=false</label>
<nail x="-25" y="195"/>
<nail x="-986" y="195"/>
</transition>
<transition>
<source ref="id12"/>
<target ref="id17"/>
<label kind="synchronisation" x="-17" y="-119">SAI_CONNECT_confirm[id]?</label>
<label kind="assignment" x="-17" y="-102">isTTSInitializing:=false</label>
</transition>
<transition>
<source ref="id15"/>
<target ref="id14"/>
<label kind="synchronisation" x="-484" y="-136">SAI_CONNECT_request[id]?</label>
<label kind="assignment" x="-586" y="-119">prepareSig(sig,SIG_Sa_CONNECT_request)</label>
<nail x="-289" y="-102"/>
<nail x="-603" y="-102"/>
</transition>
<transition>
<source ref="id15"/>
<target ref="id16"/>
<label kind="synchronisation" x="-510" y="93">Sa_DISCONNECT_indication[id]?</label>
<nail x="-289" y="110"/>
</transition>
<transition>
<source ref="id14"/>
<target ref="id15"/>
<label kind="synchronisation" x="-578" y="-17">Sa_CONNECT_request[id]!</label>
<label kind="assignment" x="-578" y="0">sig_out:=sig,
sig:=empty_sig</label>
</transition>
<transition>
<source ref="id13"/>
<target ref="id14"/>
<label kind="synchronisation" x="-952" y="-17">SAI_CONNECT_request[id]?</label>
<label kind="assignment" x="-952" y="0">prepareSig(sig,SIG_Sa_CONNECT_request)</label>
</transition>
<transition>
<source ref="id15"/>
<target ref="id12"/>
<label kind="synchronisation" x="-255" y="-17">Sa_CONNECT_confirm[id]?</label>
<label kind="assignment" x="-255" y="0">isTTSInitializing:=true</label>
</transition>
<transition>
<source ref="id16"/>
<target ref="id13"/>
<label kind="synchronisation" x="-858" y="93">SAI_DISCONNECT_indication[id]!</label>
<nail x="-986" y="110"/>
</transition>
</template>
<template>
<name>SAI_Conn_Res</name>
<parameter>const id_t id</parameter>
<declaration>
sig_t sig:=empty_sig;</declaration>
<location id="id18" x="-1598" y="85">
<name x="-1573" y="85">WaitTTSAnswer</name>
<label kind="invariant" x="-1573" y="68">sig_out==empty_sig</label>
</location>
<location id="id19" x="-2159" y="85">
<name x="-2269" y="51">Disconnected</name>
</location>
<location id="id20" x="-1895" y="85">
<name x="-1972" y="51">SendConnResponseSig</name>
<committed/>
</location>
<location id="id21" x="-1598" y="-76">
<name x="-1581" y="-85">Connected</name>
<label kind="invariant" x="-1581" y="-102">sig_out==empty_sig</label>
</location>
<init ref="id19"/>
<transition>
<source ref="id19"/>
<target ref="id19"/>
<label kind="synchronisation" x="-2346" y="85">Sa_DATA_indication[id]?</label>
<label kind="assignment" x="-2346" y="102">sig_out:=empty_sig</label>
<nail x="-2193" y="85"/>
<nail x="-2354" y="85"/>
<nail x="-2354" y="221"/>
<nail x="-2159" y="221"/>
</transition>
<transition>
<source ref="id21"/>
<target ref="id19"/>
<label kind="synchronisation" x="-1861" y="-153">SAI_DISCONNECT_request[id]?</label>
<nail x="-1598" y="-153"/>
<nail x="-2159" y="-153"/>
</transition>
<transition>
<source ref="id21"/>
<target ref="id19"/>
<label kind="synchronisation" x="-1861" y="-76">SAI_DISCONNECT_indication[id]?</label>
<nail x="-2159" y="-76"/>
</transition>
<transition>
<source ref="id18"/>
<target ref="id21"/>
<label kind="synchronisation" x="-1589" y="-17">SAI_CONNECT_response[id]?</label>
</transition>
<transition>
<source ref="id18"/>
<target ref="id19"/>
<label kind="synchronisation" x="-1589" y="144">SAI_DISCONNECT_indication[id]?</label>
<nail x="-1598" y="221"/>
<nail x="-2159" y="221"/>
</transition>
<transition>
<source ref="id20"/>
<target ref="id18"/>
<label kind="synchronisation" x="-1861" y="85">Sa_CONNECT_response[id]!</label>
<label kind="assignment" x="-1861" y="102">sig_out:=sig,
sig:=empty_sig</label>
</transition>
<transition>
<source ref="id19"/>
<target ref="id20"/>
<label kind="synchronisation" x="-2133" y="85">Sa_CONNECT_indication[id]?</label>
</transition>
</template>
<template>
<name>SAI_TTS_Init_Ini</name>
<parameter>const id_t id</parameter>
<declaration>
clock t; //timer for TTS answer wait
sig_t sig:=empty_sig;
int last_mtf:=0;
int TTS_check:=0;
</declaration>
<location id="id22" x="-1207" y="51">
<name x="-1241" y="68">StartTTSInit</name>
<committed/>
</location>
<location id="id23" x="-816" y="51">
<name x="-799" y="26">WaitAnswer</name>
<label kind="invariant" x="-799" y="-8">t <=T_start_max[id] &&
sig_out==empty_sig</label>
</location>
<location id="id24" x="-816" y="-246">
<name x="-807" y="-238">CheckMsg</name>
<committed/>
</location>
<location id="id25" x="-1130" y="-586">
<name x="-1156" y="-620">TTSCheck</name>
<committed/>
</location>
<location id="id26" x="-1632" y="51">
<name x="-1751" y="42">Disconnected</name>
</location>
<location id="id27" x="-535" y="102">
<name x="-518" y="93">ConnectionFailure</name>
<committed/>
</location>
<location id="id28" x="-1130" y="-59">
<name x="-1232" y="-42">DisconnectIndication</name>
<committed/>
</location>
<location id="id29" x="-1377" y="-586">
<name x="-1368" y="-612">Connected</name>
<label kind="invariant" x="-1368" y="-629">sig_out==empty_sig</label>
</location>
<init ref="id26"/>
<transition>
<source ref="id27"/>
<target ref="id26"/>
<label kind="synchronisation" x="-527" y="136">SAI_DISCONNECT_indication[id]!</label>
<label kind="assignment" x="-527" y="153">resetParams(id),
last_mtf:=0</label>
<nail x="-535" y="212"/>
<nail x="-1632" y="212"/>
</transition>
<transition>
<source ref="id29"/>
<target ref="id26"/>
<label kind="synchronisation" x="-1615" y="-637">SAI_DISCONNECT_request[id]?</label>
<nail x="-1377" y="-637"/>
<nail x="-1632" y="-637"/>
</transition>
<transition>
<source ref="id29"/>
<target ref="id26"/>
<label kind="synchronisation" x="-1623" y="-586">SAI_DISCONNECT_indication[id]?</label>
<nail x="-1632" y="-586"/>
</transition>
<transition>
<source ref="id23"/>
<target ref="id27"/>
<label kind="synchronisation" x="-782" y="85">SAI_CONNECT_request[id]?</label>
<nail x="-816" y="102"/>
</transition>
<transition>
<source ref="id24"/>
<target ref="id26"/>
<label kind="guard" x="-1071" y="-246">!(last_mtf==0 &&
sig.msg.mtf==O_Answ1) &&
!(last_mtf==O_Answ1 &&
sig.msg.mtf==O_Est &&
sig.msg.sn==last_sn[id]+1)</label>
<label kind="synchronisation" x="-1071" y="-161">SAI_DISCONNECT_indication[id]!</label>
<label kind="assignment" x="-1071" y="-144">sig:=empty_sig,
resetParams(id),
last_mtf:=0</label>
<nail x="-1632" y="-246"/>
</transition>
<transition>
<source ref="id25"/>
<target ref="id28"/>
<label kind="synchronisation" x="-1122" y="-442">Sa_DISCONNECT_indication[id]?</label>
<label kind="assignment" x="-1122" y="-425">TTS_check:=0,
resetParams(id)</label>
</transition>
<transition>
<source ref="id25"/>
<target ref="id26"/>
<label kind="guard" x="-1283" y="-518">TTS_check==0</label>
<label kind="synchronisation" x="-1394" y="-501">SAI_DISCONNECT_indication[id]!</label>
<label kind="assignment" x="-1283" y="-484">resetParams(id)</label>
<nail x="-1130" y="-518"/>
<nail x="-1632" y="-518"/>
</transition>
<transition>
<source ref="id25"/>
<target ref="id29"/>
<label kind="guard" x="-1283" y="-586">TTS_check==1</label>
<label kind="synchronisation" x="-1351" y="-569">SAI_CONNECT_confirm[id]!</label>
<label kind="assignment" x="-1275" y="-552">TTS_check:=0</label>
</transition>
<transition>
<source ref="id23"/>
<target ref="id28"/>
<label kind="synchronisation" x="-1071" y="-59">Sa_DISCONNECT_indication[id]?</label>
<label kind="assignment" x="-1071" y="-42">resetParams(id),
last_mtf:=0</label>
<nail x="-816" y="-59"/>
</transition>
<transition>
<source ref="id23"/>
<target ref="id26"/>
<label kind="guard" x="-807" y="127">t >=T_start_max[id]</label>
<label kind="synchronisation" x="-807" y="144">SAI_DISCONNECT_indication[id]!</label>
<label kind="assignment" x="-807" y="161">resetParams(id),
last_mtf:=0</label>
<nail x="-816" y="212"/>
<nail x="-1632" y="212"/>
</transition>
<transition>
<source ref="id24"/>
<target ref="id25"/>
<label kind="guard" x="-807" y="-586">last_mtf==O_Answ1 &&
sig.msg.mtf==O_Est &&
sig.msg.sn==last_sn[id]+1</label>
<label kind="synchronisation" x="-808" y="-535">Sa_DATA_request[id]!</label>
<label kind="assignment" x="-808" y="-518">last_sn[id]:=sig.msg.sn,
TTS_check:=(abs(T_offset_max[id]+sig.msg.user_data.min_offset)==0 &&
abs(T_offset_min[id]+sig.msg.user_data.max_offset)<T_off_max),
sn[id]:=(sn[id]<SN_max)?++sn[id]:0,
prepareTTSSig(sig,
SIG_Sa_DATA_request,
O_End,
sn[id],
fint(SAI_clock[id]),
last_received_ts[id],
last_msg_ts[id]),
sig.msg.user_data.check_field:=TTS_check,
sig_out:=sig,
sig:=empty_sig,
last_mtf:=0</label>
<nail x="-816" y="-586"/>
</transition>
<transition>
<source ref="id24"/>
<target ref="id23"/>
<label kind="guard" x="-544" y="-238">last_mtf==0 &&
sig.msg.mtf==O_Answ1</label>
<label kind="synchronisation" x="-544" y="-204">Sa_DATA_request[id]!</label>
<label kind="assignment" x="-544" y="-187">last_sn[id]:=sig.msg.sn,
last_mtf:=sig.msg.mtf,
computeMinMaxOffsets(id,sig),
sn[id]:=(sn[id]<SN_max)?++sn[id]:0,
prepareTTSSig(sig,
SIG_Sa_DATA_request,
O_Answ2,
sn[id],
fint(SAI_clock[id]),
last_received_ts[id],
last_msg_ts[id]),
sig_out:=sig,
sig:=empty_sig,
t:=0</label>
<nail x="-552" y="-246"/>
<nail x="-552" y="51"/>
</transition>
<transition>
<source ref="id23"/>
<target ref="id24"/>
<label kind="guard" x="-808" y="-178">t <=T_start_max[id]</label>
<label kind="synchronisation" x="-808" y="-161">Sa_DATA_indication[id]?</label>
<label kind="assignment" x="-808" y="-144">sig:=sig_out,
sig_out:=empty_sig,
last_received_ts[id]:=sig.msg.s_ts,
last_msg_ts[id]:=fint(SAI_clock[id])</label>
</transition>
<transition>
<source ref="id22"/>
<target ref="id23"/>
<label kind="synchronisation" x="-1122" y="51">Sa_DATA_request[id]!</label>
<label kind="assignment" x="-1122" y="68">sig_out:=sig,
sig:=empty_sig,
t:=0</label>
</transition>
<transition>
<source ref="id26"/>
<target ref="id22"/>
<label kind="synchronisation" x="-1589" y="51">Sa_CONNECT_confirm[id]?</label>
<label kind="assignment" x="-1589" y="68">sn[id]:=(sn[id]<SN_max)?++sn[id]:0,
prepareTTSSig(sig,
SIG_Sa_DATA_request,
O_Start,
sn[id],
fint(SAI_clock[id]),
0,
0)</label>
</transition>
<transition>
<source ref="id28"/>
<target ref="id26"/>
<label kind="synchronisation" x="-1496" y="-59">SAI_DISCONNECT_indication[id]!</label>
<nail x="-1632" y="-59"/>
</transition>
</template>
<template>
<name>SAI_TTS_Init_Res</name>
<parameter>const id_t id</parameter>
<declaration>
clock t; //timer for TTS answer wait
sig_t sig:=empty_sig;
int last_mtf:=0;
</declaration>
<location id="id30" x="-1496" y="595">
<name x="-1666" y="603">WaitTTSOffsetStartMsg</name>
<label kind="invariant" x="-1657" y="620">sig_out==empty_sig</label>
</location>
<location id="id31" x="-1496" y="433">
<name x="-1564" y="399">CheckOffsetStartMsg</name>
<committed/>
</location>
<location id="id32" x="-918" y="433">
<name x="-901" y="408">WaitAnswer</name>
<label kind="invariant" x="-901" y="374">t <=T_start_max[id] &&
sig_out==empty_sig</label>
</location>
<location id="id33" x="-918" y="93">
<name x="-910" y="68">CheckOffsetMsg</name>
<committed/>
</location>
<location id="id34" x="-1819" y="595">
<name x="-1938" y="586">Disconnected</name>
</location>
<location id="id35" x="-1496" y="722">
<name x="-1564" y="739">DisconnectIndication</name>
<committed/>
</location>
<location id="id36" x="-1241" y="-68">
<name x="-1317" y="-102">WaitConnResponseSig</name>
</location>
<location id="id37" x="-1538" y="-68">
<name x="-1572" y="-52">Connected</name>
<label kind="invariant" x="-1606" y="-34">sig_out==empty_sig</label>
</location>
<init ref="id34"/>
<transition>
<source ref="id30"/>
<target ref="id35"/>
<label kind="synchronisation" x="-1462" y="595">Sa_CONNECT_indication[id]?</label>
<nail x="-1241" y="595"/>
<nail x="-1241" y="722"/>
</transition>
<transition>
<source ref="id37"/>
<target ref="id34"/>
<label kind="synchronisation" x="-1793" y="-110">SAI_DISCONNECT_request[id]?</label>
<nail x="-1538" y="-110"/>
<nail x="-1819" y="-110"/>
</transition>
<transition>
<source ref="id37"/>