diff --git a/PepperDashEssentials/Bridges/EiscBridge.cs b/PepperDashEssentials/Bridges/EiscBridge.cs index 984a1d9d..1a7ec02a 100644 --- a/PepperDashEssentials/Bridges/EiscBridge.cs +++ b/PepperDashEssentials/Bridges/EiscBridge.cs @@ -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."); diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/PepperDashEssentials/Bridges/IBridge.cs index 8bc741ec..497985c7 100644 --- a/PepperDashEssentials/Bridges/IBridge.cs +++ b/PepperDashEssentials/Bridges/IBridge.cs @@ -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 /// [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); } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs index 512401bc..0919335d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs @@ -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() { "eiscapiadv", "eiscapiadvanced" }; + TypeNames = new List { "eiscapiadv", "eiscapiadvanced" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs index 4aca333a..0c6b44ed 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs @@ -1,19 +1,12 @@ -using System; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; +using Crestron.SimplSharpPro.DeviceSupport; namespace PepperDash.Essentials.Core.Bridges { /// /// Defines a device that uses JoinMapBaseAdvanced for its join map /// - 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); - } } \ No newline at end of file diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index 974d2f47..18cb0c27 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit 974d2f473c06b2c90b18c06e0f758ca47d466be8 +Subproject commit 18cb0c273eb8b750f657d74160ad82eff1b24bca