#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
use syunit::*;
use crate::SyncActuator;
use crate::parent::{ActuatorParent, RatioActuatorParent};
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Gear<C : SyncActuator> {
pub actuator : C,
pub ratio : f32
}
impl<C : SyncActuator> Gear<C> {
pub fn new(ctrl : C, ratio : f32) -> Self {
Self {
actuator: ctrl,
ratio
}
}
}
impl<C : SyncActuator> ActuatorParent for Gear<C> {
type Child = C;
fn child(&self) -> &Self::Child {
&self.actuator
}
fn child_mut(&mut self) -> &mut Self::Child {
&mut self.actuator
}
}
impl<C : SyncActuator> RatioActuatorParent for Gear<C> {
type Input = Rotary;
type Output = Rotary;
type Ratio = f32;
fn ratio(&self) -> Self::Ratio {
self.ratio
}
}