feat: Implement simulation analysis data display and dashboard element configuration
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -533,7 +533,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
||||
updateElementData(selectedBlock, selectedElement, { label: value });
|
||||
}}
|
||||
/>
|
||||
<InputWithDropDown label="Title" value={`title`} placeholder={"Label 1"} min={0.1} step={0.1} max={2} onChange={() => { }} />
|
||||
<div className="data">
|
||||
<DataDetailedDropdown
|
||||
title="Data Source"
|
||||
|
||||
@@ -284,7 +284,7 @@ function Analyzer() {
|
||||
const timestamp = new Date().toISOString();
|
||||
const newEntry = {
|
||||
timestamp,
|
||||
isActive: conveyor.isActive,
|
||||
isActive: !conveyor.isPaused,
|
||||
speed: conveyor.speed,
|
||||
state: conveyor.state,
|
||||
materialsCount: materialFlow.currentMaterials,
|
||||
@@ -306,7 +306,7 @@ function Analyzer() {
|
||||
assetType: "conveyor",
|
||||
|
||||
currentStatus: {
|
||||
isActive: conveyor.isActive,
|
||||
isActive: !conveyor.isPaused,
|
||||
isPaused: conveyor.isPaused,
|
||||
state: conveyor.state,
|
||||
speed: conveyor.speed,
|
||||
@@ -427,16 +427,19 @@ function Analyzer() {
|
||||
// Update historical data
|
||||
const timestamp = new Date().toISOString();
|
||||
const currentData = historicalDataRef.current[vehicle.modelUuid] || [];
|
||||
historicalDataRef.current[vehicle.modelUuid] = [...currentData, {
|
||||
timestamp,
|
||||
phase: vehicle.currentPhase,
|
||||
load: vehicle.currentLoad,
|
||||
distanceTraveled: actualDistance,
|
||||
state: vehicle.state,
|
||||
performance: performance.performanceRate,
|
||||
speed: vehicle.speed,
|
||||
tripsCompleted,
|
||||
}].slice(-100);
|
||||
historicalDataRef.current[vehicle.modelUuid] = [
|
||||
...currentData,
|
||||
{
|
||||
timestamp,
|
||||
phase: vehicle.currentPhase,
|
||||
load: vehicle.currentLoad,
|
||||
distanceTraveled: actualDistance,
|
||||
state: vehicle.state,
|
||||
performance: performance.performanceRate,
|
||||
speed: vehicle.speed,
|
||||
tripsCompleted,
|
||||
},
|
||||
].slice(-100);
|
||||
|
||||
return {
|
||||
assetId: vehicle.modelUuid,
|
||||
@@ -698,15 +701,18 @@ function Analyzer() {
|
||||
// Update historical data
|
||||
const timestamp = new Date().toISOString();
|
||||
const currentData = historicalDataRef.current[machine.modelUuid] || [];
|
||||
historicalDataRef.current[machine.modelUuid] = [...currentData, {
|
||||
timestamp,
|
||||
processTime: actualProcessTime,
|
||||
partsProcessed,
|
||||
isActive: machine.isActive,
|
||||
state: machine.state,
|
||||
defectRate,
|
||||
performance: performance.performanceRate,
|
||||
}].slice(-100);
|
||||
historicalDataRef.current[machine.modelUuid] = [
|
||||
...currentData,
|
||||
{
|
||||
timestamp,
|
||||
processTime: actualProcessTime,
|
||||
partsProcessed,
|
||||
isActive: machine.isActive,
|
||||
state: machine.state,
|
||||
defectRate,
|
||||
performance: performance.performanceRate,
|
||||
},
|
||||
].slice(-100);
|
||||
|
||||
return {
|
||||
assetId: machine.modelUuid,
|
||||
@@ -1336,9 +1342,9 @@ function Analyzer() {
|
||||
const averageResidenceTime =
|
||||
materialHistoryRef.current.length > 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user