feat: introduce comprehensive simulation analysis module with detailed performance and material flow tracking.
This commit is contained in:
@@ -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
|
// ENHANCED UTILITY FUNCTIONS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -2157,6 +2179,14 @@ function Analyzer() {
|
|||||||
performAnalysisRef.current = performAnalysis;
|
performAnalysisRef.current = performAnalysis;
|
||||||
}, [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
|
// Perform initial analysis and set up interval
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPlaying) return;
|
if (!isPlaying) return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ interface AnalysisStore {
|
|||||||
lastUpdateTime: string | null;
|
lastUpdateTime: string | null;
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
setAnalysis: (analysis: AnalysisSchema) => void;
|
setAnalysis: (analysis: AnalysisSchema | null) => void;
|
||||||
updateAssetAnalysis: (assetId: string, assetAnalysis: AssetAnalysis) => void;
|
updateAssetAnalysis: (assetId: string, assetAnalysis: AssetAnalysis) => void;
|
||||||
addHistoricalDataPoint: (assetId: string, dataPoint: any) => void;
|
addHistoricalDataPoint: (assetId: string, dataPoint: any) => void;
|
||||||
clearAnalysis: () => void;
|
clearAnalysis: () => void;
|
||||||
@@ -29,7 +29,7 @@ export const createAnalysisStore = () => {
|
|||||||
lastUpdateTime: null,
|
lastUpdateTime: null,
|
||||||
|
|
||||||
// Set complete analysis
|
// Set complete analysis
|
||||||
setAnalysis: (analysis: AnalysisSchema) => {
|
setAnalysis: (analysis: AnalysisSchema | null) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
state.analysis = analysis;
|
state.analysis = analysis;
|
||||||
state.lastUpdateTime = new Date().toISOString();
|
state.lastUpdateTime = new Date().toISOString();
|
||||||
|
|||||||
Reference in New Issue
Block a user