From e836e7dd4ed5e9fa60e949d159100040b22a8f48 Mon Sep 17 00:00:00 2001 From: Arne Rief Date: Mon, 22 Dec 2025 21:20:39 +0100 Subject: Movement simulator for all and single robot, project v1 ready --- backend/src/controllers/moveAllRobots.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/src/controllers/moveAllRobots.ts (limited to 'backend/src/controllers/moveAllRobots.ts') diff --git a/backend/src/controllers/moveAllRobots.ts b/backend/src/controllers/moveAllRobots.ts new file mode 100644 index 0000000..e4d1252 --- /dev/null +++ b/backend/src/controllers/moveAllRobots.ts @@ -0,0 +1,25 @@ +import { Request, Response } from "express"; +import { Server } from "socket.io"; +import { setAllRobotsMoving } from "../simulation/robotMovementSimulator"; +import { ErrorResponse } from "../types/error"; +import { SimulationResponse } from "../types/robot"; + +async function moveAllRobots(req: Request, res: Response) { + const io: Server = req.app.get("io"); + + try { + const result: SimulationResponse = await setAllRobotsMoving(io); + return res.status(200).json(result); + } catch (error) { + console.error("Error on trying to set all robots moving:", error); + + const errorResponse: ErrorResponse = { + message: + "Internal server error on trying to set all robots moving.", + error, + }; + return res.status(500).json(errorResponse); + } +} + +export default moveAllRobots; -- cgit v1.2.3