forked from org-arl/unet-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagscope.html
280 lines (260 loc) · 11.2 KB
/
diagscope.html
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
<!DOCTYPE HTML>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Unet Diagscope</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="/img/unet.ico">
<link rel="stylesheet" href="/css/vendor/modular-admin.css">
<link rel="stylesheet" href="/css/vendor/app-orange.css">
<link rel="stylesheet" href="/css/vendor/font.css">
<link rel="stylesheet" href="/css/vendor/sweetalert.min.css">
<link rel="stylesheet" href="/css/style.css">
<script src="/js/vendor/sweetalert/sweetalert.min.js"></script>
<script src="/js/vendor/fetch/fetch.umd.js"></script>
<script src="/js/vendor/modular-admin/modular-admin.js" ></script>
<script src="plotly-latest.min.js"></script>
<script type='module' src='/js/nodeInfo.js'></script>
<script type='module'>
import { Gateway, Performative, MessageClass } from '../fjage/fjage.js';
import '/js/nodeInfo.js';
setTimeout(() => {
if (document.querySelector('#logo').src.endsWith('subnero.png')) {
document.querySelector('#logo').src = '/modem/img/subnero.png'
}
},1000)
var gw = new Gateway();
gw.addMessageListener(listener);
var ParameterReq = MessageClass('org.arl.unet.ParameterReq');
var ParameterRsp = MessageClass('org.arl.unet.ParameterRsp');
var DiagnosticsNtf = MessageClass('org.arl.yoda.DiagnosticsNtf');
var phy = gw.agent('phy');
gw.subscribe(gw.topic(phy,'diag'));
var axis = null;
var run = -1;
var trig = null;
var trigMode = false;
function stride2(x, p) {
var y = [];
y.length = x.length/2;
for (var i = 0; i < y.length; i++)
y[i] = x[2*i+p];
return y;
}
function plot(xmin, xmax, ymin, ymax, ydata = [], cplx = false) {
if (trig !== null && Math.max(...ydata) < trig) return;
if (axis !== null && xmin == axis[0] && xmax == axis[1] && ymin == axis[2] && ymax == axis[3] && cplx == axis[4]) {
if (cplx) {
Plotly.update('graph', {
x: [stride2(ydata, 0)],
y: [stride2(ydata, 1)]
});
} else {
Plotly.update('graph', {
x0: xmin,
dx: (xmax-xmin)/ydata.length,
y: [ydata]
});
}
} else {
axis = [xmin, xmax, ymin, ymax, cplx];
Plotly.newPlot('graph', cplx ? [{
type: 'scatter',
x: [stride2(ydata, 0)],
y: [stride2(ydata, 1)],
mode: 'markers',
marker: { size: 2 }
}] : [{
type: 'scatter',
x0: xmin,
dx: (xmax-xmin)/ydata.length,
y: [ydata],
mode: 'lines',
line: { width: 1, color: '#000080' },
}], {
xaxis: {
range: [xmin, xmax],
autorange: false,
linecolor: 'black',
linewidth: 1,
mirror: true
},
yaxis: {
range: [ymin, ymax],
autorange: false,
linecolor: 'black',
linewidth: 1,
mirror: true
},
paper_bgcolor: '#f0f3f6',
margin: {
l: 40, t: 50, b: 40, r: 20
}
}, {
displayModeBar: true,
scrollZoom: true,
displaylogo: false,
modeBarButtonsToRemove: ['toImage', 'hoverClosestCartesian', 'hoverCompareCartesian', 'toggleSpikelines']
}
);
}
}
plot(0, 1, 0, 1);
function cls() {
if (run == 0) return;
document.getElementById('output').innerHTML = '';
}
function out(s) {
if (run == 0) return;
s = s.replace('\f','');
s = s.replace('&', '&');
s = s.replace('<', '<');
s = s.replace('>', '>');
s = s.replace('\r','<br>');
s = s.replace('\n','<br>');
if (s.length > 0) document.getElementById('output').innerHTML += s + '<br>';
}
function updateRun() {
if (run == 0) {
document.getElementById('run').classList.remove('btn-primary');
document.getElementById('run').classList.add('btn-secondary');
document.getElementById('stop').classList.remove('btn-secondary');
document.getElementById('stop').classList.add('btn-primary');
} else {
document.getElementById('run').classList.remove('btn-secondary');
document.getElementById('run').classList.add('btn-primary');
document.getElementById('stop').classList.remove('btn-primary');
document.getElementById('stop').classList.add('btn-secondary');
}
}
function listener(msg) {
if (msg instanceof DiagnosticsNtf) {
if ('data' in msg) {
if (run != 0) plot(msg.xmin, msg.xmax, msg.ymin, msg.ymax, msg.data, msg.cplx);
if (run > 0) run--;
updateRun();
} else if ('text' in msg) {
if (msg.text.startsWith('\f')) cls();
out(msg.text);
}
return true;
}
return false;
}
function setSource(src) {
let req = new ParameterReq();
req.perf = Performative.REQUEST;
req.recipient = phy;
req.index = -1;
req.param = 'diag';
req.value = src;
gw.send(req);
}
document.getElementById('dsrc-none').onclick = () => { setSource('none'); }
document.getElementById('dsrc-pb').onclick = () => { setSource('pb'); }
document.getElementById('dsrc-pb-p').onclick = () => { setSource('pb:p'); }
document.getElementById('dsrc-bb-p').onclick = () => { setSource('bb:p'); }
document.getElementById('dsrc-corr-1').onclick = () => { setSource('corr:1'); }
document.getElementById('dsrc-corr-2').onclick = () => { setSource('corr:2'); }
document.getElementById('dsrc-corr-3').onclick = () => { setSource('corr:3'); }
document.getElementById('dsrc-mod').onclick = () => { setSource('mod'); }
document.getElementById('dsrc-adc2-1').onclick = () => { setSource('adc2:1'); }
document.getElementById('dsrc-adc2-2').onclick = () => { setSource('adc2:2'); }
document.getElementById('dsrc-adc2-3').onclick = () => { setSource('adc2:3'); }
document.getElementById('dsrc-adc2-4').onclick = () => { setSource('adc2:4'); }
document.getElementById('dsrc-adc2-p1').onclick = () => { setSource('adc2:p1'); }
document.getElementById('dsrc-adc2-p2').onclick = () => { setSource('adc2:p2'); }
document.getElementById('dsrc-adc2-p3').onclick = () => { setSource('adc2:p3'); }
document.getElementById('dsrc-adc2-p4').onclick = () => { setSource('adc2:p4'); }
document.getElementById('run').onclick = () => { run = -1; updateRun(); }
document.getElementById('stop').onclick = () => { run = 0; updateRun(); }
document.getElementById('single').onclick = () => { run = 1; updateRun(); }
document.getElementById('graph').on('plotly_click', (data) => {
if (trigMode) {
trigMode = false;
let gd = document.getElementById('graph');
let xaxis = gd._fullLayout.xaxis;
let yaxis = gd._fullLayout.yaxis;
let l = gd._fullLayout.margin.l;
let t = gd._fullLayout.margin.t;
let x = data.event.pointerX - l;
let y = data.event.pointerY - t;
x = xaxis.p2c(x);
y = yaxis.p2c(y);
trig = y;
document.getElementById('trig').innerText = String(trig);
document.getElementById('set-trig').classList.remove('btn-primary');
document.getElementById('set-trig').classList.add('btn-secondary');
}
});
document.getElementById('set-trig').onclick = () => {
trig = null;
trigMode = true;
document.getElementById('trig').innerText = '';
document.getElementById('set-trig').classList.remove('btn-secondary');
document.getElementById('set-trig').classList.add('btn-primary');
}
document.getElementById('clear-trig').onclick = () => {
trig = null;
trigMode = false;
document.getElementById('trig').innerText = '';
document.getElementById('set-trig').classList.remove('btn-primary');
document.getElementById('set-trig').classList.add('btn-secondary');
}
</script>
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<div class="main-wrapper">
<div class="app header-fixed footer-fixed sidebar-fixed full-screen" id="app">
<article class="content dashboard-page d-flex flex-column">
<div class="row sameheight-container flex-grow-1">
<div class="col col-6">
<h1>Diagnostic Scope</h1><hr>
<div id="graph"></div><hr>
<table width="100%">
<tr><td width="50%">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="diagsrc" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Source</button>
<div class="dropdown-menu" aria-labelledby="diagsrc">
<a class="dropdown-item" id="dsrc-none">None</a>
<a class="dropdown-item" id="dsrc-pb">Passband</a>
<a class="dropdown-item" id="dsrc-pb-p">Passband PSD</a>
<a class="dropdown-item" id="dsrc-bb-p">Baseband PSD</a>
<a class="dropdown-item" id="dsrc-corr-1">Correlator #1</a>
<a class="dropdown-item" id="dsrc-corr-2">Correlator #2</a>
<a class="dropdown-item" id="dsrc-corr-3">Correlator #3</a>
<a class="dropdown-item" id="dsrc-mod">Modulation</a>
<a class="dropdown-item" id="dsrc-adc2-1">ADC2 channel #1</a>
<a class="dropdown-item" id="dsrc-adc2-2">ADC2 channel #2</a>
<a class="dropdown-item" id="dsrc-adc2-3">ADC2 channel #3</a>
<a class="dropdown-item" id="dsrc-adc2-4">ADC2 channel #4</a>
<a class="dropdown-item" id="dsrc-adc2-p1">ADC2 channel #1 PSD</a>
<a class="dropdown-item" id="dsrc-adc2-p2">ADC2 channel #2 PSD</a>
<a class="dropdown-item" id="dsrc-adc2-p3">ADC2 channel #3 PSD</a>
<a class="dropdown-item" id="dsrc-adc2-p4">ADC2 channel #4 PSD</a>
</div>
</div><hr>
<button type="button" class="btn btn-secondary" id="run">Run</button>
<button type="button" class="btn btn-secondary" id="single">Single</button>
<button type="button" class="btn btn-secondary" id="stop">Stop</button>
<br>
<span style="font-size: 12px;">Trigger: <span id="trig"></span></span><br>
<button type="button" class="btn btn-secondary" id="set-trig">Set Level</button>
<button type="button" class="btn btn-secondary" id="clear-trig">Clear</button>
</td><td width="50%" valign="top">
<p id="output" style="font-size:12px;"></p>
</td></tr>
</table>
</div><div class="col col-6">
<iframe src="/fjage/shell/index.html" class="terminal shell-frame"></iframe>
</div>
</div>
</article>
</div>
</div>
</body>
</html>