Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cwilling committed Oct 28, 2017
2 parents 8a9745d + e18aa9f commit 20c260e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 16 deletions.
29 changes: 23 additions & 6 deletions src/scripts/modules/gpioworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ function gpioWorker (input_queue, output_queue) {
console.log("Failed to read running jobs directory " + this.runDir);
} else {
console.log("job files: " + files);
//files.forEach( function (file) {
//files.forEach( function (file, index) {
files.forEach( function (file) {
var filePath = path.join(this.runDir, file);
fs.readFile(filePath, 'utf8', function (err, data) {
Expand All @@ -120,10 +118,18 @@ function gpioWorker (input_queue, output_queue) {
console.log("job jobName: " + jobName + " has " + header.updates.length + " updates");

// Check that all sensor devices are available
console.log("Need devices: " + header.jobSensorIds + " for job: " + jobName);

var haveAllSensors = false;
if (haveAllSensors) {
var devicesNeeded = header.jobSensorIds.length;
console.log("checking haveAllSensors: " + jobName + ". Needs: " + devicesNeeded + " devices. " + header.jobSensorIds);
var devices = this.sensorDevices();
devices.forEach( function (item) {
console.log("Have device: " + item.chipId + ", type: " + typeof(item.chipId));
if (header.jobSensorIds.indexOf(item.chipId.toString()) > -1) {
devicesNeeded -= 1;
console.log("Still need " + devicesNeeded + " devices");
}
});
console.log("Still need " + devicesNeeded + " devices for " + jobName);
if (devicesNeeded < 1) {
if ( (! this.setupJobRun({'jobData': header})) ) {
console.log("Couldn't start job " + jobName);
} else {
Expand Down Expand Up @@ -183,6 +189,17 @@ function gpioWorker (input_queue, output_queue) {
} else {
console.log("Started job " + header.jobName);
this.waitingJobs.splice(i, 1);

// Update job list for clients
this.load_running_jobs({"type":"run_job"});

// Process the new job
for (var j=0;j<this.runningJobs.length;j++) {
console.log("runningJobs: " + this.runningJobs[j].name());
if (this.runningJobs[j].name() == header.jobName) {
this.runningJobs[j].process();
}
}
}
}
}
Expand Down
46 changes: 36 additions & 10 deletions src/scripts/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ var searchDeviceListByChipId = function (Id) {
var i, duplicate, result;
do {
for (i=0;i<iSpindelDevices.length;i++) {
if (iSpindelDevices[i].raw.chipId == Id) {
if (iSpindelDevices[i].chipId == Id) {
if (result) {
duplicate = i;
duplicates += 1;
Expand Down Expand Up @@ -232,21 +232,41 @@ class Ispindel {
}

set_contents (state, tempScale) {
//console.log("set_contents() state: " + JSON.stringify(state));

this.temp = state.temperature;
if (tempScale == 'F') {
document.getElementById(this.elementName + "_temp").textContent = ((state.temperature * 9 / 5 ) + 32).toFixed(2);
} else {
document.getElementById(this.elementName + "_temp").textContent = (state.temperature).toFixed(2);
}
this.grav = state.grav;
document.getElementById(this.elementName + "_grav").textContent = (state.grav).toFixed(2);
this.tilt = state.tilt;
//document.getElementById(this.elementName + "_tilt").textContent = (state.tilt).toFixed(2);
this.batt = state.batt;

this.stamp = state.stamp;

//console.log("set_contents() elementName: " + this.elementName);
var have_isp_temp = document.getElementById(this.elementName + "_temp");
if (! have_isp_temp) {
var isp_temp, isp_grav;

isp_temp = document.createElement("DIV");
isp_temp.id = this.elementName + "_temp";
isp_temp.className = "isp_entry";
document.getElementById(this.elementName).appendChild(isp_temp);

isp_grav = document.createElement("DIV");
isp_grav.id = this.elementName + "_grav";
isp_grav.className = "isp_entry";
document.getElementById(this.elementName).appendChild(isp_grav);
}
try {
if (tempScale == 'F') {
document.getElementById(this.elementName + "_temp").textContent = ((state.temperature * 9 / 5 ) + 32).toFixed(2);
} else {
document.getElementById(this.elementName + "_temp").textContent = (state.temperature).toFixed(2);
}
document.getElementById(this.elementName + "_grav").textContent = (state.grav).toFixed(2);
}
catch (err) {
console.log("set_contents() caught " + err);
}

}

setNewWaitTime(val) {
Expand Down Expand Up @@ -924,7 +944,13 @@ window.onload = function () {
console.log("iSpindelDevices was: " + JSON.stringify(iSpindelDevices));
asensor.className = 'isp_sensor_update';

var device = searchDeviceListByChipId(sensor_state[i].chipId);
var device;
try {
device = searchDeviceListByChipId(sensor_state[i].chipId);
}
catch (err) {
console.log("Couldn't searchDeviceListByChipId() for some reason; " + err);
}
if (device) {
console.log("Already have device: " + device.chipId);
} else {
Expand Down

0 comments on commit 20c260e

Please sign in to comment.