File: /home/oboss/Users/gec/sources/PUS_Services/Monitor/monitor_parser.ads
1 --% Compilation Unit: Monitor_Parser
2 --
3 --% Category: Generic Package Declaration
4 --
5 --% Release: $Name: $
6 --
7 --% Version: $Revision: 2.1 $
8 --
9 --% Author: $Author: gec $
10 --
11 --% Revision Log:
12 -- $Log: monitor_parser.ads,v $
13 -- Revision 2.1 2003/11/13 14:57:50 gec
14 -- Merged ECSS Migration branch to main trunk.
15 --
16 -- Revision 2.0.8.1 2003/11/13 14:40:50 gec
17 -- Updated On-board Monitoring Service in accordance with ECSS-E-70-41A
18 --
19 -- Revision 2.0 2003/04/04 08:51:12 gec
20 -- Initial release of source files serving as baseline for OBOSS-III
21 --+ project.
22 --
23 -- Revision 1.1.1.1 2003/04/04 08:13:13 gec
24 -- Imported using TkCVS
25 --
26 --
27 --
28 --% Project: OBOSS
29 --
30 --% Copyright (C) 2003 by Terma A/S
31 -- Proprietary and intellectual rights of Terma A/S, Denmark,
32 -- are involved in the subject-matter of this material and
33 -- all manufacturing, reproduction, use, disclosure, and
34 -- sales rights pertaining to such subject-matter are
35 -- expressly reserved. This material is submitted for a
36 -- specific purpose as agreed, and the recipient by
37 -- accepting this material agrees that this material will
38 -- not be used, copied, or reproduced in whole or in part
39 -- nor its contents revealed in any manner or to any person,
40 -- except to meet the purpose for which it was submitted and
41 -- subject to the terms of the agreement.
42 --
43 --% Target Dependencies:
44 -- None
45 --% Compiler Dependencies:
46 -- None
47
48 --~-----------------------------------------------------------------------------
49
50 with PUS;
51 with PUS_Data_Types;
52 with Onboard_Monitoring_Types;
53 with Verification_Types;
54 with Mission_Parameters;
55 with Parameter_Structure_Descriptions;
56 with Source_Data_Stream;
57 with Parser;
58 with Task_Priority_Control;
59 with Default_OOL_Event_Handler;
60 generic
61
62 --% Generic Parameter Constraints:
63 --> None
64
65 -- Application ID of application process to which service is associated.
66 Application_ID : in Mission_Parameters.APID;
67
68 -- Maximum number of parameters that may be monitored at one time.
69 Max_Params : in Natural;
70
71 -- Maximum number of checks that may be applied by the monitoring service at
72 --+ one time.
73 -- This number covers the entire set of parameters.
74 Max_Checks : in Natural;
75
76 -- Monitoring_Period indicates the period by which parameter values are
77 --+ checked.
78 -- Unit is Mission_Parameters.Diag_Min_Interval.
79 -- Monitoring is implemented based on polling, meaning that the monitoring
80 --+ task once every Monitoring_Period checkes all parameters due for
81 --+ monitoring.
82 -- The actual monitoring time of one parameter are thus subject to a jitter
83 --+ equaling Monitoring_Period
84 Monitoring_Period : in Positive;
85
86 -- Max_No_Of_Checks_In_Monitoring_Period indicates the maximum number of
87 --+ parameters that are to be checked during one Monitoring_Period as
88 --+ defined above.
89 Max_No_Of_Checks_In_Monitoring_Period : in Natural;
90
91 -- Maximum_Reporting_Delay is the maximal time from detection of an
92 --+ out-of-limit event until it is submitted in an OOL report.
93 -- The delay is expressed in units of Mission_Parameters.Diag_Min_Interv
94 Maximum_Reporting_Delay : in Positive;
95
96 -- Maximum number of out-of-limit transitions that can be reported within
97 --+ Maximum_Reporting_Delay * Mission_Parameters.Diag_Min_Interv
98 Max_No_Of_OOL_Transitions : in Natural;
99
100 with function Optional_Deposit
101 (P : PUS.Optional_PUS_Packet)
102 return Boolean;
103
104 with function Is_Legal_Parameter_ID
105 (Par_ID : Parameter_Structure_Descriptions.Parameter_ID)
106 return Boolean;
107
108 with function Receive
109 (Par_ID : Parameter_Structure_Descriptions.Parameter_ID)
110 return Onboard_Monitoring_Types.Parameter_Value'Class;
111 with function Is_Valid
112 (Validity_ID : Onboard_Monitoring_Types.Validity_Parameter_No)
113 return Boolean;
114 with function Is_Selected
115 (Selection_ID
116 : Onboard_Monitoring_Types.
117 Check_Selection_Parameter_Number)
118 return Boolean;
119
120 -- Priority of protected object implementing monitoring list.
121 Monitoring_List_Priority
122 : in Task_Priority_Control.
123 Passive_Task_Priority;
124
125 -- Priority of protected object implementing collection of check
126 --+ definitions.
127 Check_Definitions_Collection_Priority
128 : in Task_Priority_Control.Passive_Task_Priority;
129
130 -- Priority of protected object implementing timeline of monitoring events.
131 Monitor_Timeline_Priority
132 : in Task_Priority_Control.
133 Passive_Task_Priority;
134
135 -- Priority and stack size of cyclic task performing parameter monitoring
136 Monitor_Task_Priority : in Task_Priority_Control.Active_Task_Priority;
137 Monitor_Task_Stack_Size : in Natural;
138
139 -- Priority of protected object implementing list of OOL transitions
140 OOL_Transition_List_Priority
141 : in Task_Priority_Control.
142 Passive_Task_Priority;
143
144 -- Priority and stack size of cyclic task generating out-of-limit reports.
145 OOL_Reporter_Priority : in Task_Priority_Control.Active_Task_Priority;
146 OOL_Reporter_Task_Stack_Size : in Natural;
147
148 package Monitor_Parser is
149
150 --% Package:
151 -- Provides transformation parsing telecommands into an internal command
152 --+ representation and unparsing telemetry from an internal
153 --+ representation to PUS.PUS_Packet
154 --% Active Tasks:
155 --> None
156 --% Passive Tasks:
157 --> None
158
159 -- Indicates that unparsing of internal TM representation failed
160 Unparsing_Failed : exception;
161
162 subtype List_Length is Onboard_Monitoring_Types.List_Length;
163 subtype Parameter_Index is List_Length range 1 .. Max_Params;
164 subtype Check_Index is List_Length range 1 .. Max_Checks;
165
166 -- Types related to internal representation of Telecommands
167
168 -- Implementation of lists of check definitions
169 type Check_Definition_List is array (Check_Index) of
170 Onboard_Monitoring_Types.Check_Definition;
171
172 type Check_Definitions is
173 record
174 Number_Of_Definitions : List_Length;
175 Definitions : Check_Definition_List;
176 end record;
177
178 -- Implementation of lists of parameter IDs
179 type Parameter_Identification_List is array (Parameter_Index) of
180 Onboard_Monitoring_Types.Parameter_ID;
181
182 type Parameter_Identifications is
183 record
184 Number_Of_Identifications : List_Length;
185 Identifications : Parameter_Identification_List;
186 end record;
187
188
189 -- Implementation of list of check defintion addition requests
190
191 type Check_Definition_Addition is
192 record
193 ID : Onboard_Monitoring_Types.Parameter_ID;
194 Validity : Onboard_Monitoring_Types.Validity_Parameter_No;
195 Limit_Defs : Check_Definitions;
196 Expected_Value_Defs : Check_Definitions;
197 end record;
198
199 type Check_Definition_Addition_List is array (Parameter_Index) of
200 Check_Definition_Addition;
201
202 type Check_Definition_Additions is
203 record
204 Number_Of_Additions : List_Length;
205 Additions : Check_Definition_Addition_List;
206 end record;
207
208 -- Implementation of list of check definition modification requests
209 type Modification_Request_Kind is
210 (Add,
211 Replace,
212 Delete);
213
214 type Modification_Specification
215 (Modification_Kind : Modification_Request_Kind :=
216 Modification_Request_Kind'First) is
217 record
218 case Modification_Kind is
219 when Add =>
220 Check_Def_To_Be_Added :
221 Onboard_Monitoring_Types.Check_Definition;
222 when Replace =>
223 Position_Of_Replacement :
224 Natural;
225 Check_Def_To_Be_Modified :
226 Onboard_Monitoring_Types.Check_Definition;
227 when Delete =>
228 Check_Type :
229 Onboard_Monitoring_Types.Check_Definition_Type;
230 Position_Of_Deletion :
231 Natural;
232 end case;
233 end record;
234
235 type Modification_Specification_List is array (Check_Index) of
236 Modification_Specification;
237
238 type Modification_Specifications is
239 record
240 Number_Of_Specifications : List_Length;
241 Specifications : Modification_Specification_List;
242 end record;
243
244 type Check_Definition_Modification is
245 record
246 ID : Onboard_Monitoring_Types.Parameter_ID;
247 Validity : Onboard_Monitoring_Types.Validity_Parameter_No;
248 Limit_Defs : Modification_Specifications;
249 Expected_Value_Defs : Modification_Specifications;
250 end record;
251
252 type Check_Definition_Modification_List is array (Parameter_Index) of
253 Check_Definition_Modification;
254
255 type Check_Definition_Modifications is
256 record
257 Number_Of_Modifications : List_Length;
258 Modifications : Check_Definition_Modification_List;
259 end record;
260
261
262 -- Internal representation of supported subservices
263 type TC_Subservice is
264 (Enable_Monitoring_Of_Parameters,
265 Disable_Monitoring_Of_Parameters,
266 Clear_Monitoring_List,
267 Add_Parameters_To_Monitoring_List,
268 Delete_Parameters_From_Monitoring_List,
269 Modify_Parameter_Checking_Information,
270 Report_Current_Monitoring_List,
271 Report_Current_Parameters_OOL_List);
272
273 -- Internal representation of telecommands related to onboard monitoring
274 --+ service (service type 12)
275
276 -- type Internal_TC_Source_Data(Subservice : TC_Subservice) is
277 -- record
278 -- case Subservice is
279 -- when Enable_Monitoring_Of_Parameters =>
280 -- -- Service type (12,1)
281 -- Enabling_Parameter_IDs : Parameter_Identifications;
282 -- when Disable_Monitoring_Of_Parameters =>
283 -- -- Service type (12,2)
284 -- Disabling_Parameter_IDs : Parameter_Identifications;
285 -- when Clear_Monitoring_List =>
286 -- -- Service type (12,4)
287 -- null;
288 -- when Add_Parameters_To_Monitoring_List =>
289 -- -- Service type (12,5)
290 -- Interval : Onboard_Monitoring_Types.Interval;
291 -- Filter : Onboard_Monitoring_Types.Value_Filter;
292 -- Additions : Check_Definition_Additions;
293 -- when Delete_Parameters_From_Monitoring_List =>
294 -- -- Service type (12,6)
295 -- Deleting_Parameter_IDs : Parameter_Identifications;
296 -- when Modify_Parameter_Checking_Information =>
297 -- -- Service type (12,7)
298 -- Modifications : Check_Definition_Modifications;
299 -- when Report_Current_Monitoring_List =>
300 -- -- Service type (12,8)
301 -- null;
302 -- when Report_Current_Parameters_OOL_List =>
303 -- -- Service type (12,10)
304 -- null;
305 -- end case;
306 -- end record;
307
308 -- Utility functions for generation of telecommand verification packets
309
310 procedure Initialize;
311
312 --% Subprogram:
313 -- Initialises the command interpreter state for a new telecommand
314 --+ execution
315 --% Parameter Constraints:
316 --> None
317 --% Exceptions Raised:
318 --> None
319 procedure Start_New_TC_Interpretation;
320
321 --% Subprogram:
322 -- Submit telecommand verifications for the given stage and status
323 --% Parameter Constraints:
324 --> None
325 --% Exceptions Raised:
326 --> PUS_State.No_Streams_Available - Heap of source data streams has been
327 --+ exhausted
328 --> PUS_State.No_Packets_Available - Heap of PUS packets has been
329 --+ exhausted
330 procedure Verify_Stage
331 (TC : in PUS.PUS_Packet;
332 Stage : in PUS_Data_Types.Ack_Stages;
333 Status : in Verification_Types.Verification_Status);
334 type Internal_TC_Source_Data is tagged null record;
335 --% Subprogram:
336 -- Interpret Cmd generating telecommand verifications corresponding to
337 --+ progress of execution, if applicable.
338 --% Parameter Constraints:
339 --> TC - Cmd must contain an internal representation corresponding to
340 --+ TC.
341 --% Exceptions Raised:
342 --> Invariant_Violated - Indicates an implementation flaw in the program
343 --+ logic. Should never be raised.
344 --> Source_Data_Stream.No_Streams_Available - Heap of source streams has
345 --+ been exhausted
346 --> PUS_State.No_Streams_Available - Heap of source data streams has been
347 --+ exhausted
348 --> PUS_State.No_Packets_Available - Heap of PUS packets has been
349 --+ exhausted
350 function Interpret_TC
351 (TC : PUS.PUS_Packet;
352 Cmd : Internal_TC_Source_Data)
353 return Boolean;
354
355 type Internal_TC_Source_Data_Enable_Monitoring_Of_Parameters is new
356 Internal_TC_Source_Data
357 with record
358 -- Service type (12,1)
359 Enabling_Parameter_IDs : Parameter_Identifications;
360 end record;
361
362 function Interpret_TC
363 (TC : PUS.PUS_Packet;
364 Cmd : Internal_TC_Source_Data_Enable_Monitoring_Of_Parameters)
365 return Boolean;
366
367 type Internal_TC_Source_Data_Disable_Monitoring_Of_Parameters is new
368 Internal_TC_Source_Data
369 with record
370 -- Service type (12,2)
371 Disabling_Parameter_IDs : Parameter_Identifications;
372 end record;
373
374 function Interpret_TC
375 (TC : PUS.PUS_Packet;
376 Cmd
377 : Internal_TC_Source_Data_Disable_Monitoring_Of_Parameters)
378 return Boolean;
379
380 type Internal_TC_Source_Data_Clear_Monitoring_List is new
381 Internal_TC_Source_Data
382 with record
383 -- Service type (12,4)
384 null;
385 end record;
386
387 function Interpret_TC
388 (TC : PUS.PUS_Packet;
389 Cmd : Internal_TC_Source_Data_Clear_Monitoring_List)
390 return Boolean;
391
392 type Internal_TC_Source_Data_Add_Parameters_To_Monitoring_List is new
393 Internal_TC_Source_Data
394 with record
395 -- Service type (12,5)
396 Interval : Onboard_Monitoring_Types.Interval;
397 Repetitions : Onboard_Monitoring_Types.Value_Number_Rep;
398 Additions : Check_Definition_Additions;
399 end record;
400
401 function Interpret_TC
402 (TC : PUS.PUS_Packet;
403 Cmd
404 : Internal_TC_Source_Data_Add_Parameters_To_Monitoring_List)
405 return Boolean;
406
407 type Internal_TC_Source_Data_Delete_Parameters_From_Monitoring_List is new
408 Internal_TC_Source_Data
409 with record
410 -- Service type (12,6)
411 Deleting_Parameter_IDs : Parameter_Identifications;
412 end record;
413
414 function Interpret_TC
415 (TC : PUS.PUS_Packet;
416 Cmd
417 : Internal_TC_Source_Data_Delete_Parameters_From_Monitoring_List)
418 return Boolean;
419
420 type Internal_TC_Source_Data_Modify_Parameter_Checking_Information is new
421 Internal_TC_Source_Data
422 with record
423 -- Service type (12,7)
424 Modifications : Check_Definition_Modifications;
425 end record;
426
427 function Interpret_TC
428 (TC : PUS.PUS_Packet;
429 Cmd
430 : Internal_TC_Source_Data_Modify_Parameter_Checking_Information)
431 return Boolean;
432
433 type Internal_TC_Source_Data_Report_Current_Monitoring_List is new
434 Internal_TC_Source_Data
435 with record
436 -- Service type (12,8)
437 null;
438 end record;
439
440 function Interpret_TC
441 (TC : PUS.PUS_Packet;
442 Cmd : Internal_TC_Source_Data_Report_Current_Monitoring_List)
443 return Boolean;
444
445 type Internal_TC_Source_Data_Report_Current_Parameters_OOL_List is new
446 Internal_TC_Source_Data
447 with record
448 -- Service type (12,10)
449 null;
450 end record;
451
452 function Interpret_TC
453 (TC : PUS.PUS_Packet;
454 Cmd
455 : Internal_TC_Source_Data_Report_Current_Parameters_OOL_List)
456 return Boolean;
457
458 type Interpretation_Result is
459 (Failed,
460 Passed);
461
462 Monitoring_Service_Type :
463 constant PUS_Data_Types.Service_Type :=
464 PUS_Data_Types.Onboard_Monitoring;
465
466 --% Subprogram:
467 -- Transforms telecommand source data contained in in Src_Data read
468 --+ stream into an internal representation of a onboard monitoring
469 --+ command (service type 12) of subtype specified by Service_Subtype
470 --% Parameter Constraints:
471 --> None
472 --% Exceptions Raised:
473 --> Source_Data_Is_Inconsistent - Indicates that contents of Src_Data
474 --+ cannot be interpreted as a service request of the subtype given by
475 --+ Service_Subtype
476 function Parse_Source_Data
477 (Service_Subtype : in PUS_Data_Types.Service_Subtype;
478 Src_Data : in Source_Data_Stream.Read_Stream)
479 return Internal_TC_Source_Data'Class;
480
481 package The_Parser is new Parser
482 (Service_Type => Monitoring_Service_Type,
483 Internal_TC_Source_Data => Internal_TC_Source_Data,
484 Parse_Source_Data => Parse_Source_Data);
485
486 subtype Internal_TC_Representation is
487 The_Parser.Internal_TC_Representation;
488
489 subtype Internal_TC_Representation_Failed is
490 The_Parser.Internal_TC_Representation_Failed;
491
492 subtype Internal_TC_Representation_Passed is
493 The_Parser.Internal_TC_Representation_Passed;
494
495 -- Types related to internal representation of telemetry packets for onbaord
496 --+ monitoing service (service type 12)
497
498 -- Implementation of check defintion report (re. service type (12,9)
499
500 type Check_Definition_Report is
501 record
502 ID : Onboard_Monitoring_Types.Parameter_ID;
503 Validity : Onboard_Monitoring_Types.Validity_Parameter_No;
504 Interval : Onboard_Monitoring_Types.Interval;
505 Status : Onboard_Monitoring_Types.Monitoring_Status;
506 Repetitions : Onboard_Monitoring_Types.Value_Number_Rep;
507 Limit_Check_Defs : Check_Definitions;
508 Expected_Value_Check_Defs :
509 Check_Definitions;
510 end record;
511
512 type Check_Definitions_Report_List is array (Parameter_Index) of
513 Check_Definition_Report;
514
515 type Check_Definitions_Report is
516 record
517 Number_Of_Definitions : List_Length;
518 Definitions : Check_Definitions_Report_List;
519 end record;
520
521 type Monitoring_List_Report is
522 record
523 Global_Status : Onboard_Monitoring_Types.Monitoring_Status;
524 Reporting_Delay : Onboard_Monitoring_Types.Interval;
525 Check_Defs_Report : Check_Definitions_Report;
526 end record;
527
528 --Implementation of current paranmeters out-of-limits report (re. service
529 --+ type (12,11)
530 subtype Out_Of_Limit_Report is
531 Onboard_Monitoring_Types.Transition_Event_List;
532
533 --% Subprogram:
534 -- Parses a given PUS packet into an internal representation.
535 -- Performs validity checks applicable for verification of telecommand
536 --+ acceptance.
537 --% Parameter Constraints:
538 --> TC - Shall be a telecommand
539 --% Exceptions Raised:
540 --> None
541 function Parse_TC
542 (TC : PUS.PUS_Packet)
543 return Internal_TC_Representation'Class;
544
545 --% Subprogram:
546 -- Transform current monitoring list report to source telemetry packet
547 --+ defined by service (12,9).
548 --% Parameter Constraints:
549 --> None
550 --% Exceptions Raised:
551 --> Source_Data_Stream.Write_Stream_Exhausted - Indicates that end of
552 --+ source data was met while appending fields contained in report.
553 --+ Allocated source data stream is not sufficiently large.
554 --> Unparsing_Failed - Indicates that one or more of the fields cannot be
555 --+ represented in the external format. Results from a discrepancy
556 --+ between internal formats in Onboard_Monitoring_Types and external
557 --+ formats in External_Onboard_Monitoring_Types
558 --> Source_Data_Stream.No_Streams_Available - Heap of source streams has
559 --+ been exhausted
560 --> PUS_State.No_Packets_Available - Heap of PUS packets has been
561 --+ exhausted
562 function Unparse_Monitoring_List_Report
563 (Appl_ID : Mission_Parameters.APID;
564 Mon_List_Rep : Monitoring_List_Report)
565 return PUS.PUS_Packet;
566
567 --% Subprogram:
568 -- Transform current parameters out-of-limit list report to source
569 --+ telemetry packet defined by service (12,11).
570 --% Parameter Constraints:
571 --> None
572 --% Exceptions Raised:
573 --> Source_Data_Stream.Write_Stream_Exhausted - Indicates that end of
574 --+ source data was met while appending fields contained in report.
575 --+ Allocated source data stream is not sufficiently large.
576 --> Unparsing_Failed - Indicates that one or more of the fields cannot be
577 --+ represented in the external format. Results from a discrepancy
578 --+ between internal formats in Onboard_Monitoring_Types and external
579 --+ formats in External_Onboard_Monitoring_Types
580 --> Source_Data_Stream.No_Streams_Available - Heap of source streams has
581 --+ been exhausted
582 --> PUS_State.No_Packets_Available - Heap of PUS packets has been
583 --+ exhausted
584 function Unparse_Current_Parameters_Out_Of_Limit_Report
585 (Appl_ID : Mission_Parameters.APID;
586 OOL_Rep : Out_Of_Limit_Report)
587 return PUS.PUS_Packet;
588
589 --% Subprogram:
590 -- Unparses an out of limit report from an internal format into a
591 --+ telemetry packet conforming with service type (12,12)
592 --% Parameter Constraints:
593 --> None
594 --% Exceptions Raised:
595 --> Source_Data_Stream.Write_Stream_Exhausted - Indicates that end of
596 --+ source data was met while appending fields contained in report.
597 --+ Allocated source data stream is not sufficiently large.
598 --> Unparsing_Failed - Indicates that one or more of the fields cannot be
599 --+ represented in the external format. Results from a discrepancy
600 --+ between internal formats in Onboard_Monitoring_Types and external
601 --+ formats in External_Onboard_Monitoring_Types
602 --> Source_Data_Stream.No_Streams_Available - Heap of source streams has
603 --+ been exhausted
604 --> PUS_State.No_Packets_Available - Heap of PUS packets has been
605 --+ exhausted
606 function Unparse_Out_Of_Limit_Report
607 (Appl_ID : Mission_Parameters.APID;
608 OOL_Rep : Out_Of_Limit_Report)
609 return PUS.PUS_Packet;
610
611 end Monitor_Parser;
612
613 --~-----------------------------------------------------------------------------
614