Skip to content

Commit

Permalink
Allow jobs for which all sensors are available to start normally
Browse files Browse the repository at this point in the history
(only hold up jobs for which not all sensors are available).
  • Loading branch information
cwilling committed Oct 28, 2017
1 parent 7e937cb commit e18aa9f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 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

0 comments on commit e18aa9f

Please sign in to comment.