import React, { useState, useEffect } from 'react'; import { Play, Square, RotateCw, AlertTriangle, Siren, Terminal } from 'lucide-react'; import { Machine3D } from '../components/Machine3D'; import { SettingsModal } from '../components/SettingsModal'; import { RecipePanel } from '../components/RecipePanel'; import { MotionPanel } from '../components/MotionPanel'; import { CameraPanel } from '../components/CameraPanel'; import { CyberPanel } from '../components/common/CyberPanel'; import { TechButton } from '../components/common/TechButton'; import { ModelInfoPanel } from '../components/ModelInfoPanel'; import { SystemState, Recipe, IOPoint, LogEntry, RobotTarget, ConfigItem } from '../types'; interface HomePageProps { systemState: SystemState; currentRecipe: Recipe; recipes: Recipe[]; robotTarget: RobotTarget; logs: LogEntry[]; ioPoints: IOPoint[]; config: ConfigItem[] | null; isConfigRefreshing: boolean; doorStates: { front: boolean; right: boolean; left: boolean; back: boolean }; isLowPressure: boolean; isEmergencyStop: boolean; activeTab: 'recipe' | 'motion' | 'camera' | 'setting' | null; onSelectRecipe: (r: Recipe) => void; onMove: (axis: 'X' | 'Y' | 'Z', val: number) => void; onControl: (action: 'start' | 'stop' | 'reset') => void; onSaveConfig: (config: ConfigItem[]) => void; onFetchConfig: () => void; onCloseTab: () => void; videoRef: React.RefObject; } export const HomePage: React.FC = ({ systemState, currentRecipe, recipes, robotTarget, logs, ioPoints, config, isConfigRefreshing, doorStates, isLowPressure, isEmergencyStop, activeTab, onSelectRecipe, onMove, onControl, onSaveConfig, onFetchConfig, onCloseTab, videoRef }) => { useEffect(() => { if (activeTab === 'camera' && navigator.mediaDevices?.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true }).then(s => { if (videoRef.current) videoRef.current.srcObject = s }); } }, [activeTab, videoRef]); useEffect(() => { if (activeTab === 'setting') { onFetchConfig(); } }, [activeTab, onFetchConfig]); return (
{/* 3D Canvas (Background Layer) */}
{/* Center Alarms */}
{isEmergencyStop && (

EMERGENCY STOP

SYSTEM HALTED - RELEASE TO RESET

)} {isLowPressure && !isEmergencyStop && (
LOW AIR PRESSURE WARNING
)}
{/* Floating Panel (Left) */} {activeTab && activeTab !== 'setting' && activeTab !== 'recipe' && (
{activeTab === 'motion' && } {activeTab === 'camera' && }
)} {/* Recipe Selection Modal */} {activeTab === 'recipe' && ( )} {/* Settings Modal */} {/* Right Sidebar (Dashboard) */}
System Status
{systemState}
onControl('start')} > START AUTO onControl('stop')} > STOP / PAUSE onControl('reset')} > SYSTEM RESET
Event Log
{logs.map(log => (
[{log.timestamp}] {log.message}
))}
); };