From 151233b288b48e7a9febe1c76a13cdd67b0fd798 Mon Sep 17 00:00:00 2001 From: Mia Mirkovic Date: Thu, 8 Feb 2018 15:08:44 -0800 Subject: [PATCH 1/2] testing file downloading code #46 --- client/controls.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/client/controls.js b/client/controls.js index 3130b84..fc4c090 100644 --- a/client/controls.js +++ b/client/controls.js @@ -48,7 +48,7 @@ Template.controls.events({ }, 'click #download_button'() { - import './.meteor/local/build/programs/server/reads.csv' as csv; + let csv = readTextFile('/./.meteor/local/build/programs/server/reads.csv'); if (!csv.match(/^data:text\/csv/i)) { csv = 'data:text/csv;charset=utf-8,' + csv; } @@ -61,6 +61,23 @@ Template.controls.events({ //SOURCE: + function readTextFile(file) + { + var rawFile = new XMLHttpRequest(); + rawFile.open("GET", file, true); + rawFile.onreadystatechange = function () + { + if(rawFile.readyState === 4) + { + if(rawFile.status === 200 || rawFile.status == 0) + { + var allText = rawFile.responseText; + alert(allText); + } + } + } + rawFile.send(null); + } /*function handleFiles(files) { // Check for the various File API support. if (window.FileReader) { From 965e6b243bff497275cbd86492578cadd2e565ec Mon Sep 17 00:00:00 2001 From: Mia Mirkovic Date: Thu, 8 Feb 2018 15:17:34 -0800 Subject: [PATCH 2/2] added gas pull state and changed downloading code --- client/controls.html | 5 +++-- client/controls.js | 11 +++++------ imports/chamber.js | 11 +++++++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/controls.html b/client/controls.html index e56faf3..b4d2042 100644 --- a/client/controls.html +++ b/client/controls.html @@ -44,8 +44,9 @@

- - + +
+

diff --git a/client/controls.js b/client/controls.js index fc4c090..9b0e24a 100644 --- a/client/controls.js +++ b/client/controls.js @@ -40,11 +40,11 @@ Template.controls.events({ }, 'click #chamber_pull'() { - Peripherals.update({ _id: 'chamber' }, { $set: { running: 'pull' } }); + Peripherals.update({ _id: 'chamber' }, { $set: { running: 'pull_vac' } }); }, - 'click #chamber_pull'() { - Peripherals.update({ _id: 'chamber' }, { $set: { running: 'pull' } }); + 'click #chamber_gas'() { + Peripherals.update({ _id: 'chamber' }, { $set: { running: 'pull_gas' } }); }, 'click #download_button'() { @@ -61,8 +61,7 @@ Template.controls.events({ //SOURCE: - function readTextFile(file) - { + function readTextFile(file) { var rawFile = new XMLHttpRequest(); rawFile.open("GET", file, true); rawFile.onreadystatechange = function () @@ -121,7 +120,7 @@ Template.controls.events({ alert("Canno't read file !"); } }*/ - }, + } }); Template.controls.helpers({ diff --git a/imports/chamber.js b/imports/chamber.js index a2fc698..1fc7530 100644 --- a/imports/chamber.js +++ b/imports/chamber.js @@ -65,7 +65,7 @@ function set_valves() { } break; case 'vent': - v1 = 255; + v3 = 255; break; case 'hold': // do something @@ -74,12 +74,18 @@ function set_valves() { v3 = 0; v4 = 0; break; - case 'pull': + case 'pull_vac': v1 = 255; v2 = 0; v3 = 0; v4 = 255; break; + case 'pull_gas': + v1 = 0; + v2 = 255; + v3 = 0; + v4 = 0; + break; //case "p1": @@ -121,6 +127,7 @@ function set_valves() { } */ + Peripherals.update(peripheral_name, { $set: { v1: v1,