Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added gas pull state and changed downloading code #46 #57

Merged
merged 2 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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