/// <summary> /// Creates a GenericRelayDevice for each relay on the processor and adds them to the SwitchedOutputs collection /// </summary> void GetRelays() { try { if (Processor.SupportsRelay) { for (uint i = 1; i <= Processor.NumberOfRelayPorts; i++) { var relay = new GenericRelayDevice(string.Format("{0}-relay-{1}", this.Key, i), Processor.RelayPorts[i]); SwitchedOutputs.Add(i, relay); } } } catch (Exception e) { Debug.Console(1, this, "Error Getting Relays from processor:\n '{0}'", e); } }
public static void LinkToApi(this GenericRelayDevice relay, BasicTriList trilist, uint joinStart, string joinMapKey) { GenericRelayControllerJoinMap joinMap = new GenericRelayControllerJoinMap(); var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) { joinMap = JsonConvert.DeserializeObject <GenericRelayControllerJoinMap>(joinMapSerialized); } joinMap.OffsetJoinNumbers(joinStart); if (relay.RelayOutput == null) { Debug.Console(1, relay, "Unable to link device '{0}'. Relay is null", relay.Key); return; } Debug.Console(1, relay, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); trilist.SetBoolSigAction(joinMap.Relay, new Action <bool>(b => { if (b) { relay.CloseRelay(); } else { relay.OpenRelay(); } })); // feedback for relay state relay.OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]); }
void SetGreenLedRelay(GenericRelayDevice relay) { GreenLedRelay = relay; }
void SetRedLedRelay(GenericRelayDevice relay) { RedLedRelay = relay; }