1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.files.ccsds.definitions;
18
19 import org.orekit.errors.OrekitException;
20 import org.orekit.errors.OrekitMessages;
21 import org.orekit.files.ccsds.utils.ContextBinding;
22 import org.orekit.time.AbsoluteDate;
23 import org.orekit.time.SatelliteClockScale;
24
25
26
27
28
29
30 public enum TimeSystem {
31
32
33 GMST {
34
35 public TimeConverter getConverter(final ContextBinding context) {
36 return new TimeConverter(context.getDataContext().getTimeScales().getGMST(context.getConventions(), false),
37 context.getReferenceDate());
38 }
39 },
40
41
42 GPS {
43
44 public TimeConverter getConverter(final ContextBinding context) {
45 return new TimeConverter(context.getDataContext().getTimeScales().getGPS(),
46 context.getReferenceDate());
47 }
48 },
49
50
51 MET {
52
53 public TimeConverter getConverter(final ContextBinding context) {
54 return new TimeConverter(new SatelliteClockScale("MET",
55 context.getReferenceDate(),
56 context.getDataContext().getTimeScales().getUTC(),
57 0.0, 0.0),
58 context.getReferenceDate());
59 }
60 },
61
62
63 MRT {
64
65 public TimeConverter getConverter(final ContextBinding context) {
66 return new TimeConverter(new SatelliteClockScale("MRT",
67 context.getReferenceDate(),
68 context.getDataContext().getTimeScales().getUTC(),
69 0.0, 0.0),
70 context.getReferenceDate());
71 }
72 },
73
74
75 SCLK {
76
77 public TimeConverter getConverter(final ContextBinding context) {
78 return new TimeConverter(new SatelliteClockScale("SCLK",
79 context.getReferenceDate(),
80 context.getDataContext().getTimeScales().getUTC(),
81 context.getClockCount(),
82 context.getClockRate() - 1.0),
83 context.getReferenceDate()) {
84
85
86
87
88
89 @Override
90 public double offset(final AbsoluteDate date) {
91 return ((SatelliteClockScale) getTimeScale()).countAtDate(date);
92 }
93 };
94 }
95 },
96
97
98 TAI {
99
100 public TimeConverter getConverter(final ContextBinding context) {
101 return new TimeConverter(context.getDataContext().getTimeScales().getTAI(),
102 context.getReferenceDate());
103 }
104 },
105
106
107 TCB {
108
109 public TimeConverter getConverter(final ContextBinding context) {
110 return new TimeConverter(context.getDataContext().getTimeScales().getTCB(),
111 context.getReferenceDate());
112 }
113 },
114
115
116 TDB {
117
118 public TimeConverter getConverter(final ContextBinding context) {
119 return new TimeConverter(context.getDataContext().getTimeScales().getTDB(),
120 context.getReferenceDate());
121 }
122 },
123
124
125 TCG {
126
127 public TimeConverter getConverter(final ContextBinding context) {
128 return new TimeConverter(context.getDataContext().getTimeScales().getTCG(),
129 context.getReferenceDate());
130 }
131 },
132
133
134 TT {
135
136 public TimeConverter getConverter(final ContextBinding context) {
137 return new TimeConverter(context.getDataContext().getTimeScales().getTT(),
138 context.getReferenceDate());
139 }
140 },
141
142
143 UT1 {
144
145 public TimeConverter getConverter(final ContextBinding context) {
146 return new TimeConverter(context.getDataContext().getTimeScales().getUT1(context.getConventions(), false),
147 context.getReferenceDate());
148 }
149 },
150
151
152 UTC {
153
154 public TimeConverter getConverter(final ContextBinding context) {
155 return new TimeConverter(context.getDataContext().getTimeScales().getUTC(),
156 context.getReferenceDate());
157 }
158 };
159
160
161
162
163
164
165 public abstract TimeConverter getConverter(ContextBinding context);
166
167
168
169
170
171 public static TimeSystem parse(final String value) {
172 for (final TimeSystem scale : values()) {
173 if (scale.name().equals(value)) {
174 return scale;
175 }
176 }
177 throw new OrekitException(OrekitMessages.CCSDS_TIME_SYSTEM_NOT_IMPLEMENTED, value);
178 }
179
180 }