gmt_dos_clients_crseo/
lib.rs

1/*!
2#  GMT Optical Model
3
4A [gmt_dos-actors] client for optical propagation through the GMT using [crseo].
5
6[OpticalModel] represents the GMT optics model with M1 and M2 segmented optical prescriptions.
7An optical sensor may be added to [OpticalModel], available sensors are listed in the [sensors] module.
8The data processing algorithms applied to the [sensors] output are defined in the [processing] module.
9The [calibration] module contains the traits and types used for the calibration of the sensors with respect to either
10the rigid body motion or the shapes of M1 and M2.
11
12
13[gmt_dos-actors]: https://docs.rs/gmt_dos-actors
14[crseo]: https://docs.rs/crseo
15 */
16
17/* pub(crate) mod optical_model;
18pub use optical_model::{
19    OpticalModel, OpticalModelBuilder, OpticalModelOptions, PSSnOptions, ShackHartmannOptions,
20};
21pub(crate) mod shackhartmann;
22
23mod sensor;
24pub use sensor::SensorBuilder;
25*/
26
27use std::ops::{Deref, DerefMut};
28
29pub use crseo;
30use interface::{doublet::UidTuple, Data, TimerMarker, UniqueIdentifier, Update, Write};
31
32mod error;
33pub use error::{CeoError, Result};
34
35pub mod ngao;
36// pub use ngao::{DetectorFrame, GuideStar, ResidualM2modes, ResidualPistonMode, WavefrontSensor};
37//     , , OpticalModel, OpticalModelBuilder, ,
38//     , WavefrontSensor,
39// };
40
41mod wavefront_stats;
42pub use wavefront_stats::WavefrontStats;
43
44mod pyramid;
45pub use pyramid::{PyramidCalibrator, PyramidCommand, PyramidMeasurements, PyramidProcessor};
46
47// mod ltao;
48// pub use ltao::{
49//     Calibrate, CalibrateSegment, CalibrationMode, Centroids, DispersedFringeSensor,
50//     DispersedFringeSensorBuidler, DispersedFringeSensorProcessing, NoSensor, OpticalModel,
51//     OpticalModelBuilder, Reconstructor, WaveSensor, WaveSensorBuilder,
52// };
53
54pub mod calibration;
55mod optical_model;
56pub mod processing;
57pub mod sensors;
58
59pub use optical_model::{OpticalModel, OpticalModelError, builder::OpticalModelBuilder};
60pub use processing::{DispersedFringeSensorProcessing, centroiding};
61
62impl<T> TimerMarker for OpticalModel<T> {}
63impl<T> UidTuple for OpticalModel<T> {}
64
65/// Interface for initialization of data processing pipeline
66pub trait DeviceInitialize<D> {
67    /// Initialize a data processing pipeline `D`
68    fn initialize(&self, device: &mut D);
69}
70
71pub trait Processing {
72    type ProcessorData;
73    fn processing(&self) -> Self::ProcessorData;
74}
75
76/// Sensor data processor
77#[derive(Default, Debug)]
78pub struct Processor<P: Processing>(P);
79
80impl<P: Processing> From<P> for Processor<P> {
81    fn from(value: P) -> Self {
82        Processor(value)
83    }
84}
85
86impl<P: Processing> Deref for Processor<P> {
87    type Target = P;
88
89    fn deref(&self) -> &Self::Target {
90        &self.0
91    }
92}
93
94impl<P: Processing> DerefMut for Processor<P> {
95    fn deref_mut(&mut self) -> &mut Self::Target {
96        &mut self.0
97    }
98}
99
100impl<P: Processing + Send + Sync> Update for Processor<P> {
101    // fn update(&mut self) {
102    //     self.processing();
103    // }
104}
105
106impl<P, T> Write<T> for Processor<P>
107where
108    P: Processing + Send + Sync,
109    T: UniqueIdentifier<DataType = P::ProcessorData>,
110{
111    fn write(&mut self) -> Option<Data<T>> {
112        let data: <P as Processing>::ProcessorData = self.processing();
113        Some(Data::new(data))
114    }
115}
116
117/*
118
119#[cfg(feature = "crseo")]
120/// GMT M1 & M2 state
121#[derive(UID)]
122#[uid(data = "crseo::gmt::SegmentsDof")]
123pub enum GmtState {}
124pub enum PointingError {}
125impl UniqueIdentifier for PointingError {
126    type DataType = (f64, f64);
127}
128
129#[cfg(feature = "fem")]
130impl<S> dos_actors::io::Write<M1modes> for fem::dos::DiscreteModalSolver<S>
131where
132    S: fem::dos::Solver + Default,
133{
134    fn write(&mut self) -> Option<std::sync::Arc<dos_actors::io::Data<M1modes>>> {
135        let mut data: std::sync::Arc<dos_actors::io::Data<fem::dos::M1SegmentsAxialD>> =
136            self.write()?;
137        let inner = std::sync::Arc::get_mut(&mut data)?;
138        Some(std::sync::Arc::new(inner.into()))
139    }
140}
141 */