using ErrorAnalysis.Repository; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ErrorAnalysis.Service { public class COMergeCalcService { //Ncoef=1e8*2.54*2.54*2*6*11*2*77*0.2/0.6*speed; //Fcoef=1e8*2.54*2.54*4*6*2*11*77*0.2/0.6*speed; const double _gg = (9.0 - 0.0) / 255.0;//0.03529 const double _offset = 0.0; const int _cWinStartIndex = (int)(3.3 / _gg + _offset); //C窗口index const int _cWinEndIndex = (int)(4.78 / _gg + _offset); // width= 4.78-3.3 = 1.48 const int _oWinStartIndex = (int)(4.88 / _gg + _offset); // org const int _oWinEndIndex = (int)(6.36 / _gg + _offset); // width = 6.36-4.88=1.48 public static double GetFarMergeCResult(string connectionString, string modelId, int porosity) { var repository = new COFarResultRepository(connectionString); var cResult = repository.GetCOFarResult(modelId, porosity, 0); if (cResult == null) throw new InvalidDataException("COFarResult not found"); var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray(); if (cArr == null) throw new InvalidDataException("COFarResult InelasticSpec is null"); var length = _cWinEndIndex - _cWinStartIndex + 1; var result = cArr.Skip(_cWinStartIndex).Take(length).Sum(); return result; } public static double GetFarMergeOResult(string connectionString, string modelId, int porosity) { var repository = new COFarResultRepository(connectionString); var cResult = repository.GetCOFarResult(modelId, porosity, 100); if (cResult == null) throw new InvalidDataException("COFarResult not found"); var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray(); if (cArr == null) throw new InvalidDataException("COFarResult InelasticSpec is null"); var length = _oWinEndIndex - _oWinStartIndex + 1; var result = cArr.Skip(_oWinStartIndex).Take(length).Sum(); return result; } public static double GetNearMergeCResult(string connectionString, string modelId, int porosity) { var repository = new CONearResultRepository(connectionString); var cResult = repository.GetCONearResult(modelId, porosity, 0); if (cResult == null) throw new InvalidDataException("CONearResult not found"); var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray(); if (cArr == null) throw new InvalidDataException("CONearResult InelasticSpec is null"); var length = _cWinEndIndex - _cWinStartIndex + 1; var result = cArr.Skip(_cWinStartIndex).Take(length).Sum(); return result; } public static double GetNearMergeOResult(string connectionString, string modelId, int porosity) { var repository = new CONearResultRepository(connectionString); var cResult = repository.GetCONearResult(modelId, porosity, 100); if (cResult == null) throw new InvalidDataException("CONearResult not found"); var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray(); if (cArr == null) throw new InvalidDataException("CONearResult InelasticSpec is null"); var length = _oWinEndIndex - _oWinStartIndex + 1; var result = cArr.Skip(_oWinStartIndex).Take(length).Sum(); return result; } } }