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
|
|
|
import { create } from 'zustand';
|
|
|
|
import { immer } from 'zustand/middleware/immer';
|
|
|
|
|
|
|
|
interface MachineStore {
|
2025-04-22 09:14:09 +00:00
|
|
|
machines: MachineStatus[];
|
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-22 09:14:09 +00:00
|
|
|
addMachine: (productId: string, machine: MachineEventSchema) => 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
|
|
|
removeMachine: (modelUuid: string) => void;
|
|
|
|
updateMachine: (
|
|
|
|
modelUuid: string,
|
|
|
|
updates: Partial<Omit<MachineStatus, 'modelUuid' | 'productId'>>
|
|
|
|
) => void;
|
2025-05-02 07:43:41 +00:00
|
|
|
clearMachines: () => 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-05-02 06:41:09 +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
|
|
|
setMachineActive: (modelUuid: string, isActive: boolean) => void;
|
|
|
|
setMachineState: (modelUuid: string, newState: MachineStatus['state']) => void;
|
|
|
|
|
|
|
|
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
|
|
|
|
getMachineById: (modelUuid: string) => MachineStatus | undefined;
|
|
|
|
getMachinesByProduct: (productId: string) => MachineStatus[];
|
2025-04-22 10:04:49 +00:00
|
|
|
getMachinesBystate: (state: string) => MachineStatus[];
|
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
|
|
|
getActiveMachines: () => MachineStatus[];
|
|
|
|
getIdleMachines: () => MachineStatus[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export const useMachineStore = create<MachineStore>()(
|
|
|
|
immer((set, get) => ({
|
2025-04-22 09:14:09 +00:00
|
|
|
machines: [],
|
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
|
|
|
|
|
|
|
addMachine: (productId, machine) => {
|
|
|
|
set((state) => {
|
2025-05-02 07:43:41 +00:00
|
|
|
const exists = state.machines.some(m => m.modelUuid === machine.modelUuid);
|
|
|
|
if (!exists) {
|
|
|
|
state.machines.push({
|
|
|
|
...machine,
|
|
|
|
productId,
|
|
|
|
isActive: false,
|
|
|
|
idleTime: 0,
|
|
|
|
activeTime: 0,
|
|
|
|
state: 'idle',
|
|
|
|
});
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeMachine: (modelUuid) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
state.machines = state.machines.filter(m => m.modelUuid !== modelUuid);
|
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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMachine: (modelUuid, updates) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
const machine = state.machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
if (machine) {
|
|
|
|
Object.assign(machine, updates);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2025-05-02 07:43:41 +00:00
|
|
|
clearMachines: () => {
|
|
|
|
set((state) => {
|
|
|
|
state.machines = [];
|
|
|
|
});
|
|
|
|
},
|
2025-05-02 06:41:09 +00:00
|
|
|
|
|
|
|
addCurrentAction: (modelUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.machines.find(a => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
const action = armBot.point.action;
|
|
|
|
if (action) {
|
|
|
|
armBot.currentAction = {
|
|
|
|
actionUuid: action.actionUuid,
|
|
|
|
actionName: action.actionName,
|
2025-05-05 08:56:38 +00:00
|
|
|
materialType: null
|
2025-05-02 06:41:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeCurrentAction: (modelUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
const armBot = state.machines.find(a => a.modelUuid === modelUuid);
|
|
|
|
if (armBot) {
|
|
|
|
armBot.currentAction = undefined;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
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
|
|
|
setMachineActive: (modelUuid, isActive) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
const machine = state.machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
if (machine) {
|
|
|
|
machine.isActive = isActive;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setMachineState: (modelUuid, newState) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
const machine = state.machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
if (machine) {
|
|
|
|
machine.state = newState;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementActiveTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
const machine = state.machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
if (machine) {
|
|
|
|
machine.activeTime += incrementBy;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementIdleTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
const machine = state.machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
if (machine) {
|
|
|
|
machine.idleTime += incrementBy;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getMachineById: (modelUuid) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
return get().machines.find(m => m.modelUuid === modelUuid);
|
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
|
|
|
},
|
|
|
|
|
|
|
|
getMachinesByProduct: (productId) => {
|
2025-04-22 09:14:09 +00:00
|
|
|
return get().machines.filter(m => m.productId === productId);
|
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-22 10:04:49 +00:00
|
|
|
getMachinesBystate: (state) => {
|
|
|
|
return get().machines.filter(m => m.state === state);
|
|
|
|
},
|
|
|
|
|
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
|
|
|
getActiveMachines: () => {
|
2025-04-22 09:14:09 +00:00
|
|
|
return get().machines.filter(m => m.isActive);
|
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
|
|
|
},
|
|
|
|
|
|
|
|
getIdleMachines: () => {
|
2025-04-22 09:14:09 +00:00
|
|
|
return get().machines.filter(m => !m.isActive && m.state === 'idle');
|
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-22 09:14:09 +00:00
|
|
|
);
|