public async Task <EepromConfiguration> CalculateConfig(EepromConfigurationInput param) { var result = new EepromConfiguration(); double acc_corr = 1.0615; double jerkFactor = 25; result.StepsPerRotation = param.MicroSteps * (uint)param.StepsPerRotation; result.DistancePerRotationInMm = param.Teeth * param.ToothSizeInMm; if (Math.Abs(result.DistancePerRotationInMm) > double.Epsilon) { result.StepsPerMm = result.StepsPerRotation / result.DistancePerRotationInMm; result.DistancePerStepInMm = result.DistancePerRotationInMm / result.StepsPerRotation; } result.EstimatedMaxStepRate = result.StepsPerRotation * param.EstimatedRotationSpeed; result.EstimatedMaxSpeedInMmSec = result.DistancePerRotationInMm * param.EstimatedRotationSpeed; result.EstimatedMaxSpeedInMmMin = result.EstimatedMaxSpeedInMmSec * 60.0; if (Math.Abs(param.TimeToAcc) > double.Epsilon) { result.EstimatedAccelerationInMmSec2 = result.EstimatedMaxSpeedInMmSec / param.TimeToAcc; result.EstimatedAcc = Math.Sqrt(result.EstimatedMaxStepRate / param.TimeToAcc) * acc_corr; result.EstimatedAccelerationDistToMaxSpeedInMm = result.EstimatedAccelerationInMmSec2 * param.TimeToAcc * param.TimeToAcc; } if (Math.Abs(param.TimeToDec) > double.Epsilon) { result.EstimatedDecelerationInMmSec2 = result.EstimatedMaxSpeedInMmSec / param.TimeToDec; result.EstimatedDec = Math.Sqrt(result.EstimatedMaxStepRate / param.TimeToDec) * acc_corr; result.EstimatedDecelerationDistFromMaxSpeedInMm = result.EstimatedDecelerationInMmSec2 * param.TimeToDec * param.TimeToDec; } result.EstimatedJerkSpeed = result.EstimatedMaxStepRate / jerkFactor; result.MaxStepRate = (uint)Math.Round(result.EstimatedMaxStepRate, 0); result.Acc = (ushort)Math.Round(result.EstimatedAcc, 0); result.Dec = (ushort)Math.Round(result.EstimatedDec, 0); result.JerkSpeed = (uint)Math.Round(result.EstimatedJerkSpeed, 0); result.StepsPerMm1000 = (float)(result.StepsPerMm / 1000.0); return(await Task.FromResult(result)); }
public async Task <EepromConfiguration> CalculateConfig(EepromConfigurationInput param) { using (var scope = CreateScope()) { var paramUri = new UriQueryBuilder(); paramUri.Add("teeth", param.Teeth) .Add("toothSizeInMm", param.ToothSizeInMm) .Add("microSteps", param.MicroSteps) .Add("stepsPerRotation", param.StepsPerRotation) .Add("estimatedRotationSpeed", param.EstimatedRotationSpeed) .Add("timeToAcc", param.TimeToAcc) .Add("timeToDec", param.TimeToDec); var response = await scope.Instance.GetAsync(CreatePathBuilder().AddQuery(paramUri).Build()); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsAsync <EepromConfiguration>()); } }
public async Task <IActionResult> Get(ushort teeth, double toothsizeInMm, ushort microsteps, ushort stepsPerRotation, double estimatedRotationSpeed, double timeToAcc, double timeToDec) { // http://localhost:2024/api/EepromConfiguration?teeth=15&toothsizeInMm=2.0µsteps=16&stepsPerRotation=200&estimatedRotationSpeed=7.8&timeToAcc=0.2&timeToDec=0.15 var input = new EepromConfigurationInput { Teeth = teeth, ToothsizeinMm = toothsizeInMm, Microsteps = microsteps, StepsPerRotation = stepsPerRotation, EstimatedRotationSpeed = estimatedRotationSpeed, TimeToAcc = timeToAcc, TimeToDec = timeToDec }; var m = await _eepromConfigurationService.CalculateConfig(input); if (m == null) { return(NotFound()); } return(Ok(m)); }
public async Task <EepromConfiguration> CalculateConfig(EepromConfigurationInput param) { return(await _manager.CalculateConfig(param)); }