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
|
'use strict';
'require view';
'require dom';
'require poll';
'require rpc';
const callDSLMetrics = rpc.declare({
object: 'dsl',
method: 'metrics',
expect: { '': {} }
});
function format_on_off(val) {
return val ? _('on') : _('off');
}
function format_latency(val) {
return '%.2f ms'.format(val / 1000);
}
return view.extend({
load() {
return L.resolveDefault(callDSLMetrics(), {});
},
pollData(container) {
poll.add(L.bind(function() {
return L.resolveDefault(callDSLMetrics(), {}).then(L.bind(function(data) {
dom.content(container, this.renderContent(data));
}, this));
}, this));
},
formatHelper(format, val) {
if (val != null) {
if (format instanceof Function) {
return format(val);
} else if (typeof format === 'string') {
return format.format(val);
} else {
return val;
}
}
return '-';
},
renderSimpleTable(data) {
const table = E('table', { 'class': 'table' });
for (let [i, item] of data.entries()) {
const label = item[0];
const val = item[1];
const rowstyle = (i % 2 == 0) ? 'cbi-rowstyle-1' : 'cbi-rowstyle-2';
table.appendChild(E('tr', { 'class': 'tr ' + rowstyle }, [
E('td', { 'class': 'td left', 'width': '33%' }, [ label ]),
E('td', { 'class': 'td left' }, [ this.formatHelper(null, val) ])
]));
}
return E('div', { 'class': 'cbi-section' }, table);
},
renderTable(data) {
const table = E('table', { 'class': 'table' });
for (let [i, item] of data.entries()) {
const label = item[0];
const format = item[1];
const val1 = item[2];
const val2 = item[3];
const rowstyle = (i % 2 == 0) ? 'cbi-rowstyle-1' : 'cbi-rowstyle-2';
table.appendChild(E('tr', { 'class': 'tr ' + rowstyle }, [
E('td', { 'class': 'td left', 'width': '33%' }, [ label ]),
E('td', { 'class': 'td right', 'width': '33%' }, [ this.formatHelper(format, val1) ]),
E('td', { 'class': 'td right', 'width': '33%' }, [ this.formatHelper(format, val2) ])
]));
}
return E('div', { 'class': 'cbi-section' }, table);
},
renderContent(data) {
return E([], [
E('h3', {}, [ _('Connection State') ]),
this.renderSimpleTable([
[ _('Line State'), data.state ],
[ _('Line Mode'), data.mode ],
[ _('Line Uptime'), '%t'.format(data.uptime) ],
[ _('Annex'), data.annex ],
[ _('Power Management Mode'), data.power_state ]
]),
E('h3', {}, [ _('Inventory') ]),
this.renderSimpleTable([
[ _('Modem Chipset'), data.chipset ],
[ _('Modem Firmware'), data.firmware_version ],
[ _('xTU-C Vendor ID'), data.atu_c.vendor || data.atu_c.vendor_id ]
]),
E('h3', {}, [ _('Line Details') ]),
E('h4', {}, [ _('Data Rates') ]),
this.renderTable([
[ _('Actual Data Rate'), '%1000.3mb/s', data.downstream.data_rate, data.upstream.data_rate ],
[ _('Attainable Data Rate (ATTNDR)'), '%1000.3mb/s', data.downstream.attndr, data.upstream.attndr ],
[ _('Minimum Error-Free Throughput (MINEFTR)'), '%1000.3mb/s', data.downstream.mineftr, data.upstream.mineftr ]
]),
E('h4', {}, [ _('On-line Reconfiguration') ]),
this.renderTable([
[ _('Bitswap'), format_on_off, data.downstream.bitswap, data.upstream.bitswap ],
[ _('Rate Adaptation Mode'), '%s', data.downstream.ra_mode, data.upstream.ra_mode ]
]),
E('h4', {}, [ _('Noise Protection') ]),
this.renderTable([
[ _('Latency'), format_latency, data.downstream.interleave_delay, data.upstream.interleave_delay ],
[ _('Impulse Noise Protection (INP)'), '%.1f symbols', data.downstream.inp, data.upstream.inp ],
[ _('Retransmission (G.INP)'), format_on_off, data.downstream.retx, data.upstream.retx ]
]),
E('h4', {}, [ _('Line Parameters') ]),
this.renderTable([
[ _('Line Attenuation (LATN)'), '%.1f dB', data.downstream.latn, data.upstream.latn ],
[ _('Signal Attenuation (SATN)'), '%.1f dB', data.downstream.satn, data.upstream.satn ],
[ _('Noise Margin (SNRM)'), '%.1f dB', data.downstream.snr, data.upstream.snr ],
[ _('Aggregate Transmit Power (ACTATP)'), '%.1f dB', data.downstream.actatp, data.upstream.actatp ]
]),
E('h3', {}, [ _('Error Counters') ]),
E('h4', {}, [ _('Error Seconds') ]),
this.renderTable([
[ _('Forward Error Correction Seconds (FECS)'), '%d', data.errors.near.fecs, data.errors.far.fecs ],
[ _('Errored Seconds (ES)'), '%d', data.errors.near.es, data.errors.far.es ],
[ _('Severely Errored Seconds (SES)'), '%d', data.errors.near.ses, data.errors.far.ses ],
[ _('Loss of Signal Seconds (LOSS)'), '%d', data.errors.near.loss, data.errors.far.loss ],
[ _('Unavailable Seconds (UAS)'), '%d', data.errors.near.uas, data.errors.far.uas ],
[ _('Seconds with Low Error-Free Throughput (LEFTRS)'), '%d', data.errors.near.leftrs, data.errors.far.leftrs ]
]),
E('h4', {}, [ _('Channel Counters') ]),
this.renderTable([
[ _('CRC Errors (CV-C)'), '%d', data.errors.near.cv_c, data.errors.far.cv_c ],
[ _('Corrected by FEC (FEC-C)'), '%d', data.errors.near.fec_c, data.errors.far.fec_c ]
]),
E('h4', {}, [ _('Data Path Counters') ]),
this.renderTable([
[ _('ATM Header Error Control Errors (HEC-P)'), '%d', data.errors.near.hec, data.errors.far.hec ],
[ _('PTM Non Pre-emptive CRC Errors (CRC-P)'), '%d', data.errors.near.crc_p, data.errors.far.crc_p ],
[ _('PTM Pre-emptive CRC Errors (CRCP-P)'), '%d', data.errors.near.crcp_p, data.errors.far.crcp_p ]
]),
E('h4', {}, [ _('Retransmission Counters') ]),
this.renderTable([
[ _('Retransmitted DTUs (rtx-tx)'), '%d', data.errors.far.tx_retransmitted, data.errors.near.tx_retransmitted ],
[ _('Corrected DTUs (rtx-c)'), '%d', data.errors.near.rx_corrected, data.errors.far.rx_corrected ],
[ _('Uncorrected DTUs (rtx-uc)'), '%d', data.errors.near.rx_uncorrected_protected, data.errors.far.rx_uncorrected_protected ]
])
]);
},
render(data) {
const v = E([], [
E('h2', {}, [ _('DSL stats') ]),
E('div')
]);
const container = v.lastElementChild;
dom.content(container, this.renderContent(data));
this.pollData(container);
return v;
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});
|