aprsd 1.0.0__py3-none-any.whl → 3.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. aprsd/__init__.py +6 -4
  2. aprsd/cli_helper.py +151 -0
  3. aprsd/client/__init__.py +13 -0
  4. aprsd/client/aprsis.py +132 -0
  5. aprsd/client/base.py +105 -0
  6. aprsd/client/drivers/__init__.py +0 -0
  7. aprsd/client/drivers/aprsis.py +228 -0
  8. aprsd/client/drivers/fake.py +73 -0
  9. aprsd/client/drivers/kiss.py +119 -0
  10. aprsd/client/factory.py +88 -0
  11. aprsd/client/fake.py +48 -0
  12. aprsd/client/kiss.py +103 -0
  13. aprsd/client/stats.py +38 -0
  14. aprsd/cmds/__init__.py +0 -0
  15. aprsd/cmds/completion.py +22 -0
  16. aprsd/cmds/dev.py +162 -0
  17. aprsd/cmds/fetch_stats.py +156 -0
  18. aprsd/cmds/healthcheck.py +86 -0
  19. aprsd/cmds/list_plugins.py +319 -0
  20. aprsd/cmds/listen.py +231 -0
  21. aprsd/cmds/send_message.py +171 -0
  22. aprsd/cmds/server.py +137 -0
  23. aprsd/cmds/webchat.py +674 -0
  24. aprsd/conf/__init__.py +56 -0
  25. aprsd/conf/client.py +131 -0
  26. aprsd/conf/common.py +301 -0
  27. aprsd/conf/log.py +65 -0
  28. aprsd/conf/opts.py +80 -0
  29. aprsd/conf/plugin_common.py +182 -0
  30. aprsd/conf/plugin_email.py +105 -0
  31. aprsd/exception.py +13 -0
  32. aprsd/log/__init__.py +0 -0
  33. aprsd/log/log.py +138 -0
  34. aprsd/main.py +104 -867
  35. aprsd/packets/__init__.py +20 -0
  36. aprsd/packets/collector.py +79 -0
  37. aprsd/packets/core.py +823 -0
  38. aprsd/packets/log.py +161 -0
  39. aprsd/packets/packet_list.py +110 -0
  40. aprsd/packets/seen_list.py +49 -0
  41. aprsd/packets/tracker.py +103 -0
  42. aprsd/packets/watch_list.py +119 -0
  43. aprsd/plugin.py +474 -284
  44. aprsd/plugin_utils.py +86 -0
  45. aprsd/plugins/__init__.py +0 -0
  46. aprsd/plugins/email.py +709 -0
  47. aprsd/plugins/fortune.py +61 -0
  48. aprsd/plugins/location.py +179 -0
  49. aprsd/plugins/notify.py +61 -0
  50. aprsd/plugins/ping.py +31 -0
  51. aprsd/plugins/time.py +115 -0
  52. aprsd/plugins/version.py +31 -0
  53. aprsd/plugins/weather.py +405 -0
  54. aprsd/stats/__init__.py +20 -0
  55. aprsd/stats/app.py +49 -0
  56. aprsd/stats/collector.py +37 -0
  57. aprsd/threads/__init__.py +11 -0
  58. aprsd/threads/aprsd.py +119 -0
  59. aprsd/threads/keep_alive.py +131 -0
  60. aprsd/threads/log_monitor.py +121 -0
  61. aprsd/threads/registry.py +56 -0
  62. aprsd/threads/rx.py +354 -0
  63. aprsd/threads/stats.py +44 -0
  64. aprsd/threads/tx.py +255 -0
  65. aprsd/utils/__init__.py +218 -0
  66. aprsd/utils/counter.py +51 -0
  67. aprsd/utils/json.py +80 -0
  68. aprsd/utils/objectstore.py +123 -0
  69. aprsd/utils/ring_buffer.py +40 -0
  70. aprsd/utils/trace.py +180 -0
  71. aprsd/web/__init__.py +0 -0
  72. aprsd/web/admin/__init__.py +0 -0
  73. aprsd/web/admin/static/css/index.css +84 -0
  74. aprsd/web/admin/static/css/prism.css +4 -0
  75. aprsd/web/admin/static/css/tabs.css +35 -0
  76. aprsd/web/admin/static/images/Untitled.png +0 -0
  77. aprsd/web/admin/static/images/aprs-symbols-16-0.png +0 -0
  78. aprsd/web/admin/static/images/aprs-symbols-16-1.png +0 -0
  79. aprsd/web/admin/static/images/aprs-symbols-64-0.png +0 -0
  80. aprsd/web/admin/static/images/aprs-symbols-64-1.png +0 -0
  81. aprsd/web/admin/static/images/aprs-symbols-64-2.png +0 -0
  82. aprsd/web/admin/static/js/charts.js +235 -0
  83. aprsd/web/admin/static/js/echarts.js +465 -0
  84. aprsd/web/admin/static/js/logs.js +26 -0
  85. aprsd/web/admin/static/js/main.js +231 -0
  86. aprsd/web/admin/static/js/prism.js +12 -0
  87. aprsd/web/admin/static/js/send-message.js +114 -0
  88. aprsd/web/admin/static/js/tabs.js +28 -0
  89. aprsd/web/admin/templates/index.html +196 -0
  90. aprsd/web/chat/static/css/chat.css +115 -0
  91. aprsd/web/chat/static/css/index.css +66 -0
  92. aprsd/web/chat/static/css/style.css.map +1 -0
  93. aprsd/web/chat/static/css/tabs.css +41 -0
  94. aprsd/web/chat/static/css/upstream/bootstrap.min.css +6 -0
  95. aprsd/web/chat/static/css/upstream/font.woff2 +0 -0
  96. aprsd/web/chat/static/css/upstream/google-fonts.css +23 -0
  97. aprsd/web/chat/static/css/upstream/jquery-ui.css +1311 -0
  98. aprsd/web/chat/static/css/upstream/jquery.toast.css +28 -0
  99. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  100. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  101. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  102. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  103. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/icons.woff +0 -0
  104. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/icons.woff2 +0 -0
  105. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/outline-icons.woff +0 -0
  106. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  107. aprsd/web/chat/static/images/Untitled.png +0 -0
  108. aprsd/web/chat/static/images/aprs-symbols-16-0.png +0 -0
  109. aprsd/web/chat/static/images/aprs-symbols-16-1.png +0 -0
  110. aprsd/web/chat/static/images/aprs-symbols-64-0.png +0 -0
  111. aprsd/web/chat/static/images/aprs-symbols-64-1.png +0 -0
  112. aprsd/web/chat/static/images/aprs-symbols-64-2.png +0 -0
  113. aprsd/web/chat/static/images/globe.svg +3 -0
  114. aprsd/web/chat/static/js/gps.js +84 -0
  115. aprsd/web/chat/static/js/main.js +45 -0
  116. aprsd/web/chat/static/js/send-message.js +585 -0
  117. aprsd/web/chat/static/js/tabs.js +28 -0
  118. aprsd/web/chat/static/js/upstream/bootstrap.bundle.min.js +7 -0
  119. aprsd/web/chat/static/js/upstream/jquery-3.7.1.min.js +2 -0
  120. aprsd/web/chat/static/js/upstream/jquery-ui.min.js +13 -0
  121. aprsd/web/chat/static/js/upstream/jquery.toast.js +374 -0
  122. aprsd/web/chat/static/js/upstream/semantic.min.js +11 -0
  123. aprsd/web/chat/static/js/upstream/socket.io.min.js +7 -0
  124. aprsd/web/chat/templates/index.html +139 -0
  125. aprsd/wsgi.py +315 -0
  126. aprsd-3.4.2.dist-info/AUTHORS +13 -0
  127. aprsd-3.4.2.dist-info/LICENSE +175 -0
  128. aprsd-3.4.2.dist-info/METADATA +793 -0
  129. aprsd-3.4.2.dist-info/RECORD +133 -0
  130. {aprsd-1.0.0.dist-info → aprsd-3.4.2.dist-info}/WHEEL +1 -1
  131. aprsd-3.4.2.dist-info/entry_points.txt +8 -0
  132. aprsd/fake_aprs.py +0 -83
  133. aprsd/utils.py +0 -166
  134. aprsd-1.0.0.dist-info/AUTHORS +0 -6
  135. aprsd-1.0.0.dist-info/METADATA +0 -181
  136. aprsd-1.0.0.dist-info/RECORD +0 -13
  137. aprsd-1.0.0.dist-info/entry_points.txt +0 -4
  138. aprsd-1.0.0.dist-info/pbr.json +0 -1
  139. /aprsd/{fuzzyclock.py → utils/fuzzyclock.py} +0 -0
  140. {aprsd-1.0.0.dist-info → aprsd-3.4.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,235 @@
1
+ var packet_list = {};
2
+
3
+ window.chartColors = {
4
+ red: 'rgb(255, 99, 132)',
5
+ orange: 'rgb(255, 159, 64)',
6
+ yellow: 'rgb(255, 205, 86)',
7
+ green: 'rgb(26, 181, 77)',
8
+ blue: 'rgb(54, 162, 235)',
9
+ purple: 'rgb(153, 102, 255)',
10
+ grey: 'rgb(201, 203, 207)',
11
+ black: 'rgb(0, 0, 0)',
12
+ lightcoral: 'rgb(240,128,128)',
13
+ darkseagreen: 'rgb(143, 188,143)'
14
+
15
+ };
16
+
17
+ function size_dict(d){c=0; for (i in d) ++c; return c}
18
+
19
+ function start_charts() {
20
+ Chart.scaleService.updateScaleDefaults('linear', {
21
+ ticks: {
22
+ min: 0
23
+ }
24
+ });
25
+
26
+ packets_chart = new Chart($("#packetsChart"), {
27
+ label: 'APRS Packets',
28
+ type: 'line',
29
+ data: {
30
+ labels: [],
31
+ datasets: [{
32
+ label: 'Packets Sent',
33
+ borderColor: window.chartColors.lightcoral,
34
+ data: [],
35
+ },
36
+ {
37
+ label: 'Packets Recieved',
38
+ borderColor: window.chartColors.darkseagreen,
39
+ data: [],
40
+ }]
41
+ },
42
+ options: {
43
+ responsive: true,
44
+ maintainAspectRatio: false,
45
+ title: {
46
+ display: true,
47
+ text: 'APRS Packets',
48
+ },
49
+ scales: {
50
+ x: {
51
+ type: 'timeseries',
52
+ offset: true,
53
+ ticks: {
54
+ major: { enabled: true },
55
+ fontStyle: context => context.tick.major ? 'bold' : undefined,
56
+ source: 'data',
57
+ maxRotation: 0,
58
+ autoSkip: true,
59
+ autoSkipPadding: 75,
60
+ }
61
+ }
62
+ }
63
+ }
64
+ });
65
+
66
+ message_chart = new Chart($("#messageChart"), {
67
+ label: 'Messages',
68
+ type: 'line',
69
+ data: {
70
+ labels: [],
71
+ datasets: [{
72
+ label: 'Messages Sent',
73
+ borderColor: window.chartColors.lightcoral,
74
+ data: [],
75
+ },
76
+ {
77
+ label: 'Messages Recieved',
78
+ borderColor: window.chartColors.darkseagreen,
79
+ data: [],
80
+ },
81
+ {
82
+ label: 'Ack Sent',
83
+ borderColor: window.chartColors.purple,
84
+ data: [],
85
+ },
86
+ {
87
+ label: 'Ack Recieved',
88
+ borderColor: window.chartColors.black,
89
+ data: [],
90
+ }],
91
+ },
92
+ options: {
93
+ responsive: true,
94
+ maintainAspectRatio: false,
95
+ title: {
96
+ display: true,
97
+ text: 'APRS Messages',
98
+ },
99
+ scales: {
100
+ x: {
101
+ type: 'timeseries',
102
+ offset: true,
103
+ ticks: {
104
+ major: { enabled: true },
105
+ fontStyle: context => context.tick.major ? 'bold' : undefined,
106
+ source: 'data',
107
+ maxRotation: 0,
108
+ autoSkip: true,
109
+ autoSkipPadding: 75,
110
+ }
111
+ }
112
+ }
113
+ }
114
+ });
115
+
116
+ email_chart = new Chart($("#emailChart"), {
117
+ label: 'Email Messages',
118
+ type: 'line',
119
+ data: {
120
+ labels: [],
121
+ datasets: [{
122
+ label: 'Sent',
123
+ borderColor: window.chartColors.lightcoral,
124
+ data: [],
125
+ },
126
+ {
127
+ label: 'Recieved',
128
+ borderColor: window.chartColors.darkseagreen,
129
+ data: [],
130
+ }],
131
+ },
132
+ options: {
133
+ responsive: true,
134
+ maintainAspectRatio: false,
135
+ title: {
136
+ display: true,
137
+ text: 'Email Messages',
138
+ },
139
+ scales: {
140
+ x: {
141
+ type: 'timeseries',
142
+ offset: true,
143
+ ticks: {
144
+ major: { enabled: true },
145
+ fontStyle: context => context.tick.major ? 'bold' : undefined,
146
+ source: 'data',
147
+ maxRotation: 0,
148
+ autoSkip: true,
149
+ autoSkipPadding: 75,
150
+ }
151
+ }
152
+ }
153
+ }
154
+ });
155
+
156
+ memory_chart = new Chart($("#memChart"), {
157
+ label: 'Memory Usage',
158
+ type: 'line',
159
+ data: {
160
+ labels: [],
161
+ datasets: [{
162
+ label: 'Peak Ram usage',
163
+ borderColor: window.chartColors.red,
164
+ data: [],
165
+ },
166
+ {
167
+ label: 'Current Ram usage',
168
+ borderColor: window.chartColors.blue,
169
+ data: [],
170
+ }],
171
+ },
172
+ options: {
173
+ responsive: true,
174
+ maintainAspectRatio: false,
175
+ title: {
176
+ display: true,
177
+ text: 'Memory Usage',
178
+ },
179
+ scales: {
180
+ x: {
181
+ type: 'timeseries',
182
+ offset: true,
183
+ ticks: {
184
+ major: { enabled: true },
185
+ fontStyle: context => context.tick.major ? 'bold' : undefined,
186
+ source: 'data',
187
+ maxRotation: 0,
188
+ autoSkip: true,
189
+ autoSkipPadding: 75,
190
+ }
191
+ }
192
+ }
193
+ }
194
+ });
195
+ }
196
+
197
+
198
+ function addData(chart, label, newdata) {
199
+ chart.data.labels.push(label);
200
+ chart.data.datasets.forEach((dataset) => {
201
+ dataset.data.push(newdata);
202
+ });
203
+ chart.update();
204
+ }
205
+
206
+ function updateDualData(chart, label, first, second) {
207
+ chart.data.labels.push(label);
208
+ chart.data.datasets[0].data.push(first);
209
+ chart.data.datasets[1].data.push(second);
210
+ chart.update();
211
+ }
212
+ function updateQuadData(chart, label, first, second, third, fourth) {
213
+ chart.data.labels.push(label);
214
+ chart.data.datasets[0].data.push(first);
215
+ chart.data.datasets[1].data.push(second);
216
+ chart.data.datasets[2].data.push(third);
217
+ chart.data.datasets[3].data.push(fourth);
218
+ chart.update();
219
+ }
220
+
221
+ function update_stats( data ) {
222
+ our_callsign = data["APRSDStats"]["callsign"];
223
+ $("#version").text( data["APRSDStats"]["version"] );
224
+ $("#aprs_connection").html( data["aprs_connection"] );
225
+ $("#uptime").text( "uptime: " + data["APRSDStats"]["uptime"] );
226
+ const html_pretty = Prism.highlight(JSON.stringify(data, null, '\t'), Prism.languages.json, 'json');
227
+ $("#jsonstats").html(html_pretty);
228
+ short_time = data["time"].split(/\s(.+)/)[1];
229
+ packet_list = data["PacketList"]["packets"];
230
+ updateDualData(packets_chart, short_time, data["PacketList"]["sent"], data["PacketList"]["received"]);
231
+ updateQuadData(message_chart, short_time, packet_list["MessagePacket"]["tx"], packet_list["MessagePacket"]["rx"],
232
+ packet_list["AckPacket"]["tx"], packet_list["AckPacket"]["rx"]);
233
+ updateDualData(email_chart, short_time, data["EmailStats"]["sent"], data["EmailStats"]["recieved"]);
234
+ updateDualData(memory_chart, short_time, data["APRSDStats"]["memory_peak"], data["APRSDStats"]["memory_current"]);
235
+ }
@@ -0,0 +1,465 @@
1
+ var packet_list = {};
2
+
3
+ var tx_data = [];
4
+ var rx_data = [];
5
+
6
+ var packet_types_data = {};
7
+
8
+ var mem_current = []
9
+ var mem_peak = []
10
+
11
+ var thread_current = []
12
+
13
+
14
+ function start_charts() {
15
+ console.log("start_charts() called");
16
+ // Initialize the echarts instance based on the prepared dom
17
+ create_packets_chart();
18
+ create_packets_types_chart();
19
+ create_messages_chart();
20
+ create_ack_chart();
21
+ create_memory_chart();
22
+ create_thread_chart();
23
+ }
24
+
25
+
26
+ function create_packets_chart() {
27
+ // The packets totals TX/RX chart.
28
+ pkt_c_canvas = document.getElementById('packetsChart');
29
+ packets_chart = echarts.init(pkt_c_canvas);
30
+
31
+ // Specify the configuration items and data for the chart
32
+ var option = {
33
+ title: {
34
+ text: 'APRS Packet totals'
35
+ },
36
+ legend: {},
37
+ tooltip : {
38
+ trigger: 'axis'
39
+ },
40
+ toolbox: {
41
+ show : true,
42
+ feature : {
43
+ mark : {show: true},
44
+ dataView : {show: true, readOnly: true},
45
+ magicType : {show: true, type: ['line', 'bar']},
46
+ restore : {show: true},
47
+ saveAsImage : {show: true}
48
+ }
49
+ },
50
+ calculable : true,
51
+ xAxis: { type: 'time' },
52
+ yAxis: { },
53
+ series: [
54
+ {
55
+ name: 'tx',
56
+ type: 'line',
57
+ smooth: true,
58
+ color: 'red',
59
+ encode: {
60
+ x: 'timestamp',
61
+ y: 'tx' // refer sensor 1 value
62
+ }
63
+ },{
64
+ name: 'rx',
65
+ type: 'line',
66
+ smooth: true,
67
+ encode: {
68
+ x: 'timestamp',
69
+ y: 'rx'
70
+ }
71
+ }]
72
+ };
73
+
74
+ // Display the chart using the configuration items and data just specified.
75
+ packets_chart.setOption(option);
76
+ }
77
+
78
+
79
+ function create_packets_types_chart() {
80
+ // The packets types chart
81
+ pkt_types_canvas = document.getElementById('packetTypesChart');
82
+ packet_types_chart = echarts.init(pkt_types_canvas);
83
+
84
+ // The series and data are built and updated on the fly
85
+ // as packets come in.
86
+ var option = {
87
+ title: {
88
+ text: 'Packet Types'
89
+ },
90
+ legend: {},
91
+ tooltip : {
92
+ trigger: 'axis'
93
+ },
94
+ toolbox: {
95
+ show : true,
96
+ feature : {
97
+ mark : {show: true},
98
+ dataView : {show: true, readOnly: true},
99
+ magicType : {show: true, type: ['line', 'bar']},
100
+ restore : {show: true},
101
+ saveAsImage : {show: true}
102
+ }
103
+ },
104
+ calculable : true,
105
+ xAxis: { type: 'time' },
106
+ yAxis: { },
107
+ }
108
+
109
+ packet_types_chart.setOption(option);
110
+ }
111
+
112
+
113
+ function create_messages_chart() {
114
+ msg_c_canvas = document.getElementById('messagesChart');
115
+ message_chart = echarts.init(msg_c_canvas);
116
+
117
+ // Specify the configuration items and data for the chart
118
+ var option = {
119
+ title: {
120
+ text: 'Message Packets'
121
+ },
122
+ legend: {},
123
+ tooltip: {
124
+ trigger: 'axis'
125
+ },
126
+ toolbox: {
127
+ show: true,
128
+ feature: {
129
+ mark : {show: true},
130
+ dataView : {show: true, readOnly: true},
131
+ magicType : {show: true, type: ['line', 'bar']},
132
+ restore : {show: true},
133
+ saveAsImage : {show: true}
134
+ }
135
+ },
136
+ calculable: true,
137
+ xAxis: { type: 'time' },
138
+ yAxis: { },
139
+ series: [
140
+ {
141
+ name: 'tx',
142
+ type: 'line',
143
+ smooth: true,
144
+ color: 'red',
145
+ encode: {
146
+ x: 'timestamp',
147
+ y: 'tx' // refer sensor 1 value
148
+ }
149
+ },{
150
+ name: 'rx',
151
+ type: 'line',
152
+ smooth: true,
153
+ encode: {
154
+ x: 'timestamp',
155
+ y: 'rx'
156
+ }
157
+ }]
158
+ };
159
+
160
+ // Display the chart using the configuration items and data just specified.
161
+ message_chart.setOption(option);
162
+ }
163
+
164
+ function create_ack_chart() {
165
+ ack_canvas = document.getElementById('acksChart');
166
+ ack_chart = echarts.init(ack_canvas);
167
+
168
+ // Specify the configuration items and data for the chart
169
+ var option = {
170
+ title: {
171
+ text: 'Ack Packets'
172
+ },
173
+ legend: {},
174
+ tooltip: {
175
+ trigger: 'axis'
176
+ },
177
+ toolbox: {
178
+ show: true,
179
+ feature: {
180
+ mark : {show: true},
181
+ dataView : {show: true, readOnly: false},
182
+ magicType : {show: true, type: ['line', 'bar']},
183
+ restore : {show: true},
184
+ saveAsImage : {show: true}
185
+ }
186
+ },
187
+ calculable: true,
188
+ xAxis: { type: 'time' },
189
+ yAxis: { },
190
+ series: [
191
+ {
192
+ name: 'tx',
193
+ type: 'line',
194
+ smooth: true,
195
+ color: 'red',
196
+ encode: {
197
+ x: 'timestamp',
198
+ y: 'tx' // refer sensor 1 value
199
+ }
200
+ },{
201
+ name: 'rx',
202
+ type: 'line',
203
+ smooth: true,
204
+ encode: {
205
+ x: 'timestamp',
206
+ y: 'rx'
207
+ }
208
+ }]
209
+ };
210
+
211
+ ack_chart.setOption(option);
212
+ }
213
+
214
+ function create_memory_chart() {
215
+ ack_canvas = document.getElementById('memChart');
216
+ memory_chart = echarts.init(ack_canvas);
217
+
218
+ // Specify the configuration items and data for the chart
219
+ var option = {
220
+ title: {
221
+ text: 'Memory Usage'
222
+ },
223
+ legend: {},
224
+ tooltip: {
225
+ trigger: 'axis'
226
+ },
227
+ toolbox: {
228
+ show: true,
229
+ feature: {
230
+ mark : {show: true},
231
+ dataView : {show: true, readOnly: false},
232
+ magicType : {show: true, type: ['line', 'bar']},
233
+ restore : {show: true},
234
+ saveAsImage : {show: true}
235
+ }
236
+ },
237
+ calculable: true,
238
+ xAxis: { type: 'time' },
239
+ yAxis: { },
240
+ series: [
241
+ {
242
+ name: 'current',
243
+ type: 'line',
244
+ smooth: true,
245
+ color: 'red',
246
+ encode: {
247
+ x: 'timestamp',
248
+ y: 'current' // refer sensor 1 value
249
+ }
250
+ },{
251
+ name: 'peak',
252
+ type: 'line',
253
+ smooth: true,
254
+ encode: {
255
+ x: 'timestamp',
256
+ y: 'peak'
257
+ }
258
+ }]
259
+ };
260
+
261
+ memory_chart.setOption(option);
262
+ }
263
+
264
+ function create_thread_chart() {
265
+ thread_canvas = document.getElementById('threadChart');
266
+ thread_chart = echarts.init(thread_canvas);
267
+
268
+ // Specify the configuration items and data for the chart
269
+ var option = {
270
+ title: {
271
+ text: 'Active Threads'
272
+ },
273
+ legend: {},
274
+ tooltip: {
275
+ trigger: 'axis'
276
+ },
277
+ toolbox: {
278
+ show: true,
279
+ feature: {
280
+ mark : {show: true},
281
+ dataView : {show: true, readOnly: false},
282
+ magicType : {show: true, type: ['line', 'bar']},
283
+ restore : {show: true},
284
+ saveAsImage : {show: true}
285
+ }
286
+ },
287
+ calculable: true,
288
+ xAxis: { type: 'time' },
289
+ yAxis: { },
290
+ series: [
291
+ {
292
+ name: 'current',
293
+ type: 'line',
294
+ smooth: true,
295
+ color: 'red',
296
+ encode: {
297
+ x: 'timestamp',
298
+ y: 'current' // refer sensor 1 value
299
+ }
300
+ }
301
+ ]
302
+ };
303
+
304
+ thread_chart.setOption(option);
305
+ }
306
+
307
+
308
+
309
+
310
+ function updatePacketData(chart, time, first, second) {
311
+ tx_data.push([time, first]);
312
+ rx_data.push([time, second]);
313
+ option = {
314
+ series: [
315
+ {
316
+ name: 'tx',
317
+ data: tx_data,
318
+ },
319
+ {
320
+ name: 'rx',
321
+ data: rx_data,
322
+ }
323
+ ]
324
+ }
325
+ chart.setOption(option);
326
+ }
327
+
328
+ function updatePacketTypesData(time, typesdata) {
329
+ //The options series is created on the fly each time based on
330
+ //the packet types we have in the data
331
+ var series = []
332
+
333
+ for (const k in typesdata) {
334
+ tx = [time, typesdata[k]["tx"]]
335
+ rx = [time, typesdata[k]["rx"]]
336
+
337
+ if (packet_types_data.hasOwnProperty(k)) {
338
+ packet_types_data[k]["tx"].push(tx)
339
+ packet_types_data[k]["rx"].push(rx)
340
+ } else {
341
+ packet_types_data[k] = {'tx': [tx], 'rx': [rx]}
342
+ }
343
+ }
344
+ }
345
+
346
+ function updatePacketTypesChart() {
347
+ series = []
348
+ for (const k in packet_types_data) {
349
+ entry = {
350
+ name: k+"tx",
351
+ data: packet_types_data[k]["tx"],
352
+ type: 'line',
353
+ smooth: true,
354
+ encode: {
355
+ x: 'timestamp',
356
+ y: k+'tx' // refer sensor 1 value
357
+ }
358
+ }
359
+ series.push(entry)
360
+ entry = {
361
+ name: k+"rx",
362
+ data: packet_types_data[k]["rx"],
363
+ type: 'line',
364
+ smooth: true,
365
+ encode: {
366
+ x: 'timestamp',
367
+ y: k+'rx' // refer sensor 1 value
368
+ }
369
+ }
370
+ series.push(entry)
371
+ }
372
+
373
+ option = {
374
+ series: series
375
+ }
376
+ packet_types_chart.setOption(option);
377
+ }
378
+
379
+ function updateTypeChart(chart, key) {
380
+ //Generic function to update a packet type chart
381
+ if (! packet_types_data.hasOwnProperty(key)) {
382
+ return;
383
+ }
384
+
385
+ if (! packet_types_data[key].hasOwnProperty('tx')) {
386
+ return;
387
+ }
388
+ var option = {
389
+ series: [{
390
+ name: "tx",
391
+ data: packet_types_data[key]["tx"],
392
+ },
393
+ {
394
+ name: "rx",
395
+ data: packet_types_data[key]["rx"]
396
+ }]
397
+ }
398
+
399
+ chart.setOption(option);
400
+ }
401
+
402
+ function updateMemChart(time, current, peak) {
403
+ mem_current.push([time, current]);
404
+ mem_peak.push([time, peak]);
405
+ option = {
406
+ series: [
407
+ {
408
+ name: 'current',
409
+ data: mem_current,
410
+ },
411
+ {
412
+ name: 'peak',
413
+ data: mem_peak,
414
+ }
415
+ ]
416
+ }
417
+ memory_chart.setOption(option);
418
+ }
419
+
420
+ function updateThreadChart(time, threads) {
421
+ keys = Object.keys(threads);
422
+ thread_count = keys.length;
423
+ thread_current.push([time, thread_count]);
424
+ option = {
425
+ series: [
426
+ {
427
+ name: 'current',
428
+ data: thread_current,
429
+ }
430
+ ]
431
+ }
432
+ thread_chart.setOption(option);
433
+ }
434
+
435
+ function updateMessagesChart() {
436
+ updateTypeChart(message_chart, "MessagePacket")
437
+ }
438
+
439
+ function updateAcksChart() {
440
+ updateTypeChart(ack_chart, "AckPacket")
441
+ }
442
+
443
+ function update_stats( data ) {
444
+ console.log("update_stats() echarts.js called")
445
+ stats = data["stats"];
446
+ our_callsign = stats["APRSDStats"]["callsign"];
447
+ $("#version").text( stats["APRSDStats"]["version"] );
448
+ $("#aprs_connection").html( stats["aprs_connection"] );
449
+ $("#uptime").text( "uptime: " + stats["APRSDStats"]["uptime"] );
450
+ const html_pretty = Prism.highlight(JSON.stringify(data, null, '\t'), Prism.languages.json, 'json');
451
+ $("#jsonstats").html(html_pretty);
452
+
453
+ t = Date.parse(data["time"]);
454
+ ts = new Date(t);
455
+ updatePacketData(packets_chart, ts, stats["PacketList"]["tx"], stats["PacketList"]["rx"]);
456
+ updatePacketTypesData(ts, stats["PacketList"]["types"]);
457
+ updatePacketTypesChart();
458
+ updateMessagesChart();
459
+ updateAcksChart();
460
+ updateMemChart(ts, stats["APRSDStats"]["memory_current"], stats["APRSDStats"]["memory_peak"]);
461
+ updateThreadChart(ts, stats["APRSDThreadList"]);
462
+ //updateQuadData(message_chart, short_time, data["stats"]["messages"]["sent"], data["stats"]["messages"]["received"], data["stats"]["messages"]["ack_sent"], data["stats"]["messages"]["ack_recieved"]);
463
+ //updateDualData(email_chart, short_time, data["stats"]["email"]["sent"], data["stats"]["email"]["recieved"]);
464
+ //updateDualData(memory_chart, short_time, data["stats"]["aprsd"]["memory_peak"], data["stats"]["aprsd"]["memory_current"]);
465
+ }