gmt_dos_clients_crseo/lib.rs
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
/*!
# CEO Optical Model
This module is a high-level interface to [crseo] and [crseo] is a Rust wrapper around CEO.
CEO is a CUDA-based optical propagation model for the GMT.
Follow the instructions [here](https://github.com/rconan/crseo) to install and to setup CEO.
A default optical model consists in the GMT and an on-axis source
```no_run
use gmt_dos_clients_crseo::OpticalModel;
let optical_model = OpticalModel::builder().build().expect("Failed to build CEO optical model");
```
*/
/* pub(crate) mod optical_model;
pub use optical_model::{
OpticalModel, OpticalModelBuilder, OpticalModelOptions, PSSnOptions, ShackHartmannOptions,
};
pub(crate) mod shackhartmann;
mod sensor;
pub use sensor::SensorBuilder;
*/
use std::ops::{Deref, DerefMut};
pub use crseo::{self, CrseoError};
use interface::{Data, Read, UniqueIdentifier, Update, Write};
mod error;
pub use error::{CeoError, Result};
mod ngao;
pub use ngao::{
DetectorFrame, GuideStar, OpticalModel, OpticalModelBuilder, ResidualM2modes,
ResidualPistonMode, WavefrontSensor,
};
mod wavefront_stats;
pub use wavefront_stats::WavefrontStats;
mod pyramid;
pub use pyramid::{PyramidCalibrator, PyramidCommand, PyramidMeasurements, PyramidProcessor};
mod calibration;
pub use calibration::{Calibrating, CalibratingError, Calibration};
pub trait Processing {
type ProcessorData;
fn processing(&self) -> Self::ProcessorData;
}
/// Sensor data processor
#[derive(Default, Debug)]
pub struct Processor<P: Processing>(P);
impl<P: Processing> From<P> for Processor<P> {
fn from(value: P) -> Self {
Processor(value)
}
}
impl<P: Processing> Deref for Processor<P> {
type Target = P;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<P: Processing> DerefMut for Processor<P> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<P: Processing + Send + Sync> Update for Processor<P> {
// fn update(&mut self) {
// self.processing();
// }
}
impl Read<DetectorFrame> for Processor<PyramidProcessor> {
fn read(&mut self, data: Data<DetectorFrame>) {
self.frame = data.as_arc();
}
}
impl<P, T> Write<T> for Processor<P>
where
P: Processing + Send + Sync,
T: UniqueIdentifier<DataType = P::ProcessorData>,
{
fn write(&mut self) -> Option<Data<T>> {
let data: <P as Processing>::ProcessorData = self.processing();
Some(Data::new(data))
}
}
/*
#[cfg(feature = "crseo")]
/// GMT M1 & M2 state
#[derive(UID)]
#[uid(data = "crseo::gmt::SegmentsDof")]
pub enum GmtState {}
pub enum PointingError {}
impl UniqueIdentifier for PointingError {
type DataType = (f64, f64);
}
#[cfg(feature = "fem")]
impl<S> dos_actors::io::Write<M1modes> for fem::dos::DiscreteModalSolver<S>
where
S: fem::dos::Solver + Default,
{
fn write(&mut self) -> Option<std::sync::Arc<dos_actors::io::Data<M1modes>>> {
let mut data: std::sync::Arc<dos_actors::io::Data<fem::dos::M1SegmentsAxialD>> =
self.write()?;
let inner = std::sync::Arc::get_mut(&mut data)?;
Some(std::sync::Arc::new(inner.into()))
}
}
*/