|
|
|
@ -274,7 +274,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
// Calculate new water levels
|
|
|
|
|
const supplier_tank_info2 = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type});
|
|
|
|
|
const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
|
|
|
|
|
const newWaterLevel = receiver_waterlevel + 250//Math.floor(supplier_waterlevel * 0.1);
|
|
|
|
|
const newWaterLevel = receiver_waterlevel + (250*sum_oh_count)//Math.floor(supplier_waterlevel * 0.1);
|
|
|
|
|
const newSupplierWaterLevel = supplier_waterlevel//Math.floor(supplier_waterlevel * 0.1);
|
|
|
|
|
const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
|
|
|
|
|
console.log((newSupplierWaterLevel/supplier_capacity)*100)
|
|
|
|
@ -283,7 +283,11 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
|
sum_oh_count--;
|
|
|
|
|
if (sum_oh_count===0){
|
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const overheadTank = await Tank.findOne({ customerId, tankName: receiver_tank, tankLocation: receiver_type });
|
|
|
|
|
const connection = overheadTank.connections.inputConnections.find((conn) => conn.inputConnections === supplier_tank);
|
|
|
|
|
|
|
|
|
@ -382,15 +386,18 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
|
|
|
|
|
//console.log(rcvr_info)
|
|
|
|
|
//console.log(rcvr_info.motor_status)
|
|
|
|
|
const newWaterLevel = receiver_waterlevel+250;
|
|
|
|
|
const newWaterLevel = receiver_waterlevel+(250*bore_sump_count);
|
|
|
|
|
//console.log(newWaterLevel,"2",receiver_tank_info.tankName)
|
|
|
|
|
// Check if updating should stop
|
|
|
|
|
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" } });
|
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
|
bore_sump_count--;
|
|
|
|
|
if (bore_sump_count===0){
|
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const sumpTank = await Tank.findOne({ customerId, tankName: receiver_tank, tankLocation: receiver_type });
|
|
|
|
|
const connection = sumpTank.connections.inputConnections.find((conn) => conn.inputConnections === supplier_tank);
|
|
|
|
|
|
|
|
|
@ -442,6 +449,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const motor_data = await motorData.save();
|
|
|
|
|
console.log(motor_data)
|
|
|
|
|
// reply.send({ status_code: 200, data: motor_data });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|