From 3eecb3d02fdfc6c96b3ed7abd7013dcc6313553b Mon Sep 17 00:00:00 2001 From: varun Date: Thu, 9 May 2024 07:31:05 -0400 Subject: [PATCH] changes --- src/controllers/tanksController.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 0110fa94..c122ddfb 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1175,6 +1175,10 @@ exports.calculateCapacity = async (req, reply) => { // reply.code(500).send({ error: err.message }); // } // }; + + + + exports.IotDevice = async (req, reply) => { try { const { hardwareId, mode, tanks } = req.body; @@ -1222,7 +1226,8 @@ exports.IotDevice = async (req, reply) => { const tank_height = parseInt(existingTank.height.replace(/,/g, ''), 10) * 30.48; const water_level_height = tank_height - tankHeight; const waterCapacityPerCm = parseInt(existingTank.waterCapacityPerCm.replace(/,/g, ''), 10); - const water_level = water_level_height * waterCapacityPerCm; + let water_level = water_level_height * waterCapacityPerCm; + water_level = Math.round(water_level); // Round to nearest whole number existingTank.waterlevel = water_level.toString(); // Convert to string as per schema definition // Save the updated tank document @@ -1259,6 +1264,8 @@ exports.IotDevice = async (req, reply) => { } }; + + // exports.getIotD = async(req, reply) => { // try { // await IotData.find({hardwareId: req.query.hardwareId})