Enhance Machine and Vehicle components: add current action management and update machine sample structure

This commit is contained in:
2025-05-02 12:11:09 +05:30
parent 405dbe434f
commit 34c30bb5a2
4 changed files with 78 additions and 20 deletions

View File

@@ -1,29 +1,42 @@
import React from 'react'
import React, { useEffect } from 'react'
import MachineInstances from './instances/machineInstances'
import { useMachineStore } from '../../../store/simulation/useMachineStore'
import { useSelectedProduct } from '../../../store/simulation/useSimulationStore';
function Machine() {
const { addMachine, addCurrentAction, removeMachine } = useMachineStore();
const { selectedProduct } = useSelectedProduct();
const machineSample: MachineEventSchema = {
modelUuid: "machine-1234-5678-9012",
modelName: "CNC Milling Machine",
position: [10, 0, 5],
rotation: [0, 0, 0],
state: "idle",
type: "machine",
point: {
uuid: "machine-point-9876-5432-1098",
position: [10, 0.5, 5.2],
const machineSample: MachineEventSchema[] = [
{
modelUuid: "machine-1234-5678-9012",
modelName: "CNC Milling Machine",
position: [10, 0, 5],
rotation: [0, 0, 0],
action: {
actionUuid: "machine-action-2468-1357-8024",
actionName: "Metal Processing",
actionType: "process",
processTime: 10,
swapMaterial: "steel",
triggers: []
state: "idle",
type: "machine",
point: {
uuid: "machine-point-9876-5432-1098",
position: [10, 0.5, 5.2],
rotation: [0, 0, 0],
action: {
actionUuid: "machine-action-2468-1357-8024",
actionName: "Metal Processing",
actionType: "process",
processTime: 10,
swapMaterial: "steel",
triggers: []
}
}
}
};
];
useEffect(() => {
removeMachine(machineSample[0].modelUuid);
addMachine(selectedProduct.productId, machineSample[0]);
// addCurrentAction(machineSample[0].modelUuid, machineSample[0].point.action.actionUuid);
}, [])
return (
<>

View File

@@ -8,7 +8,7 @@ import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
import { useProductStore } from "../../../store/simulation/useProductStore";
function Vehicles() {
const { getProductById } = useProductStore();
const { products, getProductById } = useProductStore();
const { selectedProduct } = useSelectedProduct();
const { vehicles, addVehicle, removeVehicle } = useVehicleStore();
const { selectedEventSphere } = useSelectedEventSphere();
@@ -29,6 +29,19 @@ function Vehicles() {
}
}
}, [selectedProduct]);
// useEffect(() => {
// vehicles.forEach(vehicle => {
// const product = getProductById(vehicle.productId);
// if (product) {
// const eventData = product.eventDatas.find(event => event.modelUuid === vehicle.modelUuid);
// if (eventData) {
// vehicle.eventData = eventData;
// }
// }
// });
// }, [vehicles, products]);
useEffect(() => {
// console.log('vehicles: ', vehicles);