예제 #1
0
        public async Task ReleaseTheSpiritAsync()
        {
            if (_currentStatus.Value != Status.Ready)
            {
                return;
            }

            _currentStatus.OnNext(Status.Running);

            var positionSettings = await _shotGlassPositionSettingRepository.GetAllSettingsAsync();

            var positionsWithGlasses = positionSettings.Where(p => p.Quantity != Quantity.Empty).ToList();
            var optimizedRoute       = GetOptimizedRoute(positionsWithGlasses);

            foreach (var position in optimizedRoute)
            {
                var positionSetting = positionsWithGlasses.First(p => p.Position == position);
                if (_emergencyStop.EmergencyStopPressed)
                {
                    break;
                }

                switch (positionSetting.Quantity)
                {
                case Quantity.OneShot:
                    await DriveToPositionAsync(positionSetting.Position);

                    await _spiritDispenserControl.FillGlas();

                    OneShotPoured?.Invoke();
                    break;

                case Quantity.DoubleShot:
                    await DriveToPositionAsync(positionSetting.Position);

                    await _spiritDispenserControl.FillGlas();

                    OneShotPoured?.Invoke();
                    await _spiritDispenserControl.FillGlas();

                    OneShotPoured?.Invoke();
                    break;

                case Quantity.Empty:
                    // do nothing
                    break;
                }
            }

            CalculateStatuts(true);
        }
        public async Task InitShotGlassPositionSettingsAsync()
        {
            const int NUMBER_OF_SHOT_GLASS_POSITIONS = 12;
            var       settings = await _shotGlassPositionSettingRepository.GetAllSettingsAsync();

            if (settings != null && settings.Count() > 0)
            {
                return;
            }

            for (int i = 1; i <= NUMBER_OF_SHOT_GLASS_POSITIONS; i++)
            {
                await AddShotGlassPositionSettingAsync(i, _shotGlassPositionSettingRepository);
            }
        }