Skip to content
Snippets Groups Projects
Commit 66c6020a authored by antoinekia's avatar antoinekia
Browse files

reed captors interractions

parent e37e1d54
No related branches found
No related tags found
No related merge requests found
Pipeline #18 passed with stage
in 32 seconds
/* Insérer ici les fonctions spécifiques à cette activité. Elles peuvent marcher
avec les fonctions et variables déjà définies dans 'activity_functions.js' du
dossier 'res'.*/
var reedStatus;
var reedsStatus = null;
var catchedFull = {LH2 : false, LOX2 : false, RP1 : false, LOX1 : false}
var catchTime = {LH2 : -1, LOX2 : -1, RP1 : -1, LOX1 : -1}
var checkReedsInterval = setInterval(function() {
if (receivedMsg.startsWith('REEDS')) {
reedsStatus = JSON.parse(receivedMsg.split('_')[1])
console.log(reedsStatus)
//console.log(reedsStatus)
for (var key of Object.keys(reedsStatus)) {
if (reedsStatus[key] && catchTime[key] == -1) {
catchTime[key] = Date.now()
console.log("Catch tank plein de ", key)
}
}
}
for (var key of Object.keys(catchedFull)) {
if (catchTime[key] != -1 && !catchedFull[key]) {
if (Date.now() - catchTime[key] > 3000) {
catchedFull[key] = true
alert("Aie aie aie ! Débordement non maitrisé !")
}
}
}
}, 250);
function init_var() {
catchedFull = {LH2 : false, LOX2 : false, RP1 : false, LOX1 : false}
catchTime = {LH2 : -1, LOX2 : -1, RP1 : -1, LOX1 : -1}
reedsStatus = null
}
function isTankFull(tankId) {
if (reedsStatus == null) return false
if (reedsStatus[tankId]) {
return true;
}
}
function stopLoading(tankId) {
if (reedsStatus[tankId]) {
catchedFull[tankId] = true
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment