ashok 8 months ago
commit 9aa618fcdf

@ -2934,8 +2934,11 @@ exports.motorAction = async (req, reply) => {
);
}
}
const thresholdTime = new Date(new Date().getTime() + req.body.manual_threshold_time * 60000);
console.log("New Threshold Time:", thresholdTime);
console.log("Current Time:", new Date());
motorIntervals[motorId] = setInterval(async () => {
const supplierTank = await Tank.findOne({ customerId, tankName: req.body.from, tankLocation: req.body.from_type.toLowerCase() });
const currentWaterLevel = parseInt(supplierTank.waterlevel, 10);
@ -2999,9 +3002,19 @@ exports.motorAction = async (req, reply) => {
}
);
if (motorIntervals[motorId]) {
console.log(`🛑 Clearing interval for motorId: ${motorId}`);
clearInterval(motorIntervals[motorId]);
delete motorIntervals[motorId];
// Confirm deletion
if (!motorIntervals[motorId]) {
console.log(`✅ Interval for motorId: ${motorId} successfully deleted.`);
} else {
console.error(`❌ Failed to delete interval for motorId: ${motorId}`);
}
}
clearInterval(motorIntervals[motorId]); // Stop the motor if condition met
delete motorIntervals[motorId]; // Remove from interval object
this.publishMotorStopStatus(motorId, "1");
console.log(start_instance_id,"start_instance_id",customerId,"customerId",motorId,"motorId")

Loading…
Cancel
Save