Created
May 9, 2020 19:03
-
-
Save themakshter/1e1d5b000569a19dbe6864afd854e23b to your computer and use it in GitHub Desktop.
Ventilation Mode Parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const VentilationModes = ['VCV', 'PCV', 'AC-VCV', 'AC-PCV', 'CPAP']; | |
const ventilationMode = getVentilationMode(Data[29]); | |
function getVentilationMode(valueToParse: number): string { | |
// 0x1C is 00011100 so we find the values contain in bits 2-4 | |
// we also want the index to retrieve the correct mode from our array | |
// so we shift the bits to the end to get the actual value | |
const ventilationModeIndex = (valueToParse & 0x1C) >> 2; | |
return VentilationModes[ventilationModeIndex]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment