|
|
|
@ -58,7 +58,6 @@ $('.btn-minimize').click(function (e) {
|
|
|
|
|
if ($target.is(':visible')) {
|
|
|
|
|
if ($(this).parent().attr('id') === "RealtimePlotting") {
|
|
|
|
|
plotting.forceToRedraw(function (status) {
|
|
|
|
|
|
|
|
|
|
d3.select("#realtimechart").select("svg").remove();
|
|
|
|
|
plotting.realtime_plotting("#realtimechart", "#range_min", "#range_max", "#window_update_value",
|
|
|
|
|
600, $("#realtimechart").height(), "#window_size_current_value",
|
|
|
|
@ -71,33 +70,40 @@ $('.btn-minimize').click(function (e) {
|
|
|
|
|
$('#connectionOpen').on('click', function () {
|
|
|
|
|
$('#connectionOpen').toggleClass('active');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#xmppConnectionOpen").on('click', function () {
|
|
|
|
|
$('#xmppConnectionOpen').toggleClass('active');
|
|
|
|
|
if ($('#xmppConnectionOpen').html() === "Start") {
|
|
|
|
|
sendMessage();
|
|
|
|
|
$('#xmppConnectionOpen').html("Stop");
|
|
|
|
|
sendMessage("Start the process", function(state){
|
|
|
|
|
console.log("sending message to server..."+ state);
|
|
|
|
|
if(state<2){
|
|
|
|
|
$('#xmppConnectionOpen').html("Stop");
|
|
|
|
|
}else{
|
|
|
|
|
$('#xmppConnectionOpen').html("Start");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else if ($('#xmppConnectionOpen').html() === "Stop") {
|
|
|
|
|
closeSocket();
|
|
|
|
|
$('#xmppConnectionOpen').html("Start");
|
|
|
|
|
$("#connectionOpen").html("Connect to server").removeClass("btn btn-info").addClass("btn btn-primary");
|
|
|
|
|
closeSocket(function(state){
|
|
|
|
|
console.log("closing WebSocket..."+ state);
|
|
|
|
|
if(state<2){
|
|
|
|
|
$('#xmppConnectionOpen').html("Stop");
|
|
|
|
|
}else{
|
|
|
|
|
$('#xmppConnectionOpen').html("Start");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$("#connectionOpen").html("Connect to XMPP Server").removeClass("btn btn-info").addClass("btn btn-primary");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btn-minimize').parent().parent().next('.box-content').hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var webSocket;
|
|
|
|
|
config_api.realtime_plotting_data_window["attitude"] = new Queue();
|
|
|
|
|
|
|
|
|
|
var current_status = {};
|
|
|
|
|
|
|
|
|
|
function openSocket() {
|
|
|
|
|
if (webSocket !== undefined && webSocket.readyState !== WebSocket.CLOSED) {
|
|
|
|
|
function openSocket(wssAddress) {
|
|
|
|
|
if (webSocket !== undefined && webSocket.readyState == 1) {
|
|
|
|
|
writeResponse("WebSocket is already opened.");
|
|
|
|
|
} else {
|
|
|
|
|
webSocket = new WebSocket(config_api.web_socket_endpoint);
|
|
|
|
|
webSocket = new WebSocket(wssAddress+config_api.web_socket_endpoint);
|
|
|
|
|
}
|
|
|
|
|
webSocket.onopen = function (event) {
|
|
|
|
|
if (event === undefined) {
|
|
|
|
@ -121,15 +127,20 @@ function openSocket() {
|
|
|
|
|
writeResponse("Message has been corrupted.");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sendMessage(message) {
|
|
|
|
|
webSocket.send(message);
|
|
|
|
|
function sendMessage(message, callback) {
|
|
|
|
|
if(webSocket.readyState<2){
|
|
|
|
|
webSocket.send(message);
|
|
|
|
|
}
|
|
|
|
|
callback(webSocket.readyState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeSocket() {
|
|
|
|
|
webSocket.close();
|
|
|
|
|
function closeSocket(callback) {
|
|
|
|
|
if(webSocket.readyState<2){
|
|
|
|
|
webSocket.close();
|
|
|
|
|
}
|
|
|
|
|
callback(webSocket.readyState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function writeResponse(text) {
|
|
|
|
@ -137,8 +148,6 @@ function writeResponse(text) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.onbeforeunload = function () {
|
|
|
|
|
webSocket.onclose = function () {
|
|
|
|
|
};
|
|
|
|
|
webSocket.close()
|
|
|
|
|
webSocket.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|