From 5a1d1bdeafa3aa360c20287cb480f9d72d60f8ed Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Thu, 18 Dec 2025 13:13:09 +0530 Subject: [PATCH] feat: Implement simulation analysis data display and dashboard element configuration --- .../SimulationDashboard/AnalyzerManager.tsx | 2 +- .../components/element/ElementEditor.tsx | 1 - .../modules/simulation/analyzer/analyzer.tsx | 70 +++++++++++-------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/app/src/components/SimulationDashboard/AnalyzerManager.tsx b/app/src/components/SimulationDashboard/AnalyzerManager.tsx index c181cf4..aead756 100644 --- a/app/src/components/SimulationDashboard/AnalyzerManager.tsx +++ b/app/src/components/SimulationDashboard/AnalyzerManager.tsx @@ -121,7 +121,7 @@ const AnalyzerManager: React.FC = () => { if (hasValidData) { const currentGraphData = element.graphData || []; - const newGraphData = [...currentGraphData, newPoint].slice(-20); + const newGraphData = [...currentGraphData, newPoint].slice(-10); // Always update for single-machine as we are appending time-series data updateGraphData(block.blockUuid, element.elementUuid, newGraphData); diff --git a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx index b304518..28991e3 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx @@ -533,7 +533,6 @@ const ElementEditor: React.FC = ({ updateElementData(selectedBlock, selectedElement, { label: value }); }} /> - { }} />
0 ? materialHistoryRef.current.reduce((sum, entry) => { - const residenceTime = new Date(entry.removedAt).getTime() - (entry.material.startTime || 0); - return sum + (residenceTime || 0); - }, 0) / materialHistoryRef.current.length + const residenceTime = new Date(entry.removedAt).getTime() - (entry.material.startTime || 0); + return sum + (residenceTime || 0); + }, 0) / materialHistoryRef.current.length : 0; // Bottleneck Identification @@ -1604,23 +1610,27 @@ function Analyzer() { // EFFECTS // ============================================================================ + const performAnalysisRef = useRef(performAnalysis); + + useEffect(() => { + performAnalysisRef.current = performAnalysis; + }, [performAnalysis]); + // Perform initial analysis and set up interval useEffect(() => { if (!isPlaying) return; - // Initial analysis - performAnalysis(); - // Set up periodic analysis (every 5 seconds) + // Set up periodic analysis (every 1 second) analysisIntervalRef.current = setInterval(() => { - performAnalysis(); - }, 5000); + performAnalysisRef.current(); + }, 1000); return () => { if (analysisIntervalRef.current) { clearInterval(analysisIntervalRef.current); } }; - }, [isPlaying, conveyors, vehicles, armBots, machines, humans, cranes, materials]); + }, [isPlaying]); return null; }