Skip to content

Commit 7277f0e

Browse files
committed
Merge branch 'develop'
2 parents 20c260e + 6a33e6d commit 7277f0e

File tree

4 files changed

+119
-22
lines changed

4 files changed

+119
-22
lines changed

src/scripts/modules/gpioworker.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ gpioWorker.prototype.load_running_jobs = function (msg) {
805805
}
806806
//console.log("runningJobs history 2: " + JSON.stringify(job.history));
807807
var job_info = {};
808+
job_info['waiting'] = false;
808809
job_info['header'] = job.jobInfo();
809810
job_info['updates'] = job.history.slice(1);
810811
running_jobs.push(job_info);
@@ -813,8 +814,21 @@ gpioWorker.prototype.load_running_jobs = function (msg) {
813814
} else {
814815
console.log("No jobs running");
815816
}
817+
if (this.waitingJobs.length > 0 ) {
818+
console.log("Including waiting jobs in jobs list");
819+
this.waitingJobs.forEach( function (job) {
820+
console.log("waitingJobs job: " + JSON.stringify(job.jobData));
821+
var job_info = {};
822+
job_info['waiting'] = true;
823+
job_info['jobData'] = job.jobData;
824+
/*
825+
job_info['updates'] = job.history.slice(1);
826+
*/
827+
running_jobs.push(job_info);
828+
});
829+
}
816830
var jdata = JSON.stringify({'type':'running_jobs','data':running_jobs});
817-
console.log("load_running_jobs() returning: " + jdata);
831+
//console.log("load_running_jobs() returning: " + jdata);
818832
this.output_queue.enqueue(jdata);
819833
};
820834

src/scripts/modules/jobprocessor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ function JobProcessor(options) {
157157
}
158158
}
159159
job_status['sensors'].push(sensor);
160-
job_status[sensor] = jSensors[sensor].temp;
160+
var sensorValue = {};
161+
sensorValue["temp"] = jSensors[sensor].temp;
162+
if (jSensors[sensor].grav) {
163+
sensorValue["grav"] = jSensors[sensor].grav;
164+
}
165+
job_status[sensor] = sensorValue;
161166
});
162167
console.log("job_status: " + JSON.stringify(job_status));
163168
//console.log("jobRelays: " + JSON.stringify(this.jobRelays));

src/scripts/status.js

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var profileOwner;
4040
/* Save JobHistory data here */
4141
var historyData = {};
4242
var runningData = {};
43+
var unStartedJobs = [];
4344

4445
/*
4546
Running, stopped, suspended etc.
@@ -1163,24 +1164,43 @@ window.onload = function () {
11631164

11641165
var longJobNames = [];
11651166
data.forEach( function (job, index) {
1166-
var header = job['header'];
1167-
var updates = job['updates'];
1168-
var longName = header['jobName'] + '-' + header['jobInstance'];
1169-
var saveData = {};
1170-
1171-
console.log("Creating listing for job: " + index + " (" + longName + ")");
1172-
longJobNames.push(longName);
1173-
1174-
// Save the data for later use. It should consist of two arrays,
1175-
// 1st with just the job header and 2nd with an array of status updates
1176-
// (for a running job, updates will periodically be added to
1177-
saveData['header'] = [header];
1178-
saveData['updates'] = updates;
1179-
runningData[longName] = saveData;
1180-
//console.log("XXX " + JSON.stringify(runningData[longName]));
1167+
console.log("createRunningJobsList() handling job: " + index);
1168+
1169+
var longName;
1170+
if (job['waiting']) {
1171+
longName = job['jobData'].jobName + "-" + job['jobData'].jobInstance;
1172+
1173+
//console.log("Job waiting: " + JSON.stringify(job));
1174+
//console.log("Job waiting: " + Object.keys(job));
1175+
//console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting.");
1176+
//console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting. Needs " + JSON.stringify(job['jobData'].jobSensorIds));
1177+
1178+
// Add this job to unStartedJobs list
1179+
unStartedJobs[longName] = job;
1180+
1181+
} else {
1182+
var header = job['header'];
1183+
var updates = job['updates'];
1184+
var saveData = {};
1185+
1186+
longName = header['jobName'] + '-' + header['jobInstance'];
1187+
1188+
// If previously unstarted, remove it from list
1189+
if (unStartedJobs[longName]) delete unStartedJobs[longName];
1190+
1191+
console.log("Creating listing for running job: " + index + " (" + longName + ")");
1192+
longJobNames.push(longName);
1193+
1194+
// Save the data for later use. It should consist of two arrays,
1195+
// 1st with just the job header and 2nd with an array of status updates
1196+
// (for a running job, updates will periodically be added to
1197+
saveData['header'] = [header];
1198+
saveData['updates'] = updates;
1199+
runningData[longName] = saveData;
1200+
}
1201+
//console.log("ZZZ");
1202+
updateJobsList(longJobNames, 'running_jobsHolder');
11811203
});
1182-
console.log("ZZZ");
1183-
updateJobsList(longJobNames, 'running_jobsHolder');
11841204
}
11851205

11861206
function updateRunningJob(data) {
@@ -1966,6 +1986,35 @@ window.onload = function () {
19661986
}
19671987
});
19681988

1989+
/*
1990+
Before drawing the running jobs, look for any non starters
1991+
(perhaps due to unavailability of a required sensor)
1992+
and set up a notification.
1993+
*/
1994+
var unStartedJobsKeys = Object.keys(unStartedJobs);
1995+
//console.log("unstarted job(s): " + unStartedJobsKeys);
1996+
1997+
unStartedJobsKeys.forEach( function (key) {
1998+
//console.log("Advising of unstarted job: " + key + " --- " + JSON.stringify(unStartedJobs[key]));
1999+
2000+
var sensorIds = unStartedJobs[key]['jobData'].jobSensorIds;
2001+
//console.log("Needs sensor" + (sensorIds.length>1?"s":"") + ": " + sensorIds);
2002+
2003+
var jobElement = document.createElement('DIV');
2004+
jobElement.id = 'jobElement_' + key;
2005+
jobElement.className = 'jobCantStart';
2006+
2007+
var jobItemName = document.createElement('DIV');
2008+
jobItemName.id = 'jobItemName_' + i;
2009+
jobItemName.className = 'jobCantStartName';
2010+
jobItemName.innerHTML = "<html>Job " + key + " can't start yet. Needs sensor" + (sensorIds.length>1?"s":"") + ": " + sensorIds + "</html>";
2011+
2012+
jobElement.appendChild(jobItemName);
2013+
jobsListHolder.appendChild(jobElement);
2014+
});
2015+
2016+
/* Now the jobs running normally
2017+
*/
19692018
for (var i=0;i<jobFiles.length;i++) {
19702019
//console.log(" " + jobFiles[i]);
19712020
// Extract some identifiers from the filename

styles/brewable.css

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ div#sensor_updateHolder {
270270
.isp_sensor_update {
271271
display: flex;
272272
flex-direction: column;
273-
alilgn-items: center;
273+
align-items: center;
274274
justify-content: center;
275275

276276
display: -webkit-flex;
@@ -300,7 +300,7 @@ div#sensor_updateHolder {
300300
/* isp_sensor_overlay_title */
301301
.isp_sol_title {
302302
display: flex;
303-
alilgn-items: center;
303+
align-items: center;
304304
justify-content: center;
305305

306306
display: -webkit-flex;
@@ -314,7 +314,7 @@ div#sensor_updateHolder {
314314
/* isp_sensor_overlay_detail */
315315
.isp_sol_detail {
316316
display: flex;
317-
alilgn-items: center;
317+
align-items: center;
318318
justify-content: center;
319319

320320
display: -webkit-flex;
@@ -998,6 +998,35 @@ div#jobComposer {
998998
border-radius: 4px;
999999
direction: ltr;
10001000
}
1001+
.jobCantStart {
1002+
display: flex;
1003+
align-items: center;
1004+
justify-content: center;
1005+
1006+
display: -webkit-flex;
1007+
-webkit-align-items: center;
1008+
-webkit-justify-content: center;
1009+
1010+
height: 40px;
1011+
margin: 3px;
1012+
border: 1px solid #000;
1013+
border-radius: 4px;
1014+
direction: ltr;
1015+
background: #dc7676;
1016+
}
1017+
.jobCantStartName {
1018+
display: flex;
1019+
align-items: center;
1020+
justify-content: center;
1021+
1022+
display: -webkit-flex;
1023+
-webkit-align-items: center;
1024+
-webkit-justify-content: center;
1025+
1026+
margin-left: 2px;
1027+
padding: 0 1em;
1028+
height: 36px;
1029+
}
10011030
.jobElementGraph {
10021031
direction: ltr;
10031032
border-bottom: 1px solid #000;

0 commit comments

Comments
 (0)