From c4d8fc14c88a158582eb7503add0fa88557c1bbb Mon Sep 17 00:00:00 2001 From: sabarinathan155 Date: Tue, 8 Apr 2025 17:17:36 +0530 Subject: [PATCH] ArmBot,staticmachine poits schema creation --- .../controller/assets/pointService.ts | 87 ++++++++++++++++++- .../simulation/assetsFloorservice.ts | 20 ++++- .../model/builder/assets/assetPoint-Model.ts | 34 +++++++- 3 files changed, 134 insertions(+), 7 deletions(-) diff --git a/src/api-server/controller/assets/pointService.ts b/src/api-server/controller/assets/pointService.ts index 9bbc079..be35767 100644 --- a/src/api-server/controller/assets/pointService.ts +++ b/src/api-server/controller/assets/pointService.ts @@ -45,12 +45,39 @@ interface IPointVehicle extends IPointBase { }; speed: number; } +interface IPointArmbot extends IPointBase { + rotation: number[]; + actions: { + uuid: string; + name: string; + speed: number; + processes: { triggerId: string; startPoint: string; endPoint: string }[] + }; + triggers: { uuid: string; name: string; type: string }; + connections: { + source: { modelUUID: string; pointUUID: string }; + targets: { modelUUID: string; pointUUID: string }[] + }; +} +interface IPointStaticMachine extends IPointBase{ + rotation: number[]; + actions: { + uuid: string; + name: string; + buffer: number | string; + material: string; + }, + triggers: { uuid: string; name: string; type: string }; + connections: { + source: { modelUUID: string; pointUUID: string }; + targets: { modelUUID: string; pointUUID: string }[] }; +} export class pointService { static async addPoints(req: Request, res: Response): Promise { const { type, modelfileID, organization } = req.body; // Validate type - if (!["Conveyor", "Vehicle"].includes(type)) { + if (!["Conveyor", "Vehicle","ArmBot","StaticMachine"].includes(type)) { return res.status(400).json({ message: "Invalid type requested" }); } @@ -203,6 +230,63 @@ export class pointService { points: vehiclePoint, }); } + if (type === "ArmBot") { + console.log("ArmBot data"); + const baseData = { + modelfileID: "67eb7904c2e8f37134527eae", + type: "ArmBot", + }; + const ArmBotPoint: IPointArmbot = { + uuid: "point1UUID", + position: [0, 2.75, -0.5], + rotation:[0,0,0], + actions: { + uuid: "randomUUID", + name: "Action 1", + speed:1, + processes:[{triggerId:"triggerId",startPoint:"startPoint",endPoint:"endPoint"}] + }, + triggers: { uuid: "randomUUID", name: "trigger 1", type: "OnComplete" }, + connections: { + source: { modelUUID: "modelUUID", pointUUID: "point1UUID" }, + targets: [{ modelUUID: "modelUUID", pointUUID: "point1UUID" }], + }, + }; + + + await pointModel(organization).create({ + ...baseData, + points: ArmBotPoint, + }); + } + if (type === "StaticMachine") { + console.log("StaticMachine data"); + const baseData = { + modelfileID: "67e3db5ac2e8f37134526f40", + type: "StaticMachine", + }; + const StaticMachinePoint: IPointStaticMachine = { + uuid: "point1UUID", + position: [0, 1.5, -0.5], + rotation:[0,0,0], + actions: { + uuid: "randomUUID", + name: "Action 1", + buffer: 0, material: "Inherit", + }, + triggers: { uuid: "randomUUID", name: "trigger 1", type: "OnComplete" }, + connections: { + source: { modelUUID: "modelUUID", pointUUID: "point1UUID" }, + targets: [{ modelUUID: "modelUUID", pointUUID: "point1UUID" }], + }, + }; + + + await pointModel(organization).create({ + ...baseData, + points: StaticMachinePoint, + }); + } return res.status(201).json({ message: "Points created successfully" }); } catch (error) { @@ -215,7 +299,6 @@ export class pointService { static async gettypePoints(req: Request, res: Response): Promise { const { modelfileID, organization } = req.params; - console.log("req.params: ", req.params); try { const pointData = await pointModel(organization) .findOne({ diff --git a/src/api-server/controller/simulation/assetsFloorservice.ts b/src/api-server/controller/simulation/assetsFloorservice.ts index 4e64d5d..eac7a2a 100644 --- a/src/api-server/controller/simulation/assetsFloorservice.ts +++ b/src/api-server/controller/simulation/assetsFloorservice.ts @@ -74,7 +74,12 @@ export class assetsFloorservice { message: "triggers is not allowed for Vehicle points", }); } - } + } + // else if(eventData.type === "ArmBot"){ + // assetData.speed = eventData.position; + // }else if(eventData.type === "StaticMachine"){ + // assetData.speed = eventData.position; + // } assetData.points = eventData.points; assetData.type = eventData.type; @@ -131,7 +136,18 @@ export class assetsFloorservice { points: item.points, }; } - + if (item.type === "ArmBot" && item.points) { + responseItem.eventData = { + type: item.type, + points: item.points, + }; + } + if (item.type === "StaticMachine" && item.points) { + responseItem.eventData = { + type: item.type, + points: item.points, + }; + } return responseItem; }); diff --git a/src/shared/model/builder/assets/assetPoint-Model.ts b/src/shared/model/builder/assets/assetPoint-Model.ts index 960f105..918d0ca 100644 --- a/src/shared/model/builder/assets/assetPoint-Model.ts +++ b/src/shared/model/builder/assets/assetPoint-Model.ts @@ -72,11 +72,39 @@ interface IPointVehicle extends IPointBase { }; } +interface IPointArmbot extends IPointBase { + rotation: number[]; + actions: { + uuid: string; + name: string; + speed: number; + processes: { triggerId: string; startPoint: string; endPoint: string }[] + }; + triggers: { uuid: string; name: string; type: string }; + connections: { + source: { modelUUID: string; pointUUID: string }; + targets: { modelUUID: string; pointUUID: string }[] + }; +} + +interface IPointStaticMachine extends IPointBase{ + rotation: number[]; + actions: { + uuid: string; + name: string; + buffer: number ; + material: string; + }, + triggers: { uuid: string; name: string; type: string }; + connections: { + source: { modelUUID: string; pointUUID: string }; + targets: { modelUUID: string; pointUUID: string }[] }; +} // Main Document Interface interface IPointModel extends Document { modelfileID: string; - type: "Conveyor" | "Vehicle"; - points: IPointConveyor[] | IPointVehicle; + type: "Conveyor" | "Vehicle" |"ArmBot" |"StaticMachine", + points: IPointConveyor[] | IPointVehicle |IPointArmbot |IPointStaticMachine; isArchive: boolean; } @@ -84,7 +112,7 @@ interface IPointModel extends Document { const PointSchema = new Schema( { modelfileID: { type: String }, - type: { type: String, enum: ["Conveyor", "Vehicle"], required: true }, + type: { type: String, enum: ["Conveyor", "Vehicle","ArmBot","StaticMachine"], required: true }, isArchive: { type: Boolean, default: false }, points: { type: Schema.Types.Mixed, // Flexible structure based on type