private double GetValue(double input, double factor, TransformationOutputFactorType factorType, double demandValue) { switch (factorType) { case TransformationOutputFactorType.FixedFactor: return(factor * demandValue); case TransformationOutputFactorType.Interpolated: if (input <= _datapoints[0].Ref) { return(_datapoints[0].Val); } var max = _datapoints.Count - 1; if (input >= _datapoints[max].Ref) { return(_datapoints[max].Val); } var i = 0; while (i < _datapoints.Count && _datapoints[i].Ref < input) { i++; } var y1 = _datapoints[i - 1].Val; var x1 = _datapoints[i - 1].Ref; var y2 = _datapoints[i].Val; var x2 = _datapoints[i].Ref; var newfactor = (y2 - y1) / (x2 - x1) * (input - x1) + y1; return(newfactor * demandValue); case TransformationOutputFactorType.FixedValue: return(factor); default: throw new LPGException("Forgotten factortype"); } }
public void AddOutputLoadType([NotNull] CalcLoadType loadType, double factor, TransformationOutputFactorType factorType) { var olt = new OutputLoadType(loadType, factor, factorType); _devProcessorKeys.Add(loadType, _odap.RegisterDevice(loadType.ConvertToDto(), _deviceDto)); _outputLoadTypes.Add(olt); }
public OutputLoadType([NotNull] CalcLoadType loadType, double valueScalingFactor, TransformationOutputFactorType factorType) { LoadType = loadType; ValueScalingFactor = valueScalingFactor; FactorType = factorType; }