|
|
|
@ -152,7 +152,7 @@ exports.getTank = async (req, reply) => {
|
|
|
|
|
exports.updateTanklevels = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
const tanks = await Tank.find({ customerId });
|
|
|
|
|
const tanks = await Tank.find({ customerId,tankLocation:"overhead" });
|
|
|
|
|
|
|
|
|
|
const intervals = {};
|
|
|
|
|
|
|
|
|
@ -166,7 +166,7 @@ exports.updateTanklevels = async (req, reply) => {
|
|
|
|
|
const tank_data = await Tank.findOne({ _id:tankId });
|
|
|
|
|
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 - 150);
|
|
|
|
|
console.log("motorstatus:"+motorStatus)
|
|
|
|
|
|
|
|
|
|
if (newWaterLevel <= 0 ) {
|
|
|
|
@ -243,7 +243,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
if(action === "start"){
|
|
|
|
|
const start_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'})
|
|
|
|
|
|
|
|
|
|
const stop_at = req.body.stop_at
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -281,7 +281,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
|
|
|
|
|
console.log((newSupplierWaterLevel/supplier_capacity)*100)
|
|
|
|
|
// 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 <= stop_at || (newWaterLevel/receiver_capacity)*100 >= 95 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0") {
|
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
|
sum_oh_count--;
|
|
|
|
@ -400,7 +400,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const newWaterLevel = receiver_waterlevel + 300//Math.floor(supplier_waterlevel * 0.1);
|
|
|
|
|
const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel - 300);// Math.floor(supplier_waterlevel * 0.15));
|
|
|
|
|
// 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 <= stop_at ) {
|
|
|
|
|
|
|
|
|
|
clearInterval(intervals[interval_variable]); // Clear the interval for this tank
|
|
|
|
|
delete intervals[interval_variable];
|
|
|
|
@ -432,9 +432,6 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(supplier_tank_type==="bore" && receiver_type === "sump"){
|
|
|
|
|
const receiver_capacity = parseInt(receiver_tank_info.capacity.replace(/,/g, ''), 10)
|
|
|
|
|