@@ -0,0 +1,1959 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2014 Ausenco Engineering Canada Inc.%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A */%0Apackage com.jaamsim.BasicObjects;%0A%0Aimport com.jaamsim.events.ProcessTarget;%0Aimport com.sandwell.JavaSimulation.EntityTarget;%0A%0Apublic abstract class LinkedService extends LinkedComponent %7B%0A%0A%09private boolean busy;%0A%09protected final ProcessTarget endActionTarget = new EndActionTarget(this);%0A%0A%09public LinkedService() %7B%7D%0A%0A%09@Override%0A%09public void earlyInit() %7B%0A%09%09super.earlyInit();%0A%09%09this.setBusy(false);%0A%09%7D%0A%0A%09private static class EndActionTarget extends EntityTarget%3CLinkedService%3E %7B%0A%09%09EndActionTarget(LinkedService ent) %7B%0A%09%09%09super(ent, %22endAction%22);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void process() %7B%0A%09%09%09ent.endAction();%0A%09%09%7D%0A%09%7D%0A%0A%09protected boolean isBusy() %7B%0A%09%09return busy;%0A%09%7D%0A%0A%09protected void setBusy(boolean bool) %7B%0A%09%09busy = bool;%0A%09%7D%0A%0A%09public abstract void startAction();%0A%0A%09public abstract void endAction();%0A%0A%09@Override%0A%09public void thresholdChanged() %7B%0A%0A%09%09// If necessary, restart processing%0A%09%09if (this.isBusy()) %7B%0A%09%09%09this.setPresentState();%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09this.setBusy(true);%0A%09%09%09this.setPresentState();%0A%09%09%09this.startAction();%0A%09%09%7D%0A%09%7D%0A%0A%09protected void setPresentState() %7B%0A%09%09if (this.isOpen()) %7B%0A%09%09%09if (this.isBusy()) %7B%0A%09%09%09%09this.setPresentState(%22Working%22);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09this.setPresentState(%22Idle%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09if (this.isBusy()) %7B%0A%09%09%09%09this.setPresentState(%22Clearing_while_Stopped%22);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09this.setPresentState(%22Stopped%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Create abstract class LinkedService