All files / client/src/components/simulator/sub-components SimulatorOutputContainer.tsx

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122                                                                                                                                                    5x                                                                                              
import React from "react";
import { SerialMonitorView, SerialViewMode } from "@/components/simulator/SerialMonitorView";
import SimulatorSidebar from "@/components/features/simulator/SimulatorSidebar";
import {
  ResizablePanelGroup,
  ResizablePanel,
  ResizableHandle,
} from "@/components/ui/resizable";
import type { OutputLine } from "@shared/schema";
import type { TelemetryMetrics } from "@/hooks/use-telemetry-store";
import type { PinState, BatchStats } from "@/hooks/use-simulation-store";
 
interface SimulatorOutputContainerProps {
  readonly renderedSerialOutput: OutputLine[];
  readonly serialOutput: OutputLine[];
  readonly isConnected: boolean;
  readonly simulationStatus: "running" | "stopped" | "paused";
  readonly handleSerialSend: (message: string) => void;
  readonly handleClearSerialOutput: () => void;
  readonly showSerialMonitor: boolean;
  readonly showSerialPlotter: boolean;
  readonly serialViewMode: SerialViewMode;
  readonly cycleSerialViewMode: () => void;
  readonly autoScrollEnabled: boolean;
  readonly setAutoScrollEnabled: (enabled: boolean) => void;
  readonly serialInputValue: string;
  readonly setSerialInputValue: (value: string) => void;
  readonly handleSerialInputKeyDown: (e: React.KeyboardEvent) => void;
  readonly handleSerialInputSend: () => void;
  readonly debugMode: boolean;
  readonly telemetryData: { last: TelemetryMetrics | null } | null;
  readonly baudRate: number;
 
  readonly pinMonitorVisible: boolean;
  readonly pinStates: PinState[];
  readonly batchStats: BatchStats;
  readonly txActivity: number;
  readonly rxActivity: number;
  readonly handleReset: () => void;
  readonly handlePinToggle: (pin: number, newValue: number) => void;
  readonly analogPinsUsed: number[];
  readonly handleAnalogChange: (pin: number, newValue: number) => void;
}
 
export default function SimulatorOutputContainer({
  renderedSerialOutput,
  serialOutput,
  isConnected,
  simulationStatus,
  handleSerialSend,
  handleClearSerialOutput,
  showSerialMonitor,
  showSerialPlotter,
  serialViewMode,
  cycleSerialViewMode,
  autoScrollEnabled,
  setAutoScrollEnabled,
  serialInputValue,
  setSerialInputValue,
  handleSerialInputKeyDown,
  handleSerialInputSend,
  debugMode,
  telemetryData,
  baudRate,
  pinMonitorVisible,
  pinStates,
  batchStats,
  txActivity,
  rxActivity,
  handleReset,
  handlePinToggle,
  analogPinsUsed,
  handleAnalogChange,
}: SimulatorOutputContainerProps) {
  return (
    <ResizablePanel defaultSize={50} minSize={20} id="output-panel">
      <ResizablePanelGroup direction="vertical" id="output-layout">
        <ResizablePanel defaultSize={50} minSize={20} id="serial-panel">
          <SerialMonitorView
            renderedSerialOutput={renderedSerialOutput}
            serialOutput={serialOutput}
            isConnected={isConnected}
            simulationStatus={simulationStatus}
            handleSerialSend={handleSerialSend}
            handleClearSerialOutput={handleClearSerialOutput}
            showSerialMonitor={showSerialMonitor}
            showSerialPlotter={showSerialPlotter}
            serialViewMode={serialViewMode}
            cycleSerialViewMode={cycleSerialViewMode}
            autoScrollEnabled={autoScrollEnabled}
            setAutoScrollEnabled={setAutoScrollEnabled}
            serialInputValue={serialInputValue}
            setSerialInputValue={setSerialInputValue}
            handleSerialInputKeyDown={handleSerialInputKeyDown}
            handleSerialInputSend={handleSerialInputSend}
            debugMode={debugMode}
            telemetryData={telemetryData}
            baudRate={baudRate}
          />
        </ResizablePanel>
 
        <ResizableHandle withHandle data-testid="vertical-resizer-board" />
 
        <ResizablePanel defaultSize={50} minSize={20} id="board-panel">
          <SimulatorSidebar
            pinMonitorVisible={pinMonitorVisible}
            pinStates={pinStates}
            batchStats={batchStats}
            simulationStatus={simulationStatus}
            txActivity={txActivity}
            rxActivity={rxActivity}
            onReset={handleReset}
            onPinToggle={handlePinToggle}
            analogPins={analogPinsUsed}
            onAnalogChange={handleAnalogChange}
          />
        </ResizablePanel>
      </ResizablePanelGroup>
    </ResizablePanel>
  );
}