#[cfg(fem)]
mod builder;
#[cfg(fem)]
mod servos;
#[cfg(fem)]
mod fem {
use crate::builder::ServosBuilderError;
#[cfg(topend = "ASM")]
pub use crate::builder::{AsmsServo, asms_servo};
pub use crate::builder::{EdgeSensors, FemIO, M1SegmentFigure, ServosBuilder, WindLoads};
pub use crate::servos::GmtServoMechanisms;
use gmt_dos_actors::system::{Sys, SystemError};
#[cfg(not(feature = "cuda"))]
pub(crate) type FemSolver = gmt_dos_clients_fem::solvers::ExponentialMatrix;
#[cfg(feature = "cuda")]
pub(crate) type FemSolver = gmt_dos_clients_fem::solvers::CuStateSpace;
impl<const M1_RATE: usize, const M2_RATE: usize> GmtServoMechanisms<M1_RATE, M2_RATE> {
pub fn new(
sim_sampling_frequency: f64,
fem: gmt_fem::FEM,
) -> ServosBuilder<M1_RATE, M2_RATE> {
ServosBuilder {
sim_sampling_frequency,
fem,
..Default::default()
}
}
}
impl From<ServosBuilderError> for SystemError {
fn from(value: ServosBuilderError) -> Self {
SystemError::SubSystem(format!("{:?}", value))
}
}
impl<const M1_RATE: usize, const M2_RATE: usize> ServosBuilder<M1_RATE, M2_RATE> {
pub fn build(self) -> Result<Sys<GmtServoMechanisms<M1_RATE, M2_RATE>>, SystemError> {
log::info!("building ServosBuilder");
Ok(Sys::new(GmtServoMechanisms::<M1_RATE, M2_RATE>::try_from(self)?).build()?)
}
}
impl<const M1_RATE: usize, const M2_RATE: usize> TryFrom<ServosBuilder<M1_RATE, M2_RATE>>
for Sys<GmtServoMechanisms<M1_RATE, M2_RATE>>
{
type Error = SystemError;
fn try_from(builder: ServosBuilder<M1_RATE, M2_RATE>) -> Result<Self, Self::Error> {
builder.build()
}
}
pub type GmtFem = gmt_dos_clients_fem::DiscreteModalSolver<FemSolver>;
pub type GmtM1 = gmt_dos_systems_m1::assembly::DispatchIn;
pub type GmtM1Out = gmt_dos_systems_m1::assembly::DispatchOut;
pub type GmtMount = gmt_dos_clients_mount::Mount;
pub type GmtM2Hex = gmt_dos_clients_m2_ctrl::Positioners;
pub type GmtM2 = gmt_dos_systems_m2::DispatchIn;
#[cfg(test)]
mod tests {
use std::error::Error;
use gmt_dos_actors::actorscript;
use gmt_dos_clients::timer::Timer;
use interface::Tick;
pub use super::*;
#[test]
fn builder() {
let frequency = 1000_f64; let fem = gmt_fem::FEM::from_env().unwrap();
assert!(
GmtServoMechanisms::<10, 1>::new(frequency, fem)
.build()
.is_ok()
);
}
}
}
#[cfg(fem)]
pub use fem::*;