diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs index 0ad6e135..9db81122 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs @@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Core /// public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking { - public virtual GenericBase Hardware { get; protected set; } + protected GenericBase Hardware; /// /// Returns a list containing the Outputs that we want to expose. diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs index 6999bd74..89c0b7b3 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs @@ -6,25 +6,19 @@ using Crestron.SimplSharp; namespace PepperDash_Essentials_Core { - public delegate void IsReadyEventHandler(object source, IsReadyEventArgs e); - public class IsReadyEventArgs : EventArgs { - private readonly bool _EventData; + public bool IsReady { get; set; } public IsReadyEventArgs(bool data) { - _EventData = data; - } - - public bool GetData() - { - return _EventData; + IsReady = data; } } public interface IHasReady { - event IsReadyEventHandler IsReady; + event EventHandler IsReadyEvent; + bool IsReady { get; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs index 767714d1..ba185e4f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs @@ -20,7 +20,9 @@ namespace PepperDash.Essentials.Core [Description("Wrapper class for Crestron Infinet-EX Gateways")] public class CenRfgwController : CrestronGenericBaseDevice, IHasReady { - public event IsReadyEventHandler IsReady; + public event EventHandler IsReadyEvent; + + public bool IsReady { get; private set; } private GatewayBase _gateway; @@ -34,23 +36,27 @@ namespace PepperDash.Essentials.Core /// /// /// + /// public CenRfgwController(string key, string name, GatewayBase gateway) : base(key, name, gateway) { _gateway = gateway; - IsReady(this, new IsReadyEventArgs(true)); + IsReady = true; + FireIsReadyEvent(IsReady); } public CenRfgwController(string key, Func preActivationFunc, DeviceConfig config) : base(key, config.Name) { - IsReady(this, new IsReadyEventArgs(false)); + IsReady = false; + FireIsReadyEvent(IsReady); AddPreActivationAction(() => { _gateway = preActivationFunc(config); + IsReady = true; RegisterCrestronGenericBase(_gateway); - IsReady(this, new IsReadyEventArgs(true)); + FireIsReadyEvent(IsReady); }); } @@ -58,9 +64,7 @@ namespace PepperDash.Essentials.Core public static GatewayBase GetNewIpRfGateway(DeviceConfig dc) { var control = CommFactory.GetControlPropertiesConfig(dc); - var name = dc.Name; var type = dc.Type; - var key = dc.Key; var ipId = control.IpIdInt; if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) @@ -74,6 +78,15 @@ namespace PepperDash.Essentials.Core return null; } + private void FireIsReadyEvent(bool data) + { + var handler = IsReadyEvent; + if (handler == null) return; + + handler(this, new IsReadyEventArgs(data)); + + } + public static GatewayBase GetNewSharedIpRfGateway(DeviceConfig dc) { var control = CommFactory.GetControlPropertiesConfig(dc); @@ -135,7 +148,7 @@ namespace PepperDash.Essentials.Core - public enum eExGatewayType + public enum EExGatewayType { Ethernet, EthernetShared, @@ -159,22 +172,17 @@ namespace PepperDash.Essentials.Core var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - var cresnetId = control.CresnetIdInt; - - eExGatewayType gatewayType = - (eExGatewayType) Enum.Parse(typeof (eExGatewayType), props.GatewayType, true); + EExGatewayType gatewayType = + (EExGatewayType) Enum.Parse(typeof (EExGatewayType), props.GatewayType, true); switch (gatewayType) { - case (eExGatewayType.Ethernet): - return new CenRfgwController(dc.Key, dc.Name, CenRfgwController.GetNewIpRfGateway(dc)); - case (eExGatewayType.EthernetShared): - return new CenRfgwController(dc.Key, dc.Name, CenRfgwController.GetNewSharedIpRfGateway(dc)); - case (eExGatewayType.Cresnet): - return new CenRfgwController(dc.Key, CenRfgwController.GetCenRfgwCresnetController, dc); + case (EExGatewayType.Ethernet): + return new CenRfgwController(dc.Key, dc.Name, GetNewIpRfGateway(dc)); + case (EExGatewayType.EthernetShared): + return new CenRfgwController(dc.Key, dc.Name, GetNewSharedIpRfGateway(dc)); + case (EExGatewayType.Cresnet): + return new CenRfgwController(dc.Key, GetCenRfgwCresnetController, dc); } return null; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs index dd52257e..311df7f1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs @@ -29,6 +29,8 @@ namespace PepperDash.Essentials.Core public CrestronCollection