feat(camera): Ajouter le statut 'stopping' pour gérer l'arrêt des projets et mettre à jour la documentation des routes
All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 9s

This commit is contained in:
2025-04-27 11:41:58 +02:00
parent 2533eacf5e
commit 4427e6dde0
4 changed files with 25 additions and 0 deletions

View File

@@ -158,6 +158,7 @@ module.exports = {
brouillon: 0, brouillon: 0,
capturing: 1, capturing: 1,
idle: 2, idle: 2,
stopping: 3 // Projet en cours d'arrêt
}, },
// Statuts pour les vidéos // Statuts pour les vidéos

View File

@@ -73,7 +73,12 @@ class CameraController {
* Initie l'arrêt de la procédure de capture * Initie l'arrêt de la procédure de capture
*/ */
static stopProcedure = asyncHandler(async (req, res) => { static stopProcedure = asyncHandler(async (req, res) => {
const { project_id } = req.body;
try { try {
// Met à jour le statut du projet en cours d'arrêt
await Project.updateProject(project_id, { status: config.projectStatus.stopping });
// Marque le drapeau d'arrêt // Marque le drapeau d'arrêt
await Camera.updateCamera(1, { stop_flag: true }); await Camera.updateCamera(1, { stop_flag: true });

View File

@@ -68,6 +68,10 @@ class Project {
static updateProjectStatus = wrapDatabaseOperation(async (id, status) => { static updateProjectStatus = wrapDatabaseOperation(async (id, status) => {
const query = `UPDATE projects SET status = $1 WHERE id = $2 RETURNING *;`; const query = `UPDATE projects SET status = $1 WHERE id = $2 RETURNING *;`;
const result = await db.query(query, [status, id]); const result = await db.query(query, [status, id]);
// Ajout du statut stopping pour les projets en cours d'arrêt
if (status === config.projectStatus.stopping) {
console.log(`[PROJECT] Projet ${id} mis à jour avec le statut 'stopping'.`);
}
return result.rows[0] || null; return result.rows[0] || null;
}); });

View File

@@ -49,6 +49,9 @@ router.get('/camera/status', CameraController.getCameraStatus);
* type: integer * type: integer
* description: Nombre total d'images à capturer * description: Nombre total d'images à capturer
* example: 48 * example: 48
* status:
* type: integer
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
* required: * required:
* - project_id * - project_id
* - interval * - interval
@@ -99,6 +102,9 @@ router.post('/procedure/start', CameraController.startProcedure);
* message: * message:
* type: string * type: string
* example: Procédure d'arrêt de la caméra initiée avec succès * example: Procédure d'arrêt de la caméra initiée avec succès
* status:
* type: integer
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
* 500: * 500:
* $ref: '#/components/responses/ServerError' * $ref: '#/components/responses/ServerError'
*/ */
@@ -123,6 +129,9 @@ router.post('/procedure/stop', CameraController.stopProcedure);
* message: * message:
* type: string * type: string
* example: Caméra arrêtée avec succès * example: Caméra arrêtée avec succès
* status:
* type: integer
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
* 500: * 500:
* $ref: '#/components/responses/ServerError' * $ref: '#/components/responses/ServerError'
*/ */
@@ -147,6 +156,9 @@ router.post('/camera/stop', CameraController.confirmStopProcedure);
* message: * message:
* type: string * type: string
* example: Caméra en mode maintenance * example: Caméra en mode maintenance
* status:
* type: integer
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
* 500: * 500:
* $ref: '#/components/responses/ServerError' * $ref: '#/components/responses/ServerError'
*/ */
@@ -171,6 +183,9 @@ router.post('/camera/maintenance', CameraController.activateMaintenance);
* message: * message:
* type: string * type: string
* example: Caméra sortie du mode maintenance * example: Caméra sortie du mode maintenance
* status:
* type: integer
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
* 500: * 500:
* $ref: '#/components/responses/ServerError' * $ref: '#/components/responses/ServerError'
*/ */