feat: Add simulation analyzer component for comprehensive simulation data tracking and performance metrics.
This commit is contained in:
@@ -190,6 +190,9 @@ function Analyzer() {
|
|||||||
// Track previous action counts for Humans to detect completion from EventManager
|
// Track previous action counts for Humans to detect completion from EventManager
|
||||||
const previousHumanCountsRef = useRef<Record<string, Record<string, number>>>({});
|
const previousHumanCountsRef = useRef<Record<string, Record<string, number>>>({});
|
||||||
|
|
||||||
|
// Track previous vehicle phases to detect trip completion
|
||||||
|
const previousVehiclePhasesRef = useRef<Record<string, string>>({});
|
||||||
|
|
||||||
// Material lifecycle tracking
|
// Material lifecycle tracking
|
||||||
const materialLifecycleRef = useRef<
|
const materialLifecycleRef = useRef<
|
||||||
Record<
|
Record<
|
||||||
@@ -223,6 +226,7 @@ function Analyzer() {
|
|||||||
previousAssetStatesRef.current = {};
|
previousAssetStatesRef.current = {};
|
||||||
previousArmBotActionsRef.current = {};
|
previousArmBotActionsRef.current = {};
|
||||||
previousHumanCountsRef.current = {};
|
previousHumanCountsRef.current = {};
|
||||||
|
previousVehiclePhasesRef.current = {};
|
||||||
materialLifecycleRef.current = {};
|
materialLifecycleRef.current = {};
|
||||||
setAnalysis(null);
|
setAnalysis(null);
|
||||||
setAnalyzing(false);
|
setAnalyzing(false);
|
||||||
@@ -2457,6 +2461,26 @@ function Analyzer() {
|
|||||||
return () => clearInterval(snapshotInterval);
|
return () => clearInterval(snapshotInterval);
|
||||||
}, [conveyors, machines, armBots, vehicles, humans, cranes, storageUnits, isPlaying, updateWIPSnapshot]);
|
}, [conveyors, machines, armBots, vehicles, humans, cranes, storageUnits, isPlaying, updateWIPSnapshot]);
|
||||||
|
|
||||||
|
// Monitor Vehicle phase changes to track completed trips
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isPlaying) return;
|
||||||
|
|
||||||
|
vehicles.forEach((vehicle) => {
|
||||||
|
const previousPhase = previousVehiclePhasesRef.current[vehicle.modelUuid];
|
||||||
|
const currentPhase = vehicle.currentPhase;
|
||||||
|
|
||||||
|
// Check for transition from 'drop-pickup' to 'picking' (Trip completed)
|
||||||
|
if (previousPhase === "drop-pickup" && currentPhase === "picking") {
|
||||||
|
if (!completedActionsRef.current[vehicle.modelUuid]) {
|
||||||
|
completedActionsRef.current[vehicle.modelUuid] = 0;
|
||||||
|
}
|
||||||
|
completedActionsRef.current[vehicle.modelUuid]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousVehiclePhasesRef.current[vehicle.modelUuid] = currentPhase;
|
||||||
|
});
|
||||||
|
}, [vehicles, isPlaying]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user