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({

View File

@@ -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;
});

View File

@@ -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<IPointModel>(
{
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