public IAsyncOperationContext BeginRampToTemperature(Value <Unit.Temperature> targetTemperature,
                                                      Value <Unit.TemperatureRate> rampRateAbs, ReadOnlyRange <Unit.Temperature> settlingBand,
                                                      TimeSpan settlingTime)
 {
     if (_operationService.GetOperationStatus())
     {
         return(_operationService);
     }
     if (_operationService.GetCurrentTemperature() < targetTemperature)
     {
         var task = _operationService.RampingUpAsync(targetTemperature, rampRateAbs, settlingBand, settlingTime);
         try
         {
             task.ConfigureAwait(false);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
     else if (_operationService.GetCurrentTemperature() > targetTemperature)
     {
         var task = _operationService.RampingDownAsync(targetTemperature, rampRateAbs, settlingBand, settlingTime);
         try
         {
             task.ConfigureAwait(false);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
     return(_operationService);
 }
Example #2
0
        public async Task TestRampingUp()
        {
            var operationService  = new AsyncOperationService();
            var targetTemperature = new Value <Unit.Temperature>(50.0, Unit.Temperature.TemperatureInDegC);
            var rampRate          = new Value <Unit.TemperatureRate>(10.0, Unit.TemperatureRate.TemperatureRateInDegCPerMinute);
            var minBand           = new Value <Unit.Temperature>(targetTemperature.Number - 0.5, Unit.Temperature.TemperatureInDegC);
            var maxBand           = new Value <Unit.Temperature>(targetTemperature.Number + 0.5, Unit.Temperature.TemperatureInDegC);
            var band = new ReadOnlyRange <Unit.Temperature>(minBand, maxBand);
            var time = TimeSpan.FromMinutes(5);
            await operationService.RampingUpAsync(targetTemperature, rampRate, band, time);

            var currentTemp = operationService.GetCurrentTemperature().Number;

            Assert.AreEqual(50.0, currentTemp);
        }