changes in tanks and start and stop regarding bore to sump

master
varun 3 years ago
parent 68f92cee98
commit d88bb6578a

@ -292,7 +292,7 @@ exports.motorAction = async (req, reply) => {
const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10) const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
// Check if updating should stop // Check if updating should stop
if ((newSupplierWaterLevel/supplier_capacity)*100 <= 5 || (newWaterLevel/receiver_capacity)*100 >= 95 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === 0) { if ((newSupplierWaterLevel/supplier_capacity)*100 <= 5 || (newWaterLevel/receiver_capacity)*100 >= 95 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0") {
clearInterval(intervalId) clearInterval(intervalId)
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: 0 } }); await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: 0 } });
@ -370,10 +370,11 @@ exports.motorAction = async (req, reply) => {
intervalId = setInterval(async function () { intervalId = setInterval(async function () {
// Calculate new water levels // Calculate new water levels
const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type}); const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
console.log(rcvr_info.motor_status)
const newWaterLevel = receiver_waterlevel+200; const newWaterLevel = receiver_waterlevel+200;
console.log(newWaterLevel,"2") console.log(newWaterLevel,"2")
// Check if updating should stop // Check if updating should stop
if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === 0 ) { if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0" ) {
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: 0 } }); await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: 0 } });
clearInterval(intervalId) clearInterval(intervalId)

Loading…
Cancel
Save