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.
SBVentilatorChannel.h@1:278bfa29bd0d, 2020-04-11 (annotated)
- Committer:
- kabukistarship
- Date:
- Sat Apr 11 08:48:12 2020 +0000
- Revision:
- 1:278bfa29bd0d
- Parent:
- 0:7319afbc731c
Detail.Tek.Describe The SickBay Device firmware toolkit built with Kabuki Tek. #76
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kabukistarship | 0:7319afbc731c | 1 | /** SickBay Tek @version 0.x |
kabukistarship | 0:7319afbc731c | 2 | @link https://github.com/KabukiStarship/SickBay.git |
kabukistarship | 0:7319afbc731c | 3 | @file /SBVentilatorChannel.h |
kabukistarship | 0:7319afbc731c | 4 | @author Cale McCollough <https://cale-mccollough.github.io> |
kabukistarship | 0:7319afbc731c | 5 | @license Copyright 2020 (C) Kabuki Starship <kabukistarship.com>. |
kabukistarship | 0:7319afbc731c | 6 | This Source Code Form is subject to the terms of the Mozilla Public License, |
kabukistarship | 0:7319afbc731c | 7 | v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain |
kabukistarship | 0:7319afbc731c | 8 | one at <https://mozilla.org/MPL/2.0/>. */ |
kabukistarship | 0:7319afbc731c | 9 | #pragma once |
kabukistarship | 0:7319afbc731c | 10 | #ifndef SBVentilatorChannelDecl |
kabukistarship | 0:7319afbc731c | 11 | #define SBVentilatorChannelDecl |
kabukistarship | 1:278bfa29bd0d | 12 | #include <_Config.h> |
kabukistarship | 0:7319afbc731c | 13 | #ifndef SBVentilatorChannelCount |
kabukistarship | 1:278bfa29bd0d | 14 | #define SBVentilatorChannelCount 1 |
kabukistarship | 0:7319afbc731c | 15 | #endif |
kabukistarship | 0:7319afbc731c | 16 | namespace SickBay { |
kabukistarship | 0:7319afbc731c | 17 | |
kabukistarship | 0:7319afbc731c | 18 | class SBVentilator; |
kabukistarship | 0:7319afbc731c | 19 | |
kabukistarship | 0:7319afbc731c | 20 | /* A Ventilator channel for one patient. */ |
kabukistarship | 0:7319afbc731c | 21 | class SBVentilatorChannel { |
kabukistarship | 0:7319afbc731c | 22 | public: |
kabukistarship | 0:7319afbc731c | 23 | |
kabukistarship | 0:7319afbc731c | 24 | enum { |
kabukistarship | 0:7319afbc731c | 25 | StateInhaling = 1, //< The inhaling state is where Ticks < 0. |
kabukistarship | 0:7319afbc731c | 26 | StateOff = 0, //< The off state is where Ticks = 0. |
kabukistarship | 0:7319afbc731c | 27 | StateExhaling = -1, //< The exhaling state is where Ticks > 0. |
kabukistarship | 0:7319afbc731c | 28 | }; |
kabukistarship | 0:7319afbc731c | 29 | |
kabukistarship | 0:7319afbc731c | 30 | SBVentilator* Parent; //< The SBVentilator this is part of. |
kabukistarship | 0:7319afbc731c | 31 | int Ticks, //< Ticks since the beginning of the inhale. |
kabukistarship | 0:7319afbc731c | 32 | TicksInhale, //< The tick count in the inhale duty cycle. |
kabukistarship | 0:7319afbc731c | 33 | TicksExhale, //< The period of the breathing. |
kabukistarship | 0:7319afbc731c | 34 | TicksFlow, //< The number of flow sensor ticks. |
kabukistarship | 0:7319afbc731c | 35 | TicksFlowLast, //< The previous inhale cycle TicksFlow count. |
kabukistarship | 0:7319afbc731c | 36 | PulseOximeter, //< The 7-pin pulse oximeter value. |
kabukistarship | 0:7319afbc731c | 37 | Servo, //< The Servo for reducing the pressrue. |
kabukistarship | 0:7319afbc731c | 38 | ServoClosed, //< The min servo duty cycle of no air flow. |
kabukistarship | 0:7319afbc731c | 39 | ServoOpen; //< The max servo duty cycle of an open tube. |
kabukistarship | 0:7319afbc731c | 40 | int32_t Temperature, //< The Temperature of the patients breath. |
kabukistarship | 0:7319afbc731c | 41 | TemperatureReference; //< The refernce temperature upon Tare. |
kabukistarship | 0:7319afbc731c | 42 | uint32_t Pressure, //< The pressure in the patient's mask. |
kabukistarship | 0:7319afbc731c | 43 | PressureReference, //< About 1 atmosphere + the hysteresis delta. |
kabukistarship | 0:7319afbc731c | 44 | PressureHysteresis; //< The hysteresis above the PressureReference. |
kabukistarship | 0:7319afbc731c | 45 | |
kabukistarship | 0:7319afbc731c | 46 | /* Initializes the channel. |
kabukistarship | 0:7319afbc731c | 47 | @param PressureHysteresis 1.0 + the percent hysteresis up and down from the |
kabukistarship | 0:7319afbc731c | 48 | center the |
kabukistarship | 0:7319afbc731c | 49 | */ |
kabukistarship | 0:7319afbc731c | 50 | void Init (SBVentilator* Parent, int TicksInhale, int TicksExhale, |
kabukistarship | 0:7319afbc731c | 51 | float ChannelPressureHysteresis); |
kabukistarship | 0:7319afbc731c | 52 | |
kabukistarship | 0:7319afbc731c | 53 | /* Doesn't do anything and requires a call to . */ |
kabukistarship | 0:7319afbc731c | 54 | SBVentilatorChannel (); |
kabukistarship | 0:7319afbc731c | 55 | |
kabukistarship | 0:7319afbc731c | 56 | /* Returns a pointer to this. */ |
kabukistarship | 0:7319afbc731c | 57 | SBVentilatorChannel* This(); |
kabukistarship | 0:7319afbc731c | 58 | |
kabukistarship | 0:7319afbc731c | 59 | void ChannelValveSet (SBVentilatorChannel* Channel, int Value); |
kabukistarship | 0:7319afbc731c | 60 | |
kabukistarship | 0:7319afbc731c | 61 | /* Turns this channel off. */ |
kabukistarship | 0:7319afbc731c | 62 | void TurnOff (); |
kabukistarship | 0:7319afbc731c | 63 | |
kabukistarship | 0:7319afbc731c | 64 | /* Sets the number of ticks on the inhale and exhale. */ |
kabukistarship | 0:7319afbc731c | 65 | void TicksInhaleExhaleSet (int NewTicksInhale, int NewTicksExhale); |
kabukistarship | 0:7319afbc731c | 66 | |
kabukistarship | 0:7319afbc731c | 67 | /* Increments theflow rate sensor pulse counter. */ |
kabukistarship | 0:7319afbc731c | 68 | void TickFlow (); |
kabukistarship | 0:7319afbc731c | 69 | |
kabukistarship | 0:7319afbc731c | 70 | /* Prints the state of object to the debug stream. */ |
kabukistarship | 0:7319afbc731c | 71 | void Print (int Index); |
kabukistarship | 0:7319afbc731c | 72 | |
kabukistarship | 0:7319afbc731c | 73 | /* Opens the solenoid valve. */ |
kabukistarship | 0:7319afbc731c | 74 | void Inhale (); |
kabukistarship | 0:7319afbc731c | 75 | |
kabukistarship | 0:7319afbc731c | 76 | /* Closes the solenoid valve. */ |
kabukistarship | 0:7319afbc731c | 77 | void Exhale (); |
kabukistarship | 0:7319afbc731c | 78 | |
kabukistarship | 0:7319afbc731c | 79 | /* Samples the Atmospheric pressure and temperature. */ |
kabukistarship | 0:7319afbc731c | 80 | void Tare (float PressureHysteresis); |
kabukistarship | 0:7319afbc731c | 81 | |
kabukistarship | 0:7319afbc731c | 82 | /* Monitor the channel for if errors. */ |
kabukistarship | 0:7319afbc731c | 83 | int Monitor (); |
kabukistarship | 0:7319afbc731c | 84 | |
kabukistarship | 0:7319afbc731c | 85 | /* Updates the channel with the DeviceTick. */ |
kabukistarship | 0:7319afbc731c | 86 | void Update(); |
kabukistarship | 0:7319afbc731c | 87 | }; |
kabukistarship | 0:7319afbc731c | 88 | } //< namespace SickBay |
kabukistarship | 0:7319afbc731c | 89 | #endif |