From 9a5e5291c46dd779af9aac666ae294c41758951c Mon Sep 17 00:00:00 2001 From: varun Date: Wed, 3 May 2023 07:05:00 -0400 Subject: [PATCH] made changes in tanks controller --- src/controllers/tanksController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 8f397f23..c8a156d8 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -160,7 +160,7 @@ exports.updateTanklevels = async (req, reply) => { const tankId = tank._id; const tank_name = tank.tankName let capacity = parseInt(tank.capacity.replace(/,/g, ''), 10); - // let waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10); + let waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10); const intervalId = setInterval(async function () { const waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10); @@ -168,7 +168,7 @@ exports.updateTanklevels = async (req, reply) => { const motorStatus = tank.motor_status const newWaterLevel = Math.floor(waterLevel - 200); - if (newWaterLevel <= 0) { + if (newWaterLevel <= 0,motorStatus === "1") { clearInterval(intervals[tankId]); console.log(`Stopped updating tank with ID ${tankId}`); return; @@ -185,7 +185,7 @@ exports.updateTanklevels = async (req, reply) => { - //waterLevel = newWaterLevel; + waterLevel = newWaterLevel; }, 2000); intervals[tankId] = intervalId;