1use num_derive::FromPrimitive;
6use std::fmt;
7
8#[cfg(test)]
9mod test;
10
11#[cfg(feature = "python-stubgen")]
12use pyo3_stub_gen_derive::gen_stub_pyclass_enum;
13
14#[repr(C)]
17#[derive(Debug, PartialEq, Eq, Clone, Copy)]
18#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
19#[cfg_attr(
20 any(feature = "python", feature = "python-stubgen"),
21 pyo3::pyclass(eq, eq_int, from_py_object)
22)]
23pub enum MWAVersion {
24 CorrOldLegacy = 1,
26 CorrLegacy = 2,
28 CorrMWAXv2 = 3,
30 VCSLegacyRecombined = 4,
32 VCSMWAXv2 = 5,
34 BeamformerMWAXv2 = 6,
36 CorrBeamformerMWAXv2 = 7,
38}
39
40impl fmt::Display for MWAVersion {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 write!(
55 f,
56 "{}",
57 match self {
58 MWAVersion::CorrOldLegacy => "Correlator v1 old Legacy (no file indices)",
59 MWAVersion::CorrLegacy => "Correlator v1 Legacy",
60 MWAVersion::CorrMWAXv2 => "Correlator v2 MWAX",
61 MWAVersion::VCSLegacyRecombined => "VCS Legacy Recombined",
62 MWAVersion::VCSMWAXv2 => "VCS MWAX v2",
63 MWAVersion::CorrBeamformerMWAXv2 => "Correlator and Beamformer v2 MWAX",
64 MWAVersion::BeamformerMWAXv2 => "Beamformer MWAX v2",
65 }
66 )
67 }
68}
69
70#[repr(C)]
73#[derive(Debug, Clone, Copy, PartialEq)]
74#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
75#[cfg_attr(
76 any(feature = "python", feature = "python-stubgen"),
77 pyo3::pyclass(eq, eq_int, from_py_object)
78)]
79pub enum VisPol {
80 XX = 1,
81 XY = 2,
82 YX = 3,
83 YY = 4,
84}
85impl fmt::Display for VisPol {
98 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
99 write!(
100 f,
101 "{}",
102 match self {
103 VisPol::XX => "XX",
104 VisPol::XY => "XY",
105 VisPol::YX => "YX",
106 VisPol::YY => "YY",
107 }
108 )
109 }
110}
111
112#[repr(C)]
115#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive)]
116#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
117#[cfg_attr(
118 any(feature = "python", feature = "python-stubgen"),
119 pyo3::pyclass(eq, eq_int, from_py_object)
120)]
121pub enum GeometricDelaysApplied {
122 No = 0,
123 Zenith = 1,
124 TilePointing = 2,
125 AzElTracking = 3,
126}
127
128impl fmt::Display for GeometricDelaysApplied {
141 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
142 write!(
143 f,
144 "{}",
145 match self {
146 GeometricDelaysApplied::No => "No",
147 GeometricDelaysApplied::Zenith => "Zenith",
148 GeometricDelaysApplied::TilePointing => "Tile Pointing",
149 GeometricDelaysApplied::AzElTracking => "Az/El Tracking",
150 }
151 )
152 }
153}
154
155impl std::str::FromStr for GeometricDelaysApplied {
168 type Err = ();
169
170 fn from_str(input: &str) -> Result<GeometricDelaysApplied, Self::Err> {
171 match input {
172 "No" => Ok(GeometricDelaysApplied::No),
173 "Zenith" => Ok(GeometricDelaysApplied::Zenith),
174 "Tile Pointing" => Ok(GeometricDelaysApplied::TilePointing),
175 "Az/El Tracking" => Ok(GeometricDelaysApplied::AzElTracking),
176 _ => Err(()),
177 }
178 }
179}
180
181#[repr(C)]
184#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive)]
185#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
186#[cfg_attr(
187 any(feature = "python", feature = "python-stubgen"),
188 pyo3::pyclass(eq, eq_int, from_py_object)
189)]
190pub enum CableDelaysApplied {
191 NoCableDelaysApplied = 0,
192 CableAndRecClock = 1,
193 CableAndRecClockAndBeamformerDipoleDelays = 2,
194}
195
196impl fmt::Display for CableDelaysApplied {
209 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
210 write!(
211 f,
212 "{}",
213 match self {
214 CableDelaysApplied::NoCableDelaysApplied => "No",
215 CableDelaysApplied::CableAndRecClock => "Cable and receiver clock cable length",
216 CableDelaysApplied::CableAndRecClockAndBeamformerDipoleDelays =>
217 "Cable, receiver clock cable and pointing-dependent beamformer dipole delays",
218 }
219 )
220 }
221}
222
223impl std::str::FromStr for CableDelaysApplied {
224 type Err = ();
225
226 fn from_str(input: &str) -> Result<CableDelaysApplied, Self::Err> {
227 match input {
228 "No" => Ok(CableDelaysApplied::NoCableDelaysApplied),
229 "Cable and receiver clock cable length" => Ok(CableDelaysApplied::CableAndRecClock),
230 "Cable, receiver clock cable and pointing-dependent beamformer dipole delays" => {
231 Ok(CableDelaysApplied::CableAndRecClockAndBeamformerDipoleDelays)
232 }
233 _ => Err(()),
234 }
235 }
236}
237
238#[repr(C)]
240#[derive(Debug, PartialEq, Eq, Clone, Copy)]
241#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
242#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
243#[cfg_attr(
244 any(feature = "python", feature = "python-stubgen"),
245 pyo3::pyclass(eq, eq_int, from_py_object)
246)]
247pub enum MWAMode {
248 No_Capture = 0,
249 Burst_Vsib = 1,
250 Sw_Cor_Vsib = 2,
251 Hw_Cor_Pkts = 3,
252 Rts_32t = 4,
253 Hw_Lfiles = 5,
254 Hw_Lfiles_Nomentok = 6,
255 Sw_Cor_Vsib_Nomentok = 7,
256 Burst_Vsib_Synced = 8,
257 Burst_Vsib_Raw = 9,
258 Lfiles_Client = 16,
259 No_Capture_Burst = 17,
260 Enter_Burst = 18,
261 Enter_Channel = 19,
262 Voltage_Raw = 20,
263 Corr_Mode_Change = 21,
264 Voltage_Start = 22,
265 Voltage_Stop = 23,
266 Voltage_Buffer = 24,
267 Mwax_Correlator = 30,
268 Mwax_Vcs = 31,
269 Mwax_Buffer = 32,
270 Mwax_Beamformer = 33,
271 Mwax_Corr_Bf = 34,
272}
273
274impl fmt::Display for MWAMode {
287 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
288 write!(
289 f,
290 "{}",
291 match self {
292 MWAMode::No_Capture => "NO_CAPTURE",
293 MWAMode::Burst_Vsib => "BURST_VSIB",
294 MWAMode::Sw_Cor_Vsib => "SW_COR_VSIB",
295 MWAMode::Hw_Cor_Pkts => "HW_COR_PKTS",
296 MWAMode::Rts_32t => "RTS_32T",
297 MWAMode::Hw_Lfiles => "HW_LFILES",
298 MWAMode::Hw_Lfiles_Nomentok => "HW_LFILES_NOMENTOK",
299 MWAMode::Sw_Cor_Vsib_Nomentok => "SW_COR_VSIB_NOMENTOK",
300 MWAMode::Burst_Vsib_Synced => "BURST_VSIB_SYNCED",
301 MWAMode::Burst_Vsib_Raw => "BURST_VSIB_RAW",
302 MWAMode::Lfiles_Client => "LFILES_CLIENT",
303 MWAMode::No_Capture_Burst => "NO_CAPTURE_BURST",
304 MWAMode::Enter_Burst => "ENTER_BURST",
305 MWAMode::Enter_Channel => "ENTER_CHANNEL",
306 MWAMode::Voltage_Raw => "VOLTAGE_RAW",
307 MWAMode::Corr_Mode_Change => "CORR_MODE_CHANGE",
308 MWAMode::Voltage_Start => "VOLTAGE_START",
309 MWAMode::Voltage_Stop => "VOLTAGE_STOP",
310 MWAMode::Voltage_Buffer => "VOLTAGE_BUFFER",
311 MWAMode::Mwax_Correlator => "MWAX_CORRELATOR",
312 MWAMode::Mwax_Vcs => "MWAX_VCS",
313 MWAMode::Mwax_Buffer => "MWAX_BUFFER",
314 MWAMode::Mwax_Beamformer => "MWAX_BEAMFORMER",
315 MWAMode::Mwax_Corr_Bf => "MWAX_CORR_BF",
316 }
317 )
318 }
319}
320
321impl std::str::FromStr for MWAMode {
322 type Err = ();
323
324 fn from_str(input: &str) -> Result<MWAMode, Self::Err> {
325 match input {
326 "NO_CAPTURE" => Ok(MWAMode::No_Capture),
327 "BURST_VSIB" => Ok(MWAMode::Burst_Vsib),
328 "SW_COR_VSIB" => Ok(MWAMode::Sw_Cor_Vsib),
329 "HW_COR_PKTS" => Ok(MWAMode::Hw_Cor_Pkts),
330 "RTS_32T" => Ok(MWAMode::Rts_32t),
331 "HW_LFILES" => Ok(MWAMode::Hw_Lfiles),
332 "HW_LFILES_NOMENTOK" => Ok(MWAMode::Hw_Lfiles_Nomentok),
333 "SW_COR_VSIB_NOMENTOK" => Ok(MWAMode::Sw_Cor_Vsib_Nomentok),
334 "BURST_VSIB_SYNCED" => Ok(MWAMode::Burst_Vsib_Synced),
335 "BURST_VSIB_RAW" => Ok(MWAMode::Burst_Vsib_Raw),
336 "LFILES_CLIENT" => Ok(MWAMode::Lfiles_Client),
337 "NO_CAPTURE_BURST" => Ok(MWAMode::No_Capture_Burst),
338 "ENTER_BURST" => Ok(MWAMode::Enter_Burst),
339 "ENTER_CHANNEL" => Ok(MWAMode::Enter_Channel),
340 "VOLTAGE_RAW" => Ok(MWAMode::Voltage_Raw),
341 "CORR_MODE_CHANGE" => Ok(MWAMode::Corr_Mode_Change),
342 "VOLTAGE_START" => Ok(MWAMode::Voltage_Start),
343 "VOLTAGE_STOP" => Ok(MWAMode::Voltage_Stop),
344 "VOLTAGE_BUFFER" => Ok(MWAMode::Voltage_Buffer),
345 "MWAX_CORRELATOR" => Ok(MWAMode::Mwax_Correlator),
346 "MWAX_VCS" => Ok(MWAMode::Mwax_Vcs),
347 "MWAX_BUFFER" => Ok(MWAMode::Mwax_Buffer),
348 "MWAX_BEAMFORMER" => Ok(MWAMode::Mwax_Beamformer),
349 "MWAX_CORR_BF" => Ok(MWAMode::Mwax_Corr_Bf),
350 _ => Err(()),
351 }
352 }
353}
354
355#[derive(Debug, Clone, Copy, PartialEq, Eq)]
357#[cfg_attr(
358 any(feature = "python", feature = "python-stubgen"),
359 pyo3::pyclass(eq, eq_int, from_py_object)
360)]
361#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
362pub enum Pol {
363 X,
364 Y,
365}
366
367impl fmt::Display for Pol {
380 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
381 write!(
382 f,
383 "{}",
384 match self {
385 Pol::X => "X",
386 Pol::Y => "Y",
387 }
388 )
389 }
390}
391
392#[derive(Debug, Clone, Copy, PartialEq, Eq)]
394#[repr(C)]
395#[cfg_attr(
396 any(feature = "python", feature = "python-stubgen"),
397 pyo3::pyclass(eq, eq_int, from_py_object)
398)]
399#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
400#[allow(clippy::upper_case_acronyms)]
401pub enum ReceiverType {
402 Unknown,
403 RRI,
404 NI,
405 Pseudo,
406 SHAO,
407 EDA2,
408}
409
410impl fmt::Display for ReceiverType {
423 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
424 write!(
425 f,
426 "{}",
427 match self {
428 ReceiverType::Unknown => "Unknown",
429 ReceiverType::RRI => "RRI",
430 ReceiverType::NI => "NI",
431 ReceiverType::Pseudo => "Pseudo",
432 ReceiverType::SHAO => "SHAO",
433 ReceiverType::EDA2 => "EDA2",
434 }
435 )
436 }
437}
438
439impl std::str::FromStr for ReceiverType {
453 type Err = ();
454
455 fn from_str(input: &str) -> Result<ReceiverType, Self::Err> {
456 match input.to_uppercase().as_str() {
457 "RRI" => Ok(ReceiverType::RRI),
458 "NI" => Ok(ReceiverType::NI),
459 "PSEUDO" => Ok(ReceiverType::Pseudo),
460 "SHAO" => Ok(ReceiverType::SHAO),
461 "EDA2" => Ok(ReceiverType::EDA2),
462 _ => Ok(ReceiverType::Unknown),
463 }
464 }
465}
466
467#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive)]
469#[repr(C)]
470#[cfg_attr(
471 any(feature = "python", feature = "python-stubgen"),
472 pyo3::pyclass(eq, eq_int, from_py_object)
473)]
474#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass_enum)]
475#[allow(clippy::upper_case_acronyms)]
476pub enum DataFileType {
477 UnknownType = 0, RawVsib = 1, AvgVsib = 2, InstCfgTxt = 3, HdrTxt = 4, InstCfgHdr = 5, Lacspc = 6, Lccspc = 7, HwLfilesFits = 8, AntCfg = 9, Flag = 10, RawVolt = 11, RawVoltRecombined = 12, Uvfits = 13, Ppd = 14, Ics = 15, Tar = 16, Subfile = 17, MwaxFits = 18, Vdif = 19, Filterbank = 20, }
499
500impl fmt::Display for DataFileType {
513 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
514 write!(
515 f,
516 "{}",
517 match self {
518 DataFileType::UnknownType => "Unknown",
519 DataFileType::RawVsib => "RawVsib",
520 DataFileType::AvgVsib => "AvgVsib",
521 DataFileType::InstCfgTxt => "InstCfgTxt",
522 DataFileType::HdrTxt => "HdrTxt",
523 DataFileType::InstCfgHdr => "InstCfgHdr",
524 DataFileType::Lacspc => "Lacspc",
525 DataFileType::Lccspc => "Lccspc",
526 DataFileType::HwLfilesFits => "HwLfilesFits",
527 DataFileType::AntCfg => "AntCfg",
528 DataFileType::Flag => "Flag",
529 DataFileType::RawVolt => "RawVolt",
530 DataFileType::RawVoltRecombined => "RawVoltRecombined",
531 DataFileType::Uvfits => "Uvfits",
532 DataFileType::Ppd => "Ppd",
533 DataFileType::Ics => "Ics",
534 DataFileType::Tar => "Tar",
535 DataFileType::Subfile => "Subfile",
536 DataFileType::MwaxFits => "MwaxFits",
537 DataFileType::Vdif => "VDIF",
538 DataFileType::Filterbank => "Filterbank",
539 }
540 )
541 }
542}