hookup new cleanup system

10.3.x-maintenance
cTn 2014-07-10 18:45:18 +02:00
parent 31dcbbfa91
commit 75e0accf75
4 changed files with 33 additions and 46 deletions

View File

@ -196,51 +196,7 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
GUI.interval_kill_all(); // all intervals (mostly data pulling) needs to be removed on tab switch
switch (this.active_tab) {
case 'sensors':
serial.empty_output_buffer();
// sensor data tab uses scrollbars, emptying the content before loading another tab
// prevents scrollbar exposure to any of the tabs while new content is loaded in
$('#content').empty();
if (callback) callback();
break;
case 'cli':
var bufferOut = new ArrayBuffer(5);
var bufView = new Uint8Array(bufferOut);
bufView[0] = 0x65; // e
bufView[1] = 0x78; // x
bufView[2] = 0x69; // i
bufView[3] = 0x74; // t
bufView[4] = 0x0D; // enter
serial.send(bufferOut, function(writeInfo) {
// we could handle this "nicely", but this will do for now
// (another approach is however much more complicated):
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
// we could probably implement this someday
GUI.timeout_add('waiting_for_bootup', function() {
CLI_active = false;
CLI_valid = false;
if (callback) callback();
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
});
break;
case 'firmware_flasher':
PortHandler.flush_callbacks();
// unbind "global" events
$(document).unbind('keypress');
if (callback) callback();
break;
default:
if (callback) callback();
}
this.active_tab_ref.cleanup(callback);
};
// initialize object into GUI variable

View File

@ -85,7 +85,27 @@ tabs.cli.initialize = function(callback) {
};
tabs.cli.cleanup = function(callback) {
if (callback) callback();
var bufferOut = new ArrayBuffer(5);
var bufView = new Uint8Array(bufferOut);
bufView[0] = 0x65; // e
bufView[1] = 0x78; // x
bufView[2] = 0x69; // i
bufView[3] = 0x74; // t
bufView[4] = 0x0D; // enter
serial.send(bufferOut, function(writeInfo) {
// we could handle this "nicely", but this will do for now
// (another approach is however much more complicated):
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
// we could probably implement this someday
GUI.timeout_add('waiting_for_bootup', function() {
CLI_active = false;
CLI_valid = false;
if (callback) callback();
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
});
};
function send_slowly(out_arr, i, timeout_needle) {

View File

@ -237,6 +237,11 @@ tabs.firmware_flasher.initialize = function(callback) {
};
tabs.firmware_flasher.cleanup = function(callback) {
PortHandler.flush_callbacks();
// unbind "global" events
$(document).unbind('keypress');
if (callback) callback();
};

View File

@ -414,5 +414,11 @@ tabs.sensors.initialize = function(callback) {
};
tabs.sensors.cleanup = function(callback) {
serial.empty_output_buffer();
// sensor data tab uses scrollbars, emptying the content before loading another tab
// prevents scrollbar exposure to any of the tabs while new content is loaded in
$('#content').empty();
if (callback) callback();
};