made changes in tanks controller

master
varun 2 years ago
parent 68036ab6d6
commit ed9f4aa4c6

@ -165,10 +165,11 @@ exports.updateTanklevels = async (req, reply) => {
const intervalId = setInterval(async function () {
const tank_data = await Tank.findOne({ _id:tankId });
const motorStatus = tank_data.motor_status
let waterLevel = parseInt(tank_data.waterlevel.replace(/,/g, ''), 10);
const newWaterLevel = Math.floor(waterLevel - 200);
console.log("motorstatus:"+motorStatus)
if (newWaterLevel <= 0 || motorStatus === "1") {
if (newWaterLevel <= 0 ) {
clearInterval(intervals[tankId]);
console.log(`Stopped updating tank with ID ${tankId}`);
return;
@ -185,7 +186,7 @@ exports.updateTanklevels = async (req, reply) => {
waterLevel = newWaterLevel;
// waterLevel = newWaterLevel;
}, 2000);
intervals[tankId] = intervalId;

Loading…
Cancel
Save