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
{
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()
{
Relay = 1;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
Relay = Relay + joinOffset;
[JoinName("Relay")]
public JoinDataComplete Relay = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata() { Label = "Device Relay State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
public GenericRelayControllerJoinMap(uint joinStart)
: base(joinStart, typeof(GenericRelayControllerJoinMap))
{
}
}
}

View File

@@ -70,16 +70,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
#endregion
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);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized);
joinMap.OffsetJoinNumbers(joinStart);
if (RelayOutput == null)
{
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"));
trilist.SetBoolSigAction(joinMap.Relay, b =>
trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b =>
{
if (b)
CloseRelay();
@@ -98,7 +96,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
// feedback for relay state
OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]);
OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay.JoinNumber]);
}
}