move load file to end of postactivation action

and change to use the IrPortController's loadFile method
add printing of available IR Commands in the loaded file.
This commit is contained in:
Andrew Welker
2020-08-18 16:34:24 -06:00
parent a30062db71
commit 468aff6e3f
2 changed files with 24 additions and 13 deletions

View File

@@ -134,12 +134,9 @@ namespace PepperDash.Essentials.Core
var port = irDev.IROutputPorts[portNum]; var port = irDev.IROutputPorts[portNum];
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + control["irFile"].Value<string>();
Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath);
port.LoadIRDriver(filePath);
return port; return port;
} }
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)

View File

@@ -49,9 +49,22 @@ namespace PepperDash.Essentials.Core
AddPostActivationAction(() => AddPostActivationAction(() =>
{ {
IrPort = postActivationFunc(config); IrPort = postActivationFunc(config);
if (IrPort != null)
if (IrPort == null)
{ {
DriverIsLoaded = true; Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function");
return;
}
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath);
LoadDriver(filePath);
Debug.Console(2, this, "Available IR Commands in IR File {0}",IrPortUid);
foreach (var cmd in IrPort.AvailableIRCmds())
{
Debug.Console(2, this, "{0}", cmd);
} }
}); });
} }
@@ -64,6 +77,7 @@ namespace PepperDash.Essentials.Core
/// <param name="path"></param> /// <param name="path"></param>
public void LoadDriver(string path) public void LoadDriver(string path)
{ {
Debug.Console(2, this, "***Loading IR File***");
if (string.IsNullOrEmpty(path)) path = DriverFilepath; if (string.IsNullOrEmpty(path)) path = DriverFilepath;
try try
{ {