Controller

struct ControllerState

Public Members

Pressure pressure_setpoint
Volume patient_volume
VolumetricFlow net_flow
VolumetricFlow flow_correction
uint64_t breath_id = {0}
class Controller

Public Functions

Controller() = default
std::pair<ActuatorsState, ControllerState> Run(Time now, const VentParams &params, const SensorReadings &sensor_readings)

Public Static Functions

static Duration GetLoopPeriod()

Private Types

using DbgFloat = Debug::Variable::Float
using DbgUint32 = Debug::Variable::UInt32
using DbgAccess = Debug::Variable::Access

Private Members

uint32_t breath_id_ = {0}
VentilationFsm fsm_
PID blower_valve_pid_{"blower_valve_", " for blower valvePID", 0.04f, 10.0f, 0.0f, PID::TermApplication::OnError, PID::TermApplication::OnMeasurement, 0.f, 1.0f}
PID psol_pid_{"psol", " for O2 psolPID", 0.04f, 20.0f, 0.0f, PID::TermApplication::OnError, PID::TermApplication::OnMeasurement, 0.f, 1.0f}
PID fio2_pid_{"fio2_", " for FIO2PID", 0.001f, 0.1f, 0.0f, PID::TermApplication::OnError, PID::TermApplication::OnMeasurement, 0.f, 1.0f}
std::optional<FlowIntegrator> flow_integrator_ = FlowIntegrator()
std::optional<FlowIntegrator> uncorrected_flow_integrator_ = FlowIntegrator()
bool ventilator_was_on_ = {false}
DbgUint32 dbg_loop_period_{"loop_period", DbgAccess::ReadOnly, static_cast<uint32_t>(GetLoopPeriod().microseconds()), "\xB5s", "Loop period"}
DbgFloat dbg_pc_setpoint_{"pc_setpoint", DbgAccess::ReadOnly, 0.0f, "cmH2O", "Pressure control set-point"}
DbgFloat dbg_fio2_setpoint_{"fio2_setpoint", DbgAccess::ReadOnly, 0.21f, "ratio", "FiO2 setpoint [0.0, 1.0] as commanded by GUI"}
DbgFloat dbg_net_flow_ = {"net_flow", DbgAccess::ReadOnly, 0.0f, "mL/s", "Net flow rate"}
DbgFloat dbg_net_flow_uncorrected_{"net_flow_uncorrected", DbgAccess::ReadOnly, 0.0f, "mL/s", "Net flow rate w/o correction"}
DbgFloat dbg_flow_correction_{"flow_correction", DbgAccess::ReadOnly, 0.0f, "mL/s", "Correction to flow"}
DbgFloat dbg_volume_ = {"volume", DbgAccess::ReadOnly, 0.0f, "mL", "Patient volume"}
DbgFloat dbg_volume_uncorrected_{"uncorrected_volume", DbgAccess::ReadOnly, 0.0f, "mL", "Patient volume w/o correction"}
DbgUint32 dbg_breath_id_ = {"breath_id", DbgAccess::ReadOnly, 0, "", "ID of the current breath"}