From ec82d9281adddd379fdadb8dc21b3c2a0d4ffb38 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:57:25 +0530 Subject: [PATCH] changes in starta and stop --- src/controllers/tanksController.js | 27 +++++++++++++++++++++++ src/routes/tanksRoute.js | 35 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 9daca387..a8b3a6fa 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2880,7 +2880,34 @@ exports.motoractiontest = async (req, reply) => { } }; +exports.motoractiontestbeforeqc = async (req, reply) => { + try { + + + + + + + + + if (action === "start") { + await this.publishMotorStopStatus(motor_id, "2"); + } else if (action === "stop") { + await this.publishMotorStopStatus(motor_id, "1"); + } else { + return reply.status(400).send({ success: false, message: "Invalid action" }); + } + + return reply.send({ success: true, message: `Motor ${action} command sent.` }); + + + + } catch (error) { + console.error("Error fetching data:", error); + return reply.status(500).send({ success: false, message: "Internal Server Error" }); + } +}; const motorIntervals = {}; diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index 3f098f0b..78e0951a 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -415,6 +415,41 @@ module.exports = function (fastify, opts, next) { }); + + fastify.route({ + method: "PUT", + url: "/api/motoractiontestbeforeqc", + schema: { + tags: ["Install"], + summary: "This is for start and stop test before qc", + + + + body: { + type: "object", + // required: ['phone'], + properties: { + + motor_id:{type:"string"}, + action:{type:"string"}, + + }, + }, + security: [ + { + basicAuth: [], + }, + ], + }, + // preHandler: [ + // fastify.auth([fastify.operatorAuthenticate]), + // validationHandler.validatePhoneFormat, + // ], + //preHandler: fastify.auth([fastify.authenticate]), + handler: tanksController.motoractiontestbeforeqc, + }); + + // fastify.route({ // method: "PUT", // url: "/api/consumption/:customerId",