Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: SBVentilatorChannel.hpp
- Revision:
- 0:7319afbc731c
- Child:
- 1:278bfa29bd0d
diff -r 000000000000 -r 7319afbc731c SBVentilatorChannel.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SBVentilatorChannel.hpp Sat Apr 11 01:15:10 2020 +0000
@@ -0,0 +1,82 @@
+/** SickBay Tek @version 0.x
+@link https://github.com/KabukiStarship/SickBay.git
+@file /Devices/Tek/SBVentilatorChannel.cpp
+@author Cale McCollough <https://cale-mccollough.github.io>
+@license Copyright 2020 (C) Kabuki Starship <kabukistarship.com>.
+This Source Code Form is subject to the terms of the Mozilla Public License,
+v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain
+one at <https://mozilla.org/MPL/2.0/>. */
+
+#include "SBVentilatorChannel.h"
+
+#include <_Config.h>
+using namespace _;
+
+namespace SickBay {
+
+SBVentilatorChannel::SBVentilatorChannel () :
+ Ticks (0),
+ TicksInhale (0),
+ TicksExhale (0),
+ PulseOximeter (0),
+ Servo (0),
+ ServoClosed (0),
+ ServoOpen (1) {}
+
+void SBVentilatorChannel::Init (SBVentilator* Parent, int TicksInhale,
+ int TicksExhale, float PressureHysteresis) {
+ this->Parent = Parent;
+ this->TicksInhale = TicksInhale;
+ this->TicksExhale = TicksExhale;
+ this->PressureHysteresis = Pressure * PressureHysteresis;
+}
+
+SBVentilatorChannel* SBVentilatorChannel::This() { return this; }
+
+void SBVentilatorChannel::TurnOff () {
+ Parent->ChannelValveSet(this, LLLow);
+ Ticks = 0;
+}
+
+void SBVentilatorChannel::TicksInhaleExhaleSet (int NewTicksInhale,
+ int NewTicksExhale) {
+ int Tick = Ticks;
+ if (Tick == 0) {
+ TicksInhale = NewTicksInhale;
+ TicksExhale = NewTicksExhale;
+ }
+ TicksInhale = NewTicksInhale;
+ TicksExhale = NewTicksExhale;
+ if (Tick < 0) { // We're exhaling.
+ if (Ticks > NewTicksExhale) {
+ Ticks = NewTicksExhale;
+ Inhale ();
+ }
+ }
+ else if (Tick > 0) { // We're inhaling.
+ if (Ticks > NewTicksInhale) {
+ Ticks = NewTicksInhale;
+ Exhale ();
+ }
+ return;
+ }
+}
+
+void SBVentilatorChannel::TickFlow () {
+ ++TicksFlow;
+}
+
+void SBVentilatorChannel::Inhale () {
+ DPrintf ("\n ? Inhaling. <");
+ Ticks = StateInhaling;
+ Parent->ChannelValveSet(this, LLHigh);
+}
+
+void SBVentilatorChannel::Exhale () {
+ DPrintf ("\n ? Exhaling. <");
+ Ticks = StateExhaling;
+ Parent->ChannelValveSet(this, LLLow);
+ TicksFlowLast = TicksFlow;
+}
+
+} //< namespace SickBay