orchestrator.pr 3.18 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PROCESS orchestrator;
/* CIF TEXT (-354, 12), (289, 173) */
-- GNC Orchestrator for the VEGA simulator

DCL gnc_output T_GNC_LV_SIM_INPUTS;

DCL gnc_input T_GNC_LV_SIM_CONTEXT;

DCL intr T_INTR;

DCL plot_data T_Plot;

DCL major_cycle, sub_cycle T_UInt32;
/* CIF ENDTEXT */
/* CIF START (-209, 208), (100, 50) */
START;
17
/* CIF PROCEDURECALL (-253, 273), (189, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
18
19
CALL writeln
('[Orchestrator] Startup');
20
/* CIF TASK (-230, 338), (143, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
21
TASK intr := obt_pulse4;
22
23
24
/* CIF OUTPUT (-224, 403), (130, 35) */
OUTPUT telemetry;
/* CIF TASK (-231, 453), (144, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
25
26
TASK major_cycle := 1,
sub_cycle := 0;
27
/* CIF NEXTSTATE (-217, 518), (116, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
28
29
NEXTSTATE Wait_for_GUI;

30
31
32
33
34
35
36
37
38
39
40
41
/* CIF STATE (-18, 53), (116, 50) */
STATE Wait_for_GUI;
/* CIF INPUT (-28, 123), (136, 50) */
INPUT start_simulation
(gnc_input);
/* CIF PROCEDURECALL (-55, 188), (190, 50) */
CALL writeln
('[Orchestrator] Running');
/* CIF NEXTSTATE (-10, 253), (100, 50) */
NEXTSTATE Running;
ENDSTATE;

Maxime Perrotin's avatar
Maxime Perrotin committed
42
43
44

/* CIF STATE (502, 32), (100, 50) */
STATE Running;
45
46
47
48
49
50
51
52
53
/* CIF INPUT (757, 102), (136, 50) */
INPUT start_simulation
(gnc_input)
/* CIF COMMENT (913, 102), (169, 50) */
COMMENT 'Input from gui
stops the simulation';
/* CIF NEXTSTATE (767, 167), (116, 50) */
NEXTSTATE Wait_for_GUI;
/* CIF INPUT (311, 102), (105, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
54
INPUT pulse
55
/* CIF COMMENT (436, 102), (114, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
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
COMMENT 'Periodic call';
/* CIF PROCEDURECALL (175, 167), (377, 50) */
CALL S_SET_GNC_LV_SIM_CONTEXT_FOR_NEXT_MAJOR_CYCLE
(gnc_input)
/* CIF COMMENT (569, 158), (173, 68) */
COMMENT 'Set data computed
by the Simulink model
(Simulator) in the GNC
input vector';
/* CIF PROCEDURECALL (314, 232), (100, 50) */
CALL Scheduler
(intr)
/* CIF COMMENT (434, 232), (170, 50) */
COMMENT 'Call the GNC function';
/* CIF PROCEDURECALL (181, 297), (366, 50) */
CALL S_GET_GNC_LV_SIM_INPUTS_FOR_NEXT_MAJOR_CYCLE
(gnc_output)
/* CIF COMMENT (567, 297), (175, 50) */
COMMENT 'Read output data
from the GNC function';
/* CIF PROCEDURECALL (273, 362), (181, 50) */
CALL VESAT_Simulation_Step
(gnc_output, gnc_input)
/* CIF COMMENT (474, 362), (182, 50) */
COMMENT 'Call the Simulink model';
/* CIF DECISION (270, 427), (187, 115) */
DECISION major_cycle mod 50 = 0
and
sub_cycle = 0
/* CIF COMMENT (477, 459), (250, 50) */
COMMENT 'Plot only every 50 major cycles
(otherwise performance is too low)';
/* CIF ANSWER (254, 562), (100, 35) */
(true):
/* CIF TASK (169, 612), (270, 68) */
TASK plot_data!major_cycle := major_cycle,
plot_data!subcycle := sub_cycle,
plot_data!gnc_inputs := gnc_input,
plot_data!gnc_outputs := gnc_output;
95
/* CIF OUTPUT (224, 695), (159, 50) */
Maxime Perrotin's avatar
Maxime Perrotin committed
96
OUTPUT plot(plot_data);
97
98
/* CIF ANSWER (449, 562), (100, 35) */
(false):
Maxime Perrotin's avatar
Maxime Perrotin committed
99
100
101
102
103
104
105
106
107
108
109
110
ENDDECISION;
/* CIF DECISION (305, 760), (118, 70) */
DECISION sub_cycle = 7
/* CIF COMMENT (443, 770), (199, 50) */
COMMENT 'Compute next major cycle';
/* CIF ANSWER (197, 850), (100, 35) */
(true):
/* CIF TASK (137, 900), (220, 53) */
TASK sub_cycle := 0,
major_cycle := major_cycle + 1;
/* CIF PROCEDURECALL (127, 968), (240, 50) */
CALL S_JUMP_TO_NEXT_MAJOR_CYCLE;
111
112
113
114
/* CIF ANSWER (424, 850), (100, 35) */
(false):
/* CIF TASK (377, 900), (194, 50) */
TASK sub_cycle := sub_cycle + 1;
Maxime Perrotin's avatar
Maxime Perrotin committed
115
116
117
118
119
120
ENDDECISION;
/* CIF NEXTSTATE (314, 1033), (100, 50) */
NEXTSTATE Running;
ENDSTATE;

ENDPROCESS orchestrator;