Merge remote-tracking branch 'origin/feature/ecs-407' into feature/cisco-spark

Conflicts:
	Essentials Devices Common/Essentials Devices Common/VC/VideoCodecBase.cs
This commit is contained in:
Neil Dorin
2017-09-13 14:07:56 -06:00
57 changed files with 5131 additions and 1538 deletions

View File

@@ -6,6 +6,8 @@ using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectHelperBase
@@ -33,13 +35,37 @@ namespace PepperDash.Essentials.Core.SmartObjects
SmartObject.SigChange -= this.SmartObject_SigChange;
}
/// <summary>
/// Helper to get a sig name with debugging when fail
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public BoolOutputSig GetBoolOutputNamed(string name)
{
if (SmartObject.BooleanOutput.Contains(name))
return SmartObject.BooleanOutput[name];
else
Debug.Console(0, "WARNING: Cannot get signal. Smart object {0} on trilist {1:x2} does not contain signal '{2}'",
SmartObject.ID, SmartObject.Device.ID, name);
return null;
}
/// <summary>
/// Sets action on signal after checking for existence.
/// </summary>
/// <param name="name"></param>
/// <param name="a"></param>
public void SetBoolAction(string name, Action<bool> a)
{
if (SmartObject.BooleanOutput.Contains(name))
SmartObject.BooleanOutput[name].UserObject = a;
else
{
Debug.Console(0, "WARNING: Cannot set action. Smart object {0} on trilist {1:x2} does not contain signal '{2}'",
SmartObject.ID, SmartObject.Device.ID, name);
}
}
/// <summary>
/// Standard Action listener
/// </summary>

View File

@@ -10,6 +10,14 @@ namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectNumeric : SmartObjectHelperBase
{
/// <summary>
/// Defaults to "Misc_1". The name of the button in VTPro (Usually the text)
/// </summary>
public string Misc1SigName { get; set; }
/// <summary>
/// Defaults to "Misc_2". The name of the button in VTPro (Usually the text)
/// </summary>
public string Misc2SigName { get; set; }
public BoolOutputSig Digit1 { get { return GetBoolOutputNamed("1"); } }
public BoolOutputSig Digit2 { get { return GetBoolOutputNamed("2"); } }
@@ -21,11 +29,13 @@ namespace PepperDash.Essentials.Core.SmartObjects
public BoolOutputSig Digit8 { get { return GetBoolOutputNamed("8"); } }
public BoolOutputSig Digit9 { get { return GetBoolOutputNamed("9"); } }
public BoolOutputSig Digit0 { get { return GetBoolOutputNamed("0"); } }
public BoolOutputSig Misc1 { get { return GetBoolOutputNamed("Misc_1"); } }
public BoolOutputSig Misc2 { get { return GetBoolOutputNamed("Misc_2"); } }
public BoolOutputSig Misc1 { get { return GetBoolOutputNamed(Misc1SigName); } }
public BoolOutputSig Misc2 { get { return GetBoolOutputNamed(Misc2SigName); } }
public SmartObjectNumeric(SmartObject so, bool useUserObjectHandler) : base(so, useUserObjectHandler)
{
Misc1SigName = "Misc_1";
Misc2SigName = "Misc_2";
}
}
}

View File

@@ -53,7 +53,7 @@ namespace PepperDash.Essentials.Core
// Fail cleanly if not defined
if (triList.SmartObjects == null || triList.SmartObjects.Count == 0)
{
Debug.Console(0, "TriList {0:X2} Smart objects not loaded", triList.ID, smartObjectId);
Debug.Console(0, "TriList {0:X2} Smart objects have not been loaded", triList.ID, smartObjectId);
return;
}
if (triList.SmartObjects.TryGetValue(smartObjectId, out obj))
@@ -74,7 +74,8 @@ namespace PepperDash.Essentials.Core
SRL.SigChange += new SmartObjectSigChangeEventHandler(SRL_SigChange);
}
else
Debug.Console(0, "TriList 0x{0:X2} Cannot load smart object {1}", triList.ID, smartObjectId);
Debug.Console(0, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded",
triList.ID, smartObjectId);
}
/// <summary>

View File

@@ -17,7 +17,8 @@ namespace PepperDash.Essentials.Core
public static class SigAndTriListExtensions
{
/// <summary>
/// Attaches Action to Sig's user object and returns the same Sig.
/// Attaches Action to Sig's user object and returns the same Sig. This provides no protection
/// from null sigs
/// </summary>
/// <param name="sig">The BoolOutputSig to attach the Action to</param>
/// <param name="a">An action to run when sig is pressed and when released</param>
@@ -64,13 +65,20 @@ namespace PepperDash.Essentials.Core
}
/// <summary>
///
/// Sets an action to a held sig
/// </summary>
/// <param name="tl"></param>
/// <param name="sigNum"></param>
/// <param name="heldAction"></param>
/// <returns></returns>
/// <returns>The sig</returns>
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction)
{
return SetSigHeldAction(tl, sigNum, heldMs, heldAction, null);
}
/// <summary>
/// Sets an action to a held sig as well as a released-without-hold action
/// </summary>
/// <returns>The sig</returns>
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction, Action releaseAction)
{
CTimer heldTimer = null;
return tl.SetBoolSigAction(sigNum, press =>
@@ -87,10 +95,12 @@ namespace PepperDash.Essentials.Core
heldAction();
}, heldMs);
}
else if (heldTimer != null) // released
{
heldTimer.Stop();
// could also revise this else to fire a released action as well as cancel the timer
if (releaseAction != null)
releaseAction();
}
});
}
@@ -143,5 +153,21 @@ namespace PepperDash.Essentials.Core
{
return ClearSigAction(tl.StringOutput[sigNum]) as StringOutputSig;
}
}
/// <summary>
/// Helper method to set the value of a bool Sig on TriList
/// </summary>
public static void SetBool(this BasicTriList tl, uint sigNum, bool value)
{
tl.BooleanInput[sigNum].BoolValue = value;
}
/// <summary>
/// Helper method to set the value of a string Sig on TriList
/// </summary>
public static void SetString(this BasicTriList tl, uint sigNum, string value)
{
tl.StringInput[sigNum].StringValue = value;
}
}
}