kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Progress receiver class, stages information
rodzic
236dc104bf
commit
c574e2b83d
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Node-OpenDroneMap Node.js App and REST API to access OpenDroneMap.
|
||||
Copyright (C) 2016 Node-OpenDroneMap Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
"use strict";
|
||||
const logger = require('./logger');
|
||||
const dgram = require('dgram');
|
||||
|
||||
module.exports = class ProgressReceiver{
|
||||
constructor(){
|
||||
const server = dgram.createSocket('udp4');
|
||||
this.callbacks = [];
|
||||
|
||||
server.on('error', (err) => {
|
||||
logger.warn(`Progress listener server error: ${err.stack}`);
|
||||
server.close();
|
||||
});
|
||||
|
||||
server.on('message', (msg) => {
|
||||
const parts = String(msg).split("/");
|
||||
if (parts.length === 6){
|
||||
const cmd = parts[0];
|
||||
if (cmd === 'PGUP'){
|
||||
let [_, pid, uuid, globalProgress, stageProgress, stage] = parts;
|
||||
globalProgress = parseFloat(globalProgress);
|
||||
stageProgress = parseFloat(stageProgress);
|
||||
|
||||
if (!isNaN(globalProgress) && !isNaN(stageProgress)){
|
||||
this.callbacks.forEach(callback => callback(uuid, globalProgress, stageProgress, stage));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.on('listening', () => {
|
||||
const address = server.address();
|
||||
logger.info(`Listening on ${address.address}:${address.port} UDP for progress updates`);
|
||||
});
|
||||
|
||||
server.bind(6367);
|
||||
}
|
||||
|
||||
addListener(callback){
|
||||
this.callbacks.push(callback);
|
||||
}
|
||||
};
|
||||
|
|
@ -53,6 +53,7 @@ module.exports = class Task{
|
|||
this.webhook = webhook;
|
||||
this.skipPostProcessing = skipPostProcessing;
|
||||
this.outputs = utils.parseUnsafePathsList(outputs);
|
||||
// TODO: add stages getPipelineStages
|
||||
|
||||
async.series([
|
||||
// Read images info
|
||||
|
@ -163,6 +164,10 @@ module.exports = class Task{
|
|||
}
|
||||
}
|
||||
|
||||
updateProgress(globalProgress, stageProgress, stage){
|
||||
// TODO
|
||||
}
|
||||
|
||||
updateProcessingTime(resetTime){
|
||||
this.processingTime = resetTime ?
|
||||
-1 :
|
||||
|
|
|
@ -27,6 +27,7 @@ const statusCodes = require('./statusCodes');
|
|||
const async = require('async');
|
||||
const schedule = require('node-schedule');
|
||||
const Directories = require('./Directories');
|
||||
const ProgressReceiver = require('./ProgressReceiver');
|
||||
|
||||
const TASKS_DUMP_FILE = path.join(Directories.data, "tasks.json");
|
||||
const CLEANUP_TASKS_IF_OLDER_THAN = 1000 * 60 * config.cleanupTasksAfter; // minutes
|
||||
|
@ -38,6 +39,9 @@ class TaskManager{
|
|||
constructor(done){
|
||||
this.tasks = {};
|
||||
this.runningQueue = [];
|
||||
|
||||
const progressReceiver = new ProgressReceiver();
|
||||
progressReceiver.addListener(this.onProgressUpdate.bind(this));
|
||||
|
||||
async.series([
|
||||
cb => this.restoreTaskListFromDump(cb),
|
||||
|
@ -61,6 +65,13 @@ class TaskManager{
|
|||
], done);
|
||||
}
|
||||
|
||||
onProgressUpdate(uuid, globalProgress, stageProgress, stage){
|
||||
const task = this.tasks[uuid];
|
||||
if (task){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Removes old tasks that have either failed, are completed, or
|
||||
// have been canceled.
|
||||
removeOldTasks(done){
|
||||
|
|
|
@ -135,6 +135,19 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
|
||||
// Returns a list of stages that tasks go through
|
||||
// In OpenDroneMap this is the same as the --rerun-from domain
|
||||
getPipelineStages: function(done){
|
||||
this.getOptions((err, odmOptions) => {
|
||||
if (err) done(err);
|
||||
else{
|
||||
const rerunFrom = odmOptions.find(opt => opt.name === 'rerun-from' && opt.type === 'enum');
|
||||
if (rerunFrom) done(null, rerunFrom.domain);
|
||||
else done(null, []);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Checks that the options (as received from the rest endpoint)
|
||||
// Are valid and within proper ranges.
|
||||
// The result of filtering is passed back via callback
|
||||
|
|
Ładowanie…
Reference in New Issue