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