Added Activate cycle try/catch for individual devices; added test abilities to feedbacks

This commit is contained in:
Heath Volmer
2018-01-22 14:53:09 -07:00
parent cb41b31018
commit b7bab6cfd1
15 changed files with 112 additions and 57113 deletions

View File

@@ -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;
}

View File

@@ -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>

View File

@@ -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);
}
}
}

View File

@@ -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;

View File

@@ -300,7 +300,7 @@ namespace PepperDash.Essentials.Devices.Common
}
catch (Exception e)
{
Debug.Console(0, "ERROR:Unable to convert Crestnet ID: {0} to hex. Error:\n{1}", props.CresnetId, e);
Debug.Console(0, "ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", props.CresnetId, e);
}
switch (props.Model.ToLower())

View File

@@ -16,11 +16,18 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
/// <summary>
/// Set by debugging functions
/// </summary>
public bool InMockMode { get; private set; }
public bool MockRoomIsOccupiedFeedback { get; private set; }
public Func<bool> RoomIsOccupiedFeedbackFunc
{
get
{
return () => OccSensor.OccupancyDetectedFeedback.BoolValue;
return () => InMockMode ? MockRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue;
}
}

View File

@@ -67,8 +67,6 @@ namespace PepperDash.Essentials
return;
Load();
DeviceManager.ActivateAll();
Debug.Console(0, "Essentials load complete\r" +
"-------------------------------------------------------------");
}
@@ -147,6 +145,8 @@ namespace PepperDash.Essentials
LoadTieLines();
LoadRooms();
LoadLogoServer();
DeviceManager.ActivateAll();
}
@@ -186,7 +186,6 @@ namespace PepperDash.Essentials
Debug.Console(0, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e);
}
}
}
/// <summary>

View File

@@ -130,11 +130,6 @@
<Compile Include="OTHER\Fusion\FusionEventHandlers.cs" />
<Compile Include="OTHER\Fusion\FusionProcessorQueries.cs" />
<Compile Include="OTHER\Fusion\FusionRviDataClasses.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="REMOVE EssentialsApp.cs" />
<Compile Include="OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
<Compile Include="HttpApiHandler.cs" />
@@ -198,15 +193,6 @@
<Compile Include="UI\SubpageReferenceListSourceItem.cs" />
<None Include="app.config" />
<None Include="Properties\ControlSystem.cfg" />
<None Include="Resources\PepperDash Essentials iPad.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\PepperDash Essentials TSW-560.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\PepperDash Essentials TSW-760.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj">
@@ -218,12 +204,6 @@
<Name>Essentials Devices Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

View File

@@ -4,5 +4,5 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
[assembly: AssemblyVersion("1.0.30.*")]
[assembly: AssemblyVersion("1.0.31.*")]

View File

@@ -1,81 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.8794
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PepperDash.Essentials.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PepperDash.Essentials.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static byte[] PepperDash_Essentials_iPad {
get {
object obj = ResourceManager.GetObject("PepperDash_Essentials_iPad", resourceCulture);
return ((byte[])(obj));
}
}
internal static byte[] PepperDash_Essentials_TSW_560 {
get {
object obj = ResourceManager.GetObject("PepperDash_Essentials_TSW_560", resourceCulture);
return ((byte[])(obj));
}
}
internal static byte[] PepperDash_Essentials_TSW_760 {
get {
object obj = ResourceManager.GetObject("PepperDash_Essentials_TSW_760", resourceCulture);
return ((byte[])(obj));
}
}
}
}

View File

@@ -1,130 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="PepperDash_Essentials_iPad" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PepperDash Essentials iPad.sgd;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="PepperDash_Essentials_TSW_560" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PepperDash Essentials TSW-560.sgd;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="PepperDash_Essentials_TSW_760" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PepperDash Essentials TSW-760.sgd;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@@ -22,4 +22,9 @@ devjson:1 {"deviceKey":"mockVc-1", "methodName":"TestIncomingVideoCall", "params
devjson:1 {"deviceKey":"mockVc-1", "methodName":"ListCalls"}
devjson:1 {"deviceKey":"room1-emergency", "methodName":"RunEmergencyBehavior"}
devjson:1 {"deviceKey":"room1-emergency", "methodName":"RunEmergencyBehavior"}
devjson:1 {"deviceKey":"microphonePrivacyController-1", "methodName":"TogglePrivacyMute"}
devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"SetTestValue", "params": [ true ]}
devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"ClearTestValue", "params": []}