Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Welker
09d47d3e5d add null check to all internal device LinkToApi methods
This allows for backwards compatability with EiscApi bridges.
2020-06-19 14:32:26 -06:00
Andrew Welker
d31d4eef30 update bridges and interfaces 2020-06-19 13:51:43 -06:00
28 changed files with 215 additions and 70 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Crestron.SimplSharp.Reflection;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using PepperDash.Core;
@@ -39,19 +40,31 @@ namespace PepperDash.Essentials.Bridges
if (device == null) continue;
Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
if (typeof(IBridge).IsAssignableFrom(device.GetType().GetCType())) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
{
Debug.Console(2, this, "'{0}' is IBridge", device.Key);
var dev = device as IBridge;
if (dev == null)
{
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Cast to IBridge failed for {0}");
continue;
}
dev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
}
if (!(device is IBridgeAdvanced)) continue;
if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) continue;
Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key);
var advDev = device as IBridgeAdvanced;
if (advDev == null)
{
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Cast to IBridgeAdvanced failed for {0}");
continue;
}
try
{
advDev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, null);
@@ -61,7 +74,6 @@ namespace PepperDash.Essentials.Bridges
Debug.ConsoleWithLog(0, this,
"Please update the bridge config to use EiscBridgeAdvanced with this device: {0}", device.Key);
}
}
Debug.Console(1, this, "Devices Linked.");

View File

@@ -1,4 +1,5 @@
using System;
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Bridges
{
@@ -6,7 +7,8 @@ namespace PepperDash.Essentials.Bridges
/// Defines a device that uses the legacy JoinMapBase for its join map
/// </summary>
[Obsolete("IBridgeAdvanced should be used going forward with JoinMapBaseAdvanced")]
public interface IBridge:Core.Bridges.IBridge
public interface IBridge
{
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey);
}
}

View File

@@ -7,7 +7,6 @@ using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
//using PepperDash.Essentials.Devices.Common.Cameras;
@@ -111,28 +110,17 @@ namespace PepperDash.Essentials.Core.Bridges
Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
if (typeof (IBridge).IsAssignableFrom(device.GetType().GetCType()))
if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
{
var basicBridge = device as IBridge;
if (basicBridge != null)
{
Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
"Linking EiscApiAdvanced {0} to device {1} using obsolete join map. Please update the device's join map.",
Key, device.Key);
basicBridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
}
Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
device.Key);
continue;
}
if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
{
continue;
}
var bridge = device as IBridgeAdvanced;
if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
}
});
}
@@ -303,7 +291,7 @@ namespace PepperDash.Essentials.Core.Bridges
{
public EiscApiAdvancedFactory()
{
TypeNames = new List<string>() { "eiscapiadv", "eiscapiadvanced" };
TypeNames = new List<string> { "eiscapiadv", "eiscapiadvanced" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)

View File

@@ -1,19 +1,12 @@
using System;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Defines a device that uses JoinMapBaseAdvanced for its join map
/// </summary>
public interface IBridgeAdvanced:IKeyed
public interface IBridgeAdvanced
{
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
}
public interface IBridge:IKeyed
{
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey);
}
}

View File

@@ -76,7 +76,14 @@ namespace PepperDash.Essentials.Core
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IBasicCommunicationJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
if (CommPort == null)
{

View File

@@ -55,7 +55,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<C2nRthsControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -108,7 +108,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IDigitalInputJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
try
{

View File

@@ -148,7 +148,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
if (RelayOutput == null)
{

View File

@@ -118,7 +118,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<StatusSignControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -128,9 +128,16 @@ namespace PepperDash.Essentials.Core
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;

View File

@@ -80,7 +80,14 @@ namespace PepperDash.Essentials.Core.Lighting
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -209,7 +209,14 @@ namespace PepperDash.Essentials.Core.Monitoring
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<SystemMonitorJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(2, this, "Linking API starting at join: {0}", joinStart);

View File

@@ -158,7 +158,14 @@ namespace PepperDash.Essentials.Core
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<Hrxxx0WirelessRemoteControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
//List<string> ExcludedKeys = new List<string>();
foreach (var feedback in Feedbacks)

View File

@@ -114,7 +114,14 @@ namespace PepperDash.Essentials.DM.AirMedia
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<AirMediaControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Airmedia: {0}", Name);

View File

@@ -590,7 +590,14 @@ namespace PepperDash.Essentials.DM {
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmBladeChassisControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -1112,7 +1112,14 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmChassisControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -111,7 +111,14 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmpsAudioOutputControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -163,7 +163,14 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmpsRoutingControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -262,7 +262,14 @@ namespace PepperDash.Essentials.DM.Chassis
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<HdMdNxM4kEControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
DeviceNameFeedback[this.Name].LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]);

View File

@@ -230,7 +230,14 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<HdMdxxxCEControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -42,7 +42,14 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmRmcControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -206,6 +206,15 @@ namespace PepperDash.Essentials.DM
protected void LinkDmTxToApi(DmTxControllerBase tx, BasicTriList trilist, DmTxControllerJoinMap joinMap, EiscApiAdvanced bridge)
{
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);

View File

@@ -83,8 +83,14 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
{
CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart);
// Adds the join map to the bridge
bridge.AddJoinMap(cameraDevice.Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey);

View File

@@ -447,7 +447,14 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<CenOdtOccupancySensorBaseJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View File

@@ -268,7 +268,14 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
@@ -379,25 +386,13 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
{
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
var typeName = dc.Type.ToLower();
var key = dc.Key;
var name = dc.Name;
var comm = CommFactory.GetControlPropertiesConfig(dc);
GlsOccupancySensorBase occSensor = null;
occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem);
if (occSensor != null)
{
return new GlsOccupancySensorBaseController(key, name, occSensor);
}
else
{
Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key);
return null;
}
GlsOccupancySensorBase occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem);
return new GlsOccupancySensorBaseController(key, name, occSensor);
}
}

View File

@@ -380,7 +380,14 @@ namespace PepperDash.Essentials.Devices.Common
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<SetTopBoxControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Display: {0}", Name);

View File

@@ -153,7 +153,14 @@ namespace PepperDash.Essentials.Devices.Common
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<AppleTvJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);