Update: Relocate AutoRun controls and cleanup

This commit is contained in:
2025-12-19 00:05:27 +09:00
parent c4089aeb20
commit 051138489b
3 changed files with 1227 additions and 1217 deletions

View File

@@ -3,7 +3,7 @@ import React from 'react';
import { StopCircle, Play, Square, AlertTriangle, ChevronsUp, ChevronsDown, Magnet, Radar, ArrowLeft, ArrowRight } from 'lucide-react';
import { AgvState, AgvMotionState, AgvRunConfig } from '../types';
import AgvManualControls from './AgvManualControls';
import AgvAutoRunControls from './AgvAutoRunControls';
interface AgvControlsProps {
agvState: AgvState;
@@ -29,22 +29,7 @@ const AgvControls: React.FC<AgvControlsProps> = ({ agvState, setMotion, setLift,
});
};
const toggleRun = () => {
if (isError) return;
if (isRunning) {
setMotion(AgvMotionState.IDLE);
} else {
const isFwd = agvState.runConfig.direction === 'FWD';
const hasLine = isFwd ? agvState.sensorLineFront : agvState.sensorLineRear;
if (!hasLine) {
setError('LINE_OUT');
return;
}
setMotion(AgvMotionState.RUNNING);
}
};
const handleMarkStop = () => {
if (agvState.motionState === AgvMotionState.RUNNING) {
@@ -106,8 +91,8 @@ const AgvControls: React.FC<AgvControlsProps> = ({ agvState, setMotion, setLift,
onClick={() => setLiftStatus('DOWN')}
disabled={agvState.liftHeight === 0}
className={`p-1.5 rounded disabled:opacity-30 transition-colors ${agvState.liftStatus === 'DOWN'
? 'bg-blue-600 text-white shadow-[0_0_10px_rgba(37,99,235,0.5)]'
: 'bg-gray-700 hover:bg-gray-600 text-gray-300'
? 'bg-blue-600 text-white shadow-[0_0_10px_rgba(37,99,235,0.5)]'
: 'bg-gray-700 hover:bg-gray-600 text-gray-300'
}`}
title="Lower Lift"
>
@@ -127,8 +112,8 @@ const AgvControls: React.FC<AgvControlsProps> = ({ agvState, setMotion, setLift,
onClick={() => setLiftStatus('UP')}
disabled={agvState.liftHeight === 100}
className={`p-1.5 rounded disabled:opacity-30 transition-colors ${agvState.liftStatus === 'UP'
? 'bg-blue-600 text-white shadow-[0_0_10px_rgba(37,99,235,0.5)]'
: 'bg-gray-700 hover:bg-gray-600 text-gray-300'
? 'bg-blue-600 text-white shadow-[0_0_10px_rgba(37,99,235,0.5)]'
: 'bg-gray-700 hover:bg-gray-600 text-gray-300'
}`}
title="Raise Lift"
>
@@ -139,8 +124,8 @@ const AgvControls: React.FC<AgvControlsProps> = ({ agvState, setMotion, setLift,
<button
onClick={() => setMagnet(!agvState.magnetOn)}
className={`w-full py-1.5 text-xs rounded border flex items-center justify-center gap-2 transition-colors ${agvState.magnetOn
? 'bg-orange-600 text-white border-orange-500'
: 'bg-gray-800 text-gray-400 border-gray-600 hover:bg-gray-700'
? 'bg-orange-600 text-white border-orange-500'
: 'bg-gray-800 text-gray-400 border-gray-600 hover:bg-gray-700'
}`}
>
<Magnet size={14} className={agvState.magnetOn ? "animate-pulse" : ""} />
@@ -152,14 +137,7 @@ const AgvControls: React.FC<AgvControlsProps> = ({ agvState, setMotion, setLift,
{/* Auto Run Controls */}
{/* Auto Run Controls (분리된 콤포넌트) */}
<AgvAutoRunControls
agvState={agvState}
updateRunConfig={updateRunConfig}
toggleRun={toggleRun}
isRunning={isRunning}
isError={isError}
setLidar={setLidar}
/>
</div>
);
};