using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Web.Http; using XdCxRhDW.Dto; using XdCxRhDW.WebApi; namespace GpuCgServer.Controllers { /// /// Gpu参估接口 /// public class GpuCgController : BaseController { /// /// GPU参估计算(需要先上传文件) /// /// GPU参估参数 /// [HttpPost] public async Task>> Calc(GpuCgRequestDto dto) { dto.file1 = GetLocalFile(dto.file1); dto.file2 = GetLocalFile(dto.file2); FileInfo file1 = new FileInfo(dto.file1); FileInfo file2 = new FileInfo(dto.file2); long totalsamp = file1.Length < file2.Length ? file1.Length / 4 : file2.Length / 4; //样点数为0时计算所有样本 if (dto.smpCount == 0) { dto.smpCount = totalsamp; } else if (dto.smpCount > 0 && dto.smpCount < 1) { dto.smpCount = (long)(totalsamp * dto.smpCount); } CpuCgResDto resDto = new CpuCgResDto(); try { var result = await Task.Run(() => { return GpuCgHelper.Calc(dto.file1, dto.file2, dto.samplingRate, dto.smpCount, dto.dtCenter, dto.dtRange, dto.dfRange, dto.snrThreshold, dto.TimeoutSeconds); }); return Success(result); } catch (Exception ex) { Serilog.Log.Error(ex, "执行GPU参估异常"); return Error>($"执行GPU参估异常"); } } } }