diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs index f8486b76..f942a0f2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs @@ -23,6 +23,11 @@ namespace PepperDash_Essentials_Core.Devices { _port = irPort; + if (_port == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function"); + return; + } DeviceManager.AddDevice(_port); _port.DriverLoaded.OutputChange += DriverLoadedOnOutputChange; @@ -35,6 +40,11 @@ namespace PepperDash_Essentials_Core.Devices return; } + if (_trilist == null || _bridge == null) + { + return; + } + LinkToApi(_trilist, _joinStart, _joinMapKey, _bridge); } @@ -61,22 +71,24 @@ namespace PepperDash_Essentials_Core.Devices for (uint i = 0; i < _port.IrFileCommands.Length; i++) { - var joinData = new JoinDataComplete(new JoinData {JoinNumber = i + joinStart, JoinSpan = 1}, + var cmd = _port.IrFileCommands[i]; + var joinData = new JoinDataComplete(new JoinData {JoinNumber = i, JoinSpan = 1}, new JoinMetadata { - Description = _port.IrFileCommands[i], + Description = cmd, JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); joinData.SetJoinOffset(joinStart); - joinMap.Joins.Add(_port.IrFileCommands[i],joinData); + joinMap.Joins.Add(cmd,joinData); - var index = i; - trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(_port.IrFileCommands[index], b)); + trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); } + joinMap.PrintJoinMapInfo(); + if (bridge != null) { bridge.AddJoinMap(Key, joinMap); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index 5099f7d0..cce1d46e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -52,6 +52,7 @@ namespace PepperDash.Essentials.Core DeviceConfig config) : base(key) { + DriverLoaded = new BoolFeedback(() => DriverIsLoaded); AddPostActivationAction(() => { IrPort = postActivationFunc(config); @@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core } var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); - Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath); + Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); LoadDriver(filePath);