Updated GenericRelayControllerJoinMap and GenericRelayDevice

This commit is contained in:
Trevor Payne
2020-05-07 15:54:47 -05:00
parent 230f29d3f8
commit adbb76b87c
2 changed files with 13 additions and 23 deletions

View File

@@ -7,25 +7,17 @@ using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
public class GenericRelayControllerJoinMap : JoinMapBase public class GenericRelayControllerJoinMap : JoinMapBaseAdvanced
{ {
#region Digitals
/// <summary>
/// Sets and reports the state of the relay (High = closed, Low = Open)
/// </summary>
public uint Relay { get; set; }
#endregion
public GenericRelayControllerJoinMap() [JoinName("Relay")]
{ public JoinDataComplete Relay = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
Relay = 1; new JoinMetadata() { Label = "Device Relay State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
}
public override void OffsetJoinNumbers(uint joinStart) public GenericRelayControllerJoinMap(uint joinStart)
{ : base(joinStart, typeof(GenericRelayControllerJoinMap))
var joinOffset = joinStart - 1; {
Relay = Relay + joinOffset;
} }
} }
} }

View File

@@ -70,16 +70,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
#endregion #endregion
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
var joinMap = new GenericRelayControllerJoinMap(); var joinMap = new GenericRelayControllerJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized);
joinMap.OffsetJoinNumbers(joinStart);
if (RelayOutput == null) if (RelayOutput == null)
{ {
Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key);
@@ -88,7 +86,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
trilist.SetBoolSigAction(joinMap.Relay, b => trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b =>
{ {
if (b) if (b)
CloseRelay(); CloseRelay();
@@ -98,7 +96,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
// feedback for relay state // feedback for relay state
OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]); OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay.JoinNumber]);
} }
} }