From 7f8215199d8a100565e58c5cf1c82f1d25e9c694 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 8 Feb 2021 17:29:35 -0700 Subject: [PATCH 1/5] update processor type comparisons --- PepperDashEssentials/ControlSystem.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 74f3c617..8435209b 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -323,7 +323,12 @@ namespace PepperDash.Essentials // Skip this to prevent unnecessary warnings if (devConf.Key == "processor") { - if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower()) + var prompt = Global.ControlSystem.ControllerPrompt; + + var typeMatch = String.Equals(devConf.Type, prompt, StringComparison.OrdinalIgnoreCase) && + String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase); + + if (!typeMatch) Debug.Console(0, "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); From b19b4ae26ebf02838af3e384d82fc75c325c206b Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 9 Feb 2021 15:27:32 -0700 Subject: [PATCH 2/5] Updated to latest DBs to expose new eCrestronSeries property and adds new property to Global to reflect. Updates startup message to print series --- PepperDashEssentials/ControlSystem.cs | 2 +- .../Essentials Core/PepperDashEssentialsBase/Global/Global.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 8435209b..3e3798a4 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -130,7 +130,7 @@ namespace PepperDash.Essentials if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", Global.AssemblyVersion); + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, Global.ProcessorSeries.ToString()); // Check if User/ProgramX exists if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + "User" diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 4a846df7..aa71c1f7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -26,6 +26,8 @@ namespace PepperDash.Essentials.Core public static LicenseManager LicenseManager { get; set; } + public static eCrestronSeries ProcessorSeries { get { return CrestronEnvironment.ProgramCompatibility; } } + /// /// The file path prefix to the folder containing configuration files /// From f1fa3c07fdcf9b4b8a3c4e39aefdcc55064755b4 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 10 Feb 2021 14:15:00 -0700 Subject: [PATCH 3/5] #605 Adds try/catch and more meaningful messages when adding static assets fails --- ...ssentialsTechRoomFusionSystemController.cs | 26 ++++++------ ...lsHuddleSpaceFusionSystemControllerBase.cs | 40 +++++++++++++++---- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs b/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs index 7e465b4d..b4cfbf3e 100644 --- a/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs +++ b/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs @@ -30,27 +30,29 @@ namespace PepperDash.Essentials.Fusion foreach (var display in displays.Values.Cast()) { - Debug.Console(2, this, "Setting up Static Asset for {0}", display.Key); + var disp = display; // Local scope variable - display.UsageTracker = new UsageTracking(display) { UsageIsTracked = true }; - display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; + Debug.Console(2, this, "Setting up Static Asset for {0}", disp.Key); + + disp.UsageTracker = new UsageTracking(disp) { UsageIsTracked = true }; + disp.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; var dispPowerOnAction = new Action(b => { if (!b) { - display.PowerOn(); + disp.PowerOn(); } }); var dispPowerOffAction = new Action(b => { if (!b) { - display.PowerOff(); + disp.PowerOff(); } }); - var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(display.Key); + var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(disp.Key); FusionAsset tempAsset; @@ -63,7 +65,7 @@ namespace PepperDash.Essentials.Fusion { // Create a new asset tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), - display.Name, "Display", ""); + disp.Name, "Display", ""); FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); } @@ -72,21 +74,21 @@ namespace PepperDash.Essentials.Fusion dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; - var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback; + var defaultTwoWayDisplay = disp as IHasPowerControlWithFeedback; if (defaultTwoWayDisplay != null) { defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - if (display is IDisplayUsage) + if (disp is IDisplayUsage) { - (display as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + (disp as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); } defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); } // Use extension methods - dispAsset.TrySetMakeModel(display); - dispAsset.TryLinkAssetErrorToCommunication(display); + dispAsset.TrySetMakeModel(disp); + dispAsset.TryLinkAssetErrorToCommunication(disp); } } catch (Exception e) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index 9574743e..ff0c53ed 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -1676,20 +1676,46 @@ namespace PepperDash.Essentials.Core.Fusion public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, string instanceId) { - Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); + try + { + Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); - fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; + fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, "Error creating Static Asset: {0}", e); + return null; + } } public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, string type, string instanceId) { - Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, - instanceId); + try + { + Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, + instanceId); - fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; + fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, "Error creating Static Asset: {0}", e); + return null; + } } } From 08491bdf2a0ff76ecc41e1d1c8363f65f818839e Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 10 Feb 2021 15:01:40 -0700 Subject: [PATCH 4/5] Adds null checks if asset creation fails and returns null --- ...EssentialsTechRoomFusionSystemController.cs | 18 ++++++++++++------ ...alsHuddleSpaceFusionSystemControllerBase.cs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs b/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs index b4cfbf3e..0630c53a 100644 --- a/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs +++ b/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs @@ -71,8 +71,16 @@ namespace PepperDash.Essentials.Fusion var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); - dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; - dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; + + if (dispAsset != null) + { + dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; + dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; + + // Use extension methods + dispAsset.TrySetMakeModel(disp); + dispAsset.TryLinkAssetErrorToCommunication(disp); + } var defaultTwoWayDisplay = disp as IHasPowerControlWithFeedback; if (defaultTwoWayDisplay != null) @@ -83,12 +91,10 @@ namespace PepperDash.Essentials.Fusion (disp as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); } - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); + if(dispAsset != null) + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); } - // Use extension methods - dispAsset.TrySetMakeModel(disp); - dispAsset.TryLinkAssetErrorToCommunication(disp); } } catch (Exception e) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index ff0c53ed..784392b1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -1685,7 +1685,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (InvalidOperationException ex) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); return null; } catch (Exception e) From e7b322c3035b58f207b95514b4296ae8e87ce1ce Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 10 Feb 2021 15:39:37 -0700 Subject: [PATCH 5/5] add error log for some exceptions --- .../Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index 784392b1..b26b1980 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -1690,7 +1690,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(2, "Error creating Static Asset: {0}", e); + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); return null; } } @@ -1713,7 +1713,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(2, "Error creating Static Asset: {0}", e); + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); return null; } }