Enhance material handling: add support for additional materials in conveyor and machine mechanics, update action types, and implement material model loading.

This commit is contained in:
2025-05-05 14:26:38 +05:30
parent 19d41a775c
commit 6b0ee0ae79
15 changed files with 372 additions and 178 deletions

View File

@@ -84,6 +84,7 @@ export const useArmBotStore = create<ArmBotStore>()(
armBot.currentAction = {
actionUuid: action.actionUuid,
actionName: action.actionName,
materialType: null
};
}
}

View File

@@ -78,6 +78,7 @@ export const useMachineStore = create<MachineStore>()(
armBot.currentAction = {
actionUuid: action.actionUuid,
actionName: action.actionName,
materialType: null
};
}
}

View File

@@ -63,6 +63,7 @@ type ProductsStore = {
getEventByModelUuid: (productId: string, modelUuid: string) => EventsSchema | undefined;
getPointByUuid: (productId: string, modelUuid: string, pointUuid: string) => ConveyorPointSchema | VehiclePointSchema | RoboticArmPointSchema | MachinePointSchema | StoragePointSchema | undefined;
getActionByUuid: (productId: string, actionUuid: string) => (ConveyorPointSchema['action'] | VehiclePointSchema['action'] | RoboticArmPointSchema['actions'][0] | MachinePointSchema['action'] | StoragePointSchema['action']) | undefined;
getModelUuidByPointUuid: (productId: string, actionUuid: string) => (string) | undefined;
getModelUuidByActionUuid: (productId: string, actionUuid: string) => (string) | undefined;
getPointUuidByActionUuid: (productId: string, actionUuid: string) => (string) | undefined;
getTriggerByUuid: (productId: string, triggerUuid: string) => TriggerSchema | undefined;
@@ -575,6 +576,27 @@ export const useProductStore = create<ProductsStore>()(
return undefined;
},
getModelUuidByPointUuid: (productId, pointUuid) => {
const product = get().products.find(p => p.productId === productId);
if (!product) return undefined;
for (const event of product.eventDatas) {
if ('points' in event) {
for (const point of (event as ConveyorEventSchema).points) {
if (point.uuid === pointUuid) {
return event.modelUuid;
}
}
} else if ('point' in event) {
const point = (event as any).point;
if (point.uuid === pointUuid) {
return event.modelUuid;
}
}
}
return undefined;
},
getModelUuidByActionUuid: (productId, actionUuid) => {
const product = get().products.find(p => p.productId === productId);
if (!product) return undefined;

View File

@@ -2,15 +2,6 @@
import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';
interface VehicleStatus extends VehicleEventSchema {
productId: string;
isActive: boolean;
idleTime: number;
activeTime: number;
currentLoad: number;
distanceTraveled: number;
}
interface VehiclesStore {
vehicles: VehicleStatus[];
@@ -27,6 +18,7 @@ interface VehiclesStore {
incrementVehicleLoad: (modelUuid: string, incrementBy: number) => void;
decrementVehicleLoad: (modelUuid: string, decrementBy: number) => void;
setVehicleState: (modelUuid: string, newState: VehicleStatus['state']) => void;
setMaterialType: (modelUuid: string, materialType: string | null) => void;
incrementActiveTime: (modelUuid: string, incrementBy: number) => void;
incrementIdleTime: (modelUuid: string, incrementBy: number) => void;
@@ -51,6 +43,7 @@ export const useVehicleStore = create<VehiclesStore>()(
idleTime: 0,
activeTime: 0,
currentLoad: 0,
materialType: null,
distanceTraveled: 0,
});
}
@@ -123,6 +116,15 @@ export const useVehicleStore = create<VehiclesStore>()(
});
},
setMaterialType: (modelUuid, materialType) => {
set((state) => {
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
if (vehicle) {
vehicle.materialType = materialType;
}
});
},
incrementActiveTime: (modelUuid, incrementBy) => {
set((state) => {
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);