public Relay(Enums.Relay relay)
        {
            _relay   = relay;
            _gpioPin = Pi.Gpio[(int)relay];

            Initialize();
        }
        public void On(Enums.Relay relay, bool updateReportedProperties = true)
        {
            switch (relay)
            {
            case Enums.Relay.LightsGarden:
                _lightsGarden.On();
                break;

            case Enums.Relay.AlarmStrobe:
                _alarmStrobe.On();
                break;

            case Enums.Relay.AlarmSiren:
                _alarmSiren.On();
                break;

            case Enums.Relay.GarageRemoteButton:
                _garageRemoteButton.On();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(relay), relay, null);
            }

            if (updateReportedProperties)
            {
                UpdateReportedProperties(relay);
            }
        }
        private void UpdateReportedProperties(Enums.Relay relay)
        {
            if (ShouldIgnoreReportingPropertiesWhen(relay))
            {
                return;
            }

            UpdateReportedProperties();
        }
        /// <summary>
        /// Ignore sending DeviceTwin reported state for these relays
        /// Garage remote button relay is just a momentary action that doesn't need to have a reported state
        /// </summary>
        /// <param name="relay"></param>
        /// <returns></returns>
        private static bool ShouldIgnoreReportingPropertiesWhen(Enums.Relay relay)
        {
            switch (relay)
            {
            case Enums.Relay.GarageRemoteButton:
                return(true);

            default:
                return(false);
            }
        }
Example #5
0
        private bool Toggle(Enums.Relay relay)
        {
            if (_relayBoard.IsOn(relay))
            {
                _relayBoard.Off(relay);
            }
            else
            {
                _relayBoard.On(relay);
            }

            return(_relayBoard.IsOn(relay));
        }
        public bool IsOn(Enums.Relay relay)
        {
            switch (relay)
            {
            case Enums.Relay.LightsGarden:
                return(_lightsGarden.State);

            case Enums.Relay.AlarmStrobe:
                return(_alarmStrobe.State);

            case Enums.Relay.AlarmSiren:
                return(_alarmSiren.State);

            case Enums.Relay.GarageRemoteButton:
                return(_garageRemoteButton.State);

            default:
                throw new ArgumentOutOfRangeException(nameof(relay), relay, null);
            }
        }
 public IRelayBoard Relay(Enums.Relay relay)
 {
     _relayCollection.Add(relay);
     return(this);
 }
 public IRelayBoard Relay(Enums.Relay relay)
 {
     throw new NotImplementedException();
 }