diff --git a/raspberry-backend/app.py b/raspberry-backend/app.py index 3bfe6f2125ec7f03c1bbcc46adbc6a905d370c29..a578ac1079669c0a6bf07110614e5470be5064f6 100755 --- a/raspberry-backend/app.py +++ b/raspberry-backend/app.py @@ -56,8 +56,8 @@ def send_cmd(): print(hevclient.send_cmd("CMD_STOP")) elif web_form.get('reset') == "RESET": print(hevclient.send_cmd("CMD_RESET")) - return render_template('index.html', result=live_data()) - + #return render_template('index.html', result=live_data()) + return ('', 204) @WEBAPP.route('/data_handler', methods=['POST']) @@ -94,8 +94,7 @@ def live_data(): Output in json format """ - list_variables = ['created_at' , 'temperature' , - 'pressure' , 'version' , + list_variables = ['created_at', 'version' , 'fsm_state' , 'pressure_air_supply' , 'pressure_air_regulated' , 'pressure_o2_supply' , 'pressure_o2_regulated' , 'pressure_buffer' , diff --git a/raspberry-backend/arduino_recorder.py b/raspberry-backend/arduino_recorder.py index 6f2f94a7b40f3b894894d59fadaef3273f947494..5561c9c9cae0a0aeb19a50feff84de846be4ae33 100755 --- a/raspberry-backend/arduino_recorder.py +++ b/raspberry-backend/arduino_recorder.py @@ -24,16 +24,11 @@ def get_temperature(): """ return random() * 20 -def get_pressure(): - """ - Returns a random number to simulate data obtained from a sensor - """ - return random() * 10 def database_setup(): ''' This function creates the sqlite3 table with the timestamp column - and the columns for temperature and humidity + and the columns for the arduino packet data ''' print('Creating ' + TABLE_NAME + ' table..' ) @@ -44,8 +39,6 @@ def database_setup(): conn.execute('''CREATE TABLE IF NOT EXISTS ''' + TABLE_NAME + ''' ( created_at INTEGER NOT NULL, alarms STRING NOT NULL, - temperature FLOAT NOT NULL, - pressure FLOAT NOT NULL, version FLOAT NOT NULL, fsm_state FLOAT NOT NULL, pressure_air_supply FLOAT NOT NULL, @@ -106,9 +99,7 @@ def monitoring(source_address): data_packet = { 'time' : timestamp, 'alarms' : data_alarms, - 'temperature': 1, 'version': data_receiver["version"], - 'pressure': 1, 'fsm_state': data_receiver["fsm_state"], 'pressure_air_supply': data_receiver["pressure_air_supply"], 'pressure_air_regulated': data_receiver["pressure_air_regulated"], @@ -131,7 +122,7 @@ def monitoring(source_address): try: cursor.execute( 'INSERT INTO {tn} VALUES ' - '(:time, :alarms, :temperature, :pressure , :version, ' + '(:time, :alarms, :version, ' ':fsm_state, :pressure_air_supply, ' ':pressure_air_regulated, :pressure_o2_supply,' ':pressure_o2_regulated, :pressure_buffer,' diff --git a/raspberry-backend/static/js/Chart-plot.js b/raspberry-backend/static/js/Chart-plot.js index 424d28a84b50ea41fb0648891f762a7ddbda494c..ffaaaca7d2dadc615219edb69626ca7b6b961dd7 100644 --- a/raspberry-backend/static/js/Chart-plot.js +++ b/raspberry-backend/static/js/Chart-plot.js @@ -78,14 +78,14 @@ $(document).ready(function() { label: 'A', yAxisID: 'A', data: [], - label: "temperature", + label: "pressure_buffer", borderColor: "#0000FF", fill: false, },{ label: 'B', yAxisID: 'B', data: [], - label: "pressure", + label: "pressure_inhale", borderColor: "#000000", fill: false, } @@ -122,7 +122,7 @@ $(document).ready(function() { display: true} } }); - requestDataVar1("temperature", "pressure"); + requestDataVar1("pressure_buffer", "pressure_inhale"); }); @@ -217,12 +217,12 @@ function updateChartType() { }); requestDataVar1(selection_results[0], selection_results[1]); }; // ends update button - - document.multiselect('#chart_variables') + document.multiselect('#chart_variables') + .setCheckBoxClick("checkboxAll", function(target, args) { console.log("Checkbox 'Select All' was clicked and got value ", args.checked);}) - .setCheckBoxClick("1", function(target, args) { + .setCheckBoxClick("pressure_buffer", function(target, args) { console.log("Checkbox for item with value '1' was clicked and got value ", args.checked); }); - - + document.multiselect('#chart_variables') + .deselectAll(); diff --git a/raspberry-backend/templates/base.html b/raspberry-backend/templates/base.html index 85ff6ba34e2267d3b39b3ff186e00bf58692f91b..98781e077a5cb83c8054a06451139b29e874532c 100644 --- a/raspberry-backend/templates/base.html +++ b/raspberry-backend/templates/base.html @@ -100,12 +100,12 @@ $.getJSON("live-data", function (data) { //document.getElementById("pressure").innerHTML = data.pressure; - document.getElementById("temperature").innerHTML = data.temperature; document.getElementById("pressure_buffer").innerHTML = data.pressure_buffer; document.getElementById("pressure_inhale").innerHTML = data.pressure_inhale; document.getElementById("temperature_buffer").innerHTML = data.temperature_buffer; document.getElementById("pressure_o2_regulated").innerHTML = data.pressure_o2_regulated; document.getElementById("fsm_state").innerHTML = data.fsm_state; + document.getElementById("version").innerHTML = data.version; } ); } diff --git a/raspberry-backend/templates/index.html b/raspberry-backend/templates/index.html index f1e57d38fec53c7bb9b77277e010b271410e2e85..94422576786e4349c310f123f2841344e47020e4 100644 --- a/raspberry-backend/templates/index.html +++ b/raspberry-backend/templates/index.html @@ -11,9 +11,7 @@ <!--<h1 class="mt-4">Info</h1> !--> <div class = "row"> <div class = "col-md-7 py-0"> - <select id='chart_variables' multiple> - <option value='temperature' selected>temperature</option> - <option value='pressure' selected>pressure</option> + <select id='chart_variables' multiple="multiple"> <option value='pressure_buffer' selected>pressure_buffer</option> <option value='pressure_inhale' selected>pressure_inhale</option> <option value='temperature_buffer' selected>temperature_buffer</option> @@ -24,7 +22,7 @@ <div class="row"> <div class="col-md-12"> <div class="card mb-6"> - <div class="card-chart-header small ">Variable number 1</div> + <div class="card-chart-header small ">Plots</div> <div class="card-body px-0 py-0"><canvas id="pressure_air_supply" width="100%" height="65px"></canvas></div> </div> </div> @@ -37,9 +35,9 @@ <div class="col-xl-4 px-1 py-0 mr-0"> <div class="card bg-primary text-dark mb-2"> <div class="card-header d-flex align-items-center justify-content-between py-1"> - <a class="small text-dark stretched-link" href="#">Temperature</a> + <a class="small text-dark stretched-link" href="#">Version</a> </div> - <div class="card-body px-1 py-3"><span class = "reading-main" id="temperature">000.00</span> ℃</div> + <div class="card-body px-1 py-3"><span class = "reading-main" id="version">000.00</span></div> </div> </div>