2025-04-24 04:17:44 +00:00
|
|
|
import { create } from "zustand";
|
|
|
|
import { immer } from "zustand/middleware/immer";
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
|
|
|
interface ArmBotStore {
|
2025-04-24 04:17:44 +00:00
|
|
|
armBots: ArmBotStatus[];
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
addArmBot: (productId: string, event: RoboticArmEventSchema) => void;
|
|
|
|
removeArmBot: (modelUuid: string) => void;
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
updateArmBot: (
|
|
|
|
modelUuid: string,
|
|
|
|
updates: Partial<Omit<ArmBotStatus, "modelUuid" | "productId">>
|
|
|
|
) => void;
|
2025-04-23 09:23:27 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
addCurrentAction: (modelUuid: string, actionUuid: string) => void;
|
|
|
|
removeCurrentAction: (modelUuid: string) => void;
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
addAction: (
|
|
|
|
modelUuid: string,
|
|
|
|
action: RoboticArmPointSchema["actions"][number]
|
|
|
|
) => void;
|
|
|
|
removeAction: (modelUuid: string, actionUuid: string) => void;
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
setArmBotActive: (modelUuid: string, isActive: boolean) => void;
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
|
2025-04-24 04:17:44 +00:00
|
|
|
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
|
|
|
|
getArmBotById: (modelUuid: string) => ArmBotStatus | undefined;
|
|
|
|
getArmBotsByProduct: (productId: string) => ArmBotStatus[];
|
|
|
|
getArmBotsByState: (state: string) => ArmBotStatus[];
|
|
|
|
getActiveArmBots: () => ArmBotStatus[];
|
|
|
|
getIdleArmBots: () => ArmBotStatus[];
|
|
|
|
getArmBotsByCurrentAction: (actionUuid: string) => ArmBotStatus[];
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const useArmBotStore = create<ArmBotStore>()(
|
2025-04-24 04:17:44 +00:00
|
|
|
immer((set, get) => ({
|
|
|
|
armBots: [],
|
|
|
|
|
|
|
|
addArmBot: (productId, event) => {
|
|
|
|
set((state) => {
|
|
|
|
state.armBots.push({
|
|
|
|
...event,
|
|
|
|
productId,
|
|
|
|
isActive: false,
|
|
|
|
idleTime: 0,
|
|
|
|
activeTime: 0,
|
|
|
|
state: "idle",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeArmBot: (modelUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
state.armBots = state.armBots.filter((a) => a.modelUuid !== modelUuid);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateArmBot: (modelUuid, updates) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
Object.assign(armBot, updates);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
addCurrentAction: (modelUuid, actionUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
const action = armBot.point.actions.find(
|
|
|
|
(a) => a.actionUuid === actionUuid
|
|
|
|
);
|
|
|
|
if (action) {
|
|
|
|
armBot.currentAction = {
|
|
|
|
actionUuid: action.actionUuid,
|
|
|
|
actionName: action.actionName,
|
|
|
|
};
|
|
|
|
armBot.isActive = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeCurrentAction: (modelUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.currentAction = undefined;
|
|
|
|
armBot.isActive = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
addAction: (modelUuid, action) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.point.actions.push(action);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setArmBotActive: (modelUuid, isActive) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.isActive = isActive;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementActiveTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.activeTime += incrementBy;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementIdleTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.idleTime += incrementBy;
|
feat: Implement Zustand stores for machine, simulation, storage unit, vehicle, and visualization management
- Added `useMachineStore` for managing machine statuses, including actions for adding, removing, and updating machines.
- Introduced `useSimulationStore` to handle product and event management with actions for adding, removing, and updating products and events.
- Created `useStorageUnitStore` for managing storage unit statuses, including load tracking and state updates.
- Developed `useVehicleStore` for vehicle management, including load and state updates.
- Implemented `useChartStore` for managing measurement data and visualization settings.
- Added `useDroppedObjectsStore` for handling dropped objects in visualization zones, including object manipulation actions.
- Created `useZone3DWidgetStore` for managing 3D widget data in zones, including position and rotation updates.
- Introduced `useZoneStore` for managing selected zone states and widget configurations.
2025-04-22 08:58:29 +00:00
|
|
|
}
|
2025-04-24 04:17:44 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getArmBotById: (modelUuid) => {
|
|
|
|
return get().armBots.find((a) => a.modelUuid === modelUuid);
|
|
|
|
},
|
|
|
|
|
|
|
|
getArmBotsByProduct: (productId) => {
|
|
|
|
return get().armBots.filter((a) => a.productId === productId);
|
|
|
|
},
|
|
|
|
|
|
|
|
getArmBotsByState: (state) => {
|
|
|
|
return get().armBots.filter((a) => a.state === state);
|
|
|
|
},
|
|
|
|
|
|
|
|
getActiveArmBots: () => {
|
|
|
|
return get().armBots.filter((a) => a.isActive);
|
|
|
|
},
|
|
|
|
|
|
|
|
getIdleArmBots: () => {
|
|
|
|
return get().armBots.filter((a) => !a.isActive && a.state === "idle");
|
|
|
|
},
|
|
|
|
|
|
|
|
getArmBotsByCurrentAction: (actionUuid) => {
|
|
|
|
return get().armBots.filter(
|
|
|
|
(a) => a.currentAction?.actionUuid === actionUuid
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}))
|
2025-04-22 09:14:09 +00:00
|
|
|
);
|