ArmBot,staticmachine poits schema creation
This commit is contained in:
@@ -45,12 +45,39 @@ interface IPointVehicle extends IPointBase {
|
|||||||
};
|
};
|
||||||
speed: number;
|
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 {
|
export class pointService {
|
||||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||||
const { type, modelfileID, organization } = req.body;
|
const { type, modelfileID, organization } = req.body;
|
||||||
|
|
||||||
// Validate type
|
// Validate type
|
||||||
if (!["Conveyor", "Vehicle"].includes(type)) {
|
if (!["Conveyor", "Vehicle","ArmBot","StaticMachine"].includes(type)) {
|
||||||
return res.status(400).json({ message: "Invalid type requested" });
|
return res.status(400).json({ message: "Invalid type requested" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +230,63 @@ export class pointService {
|
|||||||
points: vehiclePoint,
|
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" });
|
return res.status(201).json({ message: "Points created successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -215,7 +299,6 @@ export class pointService {
|
|||||||
|
|
||||||
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||||
const { modelfileID, organization } = req.params;
|
const { modelfileID, organization } = req.params;
|
||||||
console.log("req.params: ", req.params);
|
|
||||||
try {
|
try {
|
||||||
const pointData = await pointModel(organization)
|
const pointData = await pointModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ export class assetsFloorservice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// else if(eventData.type === "ArmBot"){
|
||||||
|
// assetData.speed = eventData.position;
|
||||||
|
// }else if(eventData.type === "StaticMachine"){
|
||||||
|
// assetData.speed = eventData.position;
|
||||||
|
// }
|
||||||
|
|
||||||
assetData.points = eventData.points;
|
assetData.points = eventData.points;
|
||||||
assetData.type = eventData.type;
|
assetData.type = eventData.type;
|
||||||
@@ -131,7 +136,18 @@ export class assetsFloorservice {
|
|||||||
points: item.points,
|
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;
|
return responseItem;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// Main Document Interface
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
type: "Conveyor" | "Vehicle";
|
type: "Conveyor" | "Vehicle" |"ArmBot" |"StaticMachine",
|
||||||
points: IPointConveyor[] | IPointVehicle;
|
points: IPointConveyor[] | IPointVehicle |IPointArmbot |IPointStaticMachine;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +112,7 @@ interface IPointModel extends Document {
|
|||||||
const PointSchema = new Schema<IPointModel>(
|
const PointSchema = new Schema<IPointModel>(
|
||||||
{
|
{
|
||||||
modelfileID: { type: String },
|
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 },
|
isArchive: { type: Boolean, default: false },
|
||||||
points: {
|
points: {
|
||||||
type: Schema.Types.Mixed, // Flexible structure based on type
|
type: Schema.Types.Mixed, // Flexible structure based on type
|
||||||
|
|||||||
Reference in New Issue
Block a user