|
|
@ -573,184 +573,67 @@ module.exports = function (fastify, opts, next) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
fastify.post('/api/motor/write', {
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
|
|
url: '/api/motors/start',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
schema: {
|
|
|
|
tags: ["Tank"],
|
|
|
|
tags: ["Tank"],
|
|
|
|
description: "This is to start motor using IOT",
|
|
|
|
description: "This is to Write the motor status",
|
|
|
|
summary: "This is to start motor using IOT",
|
|
|
|
summary: "This is to Write the motor status",
|
|
|
|
body: {
|
|
|
|
body: {
|
|
|
|
type: 'object',
|
|
|
|
type: 'object',
|
|
|
|
|
|
|
|
required: ['motor_id', 'status'],
|
|
|
|
properties: {
|
|
|
|
properties: {
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
status: { type: 'string', enum: ['on', 'off'] },
|
|
|
|
|
|
|
|
current: { type: 'string' },
|
|
|
|
|
|
|
|
temp: { type: 'string' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["motor_id"]
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: tanksController.startmotoriot
|
|
|
|
handler: tanksController.writeMotorStatus
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
|
|
url: '/api/motors/stop',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.get('/api/motor/read', {
|
|
|
|
schema: {
|
|
|
|
schema: {
|
|
|
|
tags: ["Tank"],
|
|
|
|
tags: ["Tank"],
|
|
|
|
description: "This is to stop motor using IOT",
|
|
|
|
description: "This is to Read the motor status",
|
|
|
|
summary: "This is to stop motor using IOT",
|
|
|
|
summary: "This is to Read the motor status",
|
|
|
|
body: {
|
|
|
|
querystring: {
|
|
|
|
type: 'object',
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
properties: {
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["motor_id"]
|
|
|
|
// required: ['motor_id'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: tanksController.stopmotoriot
|
|
|
|
handler: tanksController.readMotorStatus
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
fastify.post('/api/motor/changeMotorStatus', {
|
|
|
|
method: 'GET',
|
|
|
|
|
|
|
|
url: '/api/motors/status/:motor_id',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
schema: {
|
|
|
|
tags: ["Tank"],
|
|
|
|
tags: ["Tank"],
|
|
|
|
description: "This is to get motor status",
|
|
|
|
description: "This is to change the motor status",
|
|
|
|
summary: "This is to get motor status",
|
|
|
|
summary: "This is to change the motor status",
|
|
|
|
params: {
|
|
|
|
|
|
|
|
required: ["motor_id"],
|
|
|
|
|
|
|
|
type: "object",
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
motor_id: {
|
|
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
|
|
description: "motor_id",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handler: tanksController.motorstatus
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
|
|
url: '/api/motors/speed',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
|
|
|
|
tags: ["Tank"],
|
|
|
|
|
|
|
|
description: "This is to change motor pumping speed using IOT",
|
|
|
|
|
|
|
|
summary: "This is to to change motor pumping speed using IOT",
|
|
|
|
|
|
|
|
body: {
|
|
|
|
body: {
|
|
|
|
type: 'object',
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
properties: {
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
speed: { type: 'string' },
|
|
|
|
action: { type: 'string' },
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["motor_id"]
|
|
|
|
required: ["motor_id"]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: tanksController.motorspeed
|
|
|
|
handler: tanksController.changeMotorStatus
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
|
|
|
|
method: 'GET',
|
|
|
|
|
|
|
|
url: '/api/motors/temperature/:motor_id',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
|
|
|
|
tags: ["Tank"],
|
|
|
|
|
|
|
|
description: "This is to get motor temperature",
|
|
|
|
|
|
|
|
summary: "This is to get motor temperature",
|
|
|
|
|
|
|
|
params: {
|
|
|
|
|
|
|
|
required: ["motor_id"],
|
|
|
|
|
|
|
|
type: "object",
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
motor_id: {
|
|
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
|
|
description: "motor_id",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handler: tanksController.motortemperature
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.post('/api/motor/write', {
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
|
|
|
|
tags: ["Tank"],
|
|
|
|
|
|
|
|
description: "This is to Write the motor status",
|
|
|
|
|
|
|
|
summary: "This is to Write the motor status",
|
|
|
|
|
|
|
|
body: {
|
|
|
|
|
|
|
|
type: 'object',
|
|
|
|
|
|
|
|
required: ['motor_id', 'status'],
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
status: { type: 'string', enum: ['on', 'off'] },
|
|
|
|
|
|
|
|
current: { type: 'string' },
|
|
|
|
|
|
|
|
temp: { type: 'string' },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// response: {
|
|
|
|
|
|
|
|
// 200: {
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// // Define your response properties here
|
|
|
|
|
|
|
|
// motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
// status: { type: 'string' },
|
|
|
|
|
|
|
|
// current: { type: 'string' },
|
|
|
|
|
|
|
|
// temp: { type: 'string' },
|
|
|
|
|
|
|
|
// // Add other properties as needed
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
handler: tanksController.writeMotorStatus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fastify.get('/api/motor/read', {
|
|
|
|
|
|
|
|
// schema: {
|
|
|
|
|
|
|
|
// tags: ["Tank"],
|
|
|
|
|
|
|
|
// description: "This is to Read the motor status",
|
|
|
|
|
|
|
|
// summary: "This is to Read the motor status",
|
|
|
|
|
|
|
|
// querystring: {
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
// action: { type: 'string', enum: ['1', '2'] },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// // required: ['motor_id'],
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// // response: {
|
|
|
|
|
|
|
|
// // 200: {
|
|
|
|
|
|
|
|
// // type: 'object',
|
|
|
|
|
|
|
|
// // properties: {
|
|
|
|
|
|
|
|
// // // Define your response properties here
|
|
|
|
|
|
|
|
// // motor_id: { type: 'string' },
|
|
|
|
|
|
|
|
// // motor_status: { type: 'string' },
|
|
|
|
|
|
|
|
// // motor_speed: { type: 'string' },
|
|
|
|
|
|
|
|
// // motor_temperature: { type: 'string' },
|
|
|
|
|
|
|
|
// // // Add other properties as needed
|
|
|
|
|
|
|
|
// // },
|
|
|
|
|
|
|
|
// // },
|
|
|
|
|
|
|
|
// // },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// handler: tanksController.readMotorStatus
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|