private void UpdateRelayAnnunciator(RelayStateChangedEventArgs args) { log.Info($"Relay {args.RelayNumber} changed to {args.NewState}"); if (annunciators == null || annunciators.Count == 0) { log.Warn($"Relay {args.RelayNumber} changed to {args.NewState} but there are no annunciators to update"); return; } var annunciator = annunciators[args.RelayNumber]; annunciator.Enabled = args.NewState; }
/// <summary> /// Internal event handler for the relay state changed event. /// This fires the fireplace state changed event when the /// relay's state changes. /// </summary> /// <param name="sender"> /// The object raising the event (a reference to the relay object). /// </param> /// <param name="e"> /// The event arguments. /// </param> private void InternalHandleRelayStateChange(Object sender, RelayStateChangedEventArgs e) { FireplaceStateChangedEventArgs stateChangeEvent = null; if (e.NewState == this._fireplaceOnRelayState) { stateChangeEvent = new FireplaceStateChangedEventArgs(FireplaceState.Off, FireplaceState.On); } else { stateChangeEvent = new FireplaceStateChangedEventArgs(FireplaceState.On, FireplaceState.Off); } base.OnStateChanged(stateChangeEvent); }
private static void Relays_RelayStateChanged(Object sender, RelayStateChangedEventArgs e) { Debug.WriteLine(e.Relay == 0 ? "Relay 0 state has changed" : "Relay 1 state has changed"); }