ArmBot,staticmachine poits schema creation

This commit is contained in:
2025-04-08 17:17:36 +05:30
parent e7216d9116
commit c4d8fc14c8
3 changed files with 134 additions and 7 deletions

View File

@@ -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<any> {
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<any> {
const { modelfileID, organization } = req.params;
console.log("req.params: ", req.params);
try {
const pointData = await pointModel(organization)
.findOne({