mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-17 13:45:01 +00:00
Merge pull request #214 from PepperDash/feature/Improve-JoinMetadata
Updated JoinMetadata to add Description property
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
@@ -347,6 +348,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class JoinMetadata
|
public class JoinMetadata
|
||||||
{
|
{
|
||||||
|
private string _description;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Join number (based on join offset value)
|
/// Join number (based on join offset value)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -361,10 +364,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
public uint JoinSpan { get; set; }
|
public uint JoinSpan { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A label for the join to better describe it's usage
|
/// A label for the join to better describe its usage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Use Description instead")]
|
||||||
[JsonProperty("label")]
|
[JsonProperty("label")]
|
||||||
public string Label { get; set; }
|
public string Label { get { return _description; } set { _description = value; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A description for the join to better describe its usage
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get { return _description; } set { _description = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signal type(s)
|
/// Signal type(s)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -457,8 +467,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.All)]
|
[AttributeUsage(AttributeTargets.All)]
|
||||||
public class JoinNameAttribute : Attribute
|
public class JoinNameAttribute : CAttribute
|
||||||
{
|
{
|
||||||
private string _Name;
|
private string _Name;
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, PepperDash.Essentials.Core.Bridges.EiscApiAdvanced bridge)
|
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
{
|
{
|
||||||
var joinMap = new Hrxxx0WirelessRemoteControllerJoinMap(joinStart);
|
var joinMap = new Hrxxx0WirelessRemoteControllerJoinMap(joinStart);
|
||||||
|
|
||||||
@@ -161,33 +161,39 @@ namespace PepperDash.Essentials.Core
|
|||||||
bridge.AddJoinMap(Key, joinMap);
|
bridge.AddJoinMap(Key, joinMap);
|
||||||
|
|
||||||
//List<string> ExcludedKeys = new List<string>();
|
//List<string> ExcludedKeys = new List<string>();
|
||||||
|
foreach (var feedback in Feedbacks)
|
||||||
|
|
||||||
|
|
||||||
foreach (Feedback feedback in Feedbacks)
|
|
||||||
{
|
{
|
||||||
Feedback myFeedback = feedback;
|
var myFeedback = feedback;
|
||||||
|
|
||||||
var join = joinMap.Joins.FirstOrDefault(x => x.Value.Metadata.Label.Equals(myFeedback.Key, StringComparison.InvariantCultureIgnoreCase)).Value;
|
var joinData =
|
||||||
|
joinMap.Joins.FirstOrDefault(
|
||||||
|
x =>
|
||||||
|
x.Key.Equals(myFeedback.Key, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
if (join == null) continue;
|
if (string.IsNullOrEmpty((joinData.Key))) continue;
|
||||||
|
|
||||||
|
var name = joinData.Key;
|
||||||
|
var join = joinData.Value;
|
||||||
|
|
||||||
if (join.Metadata.JoinType == eJoinType.Digital)
|
if (join.Metadata.JoinType == eJoinType.Digital)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Linking Bool Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber);
|
Debug.Console(0, this, "Linking Bool Feedback '{0}' to join {1}", name, join.JoinNumber);
|
||||||
BoolFeedback someFeedback = myFeedback as BoolFeedback;
|
var someFeedback = myFeedback as BoolFeedback;
|
||||||
|
if(someFeedback == null) continue;
|
||||||
someFeedback.LinkInputSig(trilist.BooleanInput[join.JoinNumber]);
|
someFeedback.LinkInputSig(trilist.BooleanInput[join.JoinNumber]);
|
||||||
}
|
}
|
||||||
if (join.Metadata.JoinType == eJoinType.Analog)
|
if (join.Metadata.JoinType == eJoinType.Analog)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Linking Analog Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber);
|
Debug.Console(0, this, "Linking Analog Feedback '{0}' to join {1}", name, join.JoinNumber);
|
||||||
IntFeedback someFeedback = myFeedback as IntFeedback;
|
var someFeedback = myFeedback as IntFeedback;
|
||||||
|
if (someFeedback == null) continue;
|
||||||
someFeedback.LinkInputSig(trilist.UShortInput[join.JoinNumber]);
|
someFeedback.LinkInputSig(trilist.UShortInput[join.JoinNumber]);
|
||||||
}
|
}
|
||||||
if (join.Metadata.JoinType == eJoinType.Serial)
|
if (join.Metadata.JoinType == eJoinType.Serial)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Linking Serial Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber);
|
Debug.Console(0, this, "Linking Serial Feedback '{0}' to join {1}", name, join.JoinNumber);
|
||||||
StringFeedback someFeedback = myFeedback as StringFeedback;
|
var someFeedback = myFeedback as StringFeedback;
|
||||||
|
if (someFeedback == null) continue;
|
||||||
someFeedback.LinkInputSig(trilist.StringInput[join.JoinNumber]);
|
someFeedback.LinkInputSig(trilist.StringInput[join.JoinNumber]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,13 +207,19 @@ namespace PepperDash.Essentials.Core
|
|||||||
for (uint i = 1; i <= _remote.Button.Count; i++)
|
for (uint i = 1; i <= _remote.Button.Count; i++)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Attempting to link join index {0}", i);
|
Debug.Console(2, this, "Attempting to link join index {0}", i);
|
||||||
var join = joinMap.Joins.FirstOrDefault(o => o.Value.Metadata.Label.Equals(_remote.Button[i].Name.ToString(), StringComparison.InvariantCultureIgnoreCase)).Value;
|
var index = i;
|
||||||
if (join == null)
|
var joinData =
|
||||||
{
|
joinMap.Joins.FirstOrDefault(
|
||||||
Debug.Console(2, this, "Join '{0}' is null", i);
|
o =>
|
||||||
continue;
|
o.Key.Equals(_remote.Button[index].Name.ToString(),
|
||||||
}
|
StringComparison.InvariantCultureIgnoreCase));
|
||||||
Debug.Console(2, this, "Setting User Object for '{0}'", join.Metadata.Label);
|
|
||||||
|
if (string.IsNullOrEmpty((joinData.Key))) continue;
|
||||||
|
|
||||||
|
var join = joinData.Value;
|
||||||
|
var name = joinData.Key;
|
||||||
|
|
||||||
|
Debug.Console(2, this, "Setting User Object for '{0}'", name);
|
||||||
if (join.Metadata.JoinType == eJoinType.Digital)
|
if (join.Metadata.JoinType == eJoinType.Digital)
|
||||||
{
|
{
|
||||||
_remote.Button[i].SetButtonAction((b) => trilist.BooleanInput[join.JoinNumber].BoolValue = b);
|
_remote.Button[i].SetButtonAction((b) => trilist.BooleanInput[join.JoinNumber].BoolValue = b);
|
||||||
|
|||||||
Reference in New Issue
Block a user