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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const ND: i32 = 2;
const NI: i32 = 6;
/// SPK - unpack segment descriptor
///
/// Unpack the contents of an SPK segment descriptor.
///
/// # Required Reading
///
/// * [SPK](crate::required_reading::spk)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// DESCR I An SPK segment descriptor.
/// BODY O The NAIF ID code for the body of the segment.
/// CENTER O The center of motion for BODY.
/// FRAME O The code for the frame of this segment.
/// TYPE O The type of SPK segment.
/// FIRST O The first epoch for which the segment is valid.
/// LAST O The last epoch for which the segment is valid.
/// BADDRS O Beginning DAF address of the segment.
/// EADDRS O Ending DAF address of the segment.
/// ```
///
/// # Detailed Input
///
/// ```text
/// DESCR is an SPK segment descriptor.
/// ```
///
/// # Detailed Output
///
/// ```text
/// BODY is the NAIF ID code for the body of the segment.
///
/// CENTER is the center of motion for BODY.
///
/// FRAME is the SPICE integer code for the frame to which states
/// for the body are be referenced.
///
/// TYPE is the type of SPK segment.
///
/// FIRST is the first epoch for which the segment has
/// ephemeris data.
///
/// LAST is the last epoch for which the segment has
/// ephemeris data.
///
/// BADDRS is the starting address of the data associated
/// with this descriptor.
///
/// EADDRS is the last address of the data associated with
/// this descriptor.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
///
/// 1) If the input descriptor DESCR is invalid, it's possible for
/// the output times to contain bit patterns that don't represent
/// normal double precision values. This error is not diagnosed.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine extracts the contents of an SPK segment
/// descriptor into the components needed for reading and
/// evaluating the data stored in the segment. It serves
/// as a macro for expanding the SPK segment descriptor.
/// ```
///
/// # Examples
///
/// ```text
/// Suppose you wished to summarize a particular SPK segment
/// and that you have the descriptor for that segment in hand.
/// The following code fragment shows how you might use this
/// routine to create a summary message concerning the segment.
///
/// CALL SPKUDS ( DESCR, BODY, CENTER, FRAME,
/// . TYPE, FIRST, LAST, BADDR, EADDR )
///
/// Convert the start and stop times to ephemeris calendar strings
///
/// CALL ETCAL ( FIRST, FSTCAL )
/// CALL ETCAL ( LAST, LSTCAL )
///
/// WRITE (*,*)
/// WRITE (*,*) 'Body : ', BODY
/// WRITE (*,*) 'Center : ', CENTER
/// WRITE (*,*) 'Frame ID : ', FRAME
/// WRITE (*,*) 'Data Type: ', TYPE
/// WRITE (*,*)
/// WRITE (*,*) 'Segment Start : ', FSTCAL
/// WRITE (*,*) 'Segment Stop : ', LSTCAL
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 02-OCT-2021 (JDR) (NJB)
///
/// Changed output argument names "BEGIN" and "END" to "BADDRS" and
/// "EADDRS" for consistency with other routines.
///
/// Edited the header to comply with NAIF standard. Added entry
/// #1 to $Exceptions section and declared the routine error free.
///
/// - SPICELIB Version 1.0.0, 04-JAN-1994 (WLT) (KRG)
/// ```
pub fn spkuds(
ctx: &mut SpiceContext,
descr: &[f64],
body: &mut i32,
center: &mut i32,
frame: &mut i32,
type_: &mut i32,
first: &mut f64,
last: &mut f64,
baddrs: &mut i32,
eaddrs: &mut i32,
) -> crate::Result<()> {
SPKUDS(
descr,
body,
center,
frame,
type_,
first,
last,
baddrs,
eaddrs,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure SPKUDS ( SPK - unpack segment descriptor )
pub fn SPKUDS(
DESCR: &[f64],
BODY: &mut i32,
CENTER: &mut i32,
FRAME: &mut i32,
TYPE: &mut i32,
FIRST: &mut f64,
LAST: &mut f64,
BADDRS: &mut i32,
EADDRS: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let DESCR = DummyArray::new(DESCR, 1..);
let mut DPPART = StackArray::<f64, 2>::new(1..=ND);
let mut IPART = StackArray::<i32, 6>::new(1..=NI);
//
// Spicelib Functions
//
//
// Local Parameters
//
// Values of ND and NI for SPK files.
//
//
// Local Variables
//
//
// Standard introductory error handling preparations.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"SPKUDS", ctx)?;
//
// No judgments are made about the descriptor when we
// unpack it. If things were done right when the descriptor
// was created, it should be fine now.
//
DAFUS(
DESCR.as_slice(),
ND,
NI,
DPPART.as_slice_mut(),
IPART.as_slice_mut(),
);
if FAILED(ctx) {
CHKOUT(b"SPKUDS", ctx)?;
return Ok(());
}
*BODY = IPART[1];
*CENTER = IPART[2];
*FRAME = IPART[3];
*TYPE = IPART[4];
*BADDRS = IPART[5];
*EADDRS = IPART[6];
*FIRST = DPPART[1];
*LAST = DPPART[2];
CHKOUT(b"SPKUDS", ctx)?;
Ok(())
}