Created
April 30, 2020 20:34
-
-
Save themakshter/73dc419b50fcc442566390e2ac9bce5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export default function dummyDataGenerator(updateReadingStateFunction) { | |
let intervalFunction; | |
function getRandomValue(range, valueToSubtract = 0) { | |
return Math.round(Math.random() * range - valueToSubtract); | |
} | |
function generateDummyReadings() { | |
return { | |
peep: getRandomValue(10), | |
peakPressure: getRandomValue(100, 100), | |
patientRate: getRandomValue(220), | |
vte: getRandomValue(700), | |
inspiratoryTime: getRandomValue(3), | |
expiratoryTime: getRandomValue(5).toFixed(1), | |
oxygen: getRandomValue(100), | |
flow: getRandomValue(30, 10), | |
}; | |
} | |
function startGenerating() { | |
intervalFunction = setInterval(() => { | |
const newReadings = generateDummyReadings(); | |
updateReadingStateFunction(newReadings); | |
}); | |
} | |
function stopGenerating() { | |
clearInterval(intervalFunction); | |
} | |
return { | |
startGenerating, | |
stopGenerating, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment