Compare commits
1 Commits
realTimeVi
...
simulation
| Author | SHA1 | Date | |
|---|---|---|---|
| 686c4e60c6 |
@@ -95,7 +95,7 @@ const Agv: React.FC<ProcessContainerProps> = ({
|
||||
/>
|
||||
|
||||
{pair.points.slice(1).map((point, idx) => (
|
||||
<mesh position={[point.x, point.y, point.z]} key={idx}>
|
||||
<mesh position={[point.x, point.y, point.z]} key={idx} visible={!isPlaying}>
|
||||
<sphereGeometry args={[0.3, 15, 15]} />
|
||||
<meshStandardMaterial color="red" />
|
||||
</mesh>
|
||||
|
||||
@@ -456,7 +456,7 @@ export default function PathNavigator({
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<group name="path-navigator-lines">
|
||||
<group name="path-navigator-lines" visible={!isPlaying} >
|
||||
{toPickupPath.length > 0 && (
|
||||
<Line
|
||||
points={toPickupPath}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
usePlayButtonStore,
|
||||
useResetButtonStore,
|
||||
} from "../../../store/usePlayButtonStore";
|
||||
import { usePlayAgv } from "../../../store/store";
|
||||
import { usePlayAgv, useSimulationStates } from "../../../store/store";
|
||||
|
||||
interface ArmBotProcess {
|
||||
triggerId: string;
|
||||
@@ -82,6 +82,7 @@ export const useProcessAnimation = (
|
||||
const [animationStates, setAnimationStates] = useState<Record<string, EnhancedProcessAnimationState>>({});
|
||||
const speedRef = useRef<number>(speed);
|
||||
const { PlayAgv, setPlayAgv } = usePlayAgv();
|
||||
const { simulationStates } = useSimulationStates();
|
||||
|
||||
// Effect hooks
|
||||
useEffect(() => {
|
||||
@@ -521,15 +522,19 @@ export const useProcessAnimation = (
|
||||
connections.forEach((connection) => {
|
||||
const connectedModelUUID = connection.modelUUID;
|
||||
|
||||
const matchingArmPath = armBotPaths.find((path) => path.modeluuid === connectedModelUUID);
|
||||
const isConveyor = simulationStates.find((state) => state.modeluuid === connectedModelUUID && state.type === "Conveyor");
|
||||
|
||||
if (matchingArmPath) {
|
||||
deferredArmBotUpdates.current.push({
|
||||
uuid: connectedModelUUID,
|
||||
triggerId: trigger.uuid,
|
||||
});
|
||||
} else {
|
||||
shouldLog = true;
|
||||
if (!isConveyor) {
|
||||
const matchingArmPath = armBotPaths.find((path) => path.modeluuid === connectedModelUUID);
|
||||
|
||||
if (matchingArmPath) {
|
||||
deferredArmBotUpdates.current.push({
|
||||
uuid: connectedModelUUID,
|
||||
triggerId: trigger.uuid,
|
||||
});
|
||||
} else {
|
||||
shouldLog = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -592,6 +597,7 @@ export const useProcessAnimation = (
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// console.log('deferredArmBotUpdates: ', deferredArmBotUpdates);
|
||||
if (deferredArmBotUpdates.current.length > 0) {
|
||||
const updates = [...deferredArmBotUpdates.current];
|
||||
deferredArmBotUpdates.current = [];
|
||||
|
||||
@@ -193,18 +193,12 @@ export const DraggableWidget = ({
|
||||
};
|
||||
|
||||
if (visualizationSocket) {
|
||||
console.log('duplicated');
|
||||
|
||||
visualizationSocket.emit("v2:viz-widget:add", duplicateWidget, (res: any)=> {
|
||||
if (res.success) {
|
||||
setSelectedZone((prevZone: any) => ({
|
||||
...prevZone,
|
||||
widgets: [...prevZone.widgets, duplicatedWidget],
|
||||
}));
|
||||
}
|
||||
});
|
||||
visualizationSocket.emit("v2:viz-widget:add", duplicateWidget);
|
||||
}
|
||||
|
||||
setSelectedZone((prevZone: any) => ({
|
||||
...prevZone,
|
||||
widgets: [...prevZone.widgets, duplicatedWidget],
|
||||
}));
|
||||
|
||||
// const response = await duplicateWidgetApi(selectedZone.zoneId, organization, duplicatedWidget);
|
||||
|
||||
@@ -356,14 +350,13 @@ export const DraggableWidget = ({
|
||||
{/* Render charts based on widget type */}
|
||||
|
||||
{widget.type === "progress 1" && (
|
||||
<ProgressCard1 key={widget.id} title={widget.title} id={widget.id} />
|
||||
<ProgressCard1 title={widget.title} id={widget.id} />
|
||||
)}
|
||||
{widget.type === "progress 2" && (
|
||||
<ProgressCard2 key={widget.id} title={widget.title} id={widget.id} />
|
||||
<ProgressCard2 title={widget.title} id={widget.id} />
|
||||
)}
|
||||
{widget.type === "line" && (
|
||||
<LineGraphComponent
|
||||
key={widget.id}
|
||||
id={widget.id}
|
||||
type={widget.type}
|
||||
title={widget.title}
|
||||
@@ -373,7 +366,6 @@ export const DraggableWidget = ({
|
||||
)}
|
||||
{widget.type === "bar" && (
|
||||
<BarGraphComponent
|
||||
key={widget.id}
|
||||
id={widget.id}
|
||||
type={widget.type}
|
||||
title={widget.title}
|
||||
@@ -383,7 +375,6 @@ export const DraggableWidget = ({
|
||||
)}
|
||||
{widget.type === "pie" && (
|
||||
<PieGraphComponent
|
||||
key={widget.id}
|
||||
id={widget.id}
|
||||
type={widget.type}
|
||||
title={widget.title}
|
||||
@@ -393,7 +384,6 @@ export const DraggableWidget = ({
|
||||
)}
|
||||
{widget.type === "doughnut" && (
|
||||
<DoughnutGraphComponent
|
||||
key={widget.id}
|
||||
id={widget.id}
|
||||
type={widget.type}
|
||||
title={widget.title}
|
||||
@@ -403,7 +393,6 @@ export const DraggableWidget = ({
|
||||
)}
|
||||
{widget.type === "polarArea" && (
|
||||
<PolarAreaGraphComponent
|
||||
key={widget.id}
|
||||
id={widget.id}
|
||||
type={widget.type}
|
||||
title={widget.title}
|
||||
|
||||
@@ -273,13 +273,7 @@ export default function Dropped3dWidgets() {
|
||||
zoneId: selectedZone.zoneId,
|
||||
};
|
||||
if (visualizationSocket) {
|
||||
visualizationSocket.emit("v2:viz-3D-widget:add", adding3dWidget,(res:any)=>{
|
||||
if (res.success) {
|
||||
addWidget(selectedZone.zoneId, newWidget);
|
||||
setRightSelect(null);
|
||||
setRightClickSelected(null);
|
||||
}
|
||||
});
|
||||
visualizationSocket.emit("v2:viz-3D-widget:add", adding3dWidget);
|
||||
}
|
||||
// let response = await adding3dWidgets(selectedZone.zoneId, organization, newWidget)
|
||||
//
|
||||
|
||||
@@ -132,6 +132,7 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
|
||||
: originalObject.position.left,
|
||||
},
|
||||
};
|
||||
console.log("duplicated object",duplicatedObject);
|
||||
|
||||
let duplicateFloatingWidget = {
|
||||
organization: organization,
|
||||
@@ -143,23 +144,18 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
|
||||
if (visualizationSocket) {
|
||||
visualizationSocket.emit(
|
||||
"v2:viz-float:addDuplicate",
|
||||
duplicateFloatingWidget,
|
||||
(res:any)=>{
|
||||
if (res.success) {
|
||||
useDroppedObjectsStore.setState((state) => ({
|
||||
zones: {
|
||||
...state.zones,
|
||||
[zoneName]: {
|
||||
...state.zones[zoneName],
|
||||
objects: [...state.zones[zoneName].objects, duplicatedObject], // Append duplicated object
|
||||
},
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
duplicateFloatingWidget
|
||||
);
|
||||
}
|
||||
|
||||
useDroppedObjectsStore.setState((state) => ({
|
||||
zones: {
|
||||
...state.zones,
|
||||
[zoneName]: {
|
||||
...state.zones[zoneName],
|
||||
objects: [...state.zones[zoneName].objects, duplicatedObject], // Append duplicated object
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
// Make async API call outside of Zustand set function
|
||||
// let response = await addingFloatingWidgets(
|
||||
|
||||
129
app/src/types/simulationTypes.d.ts
vendored
129
app/src/types/simulationTypes.d.ts
vendored
@@ -161,3 +161,132 @@ export type EventData = {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
interface AssetEventSchema {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||
}
|
||||
|
||||
interface TriggerSchema {
|
||||
triggerUuid: string;
|
||||
triggerName: string;
|
||||
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||
delay: number;
|
||||
triggeredAsset: {
|
||||
triggeredModel: { modelName: string, modelUuid: string };
|
||||
triggeredAction: { actionName: string, actionUuid: string };
|
||||
} | null;
|
||||
}
|
||||
|
||||
interface TransferPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||
material: string | "inherit";
|
||||
delay: number | "inherit";
|
||||
spawnInterval: number | "inherit";
|
||||
spawnCount: number | "inherit";
|
||||
triggers: TriggerSchema[] | [];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface VehiclePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "travel";
|
||||
material: string;
|
||||
unLoadDuration: number;
|
||||
loadCapacity: number;
|
||||
pickUpPoint: { x: number; y: number, z: number } | {};
|
||||
unLoadPoint: { x: number; y: number, z: number } | {};
|
||||
triggers: TriggerSchema[] | [];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface RoboticArmPointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "pickAndPlace";
|
||||
process: { startPoint: string; endPoint: string };
|
||||
triggers: TriggerSchema[] | [];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface MachinePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "process";
|
||||
processTime: number;
|
||||
swapMaterial: string;
|
||||
triggers: TriggerSchema[] | [];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface StoragePointSchema {
|
||||
uuid: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
actions: {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "storage";
|
||||
materials: { materialName: string; materialId: string; quantity: number }[];
|
||||
storageCapacity: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface TransferEventSchema extends AssetEventSchema {
|
||||
type: "transfer";
|
||||
speed: number;
|
||||
points: TransferPointSchema[];
|
||||
}
|
||||
|
||||
interface VehicleSchemaEvent extends AssetEventSchema {
|
||||
type: "vehicle";
|
||||
speed: number;
|
||||
point: VehiclePointSchema;
|
||||
}
|
||||
|
||||
interface RoboticArmSchemaEvent extends AssetEventSchema {
|
||||
type: "roboticArm";
|
||||
speed: number;
|
||||
point: RoboticArmPointSchema;
|
||||
}
|
||||
|
||||
interface MachineSchemaEvent extends AssetEventSchema {
|
||||
type: "machine";
|
||||
point: MachinePointSchema;
|
||||
}
|
||||
|
||||
interface StorageSchemaEvent extends AssetEventSchema {
|
||||
type: "storageUnit";
|
||||
point: StoragePointSchema;
|
||||
}
|
||||
|
||||
type EventsSchema = TransferEventSchema | VehicleSchemaEvent | RoboticArmSchemaEvent | MachineSchemaEvent | StorageSchemaEvent | [];
|
||||
|
||||
type productsSchema = {
|
||||
productName: string;
|
||||
productId: string;
|
||||
eventsData: EventsSchema[];
|
||||
}[] | []
|
||||
Reference in New Issue
Block a user