|
|
@ -160,7 +160,7 @@ exports.updateTanklevels = async (req, reply) => {
|
|
|
|
const tankId = tank._id;
|
|
|
|
const tankId = tank._id;
|
|
|
|
const tank_name = tank.tankName
|
|
|
|
const tank_name = tank.tankName
|
|
|
|
let capacity = parseInt(tank.capacity.replace(/,/g, ''), 10);
|
|
|
|
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 intervalId = setInterval(async function () {
|
|
|
|
const waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
const waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
@ -168,7 +168,7 @@ exports.updateTanklevels = async (req, reply) => {
|
|
|
|
const motorStatus = tank.motor_status
|
|
|
|
const motorStatus = tank.motor_status
|
|
|
|
const newWaterLevel = Math.floor(waterLevel - 200);
|
|
|
|
const newWaterLevel = Math.floor(waterLevel - 200);
|
|
|
|
|
|
|
|
|
|
|
|
if (newWaterLevel <= 0) {
|
|
|
|
if (newWaterLevel <= 0,motorStatus === "1") {
|
|
|
|
clearInterval(intervals[tankId]);
|
|
|
|
clearInterval(intervals[tankId]);
|
|
|
|
console.log(`Stopped updating tank with ID ${tankId}`);
|
|
|
|
console.log(`Stopped updating tank with ID ${tankId}`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -185,7 +185,7 @@ exports.updateTanklevels = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//waterLevel = newWaterLevel;
|
|
|
|
waterLevel = newWaterLevel;
|
|
|
|
}, 2000);
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
|
|
|
|
intervals[tankId] = intervalId;
|
|
|
|
intervals[tankId] = intervalId;
|
|
|
|