diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 8803dc6c..9802c176 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -327,7 +327,11 @@ namespace PepperDash.Essentials DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); // Add global System Monitor device - DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + { + DeviceManager.AddDevice( + new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); + } foreach (var devConf in ConfigReader.ConfigObject.Devices) { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs index ec6c2ebe..13d1948a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.EthernetCommunication; using Newtonsoft.Json; @@ -82,9 +84,9 @@ namespace PepperDash.Essentials.Core.Bridges protected Dictionary JoinMaps { get; private set; } - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } + public BasicTriList Eisc { get; private set; } - public EiscApiAdvanced(DeviceConfig dc) : + public EiscApiAdvanced(DeviceConfig dc, BasicTriList eisc) : base(dc.Key) { JoinMaps = new Dictionary(); @@ -92,44 +94,52 @@ namespace PepperDash.Essentials.Core.Bridges PropertiesConfig = dc.Properties.ToObject(); //PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); + Eisc = eisc; Eisc.SigChange += Eisc_SigChange; - AddPostActivationAction( () => + AddPostActivationAction(LinkDevices); + } + + private void LinkDevices() + { + Debug.Console(1, this, "Linking Devices..."); + + foreach (var d in PropertiesConfig.Devices) { - Debug.Console(1, this, "Linking Devices..."); + var device = DeviceManager.GetDeviceForKey(d.DeviceKey); - foreach (var d in PropertiesConfig.Devices) + if (device == null) { - var device = DeviceManager.GetDeviceForKey(d.DeviceKey); - - if (device == null) continue; - - Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - - if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) - { - 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; - } - - var bridge = device as IBridgeAdvanced; - if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + continue; } - var registerResult = Eisc.Register(); + Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) + if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult); - return; + 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; } - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful"); - }); + var bridge = device as IBridgeAdvanced; + if (bridge != null) + { + bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + } + } + + var registerResult = Eisc.Register(); + + if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult); + return; + } + + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful"); } /// @@ -152,7 +162,7 @@ namespace PepperDash.Essentials.Core.Bridges /// /// Prints all the join maps on this bridge /// - public void PrintJoinMaps() + public virtual void PrintJoinMaps() { Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); @@ -247,7 +257,7 @@ namespace PepperDash.Essentials.Core.Bridges /// /// /// - void Eisc_SigChange(object currentDevice, SigEventArgs args) + protected void Eisc_SigChange(object currentDevice, SigEventArgs args) { try { @@ -299,15 +309,34 @@ namespace PepperDash.Essentials.Core.Bridges { public EiscApiAdvancedFactory() { - TypeNames = new List { "eiscapiadv", "eiscapiadvanced" }; + TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "vceiscapiadv", "vceiscapiadvanced" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device"); - return new EiscApiAdvanced(dc); - + var controlProperties = dc.Properties["control"].ToObject(); + + switch (dc.Type) + { + case "eiscapiadv": + case "eiscapiadvanced": + { + var eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, + controlProperties.TcpSshProperties.Address, Global.ControlSystem); + return new EiscApiAdvanced(dc, eisc); + } + case "vceiscapiadv": + case "vceiscapiadvanced": + { + var eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, InitialParametersClass.RoomId, + Global.ControlSystem); + return new EiscApiAdvanced(dc, eisc); + } + default: + return null; + } } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 911c148e..4a846df7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -20,9 +20,11 @@ namespace PepperDash.Essentials.Core { public static CrestronControlSystem ControlSystem { get; set; } - public static LicenseManager LicenseManager { get; set; } + public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } } - public static Dictionary EthernetAdapterInfoCollection {get; private set;} + public static Dictionary EthernetAdapterInfoCollection { get; private set; } + + public static LicenseManager LicenseManager { get; set; } /// /// The file path prefix to the folder containing configuration files @@ -163,8 +165,6 @@ namespace PepperDash.Essentials.Core */ } - - static Global() { // Fire up CrestronDataStoreStatic @@ -174,87 +174,7 @@ namespace PepperDash.Essentials.Core CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); return; } - - GetEthernetInformation(); - } - /// - /// Populates EthernetInformationCollection - /// - static void GetEthernetInformation() - { - - EthernetAdapterInfoCollection = new Dictionary(); - - EthernetAdapterType adapterType = EthernetAdapterType.EthernetUnknownAdapter; - - List adapters = new List() - { EthernetAdapterType.EthernetLANAdapter, EthernetAdapterType.EthernetLAN2Adapter, EthernetAdapterType.EthernetCSAdapter, EthernetAdapterType.EthernetWIFIAdapter }; - - foreach (var adapter in adapters) - { - try - { - adapterType = EthernetAdapterType.EthernetLANAdapter; - - var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(adapterType); - - var adapterInfo = GetEthernetAdapterProperties(adapterId, adapterType); - - EthernetAdapterInfoCollection.Add(adapterId, adapterInfo); - } - catch (Exception e) - { - if (e is System.ArgumentException) - { - Debug.Console(1, "Error: {0} not present", adapterType); - } - else - { - Debug.Console(1, "Error: {0}", e); - } - } - } - - } - - - static EthernetAdapterInfo GetEthernetAdapterProperties(short adapterId, EthernetAdapterType adapterType) - { - EthernetAdapterInfo adapterInfo = new EthernetAdapterInfo(); - - adapterInfo.Type = adapterType; - adapterInfo.DhcpIsOn = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId) == "on" ? true : false; - adapterInfo.Hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId); - adapterInfo.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId); - adapterInfo.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId); - adapterInfo.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId); - adapterInfo.Gateway = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterId); - adapterInfo.Domain = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId); - - string dns = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId); - if (dns.Contains(",")) - { - string[] dnsList = dns.Split(','); - for (var i = 0; i < dnsList.Length; i++) - { - if (i == 0) - adapterInfo.Dns1 = !string.IsNullOrEmpty(dnsList[0]) ? dnsList[0] : "0.0.0.0"; - if (i == 1) - adapterInfo.Dns2 = !string.IsNullOrEmpty(dnsList[1]) ? dnsList[1] : "0.0.0.0"; - if (i == 2) - adapterInfo.Dns3 = !string.IsNullOrEmpty(dnsList[2]) ? dnsList[2] : "0.0.0.0"; - } - } - else - { - adapterInfo.Dns1 = !string.IsNullOrEmpty(dns) ? dns : "0.0.0.0"; - adapterInfo.Dns2 = "0.0.0.0"; - adapterInfo.Dns3 = "0.0.0.0"; - } - - return adapterInfo; - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index 814ce903..643e8b83 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -2097,6 +2097,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new Cisco Codec Device"); + var comm = CommFactory.CreateCommForDevice(dc); return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); }