feat: introduce comprehensive simulation analysis module with detailed performance and material flow tracking.

This commit is contained in:
2025-12-18 16:23:14 +05:30
parent b3adb4ea20
commit c072648397
2 changed files with 32 additions and 2 deletions

View File

@@ -203,6 +203,28 @@ function Analyzer() {
>
>({});
const resetAllRefs = () => {
assetCyclesRef.current = {};
assetStateChangesRef.current = {};
materialAdditionsRef.current = {};
materialRemovalsRef.current = {};
materialProcessingTimesRef.current = {};
wipSnapshotsRef.current = {};
throughputSnapshotsRef.current = {};
performanceSnapshotsRef.current = {};
bottleneckEventsRef.current = {};
previousAssetStatesRef.current = {};
materialLifecycleRef.current = {};
setAnalysis(null);
setAnalyzing(false);
};
useEffect(() => {
if (!isPlaying) {
resetAllRefs();
}
}, [isPlaying]);
// ============================================================================
// ENHANCED UTILITY FUNCTIONS
// ============================================================================
@@ -2157,6 +2179,14 @@ function Analyzer() {
performAnalysisRef.current = performAnalysis;
}, [performAnalysis]);
// Trigger analysis when assets or materials change
useEffect(() => {
if (!isPlaying) return;
// Perform analysis when any asset or material state changes
performAnalysisRef.current();
}, [conveyors, vehicles, armBots, machines, humans, cranes, materials, isPlaying]);
// Perform initial analysis and set up interval
useEffect(() => {
if (!isPlaying) return;

View File

@@ -7,7 +7,7 @@ interface AnalysisStore {
lastUpdateTime: string | null;
// Actions
setAnalysis: (analysis: AnalysisSchema) => void;
setAnalysis: (analysis: AnalysisSchema | null) => void;
updateAssetAnalysis: (assetId: string, assetAnalysis: AssetAnalysis) => void;
addHistoricalDataPoint: (assetId: string, dataPoint: any) => void;
clearAnalysis: () => void;
@@ -29,7 +29,7 @@ export const createAnalysisStore = () => {
lastUpdateTime: null,
// Set complete analysis
setAnalysis: (analysis: AnalysisSchema) => {
setAnalysis: (analysis: AnalysisSchema | null) => {
set((state) => {
state.analysis = analysis;
state.lastUpdateTime = new Date().toISOString();