1098 lines
30 KiB
HTML
1098 lines
30 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
<title>Gain-Viz — Spectrum Viewer</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary: #2563eb;
|
|
--primary-dark: #1d4ed8;
|
|
--primary-light: #dbeafe;
|
|
--bg: #f8fafc;
|
|
--card: #ffffff;
|
|
--muted: #64748b;
|
|
--border: #e2e8f0;
|
|
--radius: 12px;
|
|
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
--success: #10b981;
|
|
--warning: #f59e0b;
|
|
--error: #ef4444;
|
|
--terminal-bg: #1e293b;
|
|
--terminal-text: #e2e8f0;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
|
|
background: var(--bg);
|
|
color: #0f172a;
|
|
line-height: 1.5;
|
|
padding: 20px;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1600px;
|
|
margin: 0 auto;
|
|
background: var(--card);
|
|
border-radius: var(--radius);
|
|
box-shadow: var(--shadow-lg);
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: calc(100vh - 40px);
|
|
}
|
|
|
|
header {
|
|
padding: 24px 32px;
|
|
background: linear-gradient(135deg, var(--primary), var(--primary-dark));
|
|
color: #fff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
header h1 {
|
|
margin: 0;
|
|
font-size: 1.8rem;
|
|
font-weight: 700;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
header h1::before {
|
|
content: "📡";
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
header p {
|
|
margin: 0;
|
|
opacity: .9;
|
|
font-size: 1rem;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.content-wrapper {
|
|
display: flex;
|
|
flex: 1;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.controls-panel {
|
|
width: 450px;
|
|
flex-shrink: 0;
|
|
padding: 24px;
|
|
border-right: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.visualization-panel {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card {
|
|
background: #fff;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 20px;
|
|
box-shadow: var(--shadow);
|
|
}
|
|
|
|
.card h2 {
|
|
margin: 0 0 16px 0;
|
|
font-size: 1.2rem;
|
|
font-weight: 600;
|
|
color: #0f172a;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.card h2::before {
|
|
content: "⚙️";
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
/* Gain grid */
|
|
.gain-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr;
|
|
gap: 12px;
|
|
}
|
|
|
|
.gain-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 14px;
|
|
border-radius: 8px;
|
|
background: #f8fafc;
|
|
border: 1px solid var(--border);
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.gain-item:hover {
|
|
background: #f1f5f9;
|
|
border-color: #cbd5e1;
|
|
}
|
|
|
|
.gain-item label {
|
|
font-weight: 500;
|
|
font-size: 0.95rem;
|
|
width: 100px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.gain-input {
|
|
flex: 1;
|
|
}
|
|
|
|
.gain-input input {
|
|
width: 100%;
|
|
padding: 10px 12px;
|
|
border-radius: 6px;
|
|
border: 1px solid var(--border);
|
|
font-size: 0.95rem;
|
|
transition: border-color 0.2s;
|
|
}
|
|
|
|
.gain-input input:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
|
|
}
|
|
|
|
.gain-input input:disabled {
|
|
background-color: #f1f5f9;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
/* Toggle switch */
|
|
.toggle-switch {
|
|
position: relative;
|
|
width: 50px;
|
|
height: 26px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.toggle-switch input {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
.slider {
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
background: #d1d5db;
|
|
border-radius: 24px;
|
|
transition: 0.25s;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.slider:before {
|
|
content: "";
|
|
position: absolute;
|
|
left: 4px;
|
|
top: 4px;
|
|
width: 18px;
|
|
height: 18px;
|
|
background: white;
|
|
border-radius: 50%;
|
|
transition: 0.25s;
|
|
}
|
|
|
|
.toggle-switch input:checked + .slider {
|
|
background: var(--primary);
|
|
}
|
|
|
|
.toggle-switch input:checked + .slider:before {
|
|
transform: translateX(24px);
|
|
}
|
|
|
|
.form-actions {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 12px;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 10px 18px;
|
|
border-radius: 8px;
|
|
border: 0;
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.btn.primary {
|
|
background: var(--primary);
|
|
color: #fff;
|
|
}
|
|
|
|
.btn.primary:hover:not(:disabled) {
|
|
background: var(--primary-dark);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
|
|
}
|
|
|
|
.btn.secondary {
|
|
background: #f1f5f9;
|
|
color: #475569;
|
|
}
|
|
|
|
.btn.secondary:hover:not(:disabled) {
|
|
background: #e2e8f0;
|
|
}
|
|
|
|
.btn.success {
|
|
background: var(--success);
|
|
color: #fff;
|
|
}
|
|
|
|
.btn.warning {
|
|
background: var(--warning);
|
|
color: #fff;
|
|
}
|
|
|
|
.btn.error {
|
|
background: var(--error);
|
|
color: #fff;
|
|
}
|
|
|
|
.btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.status {
|
|
margin-top: 12px;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
display: none;
|
|
font-size: 0.9rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status.success {
|
|
background: rgba(16, 185, 129, 0.08);
|
|
color: #047857;
|
|
border: 1px solid rgba(16, 185, 129, 0.12);
|
|
}
|
|
|
|
.status.error {
|
|
background: rgba(239, 68, 68, 0.06);
|
|
color: #7f1d1d;
|
|
border: 1px solid rgba(239, 68, 68, 0.12);
|
|
}
|
|
|
|
/* Parameter grid */
|
|
.param-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 12px;
|
|
}
|
|
|
|
.param-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
}
|
|
|
|
.param-item label {
|
|
font-weight: 500;
|
|
font-size: 0.9rem;
|
|
color: #475569;
|
|
}
|
|
|
|
.param-item input {
|
|
padding: 10px 12px;
|
|
border-radius: 6px;
|
|
border: 1px solid var(--border);
|
|
font-size: 0.95rem;
|
|
transition: border-color 0.2s;
|
|
}
|
|
|
|
.param-item input:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
|
|
}
|
|
|
|
/* Stream controls */
|
|
.stream-controls {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.stream-status {
|
|
padding: 8px 16px;
|
|
border-radius: 20px;
|
|
font-size: 0.9rem;
|
|
font-weight: 600;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.status-stopped {
|
|
background: #fef2f2;
|
|
color: var(--error);
|
|
border: 1px solid #fecaca;
|
|
}
|
|
|
|
.status-running {
|
|
background: #f0fdf4;
|
|
color: var(--success);
|
|
border: 1px solid #bbf7d0;
|
|
}
|
|
|
|
.status-paused {
|
|
background: #fffbeb;
|
|
color: var(--warning);
|
|
border: 1px solid #fed7aa;
|
|
}
|
|
|
|
/* Plot area - OPTIMIZED FOR MAXIMUM SPACE */
|
|
.visualization-panel {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
}
|
|
|
|
.plot-area {
|
|
flex: 1;
|
|
min-height: 0;
|
|
padding: 16px; /* Reduced padding */
|
|
background: #f8fafc;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.plot-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 12px; /* Reduced margin */
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.plot-header h3 {
|
|
margin: 0;
|
|
font-size: 1.3rem;
|
|
font-weight: 600;
|
|
color: #0f172a;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.plot-header h3::before {
|
|
content: "📊";
|
|
}
|
|
|
|
.plot-controls {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
|
|
.plot-card {
|
|
flex: 1;
|
|
min-height: 0;
|
|
background: #fff;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 4px; /* Minimal padding */
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
box-shadow: var(--shadow);
|
|
position: relative;
|
|
}
|
|
|
|
#plotImage {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: contain;
|
|
border-radius: 8px;
|
|
display: block;
|
|
background: #f8fafc;
|
|
}
|
|
|
|
/* TMUX Terminal - COMPACT */
|
|
.tmux-container {
|
|
height: 150px; /* Further reduced */
|
|
margin-top: 8px; /* Minimal margin */
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.tmux-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 4px 10px; /* Minimal padding */
|
|
background: var(--terminal-bg);
|
|
color: var(--terminal-text);
|
|
border-top-left-radius: var(--radius);
|
|
border-top-right-radius: var(--radius);
|
|
font-size: 0.8rem; /* Smaller font */
|
|
font-weight: 500;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.tmux-controls {
|
|
display: flex;
|
|
gap: 4px; /* Minimal gap */
|
|
}
|
|
|
|
.tmux-btn {
|
|
background: transparent;
|
|
border: none;
|
|
color: var(--terminal-text);
|
|
cursor: pointer;
|
|
padding: 2px 4px; /* Minimal padding */
|
|
border-radius: 3px;
|
|
font-size: 0.7rem; /* Smaller font */
|
|
}
|
|
|
|
.tmux-btn:hover {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
.tmux-terminal {
|
|
flex: 1;
|
|
background: var(--terminal-bg);
|
|
color: var(--terminal-text);
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 0.75rem; /* Smaller font */
|
|
padding: 6px; /* Minimal padding */
|
|
overflow-y: auto;
|
|
border-bottom-left-radius: var(--radius);
|
|
border-bottom-right-radius: var(--radius);
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
line-height: 1.2; /* Tighter line height */
|
|
}
|
|
|
|
.tmux-terminal::-webkit-scrollbar {
|
|
width: 4px; /* Thinner scrollbar */
|
|
}
|
|
|
|
.tmux-terminal::-webkit-scrollbar-track {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.tmux-terminal::-webkit-scrollbar-thumb {
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.tmux-terminal::-webkit-scrollbar-thumb:hover {
|
|
background: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
footer {
|
|
padding: 16px 32px;
|
|
text-align: center;
|
|
color: var(--muted);
|
|
font-size: 0.9rem;
|
|
border-top: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* Responsive design */
|
|
@media (max-width: 1024px) {
|
|
.content-wrapper {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.controls-panel {
|
|
width: 100%;
|
|
border-right: none;
|
|
border-bottom: 1px solid var(--border);
|
|
max-height: 40vh;
|
|
}
|
|
|
|
.param-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
body {
|
|
padding: 10px;
|
|
}
|
|
|
|
.container {
|
|
height: calc(100vh - 20px);
|
|
}
|
|
|
|
header {
|
|
padding: 20px;
|
|
}
|
|
|
|
.controls-panel, .plot-area {
|
|
padding: 12px;
|
|
}
|
|
|
|
.gain-item {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
}
|
|
|
|
.gain-item label {
|
|
width: 100%;
|
|
}
|
|
|
|
.gain-input {
|
|
width: 100%;
|
|
}
|
|
|
|
.toggle-switch {
|
|
align-self: flex-end;
|
|
}
|
|
|
|
.form-actions {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.stream-controls {
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
|
|
/* Custom scrollbar */
|
|
.controls-panel::-webkit-scrollbar {
|
|
width: 6px;
|
|
}
|
|
|
|
.controls-panel::-webkit-scrollbar-track {
|
|
background: #f1f5f9;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.controls-panel::-webkit-scrollbar-thumb {
|
|
background: #cbd5e1;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.controls-panel::-webkit-scrollbar-thumb:hover {
|
|
background: #94a3b8;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>Gain-Viz</h1>
|
|
<p>Interactive gain control and real-time RF visualization</p>
|
|
</header>
|
|
|
|
<div class="content-wrapper">
|
|
<div class="controls-panel">
|
|
<!-- Stream Controls Card -->
|
|
<div class="card">
|
|
<h2>Stream Controls</h2>
|
|
|
|
<div class="stream-controls">
|
|
<button class="btn success" id="startBtn">
|
|
<span>▶️</span> Start
|
|
</button>
|
|
<button class="btn warning" id="pauseBtn" disabled>
|
|
<span>⏸️</span> Pause
|
|
</button>
|
|
<button class="btn error" id="stopBtn" disabled>
|
|
<span>⏹️</span> Stop
|
|
</button>
|
|
</div>
|
|
|
|
<div class="stream-status status-stopped" id="streamStatus">
|
|
<span>●</span> Stopped
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Gain Settings Card -->
|
|
<div class="card">
|
|
<h2>Gain Settings</h2>
|
|
|
|
<form id="gainForm">
|
|
<div class="gain-grid">
|
|
<!-- USRP Tx -->
|
|
<div class="gain-item">
|
|
<label for="usrp_tx_gain">USRP Tx</label>
|
|
<div class="gain-input">
|
|
<input type="number" id="usrp_tx_gain" name="usrp_tx_gain" value="60" disabled aria-label="USRP Tx Gain">
|
|
</div>
|
|
<label class="toggle-switch" title="Enable USRP Tx">
|
|
<input type="checkbox" class="gain-toggle" data-input="usrp_tx_gain" id="usrp_tx_toggle">
|
|
<span class="slider"></span>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- SCM Tx -->
|
|
<div class="gain-item">
|
|
<label for="scm_tx_gain">SCM Tx</label>
|
|
<div class="gain-input">
|
|
<input type="number" id="scm_tx_gain" name="scm_tx_gain" value="30" disabled aria-label="SCM Tx Gain">
|
|
</div>
|
|
<label class="toggle-switch" title="Enable SCM Tx">
|
|
<input type="checkbox" class="gain-toggle" data-input="scm_tx_gain" id="scm_tx_toggle">
|
|
<span class="slider"></span>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- USRP Rx -->
|
|
<div class="gain-item">
|
|
<label for="usrp_rx_gain">USRP Rx</label>
|
|
<div class="gain-input">
|
|
<input type="number" id="usrp_rx_gain" name="usrp_rx_gain" value="30" disabled aria-label="USRP Rx Gain">
|
|
</div>
|
|
<label class="toggle-switch" title="Enable USRP Rx">
|
|
<input type="checkbox" class="gain-toggle" data-input="usrp_rx_gain" id="usrp_rx_toggle">
|
|
<span class="slider"></span>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- SCM Rx -->
|
|
<div class="gain-item">
|
|
<label for="scm_rx_gain">SCM Rx</label>
|
|
<div class="gain-input">
|
|
<input type="number" id="scm_rx_gain" name="scm_rx_gain" value="30" disabled aria-label="SCM Rx Gain">
|
|
</div>
|
|
<label class="toggle-switch" title="Enable SCM Rx">
|
|
<input type="checkbox" class="gain-toggle" data-input="scm_rx_gain" id="scm_rx_toggle">
|
|
<span class="slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn primary" id="gainUpdateBtn">
|
|
<span>🔄</span> Update Gains
|
|
</button>
|
|
<button type="button" class="btn secondary" id="gainRefreshBtn" title="Reload gains from device">
|
|
<span>↻</span> Refresh
|
|
</button>
|
|
</div>
|
|
|
|
<div id="gainStatusMessage" class="status"></div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Parameters Card -->
|
|
<div class="card">
|
|
<h2>Spectrogram Parameters</h2>
|
|
|
|
<form id="paramForm">
|
|
<div class="param-grid">
|
|
<div class="param-item">
|
|
<label for="center_freq">Center Frequency (Hz)</label>
|
|
<input type="number" id="center_freq" name="center_freq" value="3415000000" step="1000000">
|
|
</div>
|
|
<div class="param-item">
|
|
<label for="sample_rate">Sample Rate (Hz)</label>
|
|
<input type="number" id="sample_rate" name="sample_rate" value="23040000" step="1000000">
|
|
</div>
|
|
<div class="param-item">
|
|
<label for="fft_size">FFT Size</label>
|
|
<input type="number" id="fft_size" name="fft_size" value="1024" step="128">
|
|
</div>
|
|
<div class="param-item">
|
|
<label for="window_ms">Window Size (ms)</label>
|
|
<input type="number" id="window_ms" name="window_ms" value="20" step="1">
|
|
</div>
|
|
<div class="param-item">
|
|
<label for="tcp_port">ZMQ Port</label>
|
|
<input type="number" id="tcp_port" name="tcp_port" value="5556" step="1">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn primary" id="paramUpdateBtn">
|
|
<span>⚡</span> Update Parameters
|
|
</button>
|
|
</div>
|
|
<div id="paramStatusMessage" class="status"></div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Visualization Panel -->
|
|
<div class="visualization-panel">
|
|
<div class="plot-area">
|
|
<div class="plot-header">
|
|
<h3>Spectrum Analysis</h3>
|
|
<div class="plot-controls">
|
|
<button class="btn secondary" id="refreshPlotBtn">
|
|
<span>🔄</span> Refresh
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="plot-card">
|
|
<img id="plotImage" src="/plot" alt="Spectrum Analysis plot">
|
|
</div>
|
|
|
|
<!-- TMUX Terminal -->
|
|
<div class="tmux-container">
|
|
<div class="tmux-header">
|
|
<span>TMUX Output (ran)</span>
|
|
<div class="tmux-controls">
|
|
<button class="tmux-btn" id="clearTmuxBtn">Clear</button>
|
|
<button class="tmux-btn" id="autoScrollTmuxBtn">Auto Scroll: ON</button>
|
|
</div>
|
|
</div>
|
|
<div class="tmux-terminal" id="tmuxTerminal"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer>
|
|
Gain-Viz • Real-time RF monitoring
|
|
</footer>
|
|
</div>
|
|
|
|
<script>
|
|
(function(){
|
|
const plotImg = document.getElementById('plotImage');
|
|
const tmuxTerminal = document.getElementById('tmuxTerminal');
|
|
let isPlotPaused = false;
|
|
let isStreaming = false;
|
|
let refreshInterval;
|
|
let tmuxInterval;
|
|
let autoScroll = true;
|
|
let lastTmuxLength = 0;
|
|
|
|
// Helper to show status for a specific element
|
|
function showStatus(id, message, type = 'success') {
|
|
const el = document.getElementById(id);
|
|
if (!el) return;
|
|
el.textContent = message;
|
|
el.className = 'status ' + (type === 'success' ? 'success' : 'error');
|
|
el.style.display = 'block';
|
|
if (type === 'success') setTimeout(()=>{ el.style.display = 'none'; }, 3000);
|
|
}
|
|
|
|
// Update stream status display
|
|
function updateStreamStatus(state) {
|
|
const statusEl = document.getElementById('streamStatus');
|
|
const startBtn = document.getElementById('startBtn');
|
|
const pauseBtn = document.getElementById('pauseBtn');
|
|
const stopBtn = document.getElementById('stopBtn');
|
|
|
|
statusEl.className = 'stream-status';
|
|
|
|
switch(state) {
|
|
case 'running':
|
|
statusEl.classList.add('status-running');
|
|
statusEl.innerHTML = '<span>●</span> Streaming';
|
|
startBtn.disabled = true;
|
|
pauseBtn.disabled = false;
|
|
stopBtn.disabled = false;
|
|
pauseBtn.innerHTML = '<span>⏸️</span> Pause';
|
|
isStreaming = true;
|
|
isPlotPaused = false;
|
|
break;
|
|
case 'paused':
|
|
statusEl.classList.add('status-paused');
|
|
statusEl.innerHTML = '<span>●</span> Paused';
|
|
startBtn.disabled = true;
|
|
pauseBtn.disabled = false;
|
|
stopBtn.disabled = false;
|
|
pauseBtn.innerHTML = '<span>▶️</span> Resume';
|
|
isStreaming = true;
|
|
isPlotPaused = true;
|
|
break;
|
|
case 'stopped':
|
|
statusEl.classList.add('status-stopped');
|
|
statusEl.innerHTML = '<span>●</span> Stopped';
|
|
startBtn.disabled = false;
|
|
pauseBtn.disabled = true;
|
|
stopBtn.disabled = true;
|
|
isStreaming = false;
|
|
isPlotPaused = false;
|
|
tmuxTerminal.textContent = ''; // Clear terminal when stopped
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Stream control functions
|
|
async function startStream() {
|
|
try {
|
|
const response = await fetch('/start_stream', { method: 'POST' });
|
|
const data = await response.json();
|
|
|
|
if (data.status === 'success') {
|
|
updateStreamStatus('running');
|
|
showStatus('gainStatusMessage', 'Streaming started', 'success');
|
|
} else {
|
|
showStatus('gainStatusMessage', data.message, 'error');
|
|
}
|
|
} catch (err) {
|
|
console.error('Start stream error:', err);
|
|
showStatus('gainStatusMessage', 'Error starting stream', 'error');
|
|
}
|
|
}
|
|
|
|
async function stopStream() {
|
|
try {
|
|
const response = await fetch('/stop_stream', { method: 'POST' });
|
|
const data = await response.json();
|
|
|
|
if (data.status === 'success') {
|
|
updateStreamStatus('stopped');
|
|
showStatus('gainStatusMessage', 'Streaming stopped', 'success');
|
|
} else {
|
|
showStatus('gainStatusMessage', data.message, 'error');
|
|
}
|
|
} catch (err) {
|
|
console.error('Stop stream error:', err);
|
|
showStatus('gainStatusMessage', 'Error stopping stream', 'error');
|
|
}
|
|
}
|
|
|
|
async function pauseStream() {
|
|
try {
|
|
const response = await fetch('/pause_stream', { method: 'POST' });
|
|
const data = await response.json();
|
|
|
|
if (data.status === 'success') {
|
|
updateStreamStatus(data.state);
|
|
showStatus('gainStatusMessage', `Streaming ${data.state}`, 'success');
|
|
} else {
|
|
showStatus('gainStatusMessage', data.message, 'error');
|
|
}
|
|
} catch (err) {
|
|
console.error('Pause stream error:', err);
|
|
showStatus('gainStatusMessage', 'Error pausing stream', 'error');
|
|
}
|
|
}
|
|
|
|
// Check stream state periodically
|
|
async function checkStreamState() {
|
|
try {
|
|
const response = await fetch('/get_stream_state');
|
|
const data = await response.json();
|
|
updateStreamStatus(data.state);
|
|
} catch (err) {
|
|
console.error('Error checking stream state:', err);
|
|
}
|
|
}
|
|
|
|
// Fetch TMUX output
|
|
async function fetchTmuxOutput() {
|
|
try {
|
|
const response = await fetch('/tmux_output');
|
|
const data = await response.json();
|
|
|
|
if (data.output && data.output.length > 0) {
|
|
// Only update if new content is available
|
|
const currentOutput = data.output.join('\n');
|
|
if (currentOutput.length !== tmuxTerminal.textContent.length) {
|
|
tmuxTerminal.textContent = currentOutput;
|
|
|
|
// Auto-scroll to bottom if enabled
|
|
if (autoScroll) {
|
|
tmuxTerminal.scrollTop = tmuxTerminal.scrollHeight;
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error('Error fetching TMUX output:', err);
|
|
}
|
|
}
|
|
|
|
// ---------------- Gain Form ----------------
|
|
const gainForm = document.getElementById('gainForm');
|
|
const toggles = document.querySelectorAll('.gain-toggle');
|
|
const gainUpdateBtn = document.getElementById('gainUpdateBtn');
|
|
const gainRefreshBtn = document.getElementById('gainRefreshBtn');
|
|
|
|
// enable/disable inputs depending on toggle
|
|
toggles.forEach(t => {
|
|
const inputId = t.dataset.input;
|
|
const inputEl = document.getElementById(inputId);
|
|
t.addEventListener('change', () => {
|
|
if (inputEl) {
|
|
inputEl.disabled = !t.checked;
|
|
if (t.checked) inputEl.focus();
|
|
}
|
|
});
|
|
});
|
|
|
|
// load existing gain values from server and populate inputs
|
|
function loadGains(){
|
|
fetch('/get_gains')
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (!data) return;
|
|
if (data.usrp_tx_gain !== undefined) document.getElementById('usrp_tx_gain').value = data.usrp_tx_gain;
|
|
if (data.usrp_rx_gain !== undefined) document.getElementById('usrp_rx_gain').value = data.usrp_rx_gain;
|
|
if (data.scm_tx_gain !== undefined) document.getElementById('scm_tx_gain').value = data.scm_tx_gain;
|
|
if (data.scm_rx_gain !== undefined) document.getElementById('scm_rx_gain').value = data.scm_rx_gain;
|
|
// ensure toggles are off and inputs disabled initially
|
|
toggles.forEach(t => {
|
|
t.checked = false;
|
|
const input = document.getElementById(t.dataset.input);
|
|
if (input) input.disabled = true;
|
|
});
|
|
})
|
|
.catch(err => console.error('loadGains error', err));
|
|
}
|
|
|
|
gainForm.addEventListener('submit', function(e){
|
|
e.preventDefault();
|
|
const formData = new FormData();
|
|
let has = false;
|
|
toggles.forEach(t => {
|
|
if (t.checked) {
|
|
const inputId = t.dataset.input;
|
|
const val = document.getElementById(inputId).value;
|
|
formData.append(inputId, val);
|
|
has = true;
|
|
}
|
|
});
|
|
if (!has) {
|
|
showStatus('gainStatusMessage', 'Please enable at least one gain to update', 'error');
|
|
return;
|
|
}
|
|
gainUpdateBtn.disabled = true;
|
|
fetch('/update_gains', { method:'POST', body: formData })
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
gainUpdateBtn.disabled = false;
|
|
if (data && data.status === 'success') {
|
|
showStatus('gainStatusMessage', data.message || 'Gains updated', 'success');
|
|
// reset toggles
|
|
toggles.forEach(t => {
|
|
t.checked = false;
|
|
const input = document.getElementById(t.dataset.input);
|
|
if (input) input.disabled = true;
|
|
});
|
|
// reload gains from server to reflect current state
|
|
loadGains();
|
|
} else {
|
|
showStatus('gainStatusMessage', data.message || 'Error updating gains', 'error');
|
|
}
|
|
})
|
|
.catch(err => {
|
|
gainUpdateBtn.disabled = false;
|
|
console.error(err);
|
|
showStatus('gainStatusMessage', 'Server error', 'error');
|
|
});
|
|
});
|
|
|
|
gainRefreshBtn.addEventListener('click', function(){
|
|
loadGains();
|
|
showStatus('gainStatusMessage','Gains reloaded','success');
|
|
});
|
|
|
|
// ---------------- Params Form ----------------
|
|
const paramForm = document.getElementById('paramForm');
|
|
paramForm.addEventListener('submit', function(e){
|
|
e.preventDefault();
|
|
const btn = document.getElementById('paramUpdateBtn');
|
|
const formData = new FormData(paramForm);
|
|
btn.disabled = true;
|
|
fetch('/update_params', { method:'POST', body: formData })
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
btn.disabled = false;
|
|
if (data && data.status === 'success') {
|
|
showStatus('paramStatusMessage', data.message || 'Parameters updated', 'success');
|
|
} else {
|
|
showStatus('paramStatusMessage', data.message || 'Error updating parameters', 'error');
|
|
}
|
|
})
|
|
.catch(err => {
|
|
btn.disabled = false;
|
|
console.error(err);
|
|
showStatus('paramStatusMessage','Server error','error');
|
|
});
|
|
});
|
|
|
|
// ---------------- Plot refresh ----------------
|
|
function refreshPlot(){
|
|
if (!isStreaming || isPlotPaused) return;
|
|
// use cache-buster to avoid cached/partial file
|
|
plotImg.src = '/plot?_ts=' + Date.now();
|
|
}
|
|
|
|
// Start auto refresh only when streaming
|
|
function startAutoRefresh() {
|
|
refreshInterval = setInterval(refreshPlot, 500);
|
|
}
|
|
|
|
// Start TMUX output refresh
|
|
function startTmuxRefresh() {
|
|
tmuxInterval = setInterval(fetchTmuxOutput, 1000); // Update every second
|
|
}
|
|
|
|
// Manual refresh button
|
|
document.getElementById('refreshPlotBtn').addEventListener('click', function() {
|
|
refreshPlot();
|
|
});
|
|
|
|
// TMUX controls
|
|
document.getElementById('clearTmuxBtn').addEventListener('click', function() {
|
|
tmuxTerminal.textContent = '';
|
|
});
|
|
|
|
document.getElementById('autoScrollTmuxBtn').addEventListener('click', function() {
|
|
autoScroll = !autoScroll;
|
|
this.textContent = `Auto Scroll: ${autoScroll ? 'ON' : 'OFF'}`;
|
|
});
|
|
|
|
// Stream control buttons
|
|
document.getElementById('startBtn').addEventListener('click', startStream);
|
|
document.getElementById('stopBtn').addEventListener('click', stopStream);
|
|
document.getElementById('pauseBtn').addEventListener('click', pauseStream);
|
|
|
|
// Check stream state every 2 seconds
|
|
setInterval(checkStreamState, 2000);
|
|
|
|
// initial load
|
|
loadGains();
|
|
checkStreamState();
|
|
startAutoRefresh();
|
|
startTmuxRefresh();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |