preventing starting active tasks

This commit is contained in:
Martin Karkowski 2021-03-18 17:18:41 +01:00
parent 18f484348b
commit fcc6e18430

View File

@ -125,6 +125,20 @@ export class XeticsInterfaceClient
})
public currentTask = new NopeObservable<MESTask>();
/**
* Property containing the current Task of the Client.
*
* @memberof XeticsInterfaceClient
*/
@exportProperty({
mode: ["publish"],
topic: "taskActive",
schema: {
type: "boolean"
}
})
public taskActive = new NopeObservable<boolean>();
/**
* List containing the available Tasks for the Client.
* You can randomly pick one.
@ -227,6 +241,12 @@ export class XeticsInterfaceClient
})
async startCurrentTask() {
if (this.currentTask.getContent()) {
// We have to consinder, whether the job is allready active or not
if (this.taskActive.getContent()){
return true;
}
return startTask(
this._station,
this.currentTask.getContent().id,
@ -256,6 +276,10 @@ export class XeticsInterfaceClient
if (this.currentTask.getContent()) {
// Call the Finish-Task Operation. Use the parameters of the current Task.
// Returns the sucess of the Operation.
if (this._logger){
this._logger.info("Finishing Task " + this.currentTask.getContent().id.toString());
}
const finished = await finishTask(
this._station,
this.currentTask.getContent().id,
@ -294,6 +318,8 @@ export class XeticsInterfaceClient
await getTasksFromMES(this._station, true, this._uri, this._token)
);
let _taskActive = false;
// Check if there exists a currently active Task
// if so => assign this task
const activeTasks = await getActiveTasksFromMES(
@ -305,6 +331,7 @@ export class XeticsInterfaceClient
if (activeTasks.length > 0) {
// If there are multiple Tasks.
this.currentTask.setContent(activeTasks[0]);
_taskActive = true;
} else {
// No active Tasks are present => use a task with the
// current lot id.
@ -318,6 +345,8 @@ export class XeticsInterfaceClient
}
}
this.taskActive.setContent(_taskActive);
// Return the whether a task has been assigned.
return (
this.currentTask.getContent() !== undefined ||