Exemple #1
0
 /**
  * Method to be executed when file data are retrieved
  * @param fileData - data of file in string array
  */
 private void OnFileRead(string[] fileData)
 {
     if (fileData != null)
     {
         try
         {
             dataVanilla_ = parser_.Parse(fileData);
             OnDataLoad();
         }
         catch (TraParseException ex)
         {
             //Show user that data in file are in correct
             notifier_.Notify(WRONG_DATA, FILE_ERROR, OK, Error);
             //Log
             logger_.Log(ex.ToString(), LOG_TYPE.ERROR);
         }
     }
     else
     {
         //Show user that data there are no Data
         notifier_.Notify(NO_DATA_IN_FILE, FILE_ERROR, OK, Warning);
         //Log
         logger_.Log("File with no data", LOG_TYPE.ERROR);
     }
 }
Exemple #2
0
        /**
         * Method to Calculate data from file
         * @param StretchData - data from file
         * @return ComputedData - computed data for App
         */
        public ComputedData CalculateValues(StretchData data)
        {
            CalculatePoints(data.GetData());
            var fMax = data.GetData().Max(p => p.StandardForce);
            var dl   = data.GetData().Last().GripToGrip;
            var s0   = Math.PI * Math.Pow((data.getFi() / 2.0), 2);
            var rm   = fMax / s0;
            var r02  = CalculateR02(s0);

            return(new ComputedData()
            {
                DeltaL = dl, Fmax = fMax, Rm = rm, R02 = r02, F02 = GetF02()
            });
        }
Exemple #3
0
        /**
         * Method to recalculate data from
         */
        private void RecalcData(double?l0, double?fi)
        {
            if (dataVanilla_ != null)
            {
                data_ = dataVanilla_.Recalc(l0, fi);


                computed_ = solver_.CalculateValues(data_);
                PlotGraph();
                ShowData();
            }
            else
            {
                //TODO: Show message cant plot graph
            }
        }
Exemple #4
0
        /**
         * Methods that Parse string lines to data
         * @param string[]
         * @return StretchData
         */
        public StretchData Parse(string[] data)
        {
            StretchData output = new StretchData();

            for (int i = 0; i < data.Length; ++i)
            {
                var row = data[i].Trim();
                if (row.StartsWith(" ") || row.Length <= 0)//Skip empty lines
                {
                    continue;
                }
                if (!row.StartsWith(COMMENT_ROW_TEMPLATE) && !row.StartsWith(TITLE_ROW_TEMPLATE))
                {
                    if (row.StartsWith(PRELOAD_ROW_TEMPLATE))//Get PRE-LOAD
                    {
                        var preData = row.Split(SPLIT_ARRAY, 3, RemoveEmptyEntries);
                        if (double.TryParse(preData[1], out double preVal))
                        {
                            output.PreLoadValue = preVal;
                            output.PreLoadUnit  = preData[2];
                        }
                        else
                        {
                            throw new TraParseException($"{PRELOAD_ROW_TEMPLATE} wrong value at row: {i + 1}");
                        }
                    }
                    else if (row.StartsWith(TEST_SPEED_ROW_TEMPLATE))//Get TEST SPEED
                    {
                        var speedData = row.Split(SPLIT_ARRAY, 4, RemoveEmptyEntries);
                        if (double.TryParse(speedData[2], out double speedVal))
                        {
                            output.TestSpeedValue = speedVal;
                            output.TestSpeedUnit  = speedData[3];
                        }
                        else
                        {
                            throw new TraParseException($"{TEST_SPEED_ROW_TEMPLATE} wrong value at row: {i + 1}");
                        }
                    }
                    else//Get LINE DATA
                    {
                        LineData lineData = new LineData();
                        var      values   = row.Split(SPLIT_LINE_DATA_SEPARATOR);
                        if (double.TryParse(values[0], NumberStyles.Any, CultureInfo.InvariantCulture, out double strainVal))
                        {
                            lineData.Strain = strainVal;
                        }
                        else
                        {
                            throw new TraParseException($"\"Strain\" data wrong value at row: {i + 1}");
                        }
                        if (double.TryParse(values[1], NumberStyles.Any, CultureInfo.InvariantCulture, out double forceVal))
                        {
                            lineData.StandardForce = forceVal;
                        }
                        else
                        {
                            throw new TraParseException($"\"Standard force\" data wrong value at row: {i + 1}");
                        }
                        if (double.TryParse(values[2], NumberStyles.Any, CultureInfo.InvariantCulture, out double gripVal))
                        {
                            lineData.GripToGrip = gripVal;
                        }
                        else
                        {
                            throw new TraParseException($"\"Grip to grip s\" data wrong value at row: {i + 1}");
                        }
                        output.Add(lineData);
                    }
                }
                else if (i == 0)//Get File Path
                {
                    output.Path = data[i];
                }
            }

            return(output);
        }