package ua.ansymo.hintco

import ua.ansymo.hintco.IAdaptedInputPort

abstract class ApproximationAdaptedPort implements IAdaptedInputPort {
	
	var protected double current_val
	var protected double previous_val
	var protected boolean firstValueKnown = false
	var protected boolean inCosimStepMode = false
	
	var protected AdaptedFMUInstance fmu
	var protected String portId;
	
	new(String pId, AdaptedFMUInstance f) {
		fmu = f
		portId = pId
		inCosimStepMode = false
	}
	
	override setReal(double v) {
		current_val = v
		if (!firstValueKnown){
			previous_val = v
			firstValueKnown = true
		}
	}
	
	override startStep() {}
	
	override endStep() {
		this.previous_val = current_val
	}
	
	override startCosimStep(double time, double stepSize) {
		inCosimStepMode = true
	}
	
	override endCosimStep(double time, double stepSize) {}
}