Exemplo n.º 1
0
        private void OnEventResult(ref PinEventConfiguration config)
        {
            if (config == null || !PinController.IsValidPin(config.GpioPin))
            {
                return;
            }

            if (config.Current.Equals(config.Previous))
            {
                return;
            }

            OnValueChangedEventArgs onValueChangedEventArgs = new OnValueChangedEventArgs(config.GpioPin, (CurrentValue)config.Current, (PreviousValue)config.Previous);

            switch (config.EventState)
            {
            case PinEventState.Activated when config.Current.DigitalValue:
                OnActivatedEventArgs onActivatedEventArgs = new OnActivatedEventArgs(config.GpioPin, (CurrentValue)config.Current);
                ParallelExecuteOnEach(config.EventState, (p) => p.OnActivated(this, onActivatedEventArgs)).RunSynchronously();
                break;

            case PinEventState.Deactivated when !config.Current.DigitalValue:
                OnDeactivatedEventArgs onDeactivatedEventArgs = new OnDeactivatedEventArgs(config.GpioPin, (CurrentValue)config.Current);
                ParallelExecuteOnEach(config.EventState, (p) => p.OnDeactivated(this, onDeactivatedEventArgs)).RunSynchronously();
                break;

            case PinEventState.Both:
                break;
            }

            ParallelExecuteOnEach(config.EventState, (p) => p.OnValueChanged(this, onValueChangedEventArgs)).RunSynchronously();
        }
Exemplo n.º 2
0
        public void OnDeactivated(object sender, OnDeactivatedEventArgs e)
        {
            if ((sender == null) || (e == null))
            {
                return;
            }

            Logger.Warn($"[{nameof(OnDeactivated)}] | {e.TimeStamp} -> {e.Pin} -> {e.Current.State}");
        }