From 07a303d469bbc80421a4aebb37e03dcb3f80261f Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Thu, 18 Mar 2021 17:19:40 +0100 Subject: [PATCH] Allow to add a mapping at a later station. --- modules/wamo/src/wamo.lineManager.module.ts | 40 ++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/modules/wamo/src/wamo.lineManager.module.ts b/modules/wamo/src/wamo.lineManager.module.ts index 9534f3d..9aecd99 100644 --- a/modules/wamo/src/wamo.lineManager.module.ts +++ b/modules/wamo/src/wamo.lineManager.module.ts @@ -27,14 +27,15 @@ import { IWaMOCarrierMapper, IWaMOConverter, IWaMOConverterModuleDescription, - IWaMOLineConnector, - IWaMOLineDescription, + + IWaMOLineDescription, IWaMOSimpleLineConnector, + IWaMOTransportManagerConfig } from "../types/interfaces"; export interface CONVERTER extends INopeModule, IWaMOConverter {} export interface BASEMODULE extends INopeModule, IWaMOBaseModule {} -export interface LINECONNECTOR extends INopeModule, IWaMOLineConnector {} +export interface LINECONNECTOR extends INopeModule, IWaMOSimpleLineConnector {} export interface CARRIERMAPPER extends INopeModule, IWaMOCarrierMapper {} // Custom Sleep Function @@ -128,7 +129,8 @@ export class WaMOLineManager extends InjectableNopeBaseModule { public async init( options: IWaMOLineDescription, - reset = true + reset = true, + demo = false, ): Promise { // Define the Author. this.author = { @@ -229,13 +231,16 @@ export class WaMOLineManager extends InjectableNopeBaseModule { return false; } - if (element == firstStation) { - // Map the Carrier with the Product. But only if - // it is the First station. + // Check if there doesnt exist a mapping for the carrier. + // Therefore we have to check if we are the first station + // and there doesnt exists a mapping. + if (element == firstStation && !await _this.carrierMapper.isProductLinkedToCarrier(options.checkedInWorkpieceCarrier)) { + // Map the Carrier with the Product. _this.carrierMapper.addProductToCarrier( options.checkedInWorkpieceCarrier, options.tasks[0].lotId ); + // And now return the Task return options.tasks[0]; } @@ -243,6 +248,21 @@ export class WaMOLineManager extends InjectableNopeBaseModule { options.checkedInWorkpieceCarrier ); + if (element != lastStation && product === undefined){ + // This is our special usecase, where we have unregistered carriers, + // which will receive a new task from the MES. Therefore we perform + // the Linking, as at station 01. + _this._logger.warn("Assigning new Task at a station, that shouldn't be allowed"); + // Map the Carrier with the Product. + _this.carrierMapper.addProductToCarrier( + options.checkedInWorkpieceCarrier, + options.tasks[0].lotId + ); + // And now return the Task + return options.tasks[0]; + } + + // ERROR: Remove only, if there are not task left, or it must be removed. if (element == lastStation) { // Remove the Mapping, but only on the Last Station. _this.carrierMapper.removeProductFromCarrier( @@ -253,7 +273,8 @@ export class WaMOLineManager extends InjectableNopeBaseModule { return product; }, reset, - false + false, + demo ]; const promise = _this._dispatcher.generateInstance({ @@ -266,10 +287,11 @@ export class WaMOLineManager extends InjectableNopeBaseModule { // Subscribe to Changes of the Base-Modules: mod.baseInformation.subscribe((description) => { // If Workpiece Carrier has checked in, register the Carrier: - if (description.physical.checkedInWorkpieceCarrier) + if (description.physical.checkedInWorkpieceCarrier){ _this.carrierMapper.registerCarrier( description.physical.checkedInWorkpieceCarrier ); + } }); // create a PLC Connector: