/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2013 Ausenco Engineering Canada Inc.
 * Copyright (C) 2016 JaamSim Software Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jaamsim.CalculationObjects;

import com.jaamsim.Graphics.DisplayEntity;
import com.jaamsim.input.EntityInput;
import com.jaamsim.input.Keyword;
import com.jaamsim.input.ValueInput;
import com.jaamsim.units.DimensionlessUnit;

/**
 * CalculationEntity is the super-class for all Calculation Objects.
 * @author Harry King
 *
 */
public abstract class CalculationEntity extends DisplayEntity {

	@Keyword(description = "The Controller object that signals the updating of the calculation.",
	         exampleList = {"Controller1"})
	protected final EntityInput<Controller> controller;

	@Keyword(description = "The sequence number used by the Controller to determine the order "
	                     + "in which calculations are performed. A calculation with a lower value "
	                     + "is executed before one with a higher value.",
	         exampleList = {"2.1"})
	private final ValueInput sequenceNumber;

	{
		controller = new EntityInput<>(Controller.class, "Controller", KEY_INPUTS, null);
		controller.setRequired(true);
		this.addInput(controller);

		sequenceNumber = new ValueInput("SequenceNumber", KEY_INPUTS, 0.0);
		sequenceNumber.setValidRange(0.0d, Double.POSITIVE_INFINITY);
		sequenceNumber.setUnitType(DimensionlessUnit.class);
		this.addInput(sequenceNumber);
	}

	public Controller getController() {
		return controller.getValue();
	}

	public double getSequenceNumber() {
		return sequenceNumber.getValue();
	}

	/*
	 * Calculate the current value for this object.
	 */
	public abstract void update(double simTime);
}

@@ -108,16 +108,21 @@
 (C) 2016
+-2018
  JaamSim
@@ -136,16 +136,16 @@
 re Inc.%0A
-
  *%0A * Li
@@ -1100,16 +1100,40 @@
 yEntity 
+implements Controllable 
 %7B%0A%0A%09@Key
@@ -2025,24 +2025,35 @@
 umber);%0A%09%7D%0A%0A
+%09@Override%0A
 %09public Cont
@@ -2113,16 +2113,27 @@
 ();%0A%09%7D%0A%0A
+%09@Override%0A
 %09public 
@@ -2206,64 +2206,17 @@
 %7D%0A%0A%09
-/*%0A%09 * Calculate the current value for this object.%0A%09 */
+@Override
 %0A%09pu
@@ -2258,10 +2258,11 @@
 mTime);%0A
+%0A
 %7D%0A

apply Controllable interface to CalculationEntity