From fcc6e18430e8a757d89a4c05f3f7dba1de753aba Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Thu, 18 Mar 2021 17:18:41 +0100 Subject: [PATCH] preventing starting active tasks --- .../src/xetics.module.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/xetics-lean-connector/src/xetics.module.ts b/modules/xetics-lean-connector/src/xetics.module.ts index 594b9e8..67981d8 100644 --- a/modules/xetics-lean-connector/src/xetics.module.ts +++ b/modules/xetics-lean-connector/src/xetics.module.ts @@ -125,6 +125,20 @@ export class XeticsInterfaceClient }) public currentTask = new NopeObservable(); + /** + * Property containing the current Task of the Client. + * + * @memberof XeticsInterfaceClient + */ + @exportProperty({ + mode: ["publish"], + topic: "taskActive", + schema: { + type: "boolean" + } + }) + public taskActive = new NopeObservable(); + /** * 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 ||