import React, { useState, useEffect } from 'react'; import { FrequencyBand, ReaderInfo, QuickTestConfig } from '../types'; import { RefreshCw, Save, RotateCcw, Cpu, Radio, Zap, Activity, HardDrive, Settings2 } from 'lucide-react'; interface Props { readerInfo: ReaderInfo | null; onGetInfo: () => void; onSetParameters: (settings: { address: number; baudRate: number; power: number; minFreq: number; maxFreq: number; band: FrequencyBand; }) => void; onFactoryReset: () => void; quickTestConfig: QuickTestConfig; onSaveQuickTestConfig: (config: QuickTestConfig) => void; } export const SettingsPanel: React.FC = ({ readerInfo, onGetInfo, onSetParameters, onFactoryReset, quickTestConfig, onSaveQuickTestConfig }) => { // Local state for the editable form const [address, setAddress] = useState(0x00); const [baudRate, setBaudRate] = useState(57600); const [power, setPower] = useState(13); const [maxResponseTime, setMaxResponseTime] = useState(0); const [minFreq, setMinFreq] = useState(0); const [maxFreq, setMaxFreq] = useState(0); const [isSingleFreq, setIsSingleFreq] = useState(false); const [band, setBand] = useState(FrequencyBand.US); // Quick Test Local State const [qtLength, setQtLength] = useState<3 | 4>(4); const [qtFormat, setQtFormat] = useState<'hex' | 'ascii'>('hex'); // Initialize form with reader info when available useEffect(() => { if (readerInfo) { setAddress(readerInfo.address); setPower(readerInfo.power); setMinFreq(readerInfo.minFreq); setMaxFreq(readerInfo.maxFreq); setMaxResponseTime(readerInfo.maxResponseTime); setBand(readerInfo.band); setIsSingleFreq(readerInfo.minFreq === readerInfo.maxFreq); } }, [readerInfo]); // Sync Quick Test config useEffect(() => { setQtLength(quickTestConfig.length); setQtFormat(quickTestConfig.format); }, [quickTestConfig]); const handleApplyReaderSettings = () => { onSetParameters({ address, baudRate, power, minFreq, maxFreq, band }); }; const handleSaveLocalSettings = () => { onSaveQuickTestConfig({ length: qtLength, format: qtFormat }); }; const baudRates = [9600, 19200, 38400, 57600, 115200]; const powerLevels = Array.from({ length: 31 }, (_, i) => i); // 0-30 dBm const isLoaded = !!readerInfo; return (
{/* Header */}

System Configuration

Manage device parameters and local browser settings.

{/* 1. Quick Test Settings Card */}

Quick Test Settings (Local)

These settings are stored in your browser's local storage and control the behavior of the "Quick Test" tab.


{/* 2. Reader Configuration */}

Reader Configuration (Device)

{/* Device Actions */}
{/* Status Info */}
Model
{readerInfo?.model || '--'}
Firmware
{readerInfo?.version || '--'}
Protocol
{readerInfo?.protocol || 'EPCC1-G2'}
Power
{readerInfo ? `${readerInfo.power} dBm` : '--'}
{/* Device Settings Form */}
{/* 1. Communication Settings */}

Communication Parameters

{ const val = parseInt(e.target.value, 16); if (!isNaN(val) && val >= 0 && val <= 0xFF) setAddress(val); }} className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all" maxLength={2} />
{/* 2. RF Settings */}

RF Configuration

{[ { label: 'User Defined', value: FrequencyBand.USER }, { label: 'Chinese Band', value: FrequencyBand.CHINESE }, { label: 'US Band', value: FrequencyBand.US }, { label: 'Korean Band', value: FrequencyBand.KOREAN }, { label: 'EU Band', value: FrequencyBand.EU }, ].map((item) => (
); };