feat: Update simulation stores and types to enhance robotic arm and vehicle handling
This commit is contained in:
parent
faed625c2a
commit
04f91585e6
|
@ -257,8 +257,8 @@ async function handleModelLoad(
|
||||||
actionName: "Pick and Place",
|
actionName: "Pick and Place",
|
||||||
actionType: "pickAndPlace",
|
actionType: "pickAndPlace",
|
||||||
process: {
|
process: {
|
||||||
startPoint: "start-point-uuid",
|
startPoint: [0, 0, 0],
|
||||||
endPoint: "end-point-uuid"
|
endPoint: [0, 0, 0]
|
||||||
},
|
},
|
||||||
triggers: []
|
triggers: []
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ import addAssetModel from "../geomentries/assets/addAssetModel";
|
||||||
import { getFloorAssets } from "../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi";
|
import { getFloorAssets } from "../../../services/factoryBuilder/assest/floorAsset/getFloorItemsApi";
|
||||||
import useModuleStore from "../../../store/useModuleStore";
|
import useModuleStore from "../../../store/useModuleStore";
|
||||||
// import { retrieveGLTF } from "../../../utils/indexDB/idbUtils";
|
// import { retrieveGLTF } from "../../../utils/indexDB/idbUtils";
|
||||||
|
import { useEventsStore } from "../../../store/simulation/useEventsStore";
|
||||||
|
|
||||||
const assetManagerWorker = new Worker(new URL("../../../services/factoryBuilder/webWorkers/assetManagerWorker.js", import.meta.url));
|
const assetManagerWorker = new Worker(new URL("../../../services/factoryBuilder/webWorkers/assetManagerWorker.js", import.meta.url));
|
||||||
const gltfLoaderWorker = new Worker(new URL("../../../services/factoryBuilder/webWorkers/gltfLoaderWorker.js", import.meta.url));
|
const gltfLoaderWorker = new Worker(new URL("../../../services/factoryBuilder/webWorkers/gltfLoaderWorker.js", import.meta.url));
|
||||||
|
|
||||||
import { useEventsStore } from "../../../store/simulation/useEventsStore";
|
|
||||||
|
|
||||||
const FloorItemsGroup = ({ itemsGroup, hoveredDeletableFloorItem, AttachedObject, floorGroup, tempLoader, isTempLoader, plane, }: any) => {
|
const FloorItemsGroup = ({ itemsGroup, hoveredDeletableFloorItem, AttachedObject, floorGroup, tempLoader, isTempLoader, plane, }: any) => {
|
||||||
const state: Types.ThreeState = useThree();
|
const state: Types.ThreeState = useThree();
|
||||||
const { raycaster, controls }: any = state;
|
const { raycaster, controls }: any = state;
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { immer } from 'zustand/middleware/immer';
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
interface ArmBotStatus extends RoboticArmEventSchema {
|
|
||||||
productId: string;
|
|
||||||
isActive: boolean;
|
|
||||||
idleTime: number;
|
|
||||||
activeTime: number;
|
|
||||||
currentAction?: {
|
|
||||||
actionUuid: string;
|
|
||||||
actionName: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ArmBotStore {
|
interface ArmBotStore {
|
||||||
armBots: ArmBotStatus[];
|
armBots: ArmBotStatus[];
|
||||||
|
|
||||||
|
@ -22,9 +11,11 @@ interface ArmBotStore {
|
||||||
updates: Partial<Omit<ArmBotStatus, 'modelUuid' | 'productId'>>
|
updates: Partial<Omit<ArmBotStatus, 'modelUuid' | 'productId'>>
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
startAction: (modelUuid: string, actionUuid: string) => void;
|
addCurrentAction: (modelUuid: string, actionUuid: string) => void;
|
||||||
completeAction: (modelUuid: string) => void;
|
removeCurrentAction: (modelUuid: string) => void;
|
||||||
cancelAction: (modelUuid: string) => void;
|
|
||||||
|
addAction: (modelUuid: string, action: RoboticArmPointSchema['actions'][number]) => void;
|
||||||
|
removeAction: (modelUuid: string, actionUuid: string) => void;
|
||||||
|
|
||||||
setArmBotActive: (modelUuid: string, isActive: boolean) => void;
|
setArmBotActive: (modelUuid: string, isActive: boolean) => void;
|
||||||
|
|
||||||
|
@ -71,7 +62,7 @@ export const useArmBotStore = create<ArmBotStore>()(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
startAction: (modelUuid, actionUuid) => {
|
addCurrentAction: (modelUuid, actionUuid) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
||||||
if (armBot) {
|
if (armBot) {
|
||||||
|
@ -87,22 +78,30 @@ export const useArmBotStore = create<ArmBotStore>()(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
completeAction: (modelUuid) => {
|
removeCurrentAction: (modelUuid) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
||||||
if (armBot && armBot.currentAction) {
|
if (armBot) {
|
||||||
armBot.currentAction = undefined;
|
armBot.currentAction = undefined;
|
||||||
armBot.isActive = false;
|
armBot.isActive = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelAction: (modelUuid) => {
|
addAction: (modelUuid, action) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
||||||
if (armBot) {
|
if (armBot) {
|
||||||
armBot.currentAction = undefined;
|
armBot.point.actions.push(action);
|
||||||
armBot.isActive = false;
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
removeAction: (modelUuid, actionUuid) => {
|
||||||
|
set((state) => {
|
||||||
|
const armBot = state.armBots.find(a => a.modelUuid === modelUuid);
|
||||||
|
if (armBot) {
|
||||||
|
armBot.point.actions = armBot.point.actions.filter(a => a.actionUuid !== actionUuid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { immer } from 'zustand/middleware/immer';
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
interface ConveyorStatus extends ConveyorEventSchema {
|
|
||||||
productId: string;
|
|
||||||
isActive: boolean;
|
|
||||||
idleTime: number;
|
|
||||||
activeTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ConveyorStore {
|
interface ConveyorStore {
|
||||||
conveyors: ConveyorStatus[];
|
conveyors: ConveyorStatus[];
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { immer } from 'zustand/middleware/immer';
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
interface MachineStatus extends MachineEventSchema {
|
|
||||||
productId: string;
|
|
||||||
isActive: boolean;
|
|
||||||
idleTime: number;
|
|
||||||
activeTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MachineStore {
|
interface MachineStore {
|
||||||
machines: MachineStatus[];
|
machines: MachineStatus[];
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { immer } from 'zustand/middleware/immer';
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
interface StorageUnitStatus extends StorageEventSchema {
|
|
||||||
productId: string;
|
|
||||||
isActive: boolean;
|
|
||||||
idleTime: number;
|
|
||||||
activeTime: number;
|
|
||||||
currentLoad: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StorageUnitStore {
|
interface StorageUnitStore {
|
||||||
storageUnits: StorageUnitStatus[];
|
storageUnits: StorageUnitStatus[];
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ interface VehiclesStore {
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
||||||
updateVehicleLoad: (modelUuid: string, load: number) => void;
|
incrementVehicleLoad: (modelUuid: string, incrementBy: number) => void;
|
||||||
|
decrementVehicleLoad: (modelUuid: string, decrementBy: number) => void;
|
||||||
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
|
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
|
||||||
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
|
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
|
||||||
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
|
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
|
||||||
|
@ -74,11 +75,20 @@ export const useVehicleStore = create<VehiclesStore>()(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
updateVehicleLoad: (modelUuid, load) => {
|
incrementVehicleLoad: (modelUuid, incrementBy) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
if (vehicle) {
|
if (vehicle) {
|
||||||
vehicle.currentLoad = load;
|
vehicle.currentLoad += incrementBy;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
decrementVehicleLoad: (modelUuid, decrementBy) => {
|
||||||
|
set((state) => {
|
||||||
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
if (vehicle) {
|
||||||
|
vehicle.currentLoad = decrementBy;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -59,7 +59,7 @@ interface RoboticArmPointSchema {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "pickAndPlace";
|
actionType: "pickAndPlace";
|
||||||
process: { startPoint: string; endPoint: string };
|
process: { startPoint: [number, number, number]; endPoint: [number, number, number] };
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,32 @@ type productsSchema = {
|
||||||
eventsData: EventsSchema[];
|
eventsData: EventsSchema[];
|
||||||
}[]
|
}[]
|
||||||
|
|
||||||
|
|
||||||
|
interface ConveyorStatus extends ConveyorEventSchema {
|
||||||
|
productId: string;
|
||||||
|
isActive: boolean;
|
||||||
|
idleTime: number;
|
||||||
|
activeTime: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MachineStatus extends MachineEventSchema {
|
||||||
|
productId: string;
|
||||||
|
isActive: boolean;
|
||||||
|
idleTime: number;
|
||||||
|
activeTime: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ArmBotStatus extends RoboticArmEventSchema {
|
||||||
|
productId: string;
|
||||||
|
isActive: boolean;
|
||||||
|
idleTime: number;
|
||||||
|
activeTime: number;
|
||||||
|
currentAction?: {
|
||||||
|
actionUuid: string;
|
||||||
|
actionName: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface VehicleStatus extends VehicleEventSchema {
|
interface VehicleStatus extends VehicleEventSchema {
|
||||||
productId: string;
|
productId: string;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
@ -135,3 +161,11 @@ interface VehicleStatus extends VehicleEventSchema {
|
||||||
currentLoad: number;
|
currentLoad: number;
|
||||||
distanceTraveled: number;
|
distanceTraveled: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface StorageUnitStatus extends StorageEventSchema {
|
||||||
|
productId: string;
|
||||||
|
isActive: boolean;
|
||||||
|
idleTime: number;
|
||||||
|
activeTime: number;
|
||||||
|
currentLoad: number;
|
||||||
|
}
|
Loading…
Reference in New Issue