fixed some null refs and got join map being created correctly

This commit is contained in:
Andrew Welker
2020-09-02 23:59:26 -06:00
parent 8a98924ad7
commit ceef883ad8
2 changed files with 19 additions and 6 deletions

View File

@@ -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);

View File

@@ -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<string>();
Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath);
Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath);
LoadDriver(filePath);