API creation for Product EventDatas and updating asset files
This commit is contained in:
@@ -3,9 +3,9 @@ import MainModel from '../../connect/mongoose.ts';
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface floorItenms extends Document {
|
||||
modeluuid: string;
|
||||
modelUuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string
|
||||
modelName: string
|
||||
isLocked:boolean
|
||||
isVisible:boolean
|
||||
position: []
|
||||
@@ -20,9 +20,9 @@ export interface floorItenms extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const floorItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String },
|
||||
modelUuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
modelName: { type: String },
|
||||
position: { type: Array},
|
||||
isLocked:{type:Boolean},
|
||||
isVisible:{type:Boolean},
|
||||
|
||||
@@ -2,8 +2,8 @@ import mongoose, { Document, Schema } from 'mongoose';
|
||||
import MainModel from '../../connect/mongoose.ts';
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface wallitems extends Document {
|
||||
modeluuid: string;
|
||||
modelname: string
|
||||
modelUuid: string;
|
||||
modelName: string
|
||||
type: string
|
||||
csgposition: []
|
||||
csgscale: []
|
||||
@@ -16,8 +16,8 @@ export interface wallitems extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const wallItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String,unique:true },
|
||||
modelname: { type: String},
|
||||
modelUuid: { type: String,unique:true },
|
||||
modelName: { type: String},
|
||||
type: { type: String },
|
||||
csgposition: { type: Array},
|
||||
csgscale: { type: Array,},
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
interface ICommonBase{
|
||||
type: string;
|
||||
}
|
||||
interface IPointsConveyor extends ICommonBase{
|
||||
points?: {
|
||||
Uuid:string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
}[];
|
||||
}
|
||||
interface IPoint extends ICommonBase{
|
||||
point?: {
|
||||
Uuid:string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
};
|
||||
}
|
||||
export interface assetData extends Document {
|
||||
modeluuid: string;
|
||||
modelUuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string;
|
||||
modelName: string;
|
||||
isLocked: boolean;
|
||||
type: string;
|
||||
isVisible: boolean;
|
||||
isArchive: false;
|
||||
points: [] | {};
|
||||
// points: [] | {};
|
||||
position: [];
|
||||
rotation: {
|
||||
x: number;
|
||||
@@ -17,15 +34,17 @@ export interface assetData extends Document {
|
||||
z: number;
|
||||
};
|
||||
speed: number | string;
|
||||
eventData: IPoint|IPointsConveyor
|
||||
}
|
||||
|
||||
|
||||
const assetDataSchema: Schema = new Schema({
|
||||
isArchive: { type: Boolean, default: false },
|
||||
modeluuid: { type: String },
|
||||
modelUuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
modelName: { type: String },
|
||||
type: { type: String },
|
||||
points: { type: Schema.Types.Mixed },
|
||||
// points: { type: Schema.Types.Mixed },
|
||||
position: { type: Array },
|
||||
rotation: {
|
||||
x: { type: Number },
|
||||
@@ -35,6 +54,10 @@ const assetDataSchema: Schema = new Schema({
|
||||
speed: { type: Schema.Types.Mixed },
|
||||
isLocked: { type: Boolean },
|
||||
isVisible: { type: Boolean },
|
||||
eventData: {
|
||||
type: Schema.Types.Mixed,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
// export default floorItemsModel;
|
||||
@@ -47,9 +70,9 @@ export default assetModel;
|
||||
// import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
// export interface assetData extends Document {
|
||||
// modeluuid: string;
|
||||
// modelUuid: string;
|
||||
// modelfileID: string;
|
||||
// modelname: string;
|
||||
// modelName: string;
|
||||
// isLocked: boolean;
|
||||
// type: string;
|
||||
// isVisible: boolean;
|
||||
@@ -92,9 +115,9 @@ export default assetModel;
|
||||
// // Define the Mongoose Schema
|
||||
// const assetDataSchema: Schema = new Schema({
|
||||
// isArchive: { type: Boolean, default: false },
|
||||
// modeluuid: { type: String },
|
||||
// modelUuid: { type: String },
|
||||
// modelfileID: { type: String },
|
||||
// modelname: { type: String },
|
||||
// modelName: { type: String },
|
||||
// type: { type: String },
|
||||
// // assetPosition: { type: Array },
|
||||
// points: [
|
||||
|
||||
@@ -2,8 +2,8 @@ import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface wallitems extends Document {
|
||||
modeluuid: string;
|
||||
modelname: string;
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
type: string;
|
||||
csgposition: [];
|
||||
csgscale: [];
|
||||
@@ -14,8 +14,8 @@ export interface wallitems extends Document {
|
||||
|
||||
// Define the Mongoose Schema
|
||||
const wallItemsSchema: Schema = new Schema({
|
||||
modeluuid: { type: String, unique: true },
|
||||
modelname: { type: String },
|
||||
modelUuid: { type: String, unique: true },
|
||||
modelName: { type: String },
|
||||
type: { type: String },
|
||||
csgposition: { type: Array },
|
||||
csgscale: { type: Array },
|
||||
|
||||
179
src/shared/model/simulation/eventsDataModel.ts
Normal file
179
src/shared/model/simulation/eventsDataModel.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
// models/Product.ts
|
||||
import mongoose, { Schema, Document, Types } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
|
||||
interface AssetEventSchema {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||
};
|
||||
|
||||
interface TriggerSchema {
|
||||
triggerUuid: string;
|
||||
triggerName: string;
|
||||
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||
delay: number;
|
||||
triggeredAsset: {
|
||||
triggeredModel: { modelName: string, modelUuid: string };
|
||||
triggeredPoint: { pointName: string, pointUuid: string };
|
||||
triggeredAction: { actionName: string, actionUuid: string };
|
||||
} | null;
|
||||
}
|
||||
|
||||
interface ConveyorPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||
material: string;
|
||||
delay: number | "inherit";
|
||||
spawnInterval: number | "inherit";
|
||||
spawnCount: number | "inherit";
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface VehiclePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "travel";
|
||||
material: string | null;
|
||||
unLoadDuration: number;
|
||||
loadCapacity: number;
|
||||
pickUpPoint: { x: number; y: number, z: number } | null;
|
||||
unLoadPoint: { x: number; y: number, z: number } | null;
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface RoboticArmPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "pickAndPlace";
|
||||
process: { startPoint: [number, number, number]; endPoint: [number, number, number] };
|
||||
triggers: TriggerSchema[];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface MachinePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "process";
|
||||
processTime: number;
|
||||
swapMaterial: string;
|
||||
triggers: TriggerSchema[];
|
||||
};
|
||||
}
|
||||
|
||||
interface StoragePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
action: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "storage";
|
||||
materials: { materialName: string; materialId: string; }[];
|
||||
storageCapacity: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ConveyorEventSchema extends AssetEventSchema {
|
||||
type: "transfer";
|
||||
speed: number;
|
||||
points: ConveyorPointSchema[];
|
||||
}
|
||||
|
||||
interface VehicleEventSchema extends AssetEventSchema {
|
||||
type: "vehicle";
|
||||
speed: number;
|
||||
point: VehiclePointSchema;
|
||||
}
|
||||
|
||||
interface RoboticArmEventSchema extends AssetEventSchema {
|
||||
type: "roboticArm";
|
||||
speed: number;
|
||||
point: RoboticArmPointSchema;
|
||||
}
|
||||
|
||||
interface MachineEventSchema extends AssetEventSchema {
|
||||
type: "machine";
|
||||
// speed: number;
|
||||
point: MachinePointSchema;
|
||||
}
|
||||
|
||||
interface StorageEventSchema extends AssetEventSchema {
|
||||
type: "storageUnit";
|
||||
// speed: number;
|
||||
point: StoragePointSchema;
|
||||
}
|
||||
interface IPointModel extends Document {
|
||||
modelUuid:String,
|
||||
modelName:String,
|
||||
position:String,
|
||||
rotation:String,
|
||||
state:String,
|
||||
productId:String,
|
||||
isArchive:boolean,
|
||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" |"storageUnit";
|
||||
speed: number;
|
||||
point: VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema
|
||||
points: ConveyorEventSchema[]
|
||||
|
||||
}
|
||||
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
|
||||
|
||||
|
||||
const BaseEventSchema = new Schema<IPointModel>(
|
||||
{
|
||||
modelUuid: { type: String, required: true },
|
||||
modelName: { type: String, required: true },
|
||||
position: { type: [Number], required: true },
|
||||
rotation: { type: [Number], required: true },
|
||||
speed: { type: Number,},
|
||||
state: {
|
||||
type: String,
|
||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||
default: "idle"
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"]
|
||||
},
|
||||
point:{
|
||||
type:Schema.Types.Mixed,
|
||||
|
||||
},
|
||||
points:{
|
||||
type:Schema.Types.Mixed,
|
||||
|
||||
},
|
||||
productId: { type:String,required: true },
|
||||
isArchive: { type: Boolean, default: false }
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const EventsDataModel = (db: string) => {
|
||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||
};
|
||||
|
||||
export default EventsDataModel;
|
||||
24
src/shared/model/simulation/productModel.ts
Normal file
24
src/shared/model/simulation/productModel.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import mongoose, { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
export interface product extends Document {
|
||||
productName: string;
|
||||
productId: string;
|
||||
eventsData: [];
|
||||
isArchive: boolean;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Product Schema
|
||||
const ProductSchema = new Schema({
|
||||
productName: { type: String, required: true },
|
||||
productId: { type: String, required: true },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
|
||||
const ProductModel = (db: string) => {
|
||||
return MainModel(db, "Product", ProductSchema, "Product");
|
||||
};
|
||||
|
||||
export default ProductModel;
|
||||
Reference in New Issue
Block a user