Refactor store creation for Conveyor, Machine, Storage Unit, and Vehicle
- Changed the store creation functions to `createConveyorStore`, `createMachineStore`, `createStorageUnitStore`, and `createVehicleStore` for better clarity and consistency. - Updated the internal state management methods to maintain functionality while improving readability. - Ensured that all stores now return their respective types for better type safety.
This commit is contained in:
parent
d198f520ea
commit
5e58606f8f
|
@ -6,18 +6,19 @@ import StorageAction from "../actions/StorageAction";
|
|||
import ActionsList from "../components/ActionsList";
|
||||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useProductStore } from "../../../../../../store/simulation/useProductStore";
|
||||
import { useStorageUnitStore } from "../../../../../../store/simulation/useStorageUnitStore";
|
||||
import { useSelectedAction, useSelectedEventData, useSelectedProduct } from "../../../../../../store/simulation/useSimulationStore";
|
||||
import * as THREE from 'three';
|
||||
import { useSceneContext } from "../../../../../../modules/scene/sceneContext";
|
||||
|
||||
function StorageMechanics() {
|
||||
const { storageUnitStore } = useSceneContext();
|
||||
const [activeOption, setActiveOption] = useState<"default" | "store" | "spawn">("default");
|
||||
const [selectedPointData, setSelectedPointData] = useState<StoragePointSchema | undefined>();
|
||||
const { selectedEventData } = useSelectedEventData();
|
||||
const { getPointByUuid, updateAction } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
const { setCurrentMaterials, clearCurrentMaterials, updateCurrentLoad, getStorageUnitById } = useStorageUnitStore();
|
||||
const { setCurrentMaterials, clearCurrentMaterials, updateCurrentLoad, getStorageUnitById } = storageUnitStore();
|
||||
|
||||
const email = localStorage.getItem('email')
|
||||
const organization = (email!.split("@")[1]).split(".")[0];
|
||||
|
|
|
@ -13,21 +13,17 @@ import { useProductStore } from "../../../../../../store/simulation/useProductSt
|
|||
import TravelAction from "../actions/TravelAction";
|
||||
import ActionsList from "../components/ActionsList";
|
||||
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { useVehicleStore } from "../../../../../../store/simulation/useVehicleStore";
|
||||
import { useSceneContext } from "../../../../../../modules/scene/sceneContext";
|
||||
|
||||
function VehicleMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"default" | "travel">(
|
||||
"default"
|
||||
);
|
||||
const [selectedPointData, setSelectedPointData] = useState<
|
||||
VehiclePointSchema | undefined
|
||||
>();
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const [activeOption, setActiveOption] = useState<"default" | "travel">("default");
|
||||
const [selectedPointData, setSelectedPointData] = useState<VehiclePointSchema | undefined>();
|
||||
const { selectedEventData } = useSelectedEventData();
|
||||
const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction } =
|
||||
useProductStore();
|
||||
const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
const { getVehicleById } = useVehicleStore();
|
||||
const { getVehicleById } = vehicleStore();
|
||||
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email!.split("@")[1].split(".")[0];
|
||||
|
|
|
@ -6,7 +6,7 @@ function AisleInstances() {
|
|||
const { aisles } = useAisleStore();
|
||||
|
||||
useEffect(() => {
|
||||
console.log('aisles: ', aisles);
|
||||
// console.log('aisles: ', aisles);
|
||||
}, [aisles]);
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import React from 'react'
|
||||
import AisleCreator from './aisleCreator/aisleCreator'
|
||||
import AisleInstances from './Instances/aisleInstances'
|
||||
|
||||
|
|
|
@ -1,16 +1,40 @@
|
|||
import { createContext, useContext, useMemo } from 'react';
|
||||
import { createMaterialStore, MaterialStoreType } from '../../store/simulation/useMaterialStore';
|
||||
import { createArmBotStore, ArmBotStoreType } from '../../store/simulation/useArmBotStore';
|
||||
import { createMachineStore, MachineStoreType } from '../../store/simulation/useMachineStore';
|
||||
import { createConveyorStore, ConveyorStoreType } from '../../store/simulation/useConveyorStore';
|
||||
import { createVehicleStore, VehicleStoreType } from '../../store/simulation/useVehicleStore';
|
||||
import { createStorageUnitStore, StorageUnitStoreType } from '../../store/simulation/useStorageUnitStore';
|
||||
|
||||
type SceneContextValue = {
|
||||
materialStore: MaterialStoreType;
|
||||
// Add other stores here if needed
|
||||
armBotStore: ArmBotStoreType;
|
||||
machineStore: MachineStoreType;
|
||||
conveyorStore: ConveyorStoreType;
|
||||
vehicleStore: VehicleStoreType;
|
||||
storageUnitStore: StorageUnitStoreType;
|
||||
};
|
||||
|
||||
const SceneContext = createContext<SceneContextValue | null>(null);
|
||||
|
||||
export function SceneProvider({ children }: { readonly children: React.ReactNode }) {
|
||||
const materialStore = useMemo(() => createMaterialStore(), []);
|
||||
const contextValue = useMemo(() => ({ materialStore }), [materialStore]);
|
||||
const armBotStore = useMemo(() => createArmBotStore(), []);
|
||||
const machineStore = useMemo(() => createMachineStore(), []);
|
||||
const conveyorStore = useMemo(() => createConveyorStore(), []);
|
||||
const vehicleStore = useMemo(() => createVehicleStore(), []);
|
||||
const storageUnitStore = useMemo(() => createStorageUnitStore(), []);
|
||||
|
||||
const contextValue = useMemo(() => (
|
||||
{
|
||||
materialStore,
|
||||
armBotStore,
|
||||
machineStore,
|
||||
conveyorStore,
|
||||
vehicleStore,
|
||||
storageUnitStore
|
||||
}
|
||||
), [materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore]);
|
||||
|
||||
return (
|
||||
<SceneContext.Provider value={contextValue}>
|
||||
|
|
|
@ -4,7 +4,6 @@ import { useFrame } from "@react-three/fiber";
|
|||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { usePlayButtonStore, useAnimationPlaySpeed, usePauseButtonStore, useResetButtonStore } from "../../../../../store/usePlayButtonStore";
|
||||
import { useConveyorStore } from "../../../../../store/simulation/useConveyorStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
interface SpawnInstance {
|
||||
|
@ -23,9 +22,9 @@ interface SpawnInstance {
|
|||
}
|
||||
|
||||
export function useSpawnHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, conveyorStore } = useSceneContext();
|
||||
const { addMaterial } = materialStore();
|
||||
const { getConveyorById } = useConveyorStore();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const { getModelUuidByActionUuid, getPointUuidByActionUuid } = useProductStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { isPaused } = usePauseButtonStore();
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { useCallback } from "react";
|
||||
import { useMachineStore } from "../../../../../store/simulation/useMachineStore";
|
||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
export function useProcessHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, machineStore } = useSceneContext();
|
||||
const { getMaterialById, setMaterial } = materialStore();
|
||||
const { addCurrentAction } = useMachineStore();
|
||||
const { addCurrentAction } = machineStore();
|
||||
const { getModelUuidByActionUuid } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { useCallback } from "react";
|
||||
import { useArmBotStore } from "../../../../../store/simulation/useArmBotStore";
|
||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
export function usePickAndPlaceHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, armBotStore } = useSceneContext();
|
||||
const { getMaterialById } = materialStore();
|
||||
const { addCurrentAction } = useArmBotStore();
|
||||
const { addCurrentAction } = armBotStore();
|
||||
const { getModelUuidByActionUuid } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
|
||||
|
|
|
@ -2,20 +2,17 @@ import { useCallback, useState, useEffect, useRef } from "react";
|
|||
import { useFrame } from "@react-three/fiber";
|
||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { useStorageUnitStore } from "../../../../../store/simulation/useStorageUnitStore";
|
||||
import { useArmBotStore } from "../../../../../store/simulation/useArmBotStore";
|
||||
import { useVehicleStore } from "../../../../../store/simulation/useVehicleStore";
|
||||
import { usePlayButtonStore, usePauseButtonStore, useResetButtonStore, useAnimationPlaySpeed } from "../../../../../store/usePlayButtonStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
export function useRetrieveHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, armBotStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { addMaterial } = materialStore();
|
||||
const { getModelUuidByActionUuid, getPointUuidByActionUuid, getEventByModelUuid, getActionByUuid } = useProductStore();
|
||||
const { getStorageUnitById, getLastMaterial, updateCurrentLoad, removeLastMaterial } = useStorageUnitStore();
|
||||
const { getVehicleById, incrementVehicleLoad, addCurrentMaterial } = useVehicleStore();
|
||||
const { getStorageUnitById, getLastMaterial, updateCurrentLoad, removeLastMaterial } = storageUnitStore();
|
||||
const { getVehicleById, incrementVehicleLoad, addCurrentMaterial } = vehicleStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { getArmBotById, addCurrentAction } = useArmBotStore();
|
||||
const { getArmBotById, addCurrentAction } = armBotStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
const { isPaused } = usePauseButtonStore();
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { useCallback } from "react";
|
||||
import { useStorageUnitStore } from "../../../../../store/simulation/useStorageUnitStore";
|
||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
export function useStoreHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, storageUnitStore } = useSceneContext();
|
||||
const { getMaterialById, removeMaterial, setEndTime } = materialStore();
|
||||
const { addCurrentMaterial, updateCurrentLoad } = useStorageUnitStore();
|
||||
const { addCurrentMaterial, updateCurrentLoad } = storageUnitStore();
|
||||
const { getModelUuidByActionUuid } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import { useCallback } from "react";
|
||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
|
||||
import { useVehicleStore } from "../../../../../store/simulation/useVehicleStore";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
|
||||
export function useTravelHandler() {
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, vehicleStore } = useSceneContext();
|
||||
const { getMaterialById } = materialStore();
|
||||
const { getModelUuidByActionUuid } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { incrementVehicleLoad, addCurrentMaterial } = useVehicleStore();
|
||||
const { incrementVehicleLoad, addCurrentMaterial } = vehicleStore();
|
||||
|
||||
const travelLogStatus = (materialUuid: string, status: string) => {
|
||||
echo.info(`${materialUuid}, ${status}`);
|
||||
|
|
|
@ -2,24 +2,19 @@ import { useEffect } from 'react';
|
|||
import { useSelectedProduct } from '../../../../store/simulation/useSimulationStore';
|
||||
import { useProductStore } from '../../../../store/simulation/useProductStore';
|
||||
import { determineExecutionMachineSequences } from '../../simulator/functions/determineExecutionMachineSequences';
|
||||
import { useArmBotStore } from '../../../../store/simulation/useArmBotStore';
|
||||
import { useMachineCount, useMachineUptime, useMaterialCycle, useProcessBar, useThroughPutData } from '../../../../store/builder/store';
|
||||
import { useVehicleStore } from '../../../../store/simulation/useVehicleStore';
|
||||
import { useMachineStore } from '../../../../store/simulation/useMachineStore';
|
||||
import { useConveyorStore } from '../../../../store/simulation/useConveyorStore';
|
||||
import { useStorageUnitStore } from '../../../../store/simulation/useStorageUnitStore';
|
||||
import { usePlayButtonStore } from '../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
export default function ThroughPutData() {
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { products, getProductById } = useProductStore();
|
||||
const { armBots } = useArmBotStore();
|
||||
const { vehicles } = useVehicleStore();
|
||||
const { machines } = useMachineStore();
|
||||
const { conveyors } = useConveyorStore();
|
||||
const { storageUnits } = useStorageUnitStore();
|
||||
const { materialStore } = useSceneContext();
|
||||
const { armBots } = armBotStore();
|
||||
const { vehicles } = vehicleStore();
|
||||
const { machines } = machineStore();
|
||||
const { conveyors } = conveyorStore();
|
||||
const { storageUnits } = storageUnitStore();
|
||||
const { materialHistory } = materialStore();
|
||||
const { machineCount, setMachineCount } = useMachineCount();
|
||||
const { machineActiveTime, setMachineActiveTime } = useMachineUptime();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useFrame } from '@react-three/fiber';
|
||||
import { useConveyorStore } from '../../../../store/simulation/useConveyorStore';
|
||||
import { usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type ConveyorCallback = {
|
||||
conveyorId: string;
|
||||
|
@ -9,7 +9,8 @@ type ConveyorCallback = {
|
|||
};
|
||||
|
||||
export function useConveyorEventManager() {
|
||||
const { getConveyorById } = useConveyorStore();
|
||||
const { conveyorStore } = useSceneContext();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const callbacksRef = useRef<ConveyorCallback[]>([]);
|
||||
const isMonitoringRef = useRef(false);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { useEffect } from 'react'
|
||||
import { useConveyorStore } from '../../../../../store/simulation/useConveyorStore';
|
||||
import { useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useSelectedProduct } from '../../../../../store/simulation/useSimulationStore';
|
||||
import { useProductStore } from '../../../../../store/simulation/useProductStore';
|
||||
|
@ -9,10 +8,10 @@ import { useSceneContext } from '../../../../scene/sceneContext';
|
|||
function ConveyorInstance({ conveyor }: { conveyor: ConveyorStatus }) {
|
||||
const { getProductById } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, conveyorStore } = useSceneContext();
|
||||
const { getMaterialsByCurrentModelUuid, materials } = materialStore();
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { setConveyorPaused } = useConveyorStore();
|
||||
const { setConveyorPaused } = conveyorStore();
|
||||
|
||||
useEffect(() => {
|
||||
const product = getProductById(selectedProduct.productId);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from 'react'
|
||||
import ConveyorInstance from './conveyorInstance/conveyorInstance'
|
||||
import { useConveyorStore } from '../../../../store/simulation/useConveyorStore'
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
function ConveyorInstances() {
|
||||
|
||||
const { conveyors } = useConveyorStore();
|
||||
const { conveyorStore } = useSceneContext();
|
||||
const { conveyors } = conveyorStore();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useFrame } from '@react-three/fiber';
|
||||
import { useMachineStore } from '../../../../store/simulation/useMachineStore';
|
||||
import { usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type MachineCallback = {
|
||||
machineId: string;
|
||||
|
@ -9,7 +9,8 @@ type MachineCallback = {
|
|||
};
|
||||
|
||||
export function useMachineEventManager() {
|
||||
const { getMachineById } = useMachineStore();
|
||||
const { machineStore } = useSceneContext();
|
||||
const { getMachineById } = machineStore();
|
||||
const callbacksRef = useRef<MachineCallback[]>([]);
|
||||
const isMonitoringRef = useRef(false);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useMachineStore } from '../../../../../store/simulation/useMachineStore';
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
|
||||
interface MachineAnimatorProps {
|
||||
currentPhase: string;
|
||||
|
@ -19,7 +18,8 @@ const MachineAnimator = ({ currentPhase, handleCallBack, processingTime, machine
|
|||
const animationFrameId = useRef<number | null>(null);
|
||||
const pauseTimeRef = useRef<number | null>(null);
|
||||
const { isPaused } = usePauseButtonStore();
|
||||
const { removeCurrentAction } = useMachineStore();
|
||||
const { machineStore } = useSceneContext();
|
||||
const { removeCurrentAction } = machineStore();
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useMachineStore } from '../../../../../store/simulation/useMachineStore';
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import MachineAnimator from '../animator/machineAnimator';
|
||||
import { useProductStore } from '../../../../../store/simulation/useProductStore';
|
||||
import { useSelectedProduct } from '../../../../../store/simulation/useSimulationStore';
|
||||
import { useTriggerHandler } from '../../../triggers/triggerHandler/useTriggerHandler';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
|
||||
function MachineInstance({ machineDetail }: { machineDetail: MachineStatus }) {
|
||||
function MachineInstance({ machineDetail }: { readonly machineDetail: MachineStatus }) {
|
||||
const [currentPhase, setCurrentPhase] = useState<string>('idle');
|
||||
let isIncrememtable = useRef<boolean>(true);
|
||||
const idleTimeRef = useRef<number>(0);
|
||||
|
@ -16,7 +16,8 @@ function MachineInstance({ machineDetail }: { machineDetail: MachineStatus }) {
|
|||
const isSpeedRef = useRef<number>(0);
|
||||
const isPausedRef = useRef<boolean>(false);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { machines, setMachineState, setMachineActive, incrementIdleTime, incrementActiveTime, resetTime } = useMachineStore();
|
||||
const { machineStore } = useSceneContext();
|
||||
const { machines, setMachineState, setMachineActive, incrementIdleTime, incrementActiveTime, resetTime } = machineStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { getActionByUuid } = useProductStore();
|
||||
const { triggerPointActions } = useTriggerHandler();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from "react";
|
||||
import MachineInstance from "./machineInstance/machineInstance";
|
||||
import { useMachineStore } from "../../../../store/simulation/useMachineStore";
|
||||
import MachineContentUi from "../../ui3d/MachineContentUi";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
|
||||
function MachineInstances() {
|
||||
const { machines } = useMachineStore();
|
||||
const { machineStore } = useSceneContext();
|
||||
const { machines } = machineStore();
|
||||
return (
|
||||
<>
|
||||
{machines.map((machine: MachineStatus) => (
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { useEffect, useState, useRef } from 'react';
|
|||
import * as THREE from 'three';
|
||||
import { useFrame, useThree } from '@react-three/fiber';
|
||||
import { usePauseButtonStore, usePlayButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useConveyorStore } from '../../../../../store/simulation/useConveyorStore';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
|
||||
interface MaterialAnimatorProps {
|
||||
matRef: React.RefObject<THREE.Mesh>;
|
||||
|
@ -20,7 +20,8 @@ function MaterialAnimator({
|
|||
const { scene } = useThree();
|
||||
const [targetPosition, setTargetPosition] = useState<THREE.Vector3 | null>(null);
|
||||
const [isAnimating, setIsAnimating] = useState(false);
|
||||
const { getConveyorById } = useConveyorStore();
|
||||
const { conveyorStore } = useSceneContext();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const animationState = useRef({
|
||||
startTime: 0,
|
||||
startPosition: new THREE.Vector3(),
|
||||
|
|
|
@ -4,21 +4,18 @@ import { useProductStore } from '../../../store/simulation/useProductStore';
|
|||
import { useSelectedProduct } from '../../../store/simulation/useSimulationStore';
|
||||
import { upsertProductOrEventApi } from '../../../services/simulation/products/UpsertProductOrEventApi';
|
||||
import { getAllProductsApi } from '../../../services/simulation/products/getallProductsApi';
|
||||
import { useVehicleStore } from '../../../store/simulation/useVehicleStore';
|
||||
import { useArmBotStore } from '../../../store/simulation/useArmBotStore';
|
||||
import { useConveyorStore } from '../../../store/simulation/useConveyorStore';
|
||||
import { useMachineStore } from '../../../store/simulation/useMachineStore';
|
||||
import { useStorageUnitStore } from '../../../store/simulation/useStorageUnitStore';
|
||||
import { usePlayButtonStore, useResetButtonStore } from '../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../scene/sceneContext';
|
||||
|
||||
function Products() {
|
||||
const { armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { products, getProductById, addProduct, setProducts } = useProductStore();
|
||||
const { selectedProduct, setSelectedProduct } = useSelectedProduct();
|
||||
const { addVehicle, clearvehicles } = useVehicleStore();
|
||||
const { addArmBot, clearArmBots } = useArmBotStore();
|
||||
const { addMachine, clearMachines } = useMachineStore();
|
||||
const { addConveyor, clearConveyors } = useConveyorStore();
|
||||
const { setCurrentMaterials, clearStorageUnits, updateCurrentLoad, addStorageUnit } = useStorageUnitStore();
|
||||
const { addVehicle, clearvehicles } = vehicleStore();
|
||||
const { addArmBot, clearArmBots } = armBotStore();
|
||||
const { addMachine, clearMachines } = machineStore();
|
||||
const { addConveyor, clearConveyors } = conveyorStore();
|
||||
const { setCurrentMaterials, clearStorageUnits, updateCurrentLoad, addStorageUnit } = storageUnitStore();
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
||||
|
@ -105,7 +102,7 @@ function Products() {
|
|||
addStorageUnit(selectedProduct.productId, event);
|
||||
|
||||
if (event.point.action.actionType === 'retrieve') {
|
||||
const storageAction = event.point.action as StorageAction;
|
||||
const storageAction = event.point.action;
|
||||
const materials = Array.from({ length: storageAction.storageCapacity }, () => ({
|
||||
materialType: storageAction.materialType || 'Default material',
|
||||
materialId: THREE.MathUtils.generateUUID()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useFrame } from '@react-three/fiber';
|
||||
import { useArmBotStore } from '../../../../store/simulation/useArmBotStore';
|
||||
import { usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type ArmBotCallback = {
|
||||
armBotId: string;
|
||||
|
@ -9,7 +9,8 @@ type ArmBotCallback = {
|
|||
};
|
||||
|
||||
export function useArmBotEventManager() {
|
||||
const { getArmBotById } = useArmBotStore();
|
||||
const {armBotStore} = useSceneContext();
|
||||
const { getArmBotById } = armBotStore();
|
||||
const callbacksRef = useRef<ArmBotCallback[]>([]);
|
||||
const isMonitoringRef = useRef(false);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useFrame, useThree } from '@react-three/fiber';
|
||||
import * as THREE from 'three';
|
||||
import { Line, Text } from '@react-three/drei';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import * as THREE from "three";
|
||||
import { useThree } from "@react-three/fiber";
|
||||
import IKInstance from '../ikInstance/ikInstance';
|
||||
|
@ -6,10 +6,7 @@ import RoboticArmAnimator from '../animator/roboticArmAnimator';
|
|||
import MaterialAnimator from '../animator/materialAnimator';
|
||||
import armModel from "../../../../../assets/gltf-glb/rigged/ik_arm_1.glb";
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useArmBotStore } from '../../../../../store/simulation/useArmBotStore';
|
||||
import { useProductStore } from '../../../../../store/simulation/useProductStore';
|
||||
import { useVehicleStore } from '../../../../../store/simulation/useVehicleStore';
|
||||
import { useStorageUnitStore } from '../../../../../store/simulation/useStorageUnitStore';
|
||||
import { useSelectedProduct } from '../../../../../store/simulation/useSimulationStore';
|
||||
import { useTriggerHandler } from '../../../triggers/triggerHandler/useTriggerHandler';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
|
@ -28,10 +25,10 @@ function RoboticArmInstance({ armBot }: {readonly armBot: ArmBotStatus }) {
|
|||
const isSpeedRef = useRef<any>(null);
|
||||
let startTime: number;
|
||||
|
||||
const { setArmBotActive, setArmBotState, removeCurrentAction, incrementActiveTime, incrementIdleTime } = useArmBotStore();
|
||||
const { decrementVehicleLoad, removeLastMaterial } = useVehicleStore();
|
||||
const { removeLastMaterial: removeLastStorageMaterial, updateCurrentLoad } = useStorageUnitStore();
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, armBotStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { setArmBotActive, setArmBotState, removeCurrentAction, incrementActiveTime, incrementIdleTime } = armBotStore();
|
||||
const { decrementVehicleLoad, removeLastMaterial } = vehicleStore();
|
||||
const { removeLastMaterial: removeLastStorageMaterial, updateCurrentLoad } = storageUnitStore();
|
||||
const { getMaterialById, setIsVisible, setIsPaused } = materialStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { getActionByUuid, getEventByActionUuid, getEventByModelUuid } = useProductStore();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
import RoboticArmInstance from "./armInstance/roboticArmInstance";
|
||||
import { useArmBotStore } from "../../../../store/simulation/useArmBotStore";
|
||||
// import RoboticArmContentUi from "../../ui3d/RoboticArmContentUi";
|
||||
import React from "react";
|
||||
|
||||
function RoboticArmInstances() {
|
||||
const { armBots } = useArmBotStore();
|
||||
const {armBotStore} = useSceneContext();
|
||||
const { armBots } = armBotStore();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useArmBotStore } from "../../../store/simulation/useArmBotStore";
|
||||
import { useSelectedEventSphere } from "../../../store/simulation/useSimulationStore";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import RoboticArmInstances from "./instances/roboticArmInstances";
|
||||
import ArmBotUI from "../spatialUI/arm/armBotUI";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
|
||||
function RoboticArm() {
|
||||
const { getArmBotById } = useArmBotStore();
|
||||
const {armBotStore} = useSceneContext();
|
||||
const { getArmBotById } = armBotStore();
|
||||
const { selectedEventSphere } = useSelectedEventSphere();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const [isArmBotSelected, setIsArmBotSelected] = useState(false);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
import { extractTriggersFromPoint } from "./extractTriggersFromPoint";
|
||||
import { useArmBotStore } from "../../../../store/simulation/useArmBotStore";
|
||||
|
||||
export function getRoboticArmSequencesInProduct(
|
||||
product: {
|
||||
|
@ -80,7 +80,8 @@ export function findRoboticArmSubsequence(
|
|||
|
||||
// React component/hook that uses the pure functions
|
||||
export function useCheckActiveRoboticArmsInSubsequence() {
|
||||
const { getArmBotById } = useArmBotStore();
|
||||
const {armBotStore} = useSceneContext();
|
||||
const { getArmBotById } = armBotStore();
|
||||
|
||||
return function (product: {
|
||||
productName: string;
|
||||
|
|
|
@ -3,7 +3,6 @@ import { useSelectedAction, useSelectedEventSphere, useSelectedProduct } from '.
|
|||
import { useGLTF } from '@react-three/drei';
|
||||
import { useThree } from '@react-three/fiber';
|
||||
import { useProductStore } from '../../../../store/simulation/useProductStore';
|
||||
import { useArmBotStore } from '../../../../store/simulation/useArmBotStore';
|
||||
import PickDropPoints from './PickDropPoints';
|
||||
import useDraggableGLTF from './useDraggableGLTF';
|
||||
import * as THREE from 'three';
|
||||
|
@ -11,6 +10,7 @@ import * as THREE from 'three';
|
|||
import armPick from "../../../../assets/gltf-glb/ui/arm_ui_pick.glb";
|
||||
import armDrop from "../../../../assets/gltf-glb/ui/arm_ui_drop.glb";
|
||||
import { upsertProductOrEventApi } from '../../../../services/simulation/products/UpsertProductOrEventApi';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type Positions = {
|
||||
pick: [number, number, number];
|
||||
|
@ -24,7 +24,8 @@ const ArmBotUI = () => {
|
|||
const { selectedProduct } = useSelectedProduct();
|
||||
const { scene } = useThree();
|
||||
const { selectedAction } = useSelectedAction();
|
||||
const { armBots } = useArmBotStore();
|
||||
const { armBotStore } = useSceneContext();
|
||||
const { armBots } = armBotStore();
|
||||
|
||||
const armUiPick = useGLTF(armPick) as any;
|
||||
const armUiDrop = useGLTF(armDrop) as any;
|
||||
|
|
|
@ -8,13 +8,13 @@ import {
|
|||
useSelectedProduct,
|
||||
useIsRotating,
|
||||
} from "../../../../store/simulation/useSimulationStore";
|
||||
import { useVehicleStore } from "../../../../store/simulation/useVehicleStore";
|
||||
import { useProductStore } from "../../../../store/simulation/useProductStore";
|
||||
import { upsertProductOrEventApi } from "../../../../services/simulation/products/UpsertProductOrEventApi";
|
||||
import { DoubleSide, Group, Plane, Vector3 } from "three";
|
||||
|
||||
import startPoint from "../../../../assets/gltf-glb/ui/arrow_green.glb";
|
||||
import startEnd from "../../../../assets/gltf-glb/ui/arrow_red.glb";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
|
||||
const VehicleUI = () => {
|
||||
const { scene: startScene } = useGLTF(startPoint) as any;
|
||||
|
@ -24,7 +24,8 @@ const VehicleUI = () => {
|
|||
const prevMousePos = useRef({ x: 0, y: 0 });
|
||||
const { selectedEventSphere } = useSelectedEventSphere();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { vehicles, getVehicleById } = useVehicleStore();
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const { vehicles, getVehicleById } = vehicleStore();
|
||||
const { updateEvent } = useProductStore();
|
||||
const [startPosition, setStartPosition] = useState<[number, number, number]>([
|
||||
0, 1, 0,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from 'react'
|
||||
import StorageUnitInstance from './storageUnitInstance/storageUnitInstance'
|
||||
import { useStorageUnitStore } from '../../../../store/simulation/useStorageUnitStore'
|
||||
import StorageContentUi from '../../ui3d/StorageContentUi';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
function StorageUnitInstances() {
|
||||
const { storageUnits } = useStorageUnitStore();
|
||||
const { storageUnitStore } = useSceneContext();
|
||||
const { storageUnits } = storageUnitStore();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -2,31 +2,26 @@ import { useCallback } from 'react';
|
|||
import { useActionHandler } from '../../actions/useActionHandler';
|
||||
import { useProductStore } from '../../../../store/simulation/useProductStore';
|
||||
import { useSelectedProduct } from '../../../../store/simulation/useSimulationStore';
|
||||
import { useArmBotStore } from '../../../../store/simulation/useArmBotStore';
|
||||
import { useVehicleStore } from '../../../../store/simulation/useVehicleStore';
|
||||
import { useMachineStore } from '../../../../store/simulation/useMachineStore';
|
||||
import { useStorageUnitStore } from '../../../../store/simulation/useStorageUnitStore';
|
||||
import { useArmBotEventManager } from '../../roboticArm/eventManager/useArmBotEventManager';
|
||||
import { useConveyorStore } from '../../../../store/simulation/useConveyorStore';
|
||||
import { useConveyorEventManager } from '../../conveyor/eventManager/useConveyorEventManager';
|
||||
import { useVehicleEventManager } from '../../vehicle/eventManager/useVehicleEventManager';
|
||||
import { useMachineEventManager } from '../../machine/eventManager/useMachineEventManager';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
export function useTriggerHandler() {
|
||||
const { materialStore, armBotStore, machineStore, conveyorStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { handleAction } = useActionHandler();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { getEventByTriggerUuid, getEventByModelUuid, getActionByUuid, getModelUuidByActionUuid } = useProductStore();
|
||||
const { getArmBotById } = useArmBotStore();
|
||||
const { getConveyorById } = useConveyorStore();
|
||||
const { getArmBotById } = armBotStore();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const { addArmBotToMonitor } = useArmBotEventManager();
|
||||
const { addConveyorToMonitor } = useConveyorEventManager();
|
||||
const { addVehicleToMonitor } = useVehicleEventManager();
|
||||
const { addMachineToMonitor } = useMachineEventManager();
|
||||
const { getVehicleById } = useVehicleStore();
|
||||
const { getMachineById } = useMachineStore();
|
||||
const { getStorageUnitById } = useStorageUnitStore();
|
||||
const { materialStore } = useSceneContext();
|
||||
const { getVehicleById } = vehicleStore();
|
||||
const { getMachineById } = machineStore();
|
||||
const { getStorageUnitById } = storageUnitStore();
|
||||
const { getMaterialById, setCurrentLocation, setNextLocation, setPreviousLocation, setIsPaused, setIsVisible, setEndTime } = materialStore();
|
||||
|
||||
const handleTrigger = (trigger: TriggerSchema, action: Action, materialId?: string) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useFrame } from '@react-three/fiber';
|
||||
import { useVehicleStore } from '../../../../store/simulation/useVehicleStore';
|
||||
import { usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type VehicleCallback = {
|
||||
vehicleId: string;
|
||||
|
@ -9,7 +9,8 @@ type VehicleCallback = {
|
|||
};
|
||||
|
||||
export function useVehicleEventManager() {
|
||||
const { getVehicleById } = useVehicleStore();
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const { getVehicleById } = vehicleStore();
|
||||
const callbacksRef = useRef<VehicleCallback[]>([]);
|
||||
const isMonitoringRef = useRef(false);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useFrame, useThree } from '@react-three/fiber';
|
|||
import * as THREE from 'three';
|
||||
import { Line } from '@react-three/drei';
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useVehicleStore } from '../../../../../store/simulation/useVehicleStore';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
|
||||
interface VehicleAnimatorProps {
|
||||
path: [number, number, number][];
|
||||
|
@ -15,8 +15,9 @@ interface VehicleAnimatorProps {
|
|||
agvDetail: VehicleStatus;
|
||||
}
|
||||
|
||||
function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetail, reset, startUnloadingProcess }: VehicleAnimatorProps) {
|
||||
const { getVehicleById } = useVehicleStore();
|
||||
function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetail, reset, startUnloadingProcess }: Readonly<VehicleAnimatorProps>) {
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const { getVehicleById } = vehicleStore();
|
||||
const { isPaused } = usePauseButtonStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import VehicleAnimator from '../animator/vehicleAnimator';
|
||||
import * as THREE from 'three';
|
||||
import { NavMeshQuery } from '@recast-navigation/core';
|
||||
import { useNavMesh } from '../../../../../store/builder/store';
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useVehicleStore } from '../../../../../store/simulation/useVehicleStore';
|
||||
import { useArmBotStore } from '../../../../../store/simulation/useArmBotStore';
|
||||
import { useConveyorStore } from '../../../../../store/simulation/useConveyorStore';
|
||||
import { useStorageUnitStore } from '../../../../../store/simulation/useStorageUnitStore';
|
||||
import { useProductStore } from '../../../../../store/simulation/useProductStore';
|
||||
import { useSelectedProduct } from '../../../../../store/simulation/useSimulationStore';
|
||||
import { useTriggerHandler } from '../../../triggers/triggerHandler/useTriggerHandler';
|
||||
|
@ -17,15 +13,15 @@ import { useSceneContext } from '../../../../scene/sceneContext';
|
|||
function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>) {
|
||||
const { navMesh } = useNavMesh();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { materialStore } = useSceneContext();
|
||||
const { materialStore, armBotStore, conveyorStore, vehicleStore, storageUnitStore } = useSceneContext();
|
||||
const { removeMaterial, setEndTime } = materialStore();
|
||||
const { getStorageUnitById } = useStorageUnitStore();
|
||||
const { getArmBotById } = useArmBotStore();
|
||||
const { getConveyorById } = useConveyorStore();
|
||||
const { getStorageUnitById } = storageUnitStore();
|
||||
const { getArmBotById } = armBotStore();
|
||||
const { getConveyorById } = conveyorStore();
|
||||
const { triggerPointActions } = useTriggerHandler();
|
||||
const { getActionByUuid, getEventByModelUuid, getTriggerByUuid } = useProductStore();
|
||||
const { selectedProduct } = useSelectedProduct();
|
||||
const { vehicles, setVehicleActive, setVehicleState, setVehiclePicking, clearCurrentMaterials, setVehicleLoad, decrementVehicleLoad, removeLastMaterial, getLastMaterial, incrementIdleTime, incrementActiveTime, resetTime } = useVehicleStore();
|
||||
const { vehicles, setVehicleActive, setVehicleState, setVehiclePicking, clearCurrentMaterials, setVehicleLoad, decrementVehicleLoad, removeLastMaterial, getLastMaterial, incrementIdleTime, incrementActiveTime, resetTime } = vehicleStore();
|
||||
|
||||
const [currentPhase, setCurrentPhase] = useState<string>('stationed');
|
||||
const [path, setPath] = useState<[number, number, number][]>([]);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from "react";
|
||||
import VehicleInstance from "./instance/vehicleInstance";
|
||||
import { useVehicleStore } from "../../../../store/simulation/useVehicleStore";
|
||||
import VehicleContentUi from "../../ui3d/VehicleContentUi";
|
||||
import { useSceneContext } from "../../../scene/sceneContext";
|
||||
|
||||
function VehicleInstances() {
|
||||
const { vehicles } = useVehicleStore();
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const { vehicles } = vehicleStore();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useVehicleStore } from "../../../store/simulation/useVehicleStore";
|
||||
import { useSelectedEventSphere } from "../../../store/simulation/useSimulationStore";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import VehicleInstances from "./instances/vehicleInstances";
|
||||
import VehicleUI from "../spatialUI/vehicle/vehicleUI";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
|
||||
function Vehicles() {
|
||||
const { getVehicleById } = useVehicleStore();
|
||||
const { vehicleStore } = useSceneContext();
|
||||
const { getVehicleById } = vehicleStore();
|
||||
const { selectedEventSphere } = useSelectedEventSphere();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const [isVehicleSelected, setIsVehicleSelected] = useState(false);
|
||||
|
|
|
@ -34,7 +34,8 @@ interface ArmBotStore {
|
|||
getArmBotsByCurrentAction: (actionUuid: string) => ArmBotStatus[];
|
||||
}
|
||||
|
||||
export const useArmBotStore = create<ArmBotStore>()(
|
||||
export const createArmBotStore = () => {
|
||||
return create<ArmBotStore>()(
|
||||
immer((set, get) => ({
|
||||
armBots: [],
|
||||
|
||||
|
@ -203,4 +204,7 @@ export const useArmBotStore = create<ArmBotStore>()(
|
|||
return get().armBots.filter(a => a.currentAction?.actionUuid === actionUuid);
|
||||
}
|
||||
}))
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export type ArmBotStoreType = ReturnType<typeof createArmBotStore>;
|
|
@ -26,7 +26,8 @@ interface ConveyorStore {
|
|||
getIdleConveyors: () => ConveyorStatus[];
|
||||
}
|
||||
|
||||
export const useConveyorStore = create<ConveyorStore>()(
|
||||
export const createConveyorStore = () => {
|
||||
return create<ConveyorStore>()(
|
||||
immer((set, get) => ({
|
||||
conveyors: [],
|
||||
|
||||
|
@ -133,4 +134,7 @@ export const useConveyorStore = create<ConveyorStore>()(
|
|||
return get().conveyors.filter(c => !c.isActive && c.state === 'idle');
|
||||
},
|
||||
}))
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export type ConveyorStoreType = ReturnType<typeof createConveyorStore>;
|
|
@ -37,7 +37,8 @@ interface MachineStore {
|
|||
getIdleMachines: () => MachineStatus[];
|
||||
}
|
||||
|
||||
export const useMachineStore = create<MachineStore>()(
|
||||
export const createMachineStore = () => {
|
||||
return create<MachineStore>()(
|
||||
immer((set, get) => ({
|
||||
machines: [],
|
||||
|
||||
|
@ -173,4 +174,7 @@ export const useMachineStore = create<MachineStore>()(
|
|||
return get().machines.filter((m) => !m.isActive && m.state === "idle");
|
||||
},
|
||||
}))
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export type MachineStoreType = ReturnType<typeof createMachineStore>;
|
||||
|
|
|
@ -35,7 +35,8 @@ interface StorageUnitStore {
|
|||
getEmptyStorageUnits: () => StorageUnitStatus[];
|
||||
}
|
||||
|
||||
export const useStorageUnitStore = create<StorageUnitStore>()(
|
||||
export const createStorageUnitStore = () => {
|
||||
return create<StorageUnitStore>()(
|
||||
immer((set, get) => ({
|
||||
storageUnits: [],
|
||||
|
||||
|
@ -212,4 +213,7 @@ export const useStorageUnitStore = create<StorageUnitStore>()(
|
|||
return get().storageUnits.filter(s => s.currentLoad === 0);
|
||||
},
|
||||
}))
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export type StorageUnitStoreType = ReturnType<typeof createStorageUnitStore>;
|
|
@ -37,7 +37,8 @@ interface VehiclesStore {
|
|||
getActiveVehicles: () => VehicleStatus[];
|
||||
}
|
||||
|
||||
export const useVehicleStore = create<VehiclesStore>()(
|
||||
export const createVehicleStore = () => {
|
||||
return create<VehiclesStore>()(
|
||||
immer((set, get) => ({
|
||||
vehicles: [],
|
||||
|
||||
|
@ -250,4 +251,7 @@ export const useVehicleStore = create<VehiclesStore>()(
|
|||
return get().vehicles.filter((v) => v.isActive);
|
||||
},
|
||||
}))
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export type VehicleStoreType = ReturnType<typeof createVehicleStore>;
|
Loading…
Reference in New Issue