Пример #1
0
        /// <summary>
        /// Write INI file.
        /// </summary>
        public void WriteParameterIni()
        {
            ClrMsppManager msObj = ClrMsppManager.getInstance();
            ClrIniFile     ini   = msObj.getParameters();

            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_BASELINE, Algorithm);
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_ABC_BASELINE_WINDOW_WIDTH, ABCWindowWidth.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_LINEAR_BASELINE_WINDOW_WIDTH, LinearWindowWidth.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_NOISE_FACTOR, NoiseFactor.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_SMOOTHING_WIDTH, SmoothingWidth.ToString());

            ini.save(ini.getFilePath());
        }
Пример #2
0
        /// <summary>
        /// Write ini file.
        /// </summary>
        public void WriteParameterIni()
        {
            ClrMsppManager msObj = ClrMsppManager.getInstance();
            ClrIniFile     ini   = msObj.getParameters();

            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_SAMPLINGPOINTS, ResamplingMode.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_INTERPOLATION, Interpolation.ToString());

            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_SPECIFIED_INTERVAL, SpecifiedInterval.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_OUTPUTRANGEMIN, OutputLowerRange.ToString());
            ini.setString(PARAMETERS_INI_SECTION_NAME, PARAMETERS_INI_OUTPUTRANGEMAX, OutputHigherRange.ToString());

            ini.save(ini.getFilePath());
        }
Пример #3
0
        /// <summary>
        /// Read ini file.
        /// </summary>
        /// <returns>result</returns>
        public bool ReadParameterIni()
        {
            ClrMsppManager msObj = ClrMsppManager.getInstance();
            ClrIniFile     ini   = msObj.getParameters();

            uint   sectionNum = ini.getNumberOfSections();
            uint   parameterNum;
            string parameterName;
            bool   flgSectionFound = default(bool);
            string errMsg          = "";

            for (uint i = 0; i < sectionNum; i++)
            {
                if (ini.getSection(i) == PARAMETERS_INI_SECTION_NAME)
                {
                    parameterNum    = ini.getNumberOfParameters(ini.getSection(i));
                    flgSectionFound = true;

                    for (uint j = 0; j < parameterNum; j++)
                    {
                        parameterName = ini.getParameterName(ini.getSection(i), j);
                        string parseResult = ini.getParameterValue(ini.getSection(i), j);
                        switch (parameterName)
                        {
                        //Sampling Points
                        case PARAMETERS_INI_SAMPLINGPOINTS:
                            SamplingMode mode = SamplingMode.FIRST;
                            if (ParseResamplingMode(parseResult, ref errMsg, ref mode) == false)
                            {
                                ErrorMessage += (errMsg + "\n");
                            }
                            else
                            {
                                ResamplingMode = mode;
                            }

                            break;

                        //Interpolation
                        case PARAMETERS_INI_INTERPOLATION:
                            InterpolationAlgorithm pol = InterpolationAlgorithm.LINEAR;
                            if (ParseInterpolation(parseResult, ref errMsg, ref pol) == false)
                            {
                                ErrorMessage += (errMsg + "\n");
                            }
                            Interpolation = pol;

                            break;

                        //Output range MIN
                        case PARAMETERS_INI_OUTPUTRANGEMIN:
                            double?min = null;
                            if (ParseOutputRangeMin(parseResult, ref errMsg, ref min) == false)
                            {
                                ErrorMessage += (errMsg + "\n");
                            }
                            OutputLowerRange = min;

                            break;

                        //Output range MAX
                        case PARAMETERS_INI_OUTPUTRANGEMAX:
                            double?max = null;
                            if (ParseOutputRangeMax(parseResult, ref errMsg, ref max) == false)
                            {
                                ErrorMessage += (errMsg + "\n");
                            }
                            OutputHigherRange = max;

                            break;

                        //Specified Interval
                        case PARAMETERS_INI_SPECIFIED_INTERVAL:
                            double?Interval = null;
                            if (ParseSpecifiedInterval(parseResult, ref errMsg, ref Interval, ResamplingMode) == false)
                            {
                                ErrorMessage = ErrorMessage + errMsg + "\n";
                            }
                            SpecifiedInterval = Interval;

                            break;

                        default:
                            break;
                        }
                    }
                }
            }


            //Debug.WriteLine(ini.getSection(0));

            return(flgSectionFound);
        }
Пример #4
0
        /// <summary>
        /// Read INI file.
        /// </summary>
        /// <returns></returns>
        public string ReadParameterIni()
        {
            ClrMsppManager msObj = ClrMsppManager.getInstance();
            ClrIniFile     ini   = msObj.getParameters();

            uint   sectionNum = ini.getNumberOfSections();
            uint   parameterNum;
            string parameterName;
            bool   sectionfindflag = default(bool);
            string errorMessage    = string.Empty;

            try
            {
                for (uint i = 0; i < sectionNum; i++)
                {
                    if (ini.getSection(i) == PARAMETERS_INI_SECTION_NAME)
                    {
                        parameterNum    = ini.getNumberOfParameters(ini.getSection(i));
                        sectionfindflag = true;

                        for (uint j = 0; j < parameterNum; j++)
                        {
                            parameterName = ini.getParameterName(ini.getSection(i), j);

                            switch (parameterName)
                            {
                            //Baseline
                            case PARAMETERS_INI_BASELINE:
                                if (ALGORITHM_ABC.CompareTo(ini.getParameterValue(ini.getSection(i), j)) == 0)
                                {
                                    Algorithm = ALGORITHM_ABC;
                                }
                                else if (ALGORITHM_LINEAR.CompareTo(ini.getParameterValue(ini.getSection(i), j)) == 0)
                                {
                                    Algorithm = ALGORITHM_LINEAR;
                                }
                                else
                                {
                                    Algorithm     = ALGORITHM_ABC;
                                    errorMessage += "There is a mistake in parameter BaseLine.\n 'ABC BaseLine' is Set.\n";
                                }

                                //Algorithm = (ALGORITHM_ABC.CompareTo(ini.getParameterValue(ini.getSection(i), j)) == 0)
                                //    ? ALGORITHM_ABC : ALGORITHM_LINEAR;
                                break;

                            //ABC_BASELINE_Windows Width
                            case PARAMETERS_INI_ABC_BASELINE_WINDOW_WIDTH:
                                try
                                {
                                    ABCWindowWidth = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    ABCWindowWidth = DEFAULT_ABC_WINDOW_WIDTH;
                                    errorMessage  += "There is a mistake in parameter Window Width(ABC BaseLine).\n '0.1' is Set.\n";
                                }
                                break;

                            //LINEAR_BASELINE_Windows width
                            case PARAMETERS_INI_LINEAR_BASELINE_WINDOW_WIDTH:
                                try
                                {
                                    LinearWindowWidth = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    LinearWindowWidth = DEFAULT_LINEAR_WINDOW_WIDTH;
                                    errorMessage     += "There is a mistake in parameter Window Width(Linear Baseline).\n '2.0' is Set.\n";
                                }
                                break;

                            //Noise Factor
                            case PARAMETERS_INI_NOISE_FACTOR:
                                try
                                {
                                    NoiseFactor = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    NoiseFactor   = DEFAULT_NOISE_FACTOR;
                                    errorMessage += "There is a mistake in parameter Noise Factor.\n '3.0' is Set.\n";
                                }
                                break;

                            //Smoothing Width
                            case PARAMETERS_INI_SMOOTHING_WIDTH:
                                try
                                {
                                    SmoothingWidth = int.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    SmoothingWidth = DEFAULT_SMOOTHING_WIDTH;
                                    errorMessage  += "There is a mistake in parameter Smoothing Width.\n '10' is Set.\n";
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //return false;
            }

            if (!sectionfindflag)
            {
                ABCWindowWidth    = DEFAULT_ABC_WINDOW_WIDTH;
                LinearWindowWidth = DEFAULT_LINEAR_WINDOW_WIDTH;
                NoiseFactor       = DEFAULT_NOISE_FACTOR;
                SmoothingWidth    = DEFAULT_SMOOTHING_WIDTH;
            }

            return(errorMessage);

            //return sectionfindflag;
        }
        /// <summary>
        /// Read INI file.
        /// </summary>
        /// <returns></returns>
        public string ReadParameterIni()
        {
            ClrMsppManager msObj = ClrMsppManager.getInstance();
            ClrIniFile     ini   = msObj.getParameters();

            uint   sectionNum = ini.getNumberOfSections();
            uint   parameterNum;
            string parameterName;
            bool   sectionFindFlag = false;
            string errorMessage    = string.Empty;

            try
            {
                for (uint i = 0; i < sectionNum; i++)
                {
                    if (ini.getSection(i) == PARAMETERS_INI_SECTION_NAME)
                    {
                        parameterNum    = ini.getNumberOfParameters(ini.getSection(i));
                        sectionFindFlag = true;

                        for (uint j = 0; j < parameterNum; j++)
                        {
                            parameterName = ini.getParameterName(ini.getSection(i), j);

                            switch (parameterName)
                            {
                            //Baseline
                            case PARAMETERS_INI_BASELINE:
                                if (ALGORITHM_ABC == ini.getParameterValue(ini.getSection(i), j))
                                {
                                    Algorithm = ALGORITHM_ABC;
                                }
                                else if (ALGORITHM_LINEAR == ini.getParameterValue(ini.getSection(i), j))
                                {
                                    Algorithm = ALGORITHM_LINEAR;
                                }
                                else
                                {
                                    Algorithm     = ALGORITHM_ABC;
                                    errorMessage += ERROR_INVALID_BASELINE;
                                }
                                break;

                            //ABC_BASELINE_Windows Width
                            case PARAMETERS_INI_ABC_BASELINE_WINDOW_WIDTH:
                                try
                                {
                                    ABCWindowWidth = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    ABCWindowWidth = DEFAULT_ABC_WINDOW_WIDTH;
                                    errorMessage  += ERROR_INVALID_ABC_WINDOW_WIDTH;
                                }
                                break;

                            //LINEAR_BASELINE_Windows width
                            case PARAMETERS_INI_LINEAR_BASELINE_WINDOW_WIDTH:
                                try
                                {
                                    LinearWindowWidth = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    LinearWindowWidth = DEFAULT_LINEAR_WINDOW_WIDTH;
                                    errorMessage     += ERROR_INVALID_LINEAR_WINDOW_WIDTH;
                                }
                                break;

                            //Noise Factor
                            case PARAMETERS_INI_NOISE_FACTOR:
                                try
                                {
                                    NoiseFactor = double.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    NoiseFactor   = DEFAULT_NOISE_FACTOR;
                                    errorMessage += ERROR_INVALID_NOISE_FACTOR;
                                }
                                break;

                            //Smoothing Width
                            case PARAMETERS_INI_SMOOTHING_WIDTH:
                                try
                                {
                                    SmoothingWidth = int.Parse(ini.getParameterValue(ini.getSection(i), j));
                                }
                                catch
                                {
                                    SmoothingWidth = DEFAULT_SMOOTHING_WIDTH;
                                    errorMessage  += ERROR_INVALID_SMOOTHING_WIDTH;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            if (!sectionFindFlag)
            {
                ABCWindowWidth    = DEFAULT_ABC_WINDOW_WIDTH;
                LinearWindowWidth = DEFAULT_LINEAR_WINDOW_WIDTH;
                NoiseFactor       = DEFAULT_NOISE_FACTOR;
                SmoothingWidth    = DEFAULT_SMOOTHING_WIDTH;
            }

            return(errorMessage);
        }