From 8e491a0002f6e8b3135c06681e64c324cd81f364 Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Wed, 16 Apr 2025 18:30:43 +0530 Subject: [PATCH] feat: Add isActive property to ArmBot state and update IKAnimationController logic refactor: Remove commented console logs in ProcessAnimator and useProcessAnimations --- app/src/modules/simulation/armbot/ArmBot.tsx | 3 +- .../armbot/IKAnimationController.tsx | 2 +- .../simulation/process/processAnimator.tsx | 62 +++++++++---------- .../process/useProcessAnimations.tsx | 4 +- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/app/src/modules/simulation/armbot/ArmBot.tsx b/app/src/modules/simulation/armbot/ArmBot.tsx index 5d55791..066779a 100644 --- a/app/src/modules/simulation/armbot/ArmBot.tsx +++ b/app/src/modules/simulation/armbot/ArmBot.tsx @@ -53,7 +53,8 @@ const ArmBot = ({ armBots, setArmBots, setStaticMachines }: ArmBotProps) => { material: "default", triggerId: '', actions: bot.points.actions, - connections: bot.points.connections + connections: bot.points.connections, + isActive: false })); setArmBots(initialStates); }, [simulationStates, isReset]); diff --git a/app/src/modules/simulation/armbot/IKAnimationController.tsx b/app/src/modules/simulation/armbot/IKAnimationController.tsx index a58e2d8..e2df7f5 100644 --- a/app/src/modules/simulation/armbot/IKAnimationController.tsx +++ b/app/src/modules/simulation/armbot/IKAnimationController.tsx @@ -347,7 +347,7 @@ const IKAnimationController = ({ if (matchedMachine.type === "Conveyor") { setArmBots((prev) => prev.map((arm) => { - if (arm.uuid === uuid) { + if (arm.uuid === uuid && arm.isActive === true) { return { ...arm, isActive: false, diff --git a/app/src/modules/simulation/process/processAnimator.tsx b/app/src/modules/simulation/process/processAnimator.tsx index 04ddf90..2cd574f 100644 --- a/app/src/modules/simulation/process/processAnimator.tsx +++ b/app/src/modules/simulation/process/processAnimator.tsx @@ -169,9 +169,9 @@ const ProcessAnimator: React.FC = ({ const spawnPoint = findSpawnPoint(process); if (!spawnPoint || !spawnPoint.actions) { - console.log( - `Process ${process.id} has no valid spawn point or actions` - ); + // console.log( + // `Process ${process.id} has no valid spawn point or actions` + // ); return; } @@ -255,10 +255,10 @@ const ProcessAnimator: React.FC = ({ // Check connection status with debugging const isConnected = isConnectedToActiveArmBot(process.id); - console.log( - `Process ${process.id} animation - connected:`, - isConnected - ); + // console.log( + // `Process ${process.id} animation - connected:`, + // isConnected + // ); if (isConnected) { // Stop all animations when connected to active arm bot @@ -293,9 +293,9 @@ const ProcessAnimator: React.FC = ({ currentTime - processState.processDelayStartTime >= effectiveDelayTime ) { - console.log( - `Process ${process.id} delay completed, resuming animation` - ); + // console.log( + // `Process ${process.id} delay completed, resuming animation` + // ); newStates[process.id] = { ...processState, isProcessDelaying: false, @@ -331,9 +331,9 @@ const ProcessAnimator: React.FC = ({ []; if (path.length < 2) { - console.log( - `Process ${process.id} has insufficient path points: ${path.length}` - ); + // console.log( + // `Process ${process.id} has insufficient path points: ${path.length}` + // ); return; } @@ -348,9 +348,9 @@ const ProcessAnimator: React.FC = ({ const currentRef = gltf?.scene ? obj.ref.current : obj.ref.current; if (!currentRef) { - console.log( - `No reference for object ${objectId}, skipping animation` - ); + // console.log( + // `No reference for object ${objectId}, skipping animation` + // ); return; } @@ -378,9 +378,9 @@ const ProcessAnimator: React.FC = ({ stateRef.currentDelayDuration / speedRef.current; if (currentTime - stateRef.delayStartTime >= effectiveDelayTime) { - console.log( - `Delay complete for object ${objectId}, resuming animation` - ); + // console.log( + // `Delay complete for object ${objectId}, resuming animation` + // ); stateRef.isDelaying = false; stateRef.delayComplete = true; stateRef.isAnimating = true; @@ -408,9 +408,9 @@ const ProcessAnimator: React.FC = ({ // Skip non-animating objects if (!stateRef.isAnimating) { - console.log( - `Object ${objectId} not animating, skipping animation updates` - ); + // console.log( + // `Object ${objectId} not animating, skipping animation updates` + // ); return; } @@ -454,9 +454,9 @@ const ProcessAnimator: React.FC = ({ if (shouldHide) { if (isAgvPicking) { - console.log( - `AGV picking at last point for object ${objectId}, hiding object` - ); + // console.log( + // `AGV picking at last point for object ${objectId}, hiding object` + // ); updatedObjects[objectId] = { ...obj, visible: false, @@ -517,14 +517,14 @@ const ProcessAnimator: React.FC = ({ if (stateRef.delayComplete && stateRef.progress < 0.01) { stateRef.progress = 0.05; stateRef.delayComplete = false; - console.log( - `Boosting progress for object ${objectId} after delay` - ); + // console.log( + // `Boosting progress for object ${objectId} after delay` + // ); } else { stateRef.progress += movement / distance; - console.log( - `Object ${objectId} progress: ${stateRef.progress.toFixed(3)}` - ); + // console.log( + // `Object ${objectId} progress: ${stateRef.progress.toFixed(3)}` + // ); } // Handle point transition diff --git a/app/src/modules/simulation/process/useProcessAnimations.tsx b/app/src/modules/simulation/process/useProcessAnimations.tsx index a46fe3c..579ee3f 100644 --- a/app/src/modules/simulation/process/useProcessAnimations.tsx +++ b/app/src/modules/simulation/process/useProcessAnimations.tsx @@ -514,8 +514,6 @@ export const useProcessAnimation = ( newTriggerCounts[triggerKey] = (newTriggerCounts[triggerKey] || 0) + 1; - shouldLog = true; - newTriggerLogs.push({ timestamp: currentTime, pointId: point.uuid, objectId, triggerId: trigger.uuid, }); const connections = point.connections?.targets || []; @@ -530,6 +528,8 @@ export const useProcessAnimation = ( uuid: connectedModelUUID, triggerId: trigger.uuid, }); + } else { + shouldLog = true; } }); });