acceptance_cpdu1.adb 15.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- This file was generated automatically: DO NOT MODIFY IT !

with System.IO;
use System.IO;

with Ada.Unchecked_Conversion;
with Ada.Numerics.Generic_Elementary_Functions;

with PUS_Implicit_Knowledge;
use PUS_Implicit_Knowledge;
with Distribute_On_Off_Device_Commands_Generic;
use Distribute_On_Off_Device_Commands_Generic;
with Distribute_CPDU_Commands_Generic;
use Distribute_CPDU_Commands_Generic;
with Request_Verification_Reports;
use Request_Verification_Reports;
17
18
with HK_Service_Structures;
use HK_Service_Structures;
19
20
21
22
with Event_Reporting_Structures;
use Event_Reporting_Structures;
with Parameter_Monitoring_Structures;
use Parameter_Monitoring_Structures;
23
24
with Taps;
use Taps;
25
26
with Taps_Test_Structures;
use Taps_Test_Structures;
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
with TASTE_Dataview;
use TASTE_Dataview;
with TASTE_BasicTypes;
use TASTE_BasicTypes;
with adaasn1rtl;
use adaasn1rtl;

with Interfaces;
use Interfaces;

package body acceptance_cpdu1 is
    type States is (wait);
    type ctxt_Ty is
        record
        state : States;
        initDone : Boolean := False;
        readydest : aliased asn1SccMyBool;
        tm11 : aliased asn1SccTM_1_1;
        serviceavailable : aliased asn1SccMyBool;
        crctest : aliased asn1SccMyBool;
        tm12 : aliased asn1SccTM_1_2;
        reqid_ack : aliased asn1SccRequest_ID_ACK;
        tm : aliased asn1SccTM;
        request_id : aliased asn1SccRequest_ID_inst;
        test : aliased asn1SccTC_2_1;
        testparams : aliased asn1SccTest_Taps_Parameters;
        tc : aliased asn1SccTelecommand;
    end record;
    ctxt: aliased ctxt_Ty;
    CS_Only  : constant Integer := 3;
    procedure runTransition(Id: Integer);
    procedure tc_cpdu1(TC: access asn1SccTelecommand) is
        begin
            case ctxt.state is
                when wait =>
                    ctxt.tc := TC.all;
                    runTransition(1);
                when others =>
                    runTransition(CS_Only);
            end case;
        end tc_cpdu1;
        

    procedure test_cpdu1(testStr: access asn1SccTest_Taps_Parameters) is
        begin
            case ctxt.state is
                when wait =>
                    ctxt.testparams := testStr.all;
                    runTransition(2);
                when others =>
                    runTransition(CS_Only);
            end case;
        end test_cpdu1;
        

    procedure runTransition(Id: Integer) is
        trId : Integer := Id;
        tmp48 : aliased asn1SccTC_2_4;
        begin
            while (trId /= -1) loop
                case trId is
                    when 0 =>
                        -- crcTest:= true (19,13)
                        ctxt.crcTest := true;
                        -- serviceAvailable := true (20,0)
                        ctxt.serviceAvailable := true;
                        -- readyDest := true (21,0)
                        ctxt.readyDest := true;
                        -- NEXT_STATE Wait (23,18) at 1003, 161
                        trId := -1;
                        ctxt.state := Wait;
                        goto next_transition;
                    when 1 =>
                        -- writeln('st01_Acceptance has received TC') (29,17)
                        Put("st01_Acceptance has received TC");
                        New_Line;
                        -- DECISION crcTest (-1,-1)
                        -- COMMENT check1: TC integrety (CRC) (33,12)
                        -- ANSWER true (35,17)
                        if (ctxt.crcTest) = true then
                            -- writeln('st01_acceptance: check 1: crc ok') (37,25)
                            Put("st01_acceptance: check 1: crc ok");
                            New_Line;
                            -- DECISION serviceAvailable (-1,-1)
                            -- COMMENT check 2: service availability (41,20)
                            -- ANSWER true (43,25)
                            if (ctxt.serviceAvailable) = true then
                                -- writeln('st01_acceptance: check 2: the service is available') (45,33)
                                Put("st01_acceptance: check 2: the service is available");
                                New_Line;
                                -- DECISION present(tc!application_data) (-1,-1)
                                -- ANSWER tc2_4 (49,33)
                                if (asn1SccTCs_Kind(ctxt.tc.application_data)) = tc2_4_PRESENT then
                                    -- writeln('st01_acceptance: check 3: request type Ok') (51,41)
                                    Put("st01_acceptance: check 3: request type Ok");
                                    New_Line;
                                    -- DECISION tc!secondary_header!ack_successful_acceptance (-1,-1)
                                    -- COMMENT check if the user wants to receive 
                                    -- successful acceptance reports (55,36)
                                    -- ANSWER true (58,41)
                                    if (ctxt.tc.secondary_header.ack_successful_acceptance) = true then
                                        -- tm11!source_apid := TC!dest_apid (60,49)
                                        ctxt.tm11.source_apid := ctxt.TC.dest_apid;
                                        -- tm11!sequence_count := TC!sequence_count (61,0)
                                        ctxt.tm11.sequence_count := Asn1Int(ctxt.TC.sequence_count);
                                        -- tm!source_data := tm1_1: tm11 (63,49)
                                        ctxt.tm.source_data := asn1SccTMs_tm1_1_set(ctxt.tm11);
                                        -- tm(tm) (65,51)
                                        -- COMMENT send the tm1_1 successful 
                                        -- acceptance verification report (67,44)
                                        RItm(ctxt.tm'Access);
                                        -- ANSWER false (70,41)
                                    elsif (ctxt.tc.secondary_header.ack_successful_acceptance) = false then
                                        null;
                                    end if;
                                    -- tc24(tc!application_data!tc2_4) (73,43)
                                    tmp48 := asn1SccTCs_tc2_4_get(ctxt.tc.application_data);
                                    RItc24(tmp48'Access);
                                    -- COMMENT after the request acceptance 
                                    -- send its ID and ack to the Execution service (81,36)
                                    -- reqID_ack!requestID!source_apid := tc!dest_apid (75,41)
                                    ctxt.reqID_ack.requestid.source_apid := ctxt.tc.dest_apid;
                                    -- reqID_ack!requestID!sequence_count := tc!sequence_count (76,0)
                                    ctxt.reqID_ack.requestid.sequence_count := Asn1Int(ctxt.tc.sequence_count);
                                    -- reqID_ack!ack_successful_start := tc!secondary_header!ack_successful_start (77,0)
                                    ctxt.reqID_ack.ack_successful_start := ctxt.tc.secondary_header.ack_successful_start;
                                    -- reqID_ack!ack_successful_progress := tc!secondary_header!ack_successful_progress (78,0)
                                    ctxt.reqID_ack.ack_successful_progress := ctxt.tc.secondary_header.ack_successful_progress;
                                    -- reqID_ack!ack_successful_completion := tc!secondary_header!ack_successful_completion (79,0)
                                    ctxt.reqID_ack.ack_successful_completion := ctxt.tc.secondary_header.ack_successful_completion;
                                    -- reqID(reqID_ack) (84,43)
                                    RIreqID(ctxt.reqID_ack'Access);
                                    -- NEXT_STATE Wait (86,46) at 667, 1200
                                    trId := -1;
                                    ctxt.state := Wait;
                                    goto next_transition;
                                    -- ANSWER else (None,None)
                                else
                                    -- COMMENT set the request ID
                                    -- fields (93,36)
                                    -- request_id!source_apid := TC!dest_apid (90,41)
                                    ctxt.request_id.source_apid := ctxt.TC.dest_apid;
                                    -- request_id!sequence_count := TC!sequence_count (91,0)
                                    ctxt.request_id.sequence_count := Asn1Int(ctxt.TC.sequence_count);
                                    -- COMMENT set the TM failed request
                                    -- integrity code and source ID (99,36)
                                    -- tm12!fail_Notice!code := wrongRequestType (96,41)
                                    ctxt.tm12.fail_notice.code := asn1SccwrongRequestType;
                                    -- tm12!req_ID := request_id (97,0)
                                    ctxt.tm12.req_id := ctxt.request_id;
                                    -- tm!source_data:= tm1_2: tm12 (102,41)
                                    ctxt.tm.source_data := asn1SccTMs_tm1_2_set(ctxt.tm12);
                                    -- tm(tm) (104,43)
                                    -- COMMENT send the tm1_2 failed 
                                    -- acceptance verification  report (106,36)
                                    RItm(ctxt.tm'Access);
                                    -- writeln('st01_acceptance: check 3: wrong request type') (109,41)
                                    Put("st01_acceptance: check 3: wrong request type");
                                    New_Line;
                                    -- NEXT_STATE Wait (111,46) at 1519, 900
                                    trId := -1;
                                    ctxt.state := Wait;
                                    goto next_transition;
                                end if;
                                -- ANSWER false (114,25)
                            elsif (ctxt.serviceAvailable) = false then
                                -- COMMENT set the request ID
                                -- fields (119,28)
                                -- request_id!source_apid := TC!dest_apid (116,33)
                                ctxt.request_id.source_apid := ctxt.TC.dest_apid;
                                -- request_id!sequence_count := TC!sequence_count (117,0)
                                ctxt.request_id.sequence_count := Asn1Int(ctxt.TC.sequence_count);
                                -- COMMENT set the TM failed request
                                -- integrity code and source ID (125,28)
                                -- tm12!fail_Notice!code := serviceNotAvailable (122,33)
                                ctxt.tm12.fail_notice.code := asn1SccserviceNotAvailable;
                                -- tm12!req_ID := request_id (123,0)
                                ctxt.tm12.req_id := ctxt.request_id;
                                -- tm!source_data := tm1_2: tm12 (128,33)
                                ctxt.tm.source_data := asn1SccTMs_tm1_2_set(ctxt.tm12);
                                -- tm(tm) (130,35)
                                -- COMMENT send the tm1_2 failed 
                                -- acceptance verification  report (132,28)
                                RItm(ctxt.tm'Access);
                                -- writeln('st01_acceptance: check 2: the service is busy...') (135,33)
                                Put("st01_acceptance: check 2: the service is busy...");
                                New_Line;
                                -- NEXT_STATE Wait (137,38) at 2089, 732
                                trId := -1;
                                ctxt.state := Wait;
                                goto next_transition;
                            end if;
                            -- ANSWER false (140,17)
                        elsif (ctxt.crcTest) = false then
                            -- COMMENT set the request ID
                            -- fields (145,20)
                            -- request_id!source_apid := TC!dest_apid (142,25)
                            ctxt.request_id.source_apid := ctxt.TC.dest_apid;
                            -- request_id!sequence_count := TC!sequence_count (143,0)
                            ctxt.request_id.sequence_count := Asn1Int(ctxt.TC.sequence_count);
                            -- COMMENT set the TM failed request
                            -- integrity code and source ID (151,20)
                            -- tm12!fail_Notice!code := reqIntegrityFailure (148,25)
                            ctxt.tm12.fail_notice.code := asn1SccreqIntegrityFailure;
                            -- tm12!req_ID := request_id (149,0)
                            ctxt.tm12.req_id := ctxt.request_id;
                            -- tm!source_data := tm1_2: tm12 (154,25)
                            ctxt.tm.source_data := asn1SccTMs_tm1_2_set(ctxt.tm12);
                            -- tm(tm) (156,27)
                            -- COMMENT send the tm1_2 failed 
                            -- acceptance verification  report (158,20)
                            RItm(ctxt.tm'Access);
                            -- writeln('st01_acceptance: check 1: crc failed') (161,25)
                            Put("st01_acceptance: check 1: crc failed");
                            New_Line;
                            -- NEXT_STATE Wait (163,30) at 2628, 566
                            trId := -1;
                            ctxt.state := Wait;
                            goto next_transition;
                        end if;
                    when 2 =>
                        -- crcTest := testParams!testST01Acceptance!crcTest (174,17)
                        ctxt.crcTest := asn1SccTest_Taps_Parameters_testst01acceptance_get(ctxt.testParams).crctest;
                        -- serviceAvailable := 
                        --   testParams!testST01Acceptance!serviceAvailableTest (175,0)
                        ctxt.serviceAvailable := asn1SccTest_Taps_Parameters_testst01acceptance_get(ctxt.testParams).serviceavailabletest;
                        -- writeln('st01_acceptance: set crcTest: ', crcTest) (178,17)
                        Put("st01_acceptance: set crcTest: ");
                        Put(Boolean'Image(ctxt.crcTest));
                        New_Line;
                        -- writeln('st01_acceptance: set serviceAvailable: ', serviceAvailable) (180,17)
                        Put("st01_acceptance: set serviceAvailable: ");
                        Put(Boolean'Image(ctxt.serviceAvailable));
                        New_Line;
                        -- readyDest:=testParams!testST01Acceptance!ready (182,17)
                        ctxt.readyDest := asn1SccTest_Taps_Parameters_testst01acceptance_get(ctxt.testParams).ready;
                        -- writeln('st01_acceptance: set readiness: ', readyDest) (184,17)
                        Put("st01_acceptance: set readiness: ");
                        Put(Boolean'Image(ctxt.readyDest));
                        New_Line;
                        -- ready_cpdu1(readyDest) (186,19)
                        RIready_cpdu1(ctxt.readyDest'Access);
                        -- NEXT_STATE Wait (188,22) at 564, 462
                        trId := -1;
                        ctxt.state := Wait;
                        goto next_transition;
                    when CS_Only =>
                        trId := -1;
                        goto next_transition;
                    when others =>
                        null;
                end case;
                <<next_transition>>
                null;
            end loop;
        end runTransition;
        

    begin
        runTransition(0);
        ctxt.initDone := True;
end acceptance_cpdu1;