1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.files.ccsds.ndm.adm.apm;
18
19 import org.orekit.files.ccsds.definitions.Units;
20 import org.orekit.files.ccsds.utils.ContextBinding;
21 import org.orekit.files.ccsds.utils.lexical.ParseToken;
22 import org.orekit.files.ccsds.utils.lexical.TokenType;
23 import org.orekit.utils.units.Unit;
24
25
26
27
28
29 public enum EulerKey {
30
31
32 rotationAngles((token, context, container) -> true),
33
34
35 rotationRates((token, context, container) -> true),
36
37
38 COMMENT((token, context, container) ->
39 token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
40
41
42 EULER_FRAME_A((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameA, context, true, true, true)),
43
44
45
46
47 REF_FRAME_A((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameA, context, true, true, true)),
48
49
50 EULER_FRAME_B((token, context, container) -> {
51 if (token.getType() == TokenType.ENTRY) {
52 container.checkNotNull(container.getEndpoints().getFrameA(), EULER_FRAME_A.name());
53 final boolean aIsSpaceraftBody = container.getEndpoints().getFrameA().asSpacecraftBodyFrame() != null;
54 return token.processAsFrame(container.getEndpoints()::setFrameB, context,
55 aIsSpaceraftBody, aIsSpaceraftBody, !aIsSpaceraftBody);
56 }
57 return true;
58 }),
59
60
61
62
63 REF_FRAME_B((token, context, container) -> {
64 if (token.getType() == TokenType.ENTRY) {
65 container.checkNotNull(container.getEndpoints().getFrameA(), EULER_FRAME_A.name());
66 final boolean aIsSpaceraftBody = container.getEndpoints().getFrameA().asSpacecraftBodyFrame() != null;
67 return token.processAsFrame(container.getEndpoints()::setFrameB, context,
68 aIsSpaceraftBody, aIsSpaceraftBody, !aIsSpaceraftBody);
69 }
70 return true;
71 }),
72
73
74 EULER_DIR((token, context, container) -> {
75 if (token.getType() == TokenType.ENTRY) {
76 container.getEndpoints().setA2b(token.getContentAsUppercaseCharacter() == 'A');
77 }
78 return true;
79 }),
80
81
82 EULER_ROT_SEQ((token, context, container) -> token.processAsRotationOrder(container::setEulerRotSeq)),
83
84
85 RATE_FRAME((token, context, container) -> {
86 if (token.getType() == TokenType.ENTRY) {
87 final String content = token.getContentAsUppercaseString();
88 final char suffix = content.charAt(content.length() - 1);
89 container.setRateFrameIsA(suffix == 'A');
90 }
91 return true;
92 }),
93
94
95 X_ANGLE((token, context, container) -> token.processAsLabeledDouble('X', Unit.DEGREE, context.getParsedUnitsBehavior(),
96 container::setLabeledRotationAngle)),
97
98
99 Y_ANGLE((token, context, container) -> token.processAsLabeledDouble('Y', Unit.DEGREE, context.getParsedUnitsBehavior(),
100 container::setLabeledRotationAngle)),
101
102
103 Z_ANGLE((token, context, container) -> token.processAsLabeledDouble('Z', Unit.DEGREE, context.getParsedUnitsBehavior(),
104 container::setLabeledRotationAngle)),
105
106
107 X_RATE((token, context, container) -> token.processAsLabeledDouble('X', Units.DEG_PER_S, context.getParsedUnitsBehavior(),
108 container::setLabeledRotationRate)),
109
110
111 Y_RATE((token, context, container) -> token.processAsLabeledDouble('Y', Units.DEG_PER_S, context.getParsedUnitsBehavior(),
112 container::setLabeledRotationRate)),
113
114
115 Z_RATE((token, context, container) -> token.processAsLabeledDouble('Z', Units.DEG_PER_S, context.getParsedUnitsBehavior(),
116 container::setLabeledRotationRate)),
117
118
119
120
121 ANGLE_1((token, context, container) -> token.processAsIndexedDouble(0, Unit.DEGREE, context.getParsedUnitsBehavior(),
122 container::setIndexedRotationAngle)),
123
124
125
126
127 ANGLE_2((token, context, container) -> token.processAsIndexedDouble(1, Unit.DEGREE, context.getParsedUnitsBehavior(),
128 container::setIndexedRotationAngle)),
129
130
131
132
133 ANGLE_3((token, context, container) -> token.processAsIndexedDouble(2, Unit.DEGREE, context.getParsedUnitsBehavior(),
134 container::setIndexedRotationAngle)),
135
136
137
138
139 ANGLE_1_DOT((token, context, container) -> token.processAsIndexedDouble(0, Units.DEG_PER_S, context.getParsedUnitsBehavior(),
140 container::setIndexedRotationRate)),
141
142
143
144
145 ANGLE_2_DOT((token, context, container) -> token.processAsIndexedDouble(1, Units.DEG_PER_S, context.getParsedUnitsBehavior(),
146 container::setIndexedRotationRate)),
147
148
149
150
151 ANGLE_3_DOT((token, context, container) -> token.processAsIndexedDouble(2, Units.DEG_PER_S, context.getParsedUnitsBehavior(),
152 container::setIndexedRotationRate));
153
154
155 private final transient TokenProcessor processor;
156
157
158
159
160 EulerKey(final TokenProcessor processor) {
161 this.processor = processor;
162 }
163
164
165
166
167
168
169
170 public boolean process(final ParseToken token, final ContextBinding context, final Euler container) {
171 return processor.process(token, context, container);
172 }
173
174
175 interface TokenProcessor {
176
177
178
179
180
181
182 boolean process(ParseToken token, ContextBinding context, Euler container);
183 }
184
185 }