mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-07 16:55:04 +00:00
Added Activate cycle try/catch for individual devices; added test abilities to feedbacks
This commit is contained in:
@@ -40,11 +40,13 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
Debug.Console(0, this, "Activating");
|
||||
var response = Hardware.RegisterWithLogging(Key);
|
||||
if (response == eDeviceRegistrationUnRegistrationResponse.Success)
|
||||
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||
{
|
||||
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
|
||||
CommunicationMonitor.Start();
|
||||
}
|
||||
Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
|
||||
return false;
|
||||
}
|
||||
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
|
||||
CommunicationMonitor.Start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,6 @@ namespace PepperDash.Essentials.Core
|
||||
System.Globalization.CultureInfo.InvariantCulture))
|
||||
.ToArray();
|
||||
object ret = method.Invoke(obj, convertedParams);
|
||||
//Debug.Console(0, JsonConvert.SerializeObject(ret));
|
||||
// return something?
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -29,10 +29,6 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public static void Initialize(CrestronControlSystem cs)
|
||||
{
|
||||
//CrestronConsole.AddNewConsoleCommand(ListDeviceCommands, "devcmdlist", "Lists commands",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
//CrestronConsole.AddNewConsoleCommand(DoDeviceCommand, "devcmd", "Runs a command on device - key Name value",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
|
||||
ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
|
||||
@@ -64,8 +60,15 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
foreach (var d in Devices.Values)
|
||||
{
|
||||
if (d is Device)
|
||||
(d as Device).Activate();
|
||||
try
|
||||
{
|
||||
if (d is Device)
|
||||
(d as Device).Activate();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, d, "ERROR: Device activation failure:\r{0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public abstract eCueType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool InTestMode { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Base Constructor - empty
|
||||
/// </summary>
|
||||
protected Feedback()
|
||||
{
|
||||
}
|
||||
@@ -28,6 +36,15 @@ namespace PepperDash.Essentials.Core
|
||||
Cue = cue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears test mode and fires update.
|
||||
/// </summary>
|
||||
public void ClearTestValue()
|
||||
{
|
||||
InTestMode = false;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an update synchronously
|
||||
/// </summary>
|
||||
@@ -60,11 +77,16 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override eCueType Type { get { return eCueType.Bool; } }
|
||||
|
||||
/// <summary>
|
||||
/// Fake value to be used in test mode
|
||||
/// </summary>
|
||||
public bool TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func that evaluates on FireUpdate
|
||||
/// </summary>
|
||||
public Func<bool> ValueFunc { get; private set; }
|
||||
/// <summary>
|
||||
/// The last value delivered on FireUpdate
|
||||
/// </summary>
|
||||
//public bool PreviousValue { get; private set; }
|
||||
|
||||
List<BoolInputSig> LinkedInputSigs = new List<BoolInputSig>();
|
||||
List<BoolInputSig> LinkedComplementInputSigs = new List<BoolInputSig>();
|
||||
|
||||
@@ -82,7 +104,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
bool newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _BoolValue)
|
||||
{
|
||||
_BoolValue = newValue;
|
||||
@@ -116,9 +138,20 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return BoolValue.ToString();
|
||||
return (InTestMode ? "TEST -- " : "") + BoolValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(bool value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = _BoolValue;
|
||||
@@ -137,8 +170,12 @@ namespace PepperDash.Essentials.Core
|
||||
int _IntValue;
|
||||
public ushort UShortValue { get { return (ushort)_IntValue; } }
|
||||
public override eCueType Type { get { return eCueType.Int; } }
|
||||
//public int PreviousValue { get; private set; }
|
||||
|
||||
public int TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func evaluated on FireUpdate
|
||||
/// </summary>
|
||||
Func<int> ValueFunc;
|
||||
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
|
||||
|
||||
@@ -156,7 +193,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _IntValue)
|
||||
{
|
||||
_IntValue = newValue;
|
||||
@@ -178,9 +215,20 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return IntValue.ToString();
|
||||
return (InTestMode ? "TEST -- " : "") + IntValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(int value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(UShortInputSig sig)
|
||||
{
|
||||
sig.UShortValue = UShortValue;
|
||||
@@ -194,7 +242,15 @@ namespace PepperDash.Essentials.Core
|
||||
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
|
||||
string _StringValue;
|
||||
public override eCueType Type { get { return eCueType.String; } }
|
||||
//public string PreviousValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used in testing. Set/Clear functions
|
||||
/// </summary>
|
||||
public string TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Evalutated on FireUpdate
|
||||
/// </summary>
|
||||
public Func<string> ValueFunc { get; private set; }
|
||||
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
|
||||
|
||||
@@ -213,7 +269,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _StringValue)
|
||||
{
|
||||
_StringValue = newValue;
|
||||
@@ -235,9 +291,20 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return StringValue;
|
||||
return (InTestMode ? "TEST -- " : "") + StringValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(string value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig)
|
||||
{
|
||||
sig.StringValue = _StringValue;
|
||||
|
||||
Reference in New Issue
Block a user