Skip to content

Commit

Permalink
Merge pull request #57 from miamirkovic/master
Browse files Browse the repository at this point in the history
added gas pull state and changed downloading code #46
  • Loading branch information
miamirkovic authored Feb 8, 2018
2 parents 8c17bec + 965e6b2 commit 4b08562
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
5 changes: 3 additions & 2 deletions client/controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ <h4>
<div class="or"></div>
<button {{chamber_hold_attributes}} id="chamber_hold">Hold</button>
<div class="or"></div>
<button {{chamber_pull_attributes}} id="chamber_pull">Pull</button>

<button {{chamber_pull_attributes}} id="chamber_pull">Pull Vacuum</button>
<div class="or"></div>
<button {{chamber_gas_attributes}} id="chamber_gas">Pull Gas</button>
</div>

<h4>
Expand Down
26 changes: 21 additions & 5 deletions client/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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'() {
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;
}
Expand All @@ -61,6 +61,22 @@ 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) {
Expand Down Expand Up @@ -104,7 +120,7 @@ Template.controls.events({
alert("Canno't read file !");
}
}*/
},
}
});

Template.controls.helpers({
Expand Down
11 changes: 9 additions & 2 deletions imports/chamber.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function set_valves() {
}
break;
case 'vent':
v1 = 255;
v3 = 255;
break;
case 'hold':
// do something
Expand All @@ -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":

Expand Down Expand Up @@ -121,6 +127,7 @@ function set_valves() {
}
*/


Peripherals.update(peripheral_name, {
$set: {
v1: v1,
Expand Down

0 comments on commit 4b08562

Please sign in to comment.