schema changes
This commit is contained in:
@@ -10,6 +10,9 @@ interface VehiclesStore {
|
|||||||
modelUuid: string,
|
modelUuid: string,
|
||||||
updates: Partial<Omit<VehicleStatus, "modelUuid" | "productUuid">>
|
updates: Partial<Omit<VehicleStatus, "modelUuid" | "productUuid">>
|
||||||
) => void;
|
) => void;
|
||||||
|
addPathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], point: VehicleAction["paths"]["initPickup"][number]) => VehicleAction["paths"];
|
||||||
|
updatePathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], pointId: string, updates: Partial<VehicleAction["paths"]["initPickup"][number]>) => VehicleAction["paths"];
|
||||||
|
deletePathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], pointId: string) => VehicleAction["paths"];
|
||||||
clearVehicles: () => void;
|
clearVehicles: () => void;
|
||||||
|
|
||||||
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
||||||
@@ -79,6 +82,48 @@ export const createVehicleStore = () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addPathPoint: (modelUuid, pathKey, point) => {
|
||||||
|
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||||
|
set((state) => {
|
||||||
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
if (vehicle) {
|
||||||
|
const path = vehicle.point.action.paths[pathKey];
|
||||||
|
path.push(point);
|
||||||
|
updatedPaths = vehicle.point.action.paths;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return updatedPaths;
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePathPoint: (modelUuid, pathKey, pointId, updates) => {
|
||||||
|
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||||
|
set((state) => {
|
||||||
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
if (vehicle) {
|
||||||
|
const path = vehicle.point.action.paths[pathKey];
|
||||||
|
const index = path.findIndex(p => p.pointId === pointId);
|
||||||
|
if (index !== -1) {
|
||||||
|
Object.assign(path[index], updates);
|
||||||
|
updatedPaths = vehicle.point.action.paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return updatedPaths;
|
||||||
|
},
|
||||||
|
|
||||||
|
deletePathPoint: (modelUuid, pathKey, pointId) => {
|
||||||
|
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||||
|
set((state) => {
|
||||||
|
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||||
|
if (vehicle) {
|
||||||
|
const path = vehicle.point.action.paths[pathKey];
|
||||||
|
vehicle.point.action.paths[pathKey] = path.filter(p => p.pointId !== pointId);
|
||||||
|
updatedPaths = vehicle.point.action.paths;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return updatedPaths;
|
||||||
|
},
|
||||||
|
|
||||||
clearVehicles: () => {
|
clearVehicles: () => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
state.vehicles = [];
|
state.vehicles = [];
|
||||||
|
|||||||
24
app/src/types/simulationTypes.d.ts
vendored
24
app/src/types/simulationTypes.d.ts
vendored
@@ -41,9 +41,27 @@ interface VehicleAction {
|
|||||||
pickUpPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
pickUpPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||||
unLoadPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
unLoadPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||||
paths: {
|
paths: {
|
||||||
initPickup: [number, number, number][],
|
initPickup: {
|
||||||
pickupDrop: [number, number, number][],
|
pointId: string;
|
||||||
dropPickup: [number, number, number][],
|
position: [number, number, number];
|
||||||
|
isCurved: boolean;
|
||||||
|
handleA: [number, number, number] | null;
|
||||||
|
handleB: [number, number, number] | null;
|
||||||
|
}[],
|
||||||
|
pickupDrop: {
|
||||||
|
pointId: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
isCurved: boolean;
|
||||||
|
handleA: [number, number, number] | null;
|
||||||
|
handleB: [number, number, number] | null;
|
||||||
|
}[],
|
||||||
|
dropPickup: {
|
||||||
|
pointId: string;
|
||||||
|
position: [number, number, number];
|
||||||
|
isCurved: boolean;
|
||||||
|
handleA: [number, number, number] | null;
|
||||||
|
handleB: [number, number, number] | null;
|
||||||
|
}[],
|
||||||
}
|
}
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user