Beispiel #1
0
        /// <summary>
        /// Stops all currently running effects and events
        /// </summary>
        private async Task StopAllEffectsAndEvents()
        {
            ScheduleTimer.StopTimer();
            _eventTriggersCollection.StopAllEvents();

            if (_customEffects.HasActiveEffects())
            {
                await _customEffects.DeactivateAllEffects();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Try to set the operation mode for a device
        /// Only the override is able to stop the override, effects and events may not remove the manual mode
        /// First stops all active effects and events before switching to the new effect or event claiming operation mode
        /// </summary>
        public async Task <bool> TrySetOperationMode(OperationMode operationMode, bool isFromOverride = false)
        {
            if (!isFromOverride && Device.OperationMode == OperationMode.Manual)
            {
                return(false);
            }

            Device.OperationMode = operationMode;

            //Stop all things that can activate an effect
            await StopAllEffectsAndEvents();

            //If its a schedule, then the schedule timer can start again. The events and override manage their own effect activation
            if (Device.OperationMode == OperationMode.Schedule)
            {
                ScheduleTimer.StartTimer();
            }

            return(true);
        }
Beispiel #3
0
        public Orchestrator(Device device)
        {
            Device = device;

            ScheduleTimer            = new ScheduleTimer(this);
            PanelLayout              = new PanelLayout(Device);
            _eventTriggersCollection = new EventTriggersCollection(this);

            // Custom effect initialization must come after panel layout initialization as custom screen mirror effect needs the panel layout
            _customEffects = new CustomEffectsCollection(Device, this);

            if (device.OperationMode == OperationMode.Schedule)
            {
                ScheduleTimer.StartTimer();
            }
            else if (device.OperationMode == OperationMode.Manual)
            {
                Task.Run(() => ActivateEffect(Device.OverrideEffect, Device.OverrideBrightness));
            }
        }