/// <summary>
        ///  Uses the primary input in evalInput to depermine which curve equation needs to be
        ///  evaluated. Then evaluates the appropriate curve equation using the given input.
        /// </summary>
        /// <param name="evalInput">Stores info neede to evaluate an expression</param>
        /// <returns>
        /// Returns the output of the evaluated equation. The return status will not be valid if
        /// the equation could not be evaluated.
        /// </returns>
        public ReturnStatus <double> Evaluate(EvaluationCurveInput evalInput)
        {
            var erroneousPoints          = new HashSet <int>();
            var controlPointValuesStatus = CalculateControlPointValues(evalInput.VariableParamInfoList, evalInput.TransformParamInfoList, evalInput.PointEquations, ref erroneousPoints);

            if (controlPointValuesStatus.IsValid)
            {
                EvaluationCurveJob evalCurveJob = new EvaluationCurveJob();

                string expressionStr      = GetCurveExpressionString(evalInput.getPrimaryInputVal(), controlPointValuesStatus.Value, evalInput.CurveEquations);
                var    returnedExpression = CreateExpressionFromString(expressionStr, EvalType.Curve);

                if (returnedExpression.IsValid)
                {
                    evalCurveJob.Configure(evalInput, controlPointValuesStatus.Value, returnedExpression.Value);

                    evalCurveJob.Execute();

                    if (evalCurveJob.OutputIsValid)
                    {
                        return(new ReturnStatus <double>(evalCurveJob.OutputVal, true));
                    }
                }
            }

            return(new ReturnStatus <double>(double.NaN, false));
        }
Example #2
0
        /// <summary>
        ///  Uses the primary input in evalInput to depermine which curve equation needs to be 
        ///  evaluated. Then evaluates the appropriate curve equation using the given input.
        /// </summary>
        /// <param name="evalInput">Stores info neede to evaluate an expression</param>
        /// <returns>
        /// Returns the output of the evaluated equation. The return status will not be valid if 
        /// the equation could not be evaluated.
        /// </returns>
        public ReturnStatus<double> Evaluate(EvaluationCurveInput evalInput)
        {
            var erroneousPoints = new HashSet<int>();
            var controlPointValuesStatus = CalculateControlPointValues(evalInput.VariableParamInfoList, evalInput.TransformParamInfoList, evalInput.PointEquations, ref erroneousPoints);

            if (controlPointValuesStatus.IsValid) {
                EvaluationCurveJob evalCurveJob = new EvaluationCurveJob();

                string expressionStr = GetCurveExpressionString(evalInput.getPrimaryInputVal(), controlPointValuesStatus.Value, evalInput.CurveEquations);
                var returnedExpression = CreateExpressionFromString(expressionStr, EvalType.Curve);

                if (returnedExpression.IsValid) {
                    evalCurveJob.Configure(evalInput, controlPointValuesStatus.Value, returnedExpression.Value);

                    evalCurveJob.Execute();

                    if (evalCurveJob.OutputIsValid)
                    {
                        return new ReturnStatus<double>(evalCurveJob.OutputVal, true);
                    }

                }

            }

            return new ReturnStatus<double>(double.NaN, false);
        }
        protected ReturnStatus <XyPoint <double> > evaluateCurveAtXVal(double inputXVal, int curveIndex, IMappingEntry mappingEntry, List <MssParamInfo> variableParamInfoList, List <XyPoint <double> > controlPointList)
        {
            //For each sample point data1 data2 and data3 will be set to the X value of the
            //sample point.
            double relData1 = inputXVal;
            double relData2 = inputXVal;
            double relData3 = inputXVal;

            IStaticMssMsgInfo inMsgInfo =
                Factory_StaticMssMsgInfo.Create(mappingEntry.InMssMsgRange.MsgType);

            //If curXVal is outside of the relative input range for data 1 then set
            //relData1 to NaN
            double max    = (double)inMsgInfo.MaxData1Value;
            double min    = (double)inMsgInfo.MinData1Value;
            double bottom = (double)mappingEntry.InMssMsgRange.Data1RangeBottom;
            double top    = (double)mappingEntry.InMssMsgRange.Data1RangeTop;

            if (inputXVal < ((bottom - min) / (max - min + 1)) ||
                inputXVal > ((top - min) / (max - min + 1)))
            {
                relData1 = double.NaN;
            }

            //If curXVal is outside of the relative input range for data 2 then set relData2
            //to NaN
            max    = (double)inMsgInfo.MaxData2Value;
            min    = (double)inMsgInfo.MinData2Value;
            bottom = (double)mappingEntry.InMssMsgRange.Data2RangeBottom;
            top    = (double)mappingEntry.InMssMsgRange.Data2RangeTop;
            if (inputXVal < ((bottom - min) / (max - min + 1)) ||
                inputXVal > ((top - min) / (max - min + 1)))
            {
                relData2 = double.NaN;
            }

            var evalInput = new EvaluationCurveInput();

            evalInput.Init(
                relData1,
                relData2,
                relData3,
                variableParamInfoList,
                mappingEntry);

            var evalJob = new EvaluationCurveJob();

            var returnedExpression = CreateExpressionFromString(mappingEntry.CurveShapeInfo.CurveEquations[curveIndex], EvalType.Curve);

            if (returnedExpression.IsValid == false)
            {
                return(new ReturnStatus <XyPoint <double> >());
            }

            evalJob.Configure(evalInput, controlPointList, returnedExpression.Value);

            evalJob.Execute();

            if (evalJob.OutputIsValid)
            {
                var curPoint = new XyPoint <double>(inputXVal, evalJob.OutputVal);
                return(new ReturnStatus <XyPoint <double> >(curPoint));
            }
            else
            {
                return(new ReturnStatus <XyPoint <double> >());
            }
        }
Example #4
0
        protected ReturnStatus<XyPoint<double>> evaluateCurveAtXVal(double inputXVal, int curveIndex, IMappingEntry mappingEntry, List<MssParamInfo> variableParamInfoList, List<XyPoint<double>> controlPointList)
        {
            //For each sample point data1 data2 and data3 will be set to the X value of the
            //sample point.
            double relData1 = inputXVal;
            double relData2 = inputXVal;
            double relData3 = inputXVal;

            IStaticMssMsgInfo inMsgInfo =
                Factory_StaticMssMsgInfo.Create(mappingEntry.InMssMsgRange.MsgType);

            //If curXVal is outside of the relative input range for data 1 then set
            //relData1 to NaN
            double max = (double)inMsgInfo.MaxData1Value;
            double min = (double)inMsgInfo.MinData1Value;
            double bottom = (double)mappingEntry.InMssMsgRange.Data1RangeBottom;
            double top = (double)mappingEntry.InMssMsgRange.Data1RangeTop;
            if (inputXVal < ((bottom - min) / (max - min + 1)) ||
                inputXVal > ((top - min) / (max - min + 1)))
            {
                relData1 = double.NaN;
            }

            //If curXVal is outside of the relative input range for data 2 then set relData2
            //to NaN
            max = (double)inMsgInfo.MaxData2Value;
            min = (double)inMsgInfo.MinData2Value;
            bottom = (double)mappingEntry.InMssMsgRange.Data2RangeBottom;
            top = (double)mappingEntry.InMssMsgRange.Data2RangeTop;
            if (inputXVal < ((bottom - min) / (max - min + 1)) ||
                inputXVal > ((top - min) / (max - min + 1)))
            {
                relData2 = double.NaN;
            }

            var evalInput = new EvaluationCurveInput();
            evalInput.Init(
                relData1,
                relData2,
                relData3,
                variableParamInfoList,
                mappingEntry);

            var evalJob = new EvaluationCurveJob();

            var returnedExpression = CreateExpressionFromString(mappingEntry.CurveShapeInfo.CurveEquations[curveIndex], EvalType.Curve);

            if (returnedExpression.IsValid == false)
            {
                return new ReturnStatus<XyPoint<double>>();
            }

            evalJob.Configure(evalInput, controlPointList, returnedExpression.Value);

            evalJob.Execute();

            if (evalJob.OutputIsValid)
            {
                var curPoint = new XyPoint<double>(inputXVal, evalJob.OutputVal);
                return new ReturnStatus<XyPoint<double>>(curPoint);
            }
            else
            {
                return new ReturnStatus<XyPoint<double>>();
            }
        }