mod mimo;
mod siso;
pub use mimo::Mimo;
pub use siso::Siso;
use std::marker::PhantomData;
use nalgebra::{ComplexField, DVector, RealField};
use num_traits::Float;
use crate::{Discrete, StateSpace};
#[derive(Clone, Debug)]
pub struct DiscreteSystem<T, K = Mimo> {
model: StateSpace<T, Discrete>,
pub state: DVector<T>,
pub output: DVector<T>,
next_state: DVector<T>,
_kind: PhantomData<K>,
}
impl<T: Float + ComplexField + RealField, K> DiscreteSystem<T, K> {
pub fn model(&self) -> &StateSpace<T, Discrete> {
&self.model
}
pub fn reset(&mut self) {
self.state.fill(T::zero());
self.output.fill(T::zero());
}
fn at_rest(model: StateSpace<T, Discrete>) -> Self {
let state = DVector::zeros(model.order.system);
let output = DVector::zeros(model.order.output);
let next_state = state.clone();
Self { model, state, output, next_state, _kind: PhantomData }
}
fn with_kind<L>(self) -> DiscreteSystem<T, L> {
let Self { model, state, output, next_state, .. } = self;
DiscreteSystem { model, state, output, next_state, _kind: PhantomData }
}
}