File: /home/oboss/Users/gec/sources/Basic_Services/External_PUS/external_pus_state.ads

1     --% Compilation Unit: External_PUS_State
2     --
3     --% Category: Package Declaration
4     --
5     --% Release:  $Name:  $
6     --
7     --% Version:  $Revision: 2.2 $
8     --
9     --% Author:   $Author: gec $
10     --
11     --% Revision Log:
12     --    $Log: external_pus_state.ads,v $
13     --    Revision 2.2  2003/11/13 14:57:33  gec
14     --    Merged ECSS Migration branch to main trunk.
15     --
16     --    Revision 2.1.4.1  2003/10/29 07:17:38  gec
17     --    Packet headers and data field headers updated to be compliant to ECSS Telemetry & Telecommand Packet Utilization standard.
18     --
19     --    Revision 2.1  2003/10/09 11:05:16  jhl
20     --    Added Service 13 And 19
21     --
22     --    Revision 2.0.4.1  2003/10/01 11:54:22  jhl
23     --    Initial version of service 13 Event Action, and 19 Large Data Transfer.
24     --
25     --    Revision 2.0  2003/04/04 08:50:01  gec
26     --    Initial release of source files serving as baseline for OBOSS-III
27     --+    project.
28     --
29     --    Revision 1.1.1.1  2003/04/04 08:13:01  gec
30     --    Imported using TkCVS
31     --
32     --
33     --
34     --% Project: OBOSS
35     --
36     --% Copyright (C) 2003 by Terma A/S
37     --  Proprietary and intellectual rights of Terma A/S, Denmark,
38     --  are involved in the subject-matter of this material and
39     --  all manufacturing, reproduction, use, disclosure, and
40     --  sales rights pertaining to such subject-matter are
41     --  expressly reserved. This material is submitted for a
42     --  specific purpose as agreed, and the recipient by
43     --  accepting this material agrees that this material will
44     --  not be used, copied, or reproduced in whole or in part
45     --  nor its contents revealed in any manner or to any person,
46     --  except to meet the purpose for which it was submitted and
47     --  subject to the terms of the agreement.
48     --
49     --% Target Dependencies:
50     --    None
51     --% Compiler Dependencies:
52     --    None
53     
54     --~-----------------------------------------------------------------------------
55     
56     with Basic_Types;
57     with Mission_Parameters;
58     with PUS;
59     with PUS_Data_Types;
60     with External_PUS_Data_Types;
61     with Source_Data_Stream;
62     with PUS_State;
63     package External_PUS_State is
64     
65        --% Library Package:
66        --    Definition of external PUS state and operations
67        --% Active Tasks:
68        -->   None
69        --% Passive Tasks:
70        -->   None
71     
72        -- Indicates that operation failed as heap of source data streams is empty
73        No_Streams_Available : exception renames Source_Data_Stream.
74                    No_Streams_Available;
75        -- Indicates that operation failed as heap of internal PUS packets is empty
76        No_Packets_Available : exception renames PUS_State.No_Packets_Available;
77     
78        -- The following is needed in order to implement ICU bus protocol
79     
80        Packet_Header_Byte_Size : constant :=
81                                     (External_PUS_Data_Types.Packet_Header_Size -
82                                     1) / Basic_Types.Byte_Size + 1;
83        subtype Packet_Header_Byte_Array is
84              Basic_Types.Byte_Array (1 .. Packet_Header_Byte_Size);
85     
86        -- Support for the Unit Type field in a Service Data Unit for the Large Data
87        --+    Transfer service
88     
89        SDU_Unit_Type_Byte_Size : constant :=
90                                     (External_PUS_Data_Types.SDU_Unit_Type'Size -
91                                     1) / Basic_Types.Byte_Size + 1;
92     
93        subtype SDU_Unit_Type_Byte_Array is
94              Basic_Types.Byte_Array (1 .. SDU_Unit_Type_Byte_Size);
95     
96        --% Subprogram:
97        --    Convert a byte array to an external telecommand header and check
98        --+    fields
99        --% Parameter Constraints:
100        -->   None
101        --% Exceptions Raised:
102        -->   External_PUS_Data_Types.Wrong_Version_Number  - When the version
103        --+    number in the packet header is not correct (currently 0).
104        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the packet type in the packet
105        --+    header is not that of a telecommand.
106        -->   External_PUS_Data_Types.Illegal_Application_ID  - When the destination
107        --+    application process in the packet header is not valid.
108        -->   External_PUS_Data_Types.Wrong_Data_Field_Header_Flag  - When the data
109        --+    field header flag in the packet header does not indicate presence of
110        --+    a data field header.
111        -->   External_PUS_Data_Types.Wrong_Sequence_Flags  - When the sequence
112        --+    flags in the packet header are not correct (currently '11' for
113        --+    "stand-alone").
114     
115        function Make_And_Check_TC_Packet_Header
116              (Header_Bytes : in     Packet_Header_Byte_Array)
117              return External_PUS_Data_Types.TC_Packet_Header;
118     
119     
120        --% Subprogram:
121        --    Convert a byte array to an external telemetry header and check fields
122        --% Parameter Constraints:
123        -->   None
124        --% Exceptions Raised:
125        -->   External_PUS_Data_Types.Wrong_Version_Number  - When the version
126        --+    number in the packet header is not correct (currently version 2,
127        --+    represented by value 4).
128        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the packet type in the packet
129        --+    header is not that of a telemetry packet.
130        -->   External_PUS_Data_Types.Illegal_Application_ID  - When the source
131        --+    application process in the packet header is not valid.
132        -->   External_PUS_Data_Types.Wrong_Data_Field_Header_Flag  - When the data
133        --+    field header flag in the packet header does not indicate presence of
134        --+    a data field header.
135        -->   External_PUS_Data_Types.Wrong_Sequence_Flags  - When the segmentation
136        --+    flags in the packet header are not correct (currently '11' for
137        --+    "unsegmented").
138     
139        function Make_And_Check_TM_Packet_Header
140              (Header_Bytes : in     Packet_Header_Byte_Array)
141              return External_PUS_Data_Types.TM_Packet_Header;
142     
143     
144        -- Conversion routines to and from external ground format
145     
146        --% Subprogram:
147        --    Read the next TC Packet from the read stream.
148        --% Parameter Constraints:
149        -->   None
150        --% Exceptions Raised:
151        -->   Source_Data_Stream.Not_Allocated  - Read_Stream is not currently
152        --+    allocated.
153        -->   Source_Data_Stream.Read_Stream_Exhausted - End of Read_Stream was met
154        --+    while reading Img.
155        -->   +
156        -->   All exceptions raised by Byte_Array_To_External_TC_Packet
157     
158        procedure Get_External_TC_Packet
159              (Read_Stream        : in out Source_Data_Stream.Read_Stream;
160               External_TC_Packet
161                                  :    out External_PUS_Data_Types.
162                                    External_TC_Packet);
163     
164        --% Subprogram:
165        --    Read the next TM Packet from the read stream.
166        --% Parameter Constraints:
167        -->   None
168        --% Exceptions Raised:
169        -->   exception_name  - Conditions
170        -->   Source_Data_Stream.Not_Allocated  - Read_Stream is not currently
171        --+    allocated.
172        -->   Source_Data_Stream.Read_Stream_Exhausted - End of Read_Stream was met
173        --+    while reading Img.
174        -->   +
175        -->   All excptions raised by Byte_Array_To_External_TM_Packet
176     
177        procedure Get_External_TM_Packet
178              (Read_Stream        : in out Source_Data_Stream.Read_Stream;
179               External_TM_Packet
180                                  :    out External_PUS_Data_Types.
181                                    External_TM_Packet);
182     
183        --% Subprogram:
184        --    Convert a byte array to an external ground telecommand and check
185        --+    fields
186        --% Parameter Constraints:
187        -->   None
188        --% Exceptions Raised:
189        -->   External_PUS_Data_Types.Checksum_Error  - When the checksum is
190        --+    incorrect.
191        -->   External_PUS_Data_Types.Wrong_PUS_Version_Number  - When the version
192        --+    number in the packet data field header is not correct (currently 0).
193        -->   External_PUS_Data_Types.Wrong_Version_Number  - When the version
194        --+    number in the packet header is not correct (currently 0).
195        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the packet type in the packet
196        --+    header is not that of a telecommand.
197        -->   External_PUS_Data_Types.Illegal_Application_ID  - When the destination
198        --+    application process in the packet header is not valid.
199        -->   External_PUS_Data_Types.Wrong_Data_Field_Header_Flag  - When the data
200        --+    field header flag in the packet header does not indicate presence of
201        --+    a data field header.
202        -->   External_PUS_Data_Types.Wrong_Sequence_Flags  - When the sequence
203        --+    flags in the packet header are not correct (currently '11' for
204        --+    "stand-alone").
205        -->   External_PUS_Data_Types.Wrong_Byte_Array_Length  - When the byte array
206        --+    does not have the correct length.
207        -->   Source_Data_Stream.No_Streams_Available - Heap of source data streams
208        --+    has been exhausted.
209        -->   External_PUS_Data_Types.Non_Supported_Service_Type  - Raised if the
210        --+    service type does not belong to the required type
211        -->   External_PUS_Data_Types.Non_Supported_Checksum_Type - when trying to
212        --+    perform a CRC check
213     
214     
215        function Byte_Array_To_External_TC_Packet
216              (Bytes :        Basic_Types.Byte_Array)
217              return External_PUS_Data_Types.External_TC_Packet;
218     
219        --% Subprogram:
220        --    Convert an SDU byte array to an external ground telecommand and check
221        --+    fields
222        --% Parameter Constraints:
223        -->   None
224        --% Exceptions Raised:
225        -- Indicates an that a Service Data Unit has wrong unit type
226        -->   External_PUS_Data_Types.Non_Supported_SDU_Unit_Type - when the Service
227        --+    Data Unit unit type is non supported, i.e. Extended.
228        -->   External_PUS_Data_Types.Wrong_PUS_Version_Number  - When the version
229        --+    number in the packet data field header is not correct (currently 0).
230        -->   External_PUS_Data_Types.Wrong_Version_Number  - When the version
231        --+    number in the packet header is not correct (currently 0).
232        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the packet type in the packet
233        --+    header is not that of a telecommand.
234        -->   External_PUS_Data_Types.Illegal_Application_ID  - When the destination
235        --+    application process in the packet header is not valid.
236        -->   External_PUS_Data_Types.Wrong_Data_Field_Header_Flag  - When the data
237        --+    field header flag in the packet header does not indicate presence of
238        --+    a data field header.
239        -->   External_PUS_Data_Types.Wrong_Sequence_Flags  - When the sequence
240        --+    flags in the packet header are not correct (currently '11' for
241        --+    "stand-alone").
242        -->   External_PUS_Data_Types.Wrong_Byte_Array_Length  - When the byte array
243        --+    does not have the correct length.
244        -->   Source_Data_Stream.No_Streams_Available - Heap of source data streams
245        --+    has been exhausted.
246        -->   External_PUS_Data_Types.Non_Supported_Service_Type  - Raised if the
247        --+    service type does not belong to the required type
248     
249        function SDU_Byte_Array_To_External_TC_Packet
250              (Bytes :        Basic_Types.Byte_Array)
251              return External_PUS_Data_Types.External_TC_Packet;
252     
253        --% Subprogram:
254        --    Convert a byte array to an external ground telemetry packet and check
255        --+    fields
256        --% Parameter Constraints:
257        -->   None
258        --% Exceptions Raised:
259        -->   External_PUS_Data_Types.Checksum_Error  - When the checksum is
260        --+    incorrect.
261        -->   External_PUS_Data_Types.Wrong_PUS_Version_Number  - When the version
262        --+    number in the packet data field header is not correct (currently 0).
263        -->   External_PUS_Data_Types.Wrong_Version_Number  - When the version
264        --+    number in the packet header is not correct (currently version 2,
265        --+    represented by value 4).
266        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the packet type in the packet
267        --+    header is not that of a telemetry packet.
268        -->   External_PUS_Data_Types.Illegal_Application_ID  - When the source
269        --+    application process in the packet header is not valid.
270        -->   External_PUS_Data_Types.Wrong_Data_Field_Header_Flag  - When the data
271        --+    field header flag in the packet header does not indicate presence of
272        --+    a data field header.
273        -->   External_PUS_Data_Types.Wrong_Sequence_Flags  - When the segmentation
274        --+    flags in the packet header are not correct (currently '11' for
275        --+    "unsegmented").
276        -->   External_PUS_Data_Types.Wrong_Byte_Array_Length  - When the byte array
277        --+    does not have the correct length.
278        -->   No_Streams_Available - Heap of source data streams has been
279        --+    exhausted.
280     
281        function Byte_Array_To_External_TM_Packet
282              (Bytes :        Basic_Types.Byte_Array)
283              return External_PUS_Data_Types.External_TM_Packet;
284     
285     
286        --% Subprogram:
287        --    Convert an external ground telecommand packet to a byte array and
288        --+    include a checksum
289        --% Parameter Constraints:
290        -->   None
291        --% Exceptions Raised:
292        -->   None
293     
294        function External_TC_Packet_To_Byte_Array
295              (Ext_TC_Packet :        External_PUS_Data_Types.External_TC_Packet)
296              return Basic_Types.Byte_Array;
297     
298     
299        --% Subprogram:
300        --    Convert an external ground telemetry packet to a byte array and
301        --+    include a checksum
302        --% Parameter Constraints:
303        -->   None
304        --% Exceptions Raised:
305        -->   None
306     
307        function External_TM_Packet_To_Byte_Array
308              (Ext_TM_Packet :        External_PUS_Data_Types.External_TM_Packet)
309              return Basic_Types.Byte_Array;
310     
311     
312        --% Subprogram:
313        --    Convert an external ground telemetry packet to a byte array without
314        --+    the checksum (Packet Error Control) field.
315        --% Parameter Constraints:
316        -->   None
317        --% Exceptions Raised:
318        -->   None
319     
320        function External_TM_Packet_To_SDU_Byte_Array
321              (Ext_TM_Packet :        External_PUS_Data_Types.External_TM_Packet)
322              return Basic_Types.Byte_Array;
323     
324     
325        --% Subprogram:
326        --    Convert an internal PUS packet to an external ground telecommand
327        --% Parameter Constraints:
328        -->   None
329        --% Exceptions Raised:
330        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the PUS packet is not a
331        --+    telecommand.
332     
333        function PUS_Packet_To_External_TC_Packet
334              (Packet :        PUS.PUS_Packet)
335              return External_PUS_Data_Types.External_TC_Packet;
336     
337     
338        --% Subprogram:
339        --    Convert an internal PUS packet to an external ground telemetry packet
340        --% Parameter Constraints:
341        -->   None
342        --% Exceptions Raised:
343        -->   PUS_Data_Types.Wrong_Packet_Kind  - When the PUS packet is not a
344        --+    telemetry packet.
345     
346        function PUS_Packet_To_External_TM_Packet
347              (Packet :        PUS.PUS_Packet)
348              return External_PUS_Data_Types.External_TM_Packet;
349     
350        --% Subprogram:
351        --    Convert an external ground telecommand to an internal PUS packet
352        --% Parameter Constraints:
353        -->   None
354        --% Exceptions Raised:
355        -->   PUS_State.No_Packets_Available - Heap of internal PUS packets has been
356        --+    exhausted.
357     
358        function External_TC_Packet_To_PUS_Packet
359              (Ext_TC_Packet :        External_PUS_Data_Types.External_TC_Packet)
360              return PUS.PUS_Packet;
361     
362     
363        --% Subprogram:
364        --    Convert an external ground telemetry packet to an internal PUS packet
365        --% Parameter Constraints:
366        -->   None
367        --% Exceptions Raised:
368        -->   PUS_State.No_Packets_Available - Heap of internal PUS packets has been
369        --+    exhausted.
370     
371        function External_TM_Packet_To_PUS_Packet
372              (Ext_TM_Packet :        External_PUS_Data_Types.External_TM_Packet)
373              return PUS.PUS_Packet;
374     
375     
376        -- Disposal routines
377     
378        --% Subprogram:
379        --    Dispose of External_TC_Packet.
380        --% Parameter Constraints:
381        -->   None
382        --% Exceptions Raised:
383        -->   None
384     
385        procedure Dispose
386              (Ext_TC_Packet : in     External_PUS_Data_Types.External_TC_Packet);
387     
388        --% Subprogram:
389        --    Dispose of External_TM_Packet.
390        --% Parameter Constraints:
391        -->   None
392        --% Exceptions Raised:
393        -->   None
394     
395        procedure Dispose
396              (Ext_TM_Packet : in     External_PUS_Data_Types.External_TM_Packet);
397     
398     
399     
400        -- Extraction routines
401     
402        --% Subprogram:
403        --    Construct a packet identifier based on an internal PUS packet by
404        --+    adding the fields that are not present in the internal PUS packet
405        --+    header.
406        --% Parameter Constraints:
407        -->   None
408        --% Exceptions Raised:
409        -->   None
410     
411        function Get_Packet_ID
412              (Packet :        PUS.PUS_Packet)
413              return External_PUS_Data_Types.Packet_ID;
414     
415     
416        --% Subprogram:
417        --    Construct the telecommand packet sequence control of an internal PUS
418        --+    packet by adding the fields that are not present in the internal PUS
419        --+    packet header.
420        --% Parameter Constraints:
421        -->   None
422        --% Exceptions Raised:
423        -->   None
424     
425        function Get_TC_Packet_Sequence_Control
426              (Packet :        PUS.PUS_Packet)
427              return External_PUS_Data_Types.TC_Packet_Sequence_Control;
428     
429     
430        --% Subprogram:
431        --    Construct the telemetry packet sequence control of an internal PUS
432        --+    packet by adding the fields that are not present in the internal PUS
433        --+    packet header.
434        --% Parameter Constraints:
435        -->   None
436        --% Exceptions Raised:
437        -->   None
438     
439        function Get_TM_Packet_Sequence_Control
440              (Packet :        PUS.PUS_Packet)
441              return External_PUS_Data_Types.TM_Packet_Sequence_Control;
442     
443     end External_PUS_State;
444     
445     --~-----------------------------------------------------------------------------
446