feat: Add new simulation module and a detailed performance analyzer component.

This commit is contained in:
2025-12-20 16:02:30 +05:30
parent 75912355c7
commit cba37f2675
2 changed files with 18 additions and 19 deletions

View File

@@ -1722,8 +1722,8 @@ function Analyzer() {
// Success rates
const liftAttempts = totalLifts + errorCount;
const liftSuccessRate = liftAttempts > 0 ? (totalLifts / liftAttempts) * 100 : 100;
const positioningAccuracy = liftSuccessRate * 0.98; // Slightly lower than success rate
const liftSuccessRate = liftAttempts > 0 ? (totalLifts / liftAttempts) * 100 : 0;
const positioningAccuracy = totalLifts > 0 ? liftSuccessRate * 1.0 : 0; // Slightly lower than success rate
// Load utilization
const maxPickUpCount = crane.point?.actions?.[0]?.maxPickUpCount || 1;
@@ -2499,22 +2499,6 @@ function Analyzer() {
const previousPhase = previousCranePhasesRef.current[crane.modelUuid];
const currentPhase = crane.currentPhase;
// Check for transition from 'pickup-drop' to 'init' (Cycle completed)
if (previousPhase === "pickup-drop" && currentPhase === "init") {
// Increment cycles completed
if (!completedActionsRef.current[crane.modelUuid]) {
completedActionsRef.current[crane.modelUuid] = 0;
}
completedActionsRef.current[crane.modelUuid]++;
// Track loads handled (number of materials carried in this cycle)
const loadsInCycle = crane.currentMaterials?.length || 1;
if (!completedActionsRef.current[`${crane.modelUuid}_loads`]) {
completedActionsRef.current[`${crane.modelUuid}_loads`] = 0;
}
completedActionsRef.current[`${crane.modelUuid}_loads`] += loadsInCycle;
}
// Track lifts (picking phase indicates a lift operation)
if (previousPhase !== "picking" && currentPhase === "picking") {
if (!completedActionsRef.current[`${crane.modelUuid}_lifts`]) {
@@ -2528,6 +2512,21 @@ function Analyzer() {
completedActionsRef.current[`${crane.modelUuid}_lift_height`] = 0;
}
completedActionsRef.current[`${crane.modelUuid}_lift_height`] += 5;
// Track loads handled when picking (each pick is a load)
if (!completedActionsRef.current[`${crane.modelUuid}_loads`]) {
completedActionsRef.current[`${crane.modelUuid}_loads`] = 0;
}
completedActionsRef.current[`${crane.modelUuid}_loads`]++;
}
// Track cycles completed when dropping is done (transition from 'dropping' to any other phase)
if (previousPhase === "dropping" && currentPhase !== "dropping") {
// Increment cycles completed
if (!completedActionsRef.current[crane.modelUuid]) {
completedActionsRef.current[crane.modelUuid] = 0;
}
completedActionsRef.current[crane.modelUuid]++;
}
previousCranePhasesRef.current[crane.modelUuid] = currentPhase;

View File

@@ -25,7 +25,7 @@ function Simulation() {
const { analysis } = analysisStore();
useEffect(() => {
console.log("analysis: ", analysis);
// console.log("analysis: ", analysis);
}, [analysis]);
useEffect(() => {