feat: Implement simulation analysis data display and dashboard element configuration
This commit is contained in:
@@ -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