|
|
@ -252,6 +252,8 @@ exports.getTanklevels = async (req, reply) => {
|
|
|
|
const intervals = {};
|
|
|
|
const intervals = {};
|
|
|
|
let sum_oh_count = 0
|
|
|
|
let sum_oh_count = 0
|
|
|
|
let bore_sump_count = 0
|
|
|
|
let bore_sump_count = 0
|
|
|
|
|
|
|
|
let sump_sump_count = 0
|
|
|
|
|
|
|
|
|
|
|
|
exports.motorAction = async (req, reply) => {
|
|
|
|
exports.motorAction = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//let start_time,stop_time
|
|
|
|
//let start_time,stop_time
|
|
|
@ -411,6 +413,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
connection.motor_status = "1";
|
|
|
|
connection.motor_status = "1";
|
|
|
|
await sumpTank.save();
|
|
|
|
await sumpTank.save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sump_sump_count++;
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(receiver_capacity,"0",receiver_tank_info.tankName)
|
|
|
|
// console.log(receiver_capacity,"0",receiver_tank_info.tankName)
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
|
|
|
@ -428,15 +431,14 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel - 300);// Math.floor(supplier_waterlevel * 0.15));
|
|
|
|
const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel - 300);// Math.floor(supplier_waterlevel * 0.15));
|
|
|
|
// 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" || (newSupplierWaterLevel/supplier_capacity)*100 <= 5 ) {
|
|
|
|
if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0" || (newSupplierWaterLevel/supplier_capacity)*100 <= 5 ) {
|
|
|
|
|
|
|
|
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
|
|
|
|
sump_sump_count--;
|
|
|
|
|
|
|
|
if (sump_sump_count===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" } });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("end for" + receiver_tank);
|
|
|
|
console.log("end for" + receiver_tank);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Update water levels in database
|
|
|
|
// Update water levels in database
|
|
|
@ -566,8 +568,12 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
if (supplier_tank_type === "sump" && receiver_type ==="sump"){
|
|
|
|
if (supplier_tank_type === "sump" && receiver_type ==="sump"){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sump_sump_count--;
|
|
|
|
|
|
|
|
if (sump_sump_count===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" } });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|