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 ConveyorStore {
|
2025-04-22 09:14:09 +00:00
|
|
|
conveyors: ConveyorStatus[];
|
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-06-05 10:07:49 +00:00
|
|
|
addConveyor: (productUuid: string, event: ConveyorEventSchema) => 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
|
|
|
removeConveyor: (modelUuid: string) => void;
|
|
|
|
updateConveyor: (
|
|
|
|
modelUuid: string,
|
2025-06-05 10:07:49 +00:00
|
|
|
updates: Partial<Omit<ConveyorStatus, 'modelUuid' | 'productUuid'>>
|
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
|
|
|
) => void;
|
2025-05-02 07:43:41 +00:00
|
|
|
clearConveyors: () => 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
|
|
|
|
|
|
|
setConveyorActive: (modelUuid: string, isActive: boolean) => void;
|
|
|
|
setConveyorState: (modelUuid: string, newState: ConveyorStatus['state']) => void;
|
2025-05-06 13:42:58 +00:00
|
|
|
setConveyorPaused: (modelUuid: string, isPaused: 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
|
|
|
|
|
|
|
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
|
|
|
|
|
|
|
|
getConveyorById: (modelUuid: string) => ConveyorStatus | undefined;
|
2025-06-05 10:07:49 +00:00
|
|
|
getConveyorsByProduct: (productUuid: string) => ConveyorStatus[];
|
2025-04-22 10:04:49 +00:00
|
|
|
getConveyorsByState: (state: string) => ConveyorStatus[];
|
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
|
|
|
getActiveConveyors: () => ConveyorStatus[];
|
|
|
|
getIdleConveyors: () => ConveyorStatus[];
|
|
|
|
}
|
|
|
|
|
2025-05-28 10:54:08 +00:00
|
|
|
export const createConveyorStore = () => {
|
|
|
|
return create<ConveyorStore>()(
|
|
|
|
immer((set, get) => ({
|
|
|
|
conveyors: [],
|
|
|
|
|
2025-06-05 10:07:49 +00:00
|
|
|
addConveyor: (productUuid, event) => {
|
2025-05-28 10:54:08 +00:00
|
|
|
set((state) => {
|
|
|
|
const exists = state.conveyors.some(c => c.modelUuid === event.modelUuid);
|
|
|
|
if (!exists) {
|
|
|
|
state.conveyors.push({
|
|
|
|
...event,
|
2025-06-05 10:07:49 +00:00
|
|
|
productUuid,
|
2025-05-28 10:54:08 +00:00
|
|
|
isActive: false,
|
|
|
|
isPaused: false,
|
|
|
|
idleTime: 0,
|
|
|
|
activeTime: 0,
|
|
|
|
state: 'idle',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeConveyor: (modelUuid) => {
|
|
|
|
set((state) => {
|
|
|
|
state.conveyors = state.conveyors.filter(c => c.modelUuid !== modelUuid);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateConveyor: (modelUuid, updates) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
Object.assign(conveyor, updates);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
clearConveyors: () => {
|
|
|
|
set((state) => {
|
|
|
|
state.conveyors = [];
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setConveyorActive: (modelUuid, isActive) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
conveyor.isActive = isActive;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setConveyorState: (modelUuid, newState) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
conveyor.state = newState;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setConveyorPaused: (modelUuid, isPaused) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
conveyor.isPaused = isPaused;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementActiveTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
conveyor.activeTime += incrementBy;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
incrementIdleTime: (modelUuid, incrementBy) => {
|
|
|
|
set((state) => {
|
|
|
|
const conveyor = state.conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
if (conveyor) {
|
|
|
|
conveyor.idleTime += incrementBy;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getConveyorById: (modelUuid) => {
|
|
|
|
return get().conveyors.find(c => c.modelUuid === modelUuid);
|
|
|
|
},
|
|
|
|
|
2025-06-05 10:07:49 +00:00
|
|
|
getConveyorsByProduct: (productUuid) => {
|
|
|
|
return get().conveyors.filter(c => c.productUuid === productUuid);
|
2025-05-28 10:54:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getConveyorsByState: (state) => {
|
|
|
|
return get().conveyors.filter(c => c.state === state);
|
|
|
|
},
|
|
|
|
|
|
|
|
getActiveConveyors: () => {
|
|
|
|
return get().conveyors.filter(c => c.isActive);
|
|
|
|
},
|
|
|
|
|
|
|
|
getIdleConveyors: () => {
|
|
|
|
return get().conveyors.filter(c => !c.isActive && c.state === 'idle');
|
|
|
|
},
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ConveyorStoreType = ReturnType<typeof createConveyorStore>;
|