use serde::{Serialize, Deserialize};
use crate::{SyncActuator, Setup};
use crate::act::parent::{ActuatorParent, RatioActuatorParent};
use syunit::*;
#[derive(Debug)]
#[derive(Serialize, Deserialize)]
pub struct Conveyor<C : SyncActuator> {
device : C,
pub r_roll : f32
}
impl<C : SyncActuator> Conveyor<C> {
pub fn new(device : C, r_roll : f32) -> Self {
Self {
device,
r_roll
}
}
}
impl<C : SyncActuator> Setup for Conveyor<C> {
fn setup(&mut self) -> Result<(), crate::Error> {
self.device.setup()
}
}
impl<C : SyncActuator> ActuatorParent for Conveyor<C> {
type Child = C;
fn child(&self) -> &Self::Child {
&self.device
}
fn child_mut(&mut self) -> &mut Self::Child {
&mut self.device
}
}
impl<C : SyncActuator> RatioActuatorParent for Conveyor<C> {
fn ratio(&self) -> f32 {
self.r_roll
}
fn force_for_child(&self, parent_force : Force) -> Force {
parent_force * (self.ratio() / 1000.0) }
fn force_for_parent(&self, child_force : Force) -> Force {
child_force / (self.ratio() / 1000.0) }
fn inertia_for_child(&self, parent_inertia : Inertia) -> Inertia {
parent_inertia * (self.ratio() / 1000.0) * (self.ratio() / 1000.0)
}
fn inertia_for_parent(&self, child_intertia : Inertia) -> Inertia {
child_intertia / (self.ratio() / 1000.0) / (self.ratio() / 1000.0)
}
}