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 29, 2017
2 parents 20c260e + 6a33e6d commit 7277f0e
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 22 deletions.
16 changes: 15 additions & 1 deletion src/scripts/modules/gpioworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ gpioWorker.prototype.load_running_jobs = function (msg) {
}
//console.log("runningJobs history 2: " + JSON.stringify(job.history));
var job_info = {};
job_info['waiting'] = false;
job_info['header'] = job.jobInfo();
job_info['updates'] = job.history.slice(1);
running_jobs.push(job_info);
Expand All @@ -813,8 +814,21 @@ gpioWorker.prototype.load_running_jobs = function (msg) {
} else {
console.log("No jobs running");
}
if (this.waitingJobs.length > 0 ) {
console.log("Including waiting jobs in jobs list");
this.waitingJobs.forEach( function (job) {
console.log("waitingJobs job: " + JSON.stringify(job.jobData));
var job_info = {};
job_info['waiting'] = true;
job_info['jobData'] = job.jobData;
/*
job_info['updates'] = job.history.slice(1);
*/
running_jobs.push(job_info);
});
}
var jdata = JSON.stringify({'type':'running_jobs','data':running_jobs});
console.log("load_running_jobs() returning: " + jdata);
//console.log("load_running_jobs() returning: " + jdata);
this.output_queue.enqueue(jdata);
};

Expand Down
7 changes: 6 additions & 1 deletion src/scripts/modules/jobprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ function JobProcessor(options) {
}
}
job_status['sensors'].push(sensor);
job_status[sensor] = jSensors[sensor].temp;
var sensorValue = {};
sensorValue["temp"] = jSensors[sensor].temp;
if (jSensors[sensor].grav) {
sensorValue["grav"] = jSensors[sensor].grav;
}
job_status[sensor] = sensorValue;
});
console.log("job_status: " + JSON.stringify(job_status));
//console.log("jobRelays: " + JSON.stringify(this.jobRelays));
Expand Down
83 changes: 66 additions & 17 deletions src/scripts/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var profileOwner;
/* Save JobHistory data here */
var historyData = {};
var runningData = {};
var unStartedJobs = [];

/*
Running, stopped, suspended etc.
Expand Down Expand Up @@ -1163,24 +1164,43 @@ window.onload = function () {

var longJobNames = [];
data.forEach( function (job, index) {
var header = job['header'];
var updates = job['updates'];
var longName = header['jobName'] + '-' + header['jobInstance'];
var saveData = {};

console.log("Creating listing for job: " + index + " (" + longName + ")");
longJobNames.push(longName);

// Save the data for later use. It should consist of two arrays,
// 1st with just the job header and 2nd with an array of status updates
// (for a running job, updates will periodically be added to
saveData['header'] = [header];
saveData['updates'] = updates;
runningData[longName] = saveData;
//console.log("XXX " + JSON.stringify(runningData[longName]));
console.log("createRunningJobsList() handling job: " + index);

var longName;
if (job['waiting']) {
longName = job['jobData'].jobName + "-" + job['jobData'].jobInstance;

//console.log("Job waiting: " + JSON.stringify(job));
//console.log("Job waiting: " + Object.keys(job));
//console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting.");
//console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting. Needs " + JSON.stringify(job['jobData'].jobSensorIds));

// Add this job to unStartedJobs list
unStartedJobs[longName] = job;

} else {
var header = job['header'];
var updates = job['updates'];
var saveData = {};

longName = header['jobName'] + '-' + header['jobInstance'];

// If previously unstarted, remove it from list
if (unStartedJobs[longName]) delete unStartedJobs[longName];

console.log("Creating listing for running job: " + index + " (" + longName + ")");
longJobNames.push(longName);

// Save the data for later use. It should consist of two arrays,
// 1st with just the job header and 2nd with an array of status updates
// (for a running job, updates will periodically be added to
saveData['header'] = [header];
saveData['updates'] = updates;
runningData[longName] = saveData;
}
//console.log("ZZZ");
updateJobsList(longJobNames, 'running_jobsHolder');
});
console.log("ZZZ");
updateJobsList(longJobNames, 'running_jobsHolder');
}

function updateRunningJob(data) {
Expand Down Expand Up @@ -1966,6 +1986,35 @@ window.onload = function () {
}
});

/*
Before drawing the running jobs, look for any non starters
(perhaps due to unavailability of a required sensor)
and set up a notification.
*/
var unStartedJobsKeys = Object.keys(unStartedJobs);
//console.log("unstarted job(s): " + unStartedJobsKeys);

unStartedJobsKeys.forEach( function (key) {
//console.log("Advising of unstarted job: " + key + " --- " + JSON.stringify(unStartedJobs[key]));

var sensorIds = unStartedJobs[key]['jobData'].jobSensorIds;
//console.log("Needs sensor" + (sensorIds.length>1?"s":"") + ": " + sensorIds);

var jobElement = document.createElement('DIV');
jobElement.id = 'jobElement_' + key;
jobElement.className = 'jobCantStart';

var jobItemName = document.createElement('DIV');
jobItemName.id = 'jobItemName_' + i;
jobItemName.className = 'jobCantStartName';
jobItemName.innerHTML = "<html>Job " + key + " can't start yet. Needs sensor" + (sensorIds.length>1?"s":"") + ": " + sensorIds + "</html>";

jobElement.appendChild(jobItemName);
jobsListHolder.appendChild(jobElement);
});

/* Now the jobs running normally
*/
for (var i=0;i<jobFiles.length;i++) {
//console.log(" " + jobFiles[i]);
// Extract some identifiers from the filename
Expand Down
35 changes: 32 additions & 3 deletions styles/brewable.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ div#sensor_updateHolder {
.isp_sensor_update {
display: flex;
flex-direction: column;
alilgn-items: center;
align-items: center;
justify-content: center;

display: -webkit-flex;
Expand Down Expand Up @@ -300,7 +300,7 @@ div#sensor_updateHolder {
/* isp_sensor_overlay_title */
.isp_sol_title {
display: flex;
alilgn-items: center;
align-items: center;
justify-content: center;

display: -webkit-flex;
Expand All @@ -314,7 +314,7 @@ div#sensor_updateHolder {
/* isp_sensor_overlay_detail */
.isp_sol_detail {
display: flex;
alilgn-items: center;
align-items: center;
justify-content: center;

display: -webkit-flex;
Expand Down Expand Up @@ -998,6 +998,35 @@ div#jobComposer {
border-radius: 4px;
direction: ltr;
}
.jobCantStart {
display: flex;
align-items: center;
justify-content: center;

display: -webkit-flex;
-webkit-align-items: center;
-webkit-justify-content: center;

height: 40px;
margin: 3px;
border: 1px solid #000;
border-radius: 4px;
direction: ltr;
background: #dc7676;
}
.jobCantStartName {
display: flex;
align-items: center;
justify-content: center;

display: -webkit-flex;
-webkit-align-items: center;
-webkit-justify-content: center;

margin-left: 2px;
padding: 0 1em;
height: 36px;
}
.jobElementGraph {
direction: ltr;
border-bottom: 1px solid #000;
Expand Down

0 comments on commit 7277f0e

Please sign in to comment.