From 18c71f69c57f65423a39ace13f9abbb539106883 Mon Sep 17 00:00:00 2001 From: cTn Date: Thu, 22 May 2014 16:29:38 +0200 Subject: [PATCH] adding selectable poll rate, i18n run in todo --- tabs/logging.css | 6 ++++++ tabs/logging.html | 13 +++++++++++++ tabs/logging.js | 20 ++++++++++++-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/tabs/logging.css b/tabs/logging.css index bcf3129d..d393f8d6 100644 --- a/tabs/logging.css +++ b/tabs/logging.css @@ -25,6 +25,12 @@ line-height: 20px; color: silver; } + .tab-logging .speed { + margin-top: 5px; + width: 80px; + + border: 1px solid silver; + } .tab-logging .info { margin-top: 10px; } diff --git a/tabs/logging.html b/tabs/logging.html index 4724ee79..2a5b08ce 100644 --- a/tabs/logging.html +++ b/tabs/logging.html @@ -14,6 +14,19 @@
4 columns
+
Samples Saved:
0
diff --git a/tabs/logging.js b/tabs/logging.js index 6dca9bda..12c9ae43 100644 --- a/tabs/logging.js +++ b/tabs/logging.js @@ -46,20 +46,23 @@ function tab_initialize_logging() { } } - GUI.interval_add('log_data_pull', poll_data, 1000, true); // refresh rate goes here + GUI.interval_add('log_data_pull', poll_data, parseInt($('select.speed').val()), true); // refresh rate goes here GUI.interval_add('flush_data', function() { - if (fileWriter.readyState == 0 || fileWriter.readyState == 2) { - append_to_file(log_buffer.join('\n')); + if (log_buffer.length) { // only execute when there is actual data to write + if (fileWriter.readyState == 0 || fileWriter.readyState == 2) { + append_to_file(log_buffer.join('\n')); - $('.samples').text(samples += log_buffer.length); - $('.size').text((fileWriter.length / 1024).toFixed(2) + ' kB'); + $('.samples').text(samples += log_buffer.length); + $('.size').text((fileWriter.length / 1024).toFixed(2) + ' kB'); - log_buffer = []; - } else { - console.log('IO having trouble keeping up with the data flow'); + log_buffer = []; + } else { + console.log('IO having trouble keeping up with the data flow'); + } } }, 1000); + $('.speed').prop('disabled', true); $(this).text('Stop Logging'); $(this).data("clicks", !clicks); } else { @@ -69,6 +72,7 @@ function tab_initialize_logging() { GUI.interval_remove('log_data_pull'); GUI.interval_remove('flush_data'); + $('.speed').prop('disabled', false); $(this).text('Start Logging'); $(this).data("clicks", !clicks); }