package ua.ansymo.hintco

class ExtrapolationAdaptedPort extends ApproximationAdaptedPort {
	
	new(String pId, AdaptedFMUInstance f) {
		super(pId, f)
	}
	
	override computeReal(double t, double dt, double h, double H) {
		var o = current_val
		if (inCosimStepMode){
			o = extrapolate(t, dt, h, H)
		}
		fmu.setInnerReal(portId, o)
	}
	
	def extrapolate(double t, double dt, double h, double H) {
		current_val + ((current_val - previous_val)/H)*(dt + h)
	}
	
}