Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
438 lines (421 loc) · 28.9 KB
/
Copy pathindex.html
File metadata and controls
438 lines (421 loc) · 28.9 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="精密科学串口网络分析仪,又称串口绘图助手、串口调试助手,是由中国科学技术大学RoboWalker战队yssickjgd同学开发的一款基于 Web 的串口、TCP/UDP 科学绘图工具,支持实时 FFT 频谱分析、多通道波形监视、自定义帧解析与 CSV 导出。">
<title>精密科学串口网络分析仪 | Advanced Plotter</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="app-container">
<!-- ══ 左侧:配置侧栏 ══ -->
<aside class="sidebar" id="sidebar">
<div class="app-title">
<span class="status-dot disconnected" id="connection-indicator"></span>
<span>Scientific Plotter</span>
</div>
<div class="tab-bar">
<button class="tab-btn active" data-tab="tab-connection">通讯</button>
<button class="tab-btn" data-tab="tab-frame">帧格式</button>
<button class="tab-btn" data-tab="tab-channels">通道</button>
</div>
<!-- ── Tab: 通讯 ── -->
<div class="tab-content active" id="tab-connection">
<div class="control-group">
<div class="section-title">通讯通道</div>
<div class="input-group">
<label>模式</label>
<select id="conn-type">
<option value="serial">原生串口 (Web Serial)</option>
<option value="tcp-client">TCP Client (Bridge)</option>
<option value="tcp-server">TCP Server (Bridge)</option>
<option value="udp">UDP (Bridge)</option>
</select>
</div>
<div id="config-serial">
<div class="input-group">
<label>波特率</label>
<input type="text" id="serial-baud" value="115200" />
</div>
<div class="row">
<div class="input-group">
<label>数据位</label>
<select id="serial-data">
<option>8</option>
<option>7</option>
</select>
</div>
<div class="input-group">
<label>停止位</label>
<select id="serial-stop">
<option>1</option>
<option>2</option>
</select>
</div>
</div>
<div class="input-group">
<label>奇偶校验</label>
<select id="serial-parity">
<option value="none">无 (None)</option>
<option value="even">偶校验 (Even)</option>
<option value="odd">奇校验 (Odd)</option>
</select>
</div>
</div>
<div id="config-net" style="display:none;">
<div class="input-group">
<label>远端 Host IP</label>
<input type="text" id="net-host" value="127.0.0.1" />
</div>
<div class="row">
<div class="input-group">
<label>端口 Port</label>
<input type="text" id="net-port" value="8081" />
</div>
<div class="input-group" id="wrap-local-port" style="display:none;">
<label>本地 Port</label>
<input type="text" id="net-local" value="" placeholder="端口..." />
</div>
</div>
<p class="hint-text">需预先启动 <code>node bridge.js</code> 辅助代理。</p>
</div>
<button id="btn-connect" class="btn btn-primary">请求建立连接</button>
<div class="status-text" id="connection-status">Ready.</div>
</div>
<div class="control-group">
<div class="section-title">配置文件</div>
<div class="row">
<button id="btn-export-cfg" class="btn btn-secondary">导出配置</button>
<button id="btn-import-cfg" class="btn btn-secondary">导入配置</button>
<input type="file" id="cfg-file-input" accept=".json" hidden />
</div>
<span class="hint-text" id="cfg-save-status">配置自动同步至本地存储。</span>
</div>
</div>
<!-- ── Tab: 帧格式 ── -->
<div class="tab-content" id="tab-frame">
<div class="control-group">
<div class="section-title">帧首</div>
<label class="chk-label"><input type="checkbox" id="chk-header" checked />启用帧首特征匹配</label>
<div class="input-group" id="header-config">
<label>帧首字节序列 (Hex, 空格分隔)</label>
<input type="text" id="frame-header" value="AB" placeholder="如: AB CD" />
<span class="hint-text">支持多字节,如: AA BB CC</span>
</div>
</div>
<div class="control-group">
<div class="section-title">帧尾</div>
<label class="chk-label"><input type="checkbox" id="chk-footer" />启用帧尾特征匹配</label>
<div class="input-group" id="footer-config" style="opacity:0.4;pointer-events:none;">
<label>帧尾字节序列 (Hex, 空格分隔)</label>
<input type="text" id="frame-footer" value="0D 0A" placeholder="如: 0D 0A" />
</div>
</div>
<div class="control-group">
<div class="section-title">校验位</div>
<label class="chk-label"><input type="checkbox" id="chk-checksum" />启用末尾 8-bit 和校验</label>
<span class="hint-text" style="margin-top:-4px;">校验仅针对数据段,不含帧首/帧尾。若启用帧尾,校验位位于帧尾之后。</span>
</div>
<div class="control-group">
<div class="section-title">数据格式</div>
<div class="row">
<div class="input-group">
<label>数据类型</label>
<select id="data-type">
<option value="int8">Int8</option>
<option value="uint8">UInt8</option>
<option value="int16">Int16</option>
<option value="uint16">UInt16</option>
<option value="int32">Int32</option>
<option value="uint32">UInt32</option>
<option value="int64">Int64</option>
<option value="uint64">UInt64</option>
<option value="float32" selected>Float32</option>
<option value="float64">Float64</option>
</select>
</div>
<div class="input-group">
<label>字节端序</label>
<select id="endianness">
<option value="little" selected>小端 (LE)</option>
<option value="big">大端 (BE)</option>
</select>
</div>
</div>
<div class="input-group">
<label>采样通道数 (Channels)</label>
<input type="number" id="channels-count" value="1" min="1" max="50" />
</div>
<button id="btn-apply-format" class="btn btn-primary" style="margin-top:2px;">应用帧格式配置</button>
</div>
</div>
<!-- ── Tab: 通道 ── -->
<div class="tab-content" id="tab-channels">
<div class="control-group">
<div class="section-title">画板与缓存</div>
<div class="input-group">
<label>最大采样点数</label>
<input type="number" step="100" min="2" max="3600000" id="max-points" value="1000" />
</div>
<div class="input-group">
<label>波形监视台内采样点数</label>
<input type="number" step="100" min="2" max="1000" id="plot-window-points" value="1000" />
</div>
<div class="row">
<button id="btn-pause" class="btn btn-secondary">暂停捕捉</button>
<button id="btn-clear" class="btn btn-danger">清空缓冲</button>
</div>
<button id="btn-export" class="btn btn-success" style="margin-top:4px;">导出全部通道至 CSV</button>
</div>
<div class="channels-split-pane" id="channels-split-pane">
<div class="control-group channels-display-panel" id="channels-display-panel">
<div class="section-title">通道显示方式</div>
<div class="input-group">
<span class="option-label">波形模式</span>
<input type="hidden" id="plot-view-mode" value="time" />
<div class="choice-group" data-plot-choice="plot-view-mode" role="radiogroup" aria-label="波形模式">
<label><input type="radio" name="plot-view-mode-choice" value="time" checked />时域图</label>
<label><input type="radio" name="plot-view-mode-choice" value="frequency" />频域图</label>
</div>
</div>
<div id="wrap-plot-time-axis" class="input-group">
<span class="option-label">时域横轴单位</span>
<input type="hidden" id="plot-time-x-unit" value="samples" />
<div class="choice-group" data-plot-choice="plot-time-x-unit" role="radiogroup" aria-label="时域横轴单位">
<label><input type="radio" name="plot-time-x-unit-choice" value="samples" checked />Sample</label>
<label><input type="radio" name="plot-time-x-unit-choice" value="s" />s</label>
</div>
</div>
<div id="wrap-plot-frequency-axis" class="axis-options" style="display:none;">
<div class="input-group">
<span class="option-label">频域横轴单位</span>
<input type="hidden" id="plot-freq-x-unit" value="hz" />
<div class="choice-group" data-plot-choice="plot-freq-x-unit" role="radiogroup" aria-label="频域横轴单位">
<label><input type="radio" name="plot-freq-x-unit-choice" value="bins" />Bin</label>
<label><input type="radio" name="plot-freq-x-unit-choice" value="hz" checked />Hz</label>
</div>
</div>
<div class="input-group">
<span class="option-label">频域横轴形式</span>
<input type="hidden" id="plot-freq-x-scale" value="linear" />
<div class="choice-group" data-plot-choice="plot-freq-x-scale" role="radiogroup" aria-label="频域横轴形式">
<label><input type="radio" name="plot-freq-x-scale-choice" value="linear" checked />线性</label>
<label><input type="radio" name="plot-freq-x-scale-choice" value="log" />对数</label>
</div>
</div>
<div class="input-group">
<span class="option-label">频域纵轴形式</span>
<input type="hidden" id="plot-freq-y-scale" value="linear" />
<div class="choice-group" data-plot-choice="plot-freq-y-scale" role="radiogroup" aria-label="频域纵轴形式">
<label><input type="radio" name="plot-freq-y-scale-choice" value="linear" checked />线性</label>
<label><input type="radio" name="plot-freq-y-scale-choice" value="log" />对数幅值</label>
</div>
</div>
<div class="input-group">
<span class="option-label">FFT 窗函数</span>
<input type="hidden" id="plot-fft-window" value="hann" />
<div class="choice-group" data-plot-choice="plot-fft-window" role="radiogroup" aria-label="FFT 窗函数">
<label><input type="radio" name="plot-fft-window-choice" value="rectangular" />无窗</label>
<label><input type="radio" name="plot-fft-window-choice" value="hann" checked />Hann</label>
<label><input type="radio" name="plot-fft-window-choice" value="hamming" />Hamming</label>
<label><input type="radio" name="plot-fft-window-choice" value="blackman" />Blackman</label>
<label><input type="radio" name="plot-fft-window-choice" value="flatTop" />Flat-top</label>
</div>
</div>
</div>
<div class="input-group">
<span class="option-label">Y 轴策略</span>
<input type="hidden" id="plot-y-scale-mode" value="auto" />
<div class="choice-group" data-plot-choice="plot-y-scale-mode" role="radiogroup" aria-label="Y 轴策略">
<label><input type="radio" name="plot-y-scale-mode-choice" value="auto" checked />自动缩放 Y 轴</label>
<label><input type="radio" name="plot-y-scale-mode-choice" value="manual" />自定义 Y 轴范围</label>
</div>
</div>
<div id="wrap-fft-remove-dc" style="display:none;">
<label class="chk-label"><input type="checkbox" id="plot-fft-remove-dc" />频域去直流</label>
</div>
<div class="row" id="wrap-plot-y-bounds" style="display:none;">
<div class="input-group">
<label>Y 轴最小值</label>
<input type="number" id="plot-y-min" step="0.1" value="-1" />
</div>
<div class="input-group">
<label>Y 轴最大值</label>
<input type="number" id="plot-y-max" step="0.1" value="1" />
</div>
</div>
<span id="plot-y-range-status" class="hint-text" role="status" aria-live="polite" style="color:#b42318;" hidden></span>
<span class="hint-text">Hz 和 s 按最近测得的接收帧率估算;对数横轴从第 1 个频点开始,对数纵轴只接受正的自定义范围。</span>
</div>
</div>
</div>
</aside>
<!-- 水平分隔条:拖拽调整侧栏宽度,与垂直分隔条 v-resizer 共用交互模式 -->
<div class="h-resizer" id="h-resizer"></div>
<!-- ══ 中央:波形 + 字节流 + 定位搜索 ══ -->
<main class="main-display" id="main-display">
<!-- ── 波形绘图区 ── -->
<div class="canvas-wrapper box-border" id="canvas-wrapper">
<div class="plot-header" id="plot-header">
<div class="plot-title-row monitor-title-row">
<span class="plot-title">波形监视台</span>
<span id="stat-plot-fps">绘图帧率: 0 FPS</span>
</div>
<!-- 单通道统计由 app.js 动态更新 -->
<div class="plot-info-row monitor-stats-row" id="plot-info-row" hidden>
<div id="plot-channel-stats" class="plot-channel-stats monitor-stat-grid"></div>
</div>
</div>
<canvas id="waveform-canvas"></canvas>
<div class="plot-y-scrollbar-wrap" id="plot-y-scrollbar-wrap" hidden>
<div class="plot-y-scrollbar-thumb" id="plot-y-scrollbar-thumb"></div>
</div>
<div class="plot-scrollbar-wrap" id="plot-scrollbar-wrap">
<div class="plot-scrollbar-thumb" id="plot-scrollbar-thumb"></div>
</div>
</div>
<!-- 垂直分隔条:拖拽调整波形区与监视台高度,与水平分隔条 h-resizer 共用交互模式 -->
<div class="v-resizer" id="v-resizer"></div>
<!-- ── 字节流监视台 ── -->
<div class="monitor-panel box-border" id="monitor-panel">
<div class="monitor-header monitor-title-row" id="monitor-header">
<span class="monitor-title">字节流监视台</span>
<div class="monitor-header-actions">
<label class="monitor-toggle"><input id="show-waveform" type="checkbox" checked />显示波形监视台</label>
</div>
</div>
<div class="stats-bar-row monitor-stats-row monitor-stat-grid" id="monitor-stats">
<span id="stat-rx" class="monitor-stat-item"><span class="monitor-stat-label">RX:</span><span id="stat-rx-value" class="monitor-stat-value">0 B/s</span></span>
<span id="stat-tx" class="monitor-stat-item"><span class="monitor-stat-label">TX:</span><span id="stat-tx-value" class="monitor-stat-value">0 B/s</span></span>
<span id="stat-fps" class="monitor-stat-item"><span class="monitor-stat-label">帧率:</span><span id="stat-fps-value" class="monitor-stat-value">0 f/s</span></span>
<span id="stat-fail" class="monitor-stat-item"><span class="monitor-stat-label">校验失败:</span><span id="stat-fail-value" class="monitor-stat-value">0%</span></span>
</div>
<!-- 可滚动的窗口原始帧记录;只渲染可见行 -->
<div id="data-log" class="log-content"></div>
<!-- 日志/发送区分隔条(暂未启用) -->
<!-- <div class="v-resizer-inner" id="log-send-resizer"></div> -->
<!-- 发送面板 -->
<div class="send-panel" id="send-panel">
<div class="send-toolbar">
<div class="send-mode-row">
<span>发送显示</span>
<input type="hidden" id="send-mode" value="hex" />
<div class="choice-group send-format-choices" role="radiogroup" aria-label="发送框显示格式">
<label><input id="send-mode-hex" type="radio" name="send-mode-choice" value="hex" checked />Hex</label>
<label><input id="send-mode-text" type="radio" name="send-mode-choice" value="text" />Text</label>
</div>
</div>
<div class="interval-wrap">
<label for="send-interval">间隔</label>
<input type="number" id="send-interval" value="0" min="0" step="0.001" title="支持浮点数" />
<input type="hidden" id="send-interval-unit" value="s" />
<div class="choice-group send-interval-choices" role="radiogroup" aria-label="发送间隔单位">
<label><input id="send-interval-unit-s" type="radio" name="send-interval-unit-choice" value="s" checked />s</label>
<label><input id="send-interval-unit-hz" type="radio" name="send-interval-unit-choice" value="hz" />Hz</label>
</div>
</div>
<div class="send-actions">
<button id="btn-load-file" class="btn btn-secondary">载入文件</button>
<input type="file" id="send-file-input" hidden />
<button id="btn-send" class="btn btn-primary">发送</button>
</div>
</div>
<textarea id="send-input" rows="4" placeholder="输入十六进制或文本内容(如: AB CD EF)..." spellcheck="false"></textarea>
</div>
<!-- 固定在字节流监视台底部,不参与波形和字节流之间的拖拽分配 -->
<section class="navigation-panel" id="navigation-panel" aria-label="接收显示、时间定位与搜索">
<div class="monitor-tool-row" id="nav-receive-tools">
<span class="tool-label">接收显示</span>
<div class="monitor-format-row">
<input type="hidden" id="monitor-display-mode" value="hex" />
<div class="choice-group monitor-format-choices" role="radiogroup" aria-label="字节流接收显示格式">
<label><input id="monitor-display-mode-hex" type="radio" name="monitor-display-mode-choice" value="hex" checked />Hex</label>
<label><input id="monitor-display-mode-ascii" type="radio" name="monitor-display-mode-choice" value="ascii" />ASCII</label>
<label><input id="monitor-display-mode-number" type="radio" name="monitor-display-mode-choice" value="number" />通道数值</label>
</div>
</div>
</div>
<div class="monitor-tool-row" id="nav-time-tools">
<span class="tool-label">时间定位</span>
<div class="jump-toolbar" id="nav-jump-toolbar">
<input type="hidden" id="nav-jump-mode" value="absolute" />
<div class="jump-selection-row">
<div class="choice-group jump-mode-choices" role="radiogroup" aria-label="时间类型">
<label><input id="nav-jump-mode-absolute" type="radio" name="nav-jump-mode-choice" value="absolute" checked />系统时间</label>
<label><input id="nav-jump-mode-relative" type="radio" name="nav-jump-mode-choice" value="relative" />相对时间</label>
</div>
<div class="jump-time-value">
<input id="nav-jump-absolute" type="datetime-local" step="0.001" aria-label="系统时间,精确到毫秒" />
<input id="nav-jump-relative" type="number" min="0" step="0.001" aria-label="相对时间(s)" hidden />
<span id="nav-jump-relative-unit" hidden>s</span>
</div>
<button id="nav-jump-button" type="button">跳转</button>
<span id="nav-jump-status" class="jump-status" role="status"></span>
</div>
</div>
</div>
<div class="monitor-tool-row" id="nav-search-tools">
<span class="tool-label">搜索</span>
<div class="monitor-search-toolbar">
<div class="search-fields">
<input id="monitor-search-query" type="text" placeholder="输入搜索内容" aria-label="搜索内容" />
<input id="monitor-search-tolerance" type="number" min="0" step="any" placeholder="±误差" aria-label="数值误差范围" title="允许的绝对误差;留空表示 0(精确匹配)" hidden />
<div id="monitor-search-channel" class="search-channel-picker" hidden>
<button id="monitor-search-channel-toggle" type="button" aria-label="搜索通道" aria-haspopup="true" aria-expanded="false" aria-controls="monitor-search-channel-options">全部通道</button>
<div id="monitor-search-channel-options" class="search-channel-options" role="group" aria-label="搜索通道" hidden></div>
</div>
</div>
<div class="search-actions">
<button id="monitor-search-nearest" type="button">就近搜索</button>
<button id="monitor-search-prev" type="button">上一个</button>
<button id="monitor-search-next" type="button">下一个</button>
</div>
<div class="search-origin-group">
<span>就近依据</span>
<div class="choice-group search-origin-choices" role="radiogroup" aria-label="就近依据">
<label><input id="monitor-search-origin-wave" type="radio" name="monitor-search-origin" value="wave" />波形当前位置就近</label>
<label><input id="monitor-search-origin-byte" type="radio" name="monitor-search-origin" value="byte" checked />字节流当前位置就近</label>
</div>
</div>
<span id="monitor-search-status" role="status"></span>
</div>
</div>
</section>
</div>
</main>
<div class="h-resizer right-resizer" id="right-resizer" role="separator" aria-label="调整通道配置宽度"></div>
<aside class="channel-sidebar" id="channel-sidebar" aria-label="通道显示配置">
<div class="control-group channels-list-panel" id="channels-list-panel">
<div class="section-title">通道显示配置</div>
<div class="channel-toolbar">
<p class="hint-text">在帧格式页配置通道数后,点击“应用”自动生成。</p>
<div class="channel-toolbar-actions">
<button id="btn-channels-all-on" class="btn btn-secondary">全部打开</button>
<button id="btn-channels-all-off" class="btn btn-secondary">全部关闭</button>
</div>
</div>
<div id="channel-config-list" class="channel-config-list"></div>
</div>
</aside>
</div>
<script src="projectLimits.js"></script>
<script src="byteUtils.js"></script>
<script src="frameBuffer.js"></script>
<script src="plotMath.js"></script>
<script src="channelTransform.js"></script>
<script src="csvExport.js"></script>
<script src="spectrum.js"></script>
<script src="monitorView.js"></script>
<script src="monitorSearch.js"></script>
<script src="configValidation.js"></script>
<script src="configView.js"></script>
<script src="configStore.js"></script>
<script src="plotter.js"></script>
<script src="dataParser.js"></script>
<script src="serialEngine.js"></script>
<script src="netEngine.js"></script>
<script src="sendController.js"></script>
<script src="app.js"></script>
</body>
</html>