mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
feat(wip): updates GenericIrController and IrOutputPortController to implement bridge map
This commit is contained in:
@@ -21,13 +21,9 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
|
|
||||||
public string[] IrCommands {get { return _port.IrFileCommands; }}
|
public string[] IrCommands {get { return _port.IrFileCommands; }}
|
||||||
|
|
||||||
public Dictionary<string, JoinDataComplete> BridgeJoins;
|
|
||||||
|
|
||||||
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
||||||
{
|
{
|
||||||
_port = irPort;
|
_port = irPort;
|
||||||
if(_port.UseBridgeJoinMap) BridgeJoins = new Dictionary<string, JoinDataComplete>();
|
|
||||||
|
|
||||||
if (_port == null)
|
if (_port == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function");
|
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function");
|
||||||
@@ -78,17 +74,75 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
{
|
{
|
||||||
Debug.Console(0, this, "Using new IR bridge join map");
|
Debug.Console(0, this, "Using new IR bridge join map");
|
||||||
|
|
||||||
var joins = BridgeJoins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key, kv=> kv.Value);
|
var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key);
|
||||||
foreach (var join in joins)
|
if (bridgeJoins == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "_useBridgeJoinMap: {0}: {1}", join.Key, join.Value);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map");
|
||||||
}
|
return;
|
||||||
//joinMap.Joins = joins.Select(kv => kv.Value.SetJoinOffset(joinStart)).ToString();
|
}
|
||||||
|
foreach (var bridgeJoin in bridgeJoins)
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, @"bridgeJoin: Key-'{0}'
|
||||||
|
Value.Key-'{1}'
|
||||||
|
Value.JoinNumber-'{2}'
|
||||||
|
Value.Metadata.Description-'{3}'",
|
||||||
|
bridgeJoin.Key,
|
||||||
|
bridgeJoin.Value.Key,
|
||||||
|
bridgeJoin.Value.Value.JoinNumber,
|
||||||
|
bridgeJoin.Value.Value.Metadata.Description);
|
||||||
|
|
||||||
|
var joinNumber = bridgeJoin.Value.Value.JoinNumber;
|
||||||
|
var joinCmd = bridgeJoin.Key;
|
||||||
|
|
||||||
|
trilist.SetBoolSigAction(joinNumber, (b) => Press(joinCmd, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
//foreach (var irFileCommand in _port.IrFileCommands)
|
||||||
|
//{
|
||||||
|
// var cmd = irFileCommand;
|
||||||
|
// JoinDataComplete joinDataComplete;
|
||||||
|
// if (joinMap.Joins.TryGetValue(cmd, out joinDataComplete))
|
||||||
|
// {
|
||||||
|
// Debug.Console(0, this, "joinDataComplete: attributeName-'{0}', joinNumber-'{1}', joinSpan-'{2}', metadata.description-'{3}'",
|
||||||
|
// joinDataComplete.AttributeName, joinDataComplete.JoinNumber, joinDataComplete.JoinSpan, joinDataComplete.Metadata.Description);
|
||||||
|
|
||||||
|
// trilist.SetBoolSigAction(joinDataComplete.JoinNumber, (b) => Press(cmd, b));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Debug.Console(0, this, "GenericIrController join map does not contain support for IR command '{0}', verify IR file.", cmd);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// //if (joinMap.Joins.ContainsKey(cmd))
|
||||||
|
// //{
|
||||||
|
// // Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'",
|
||||||
|
// // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //Debug.Console(0, this, "_port.IrFileCommand: {0}", irFileCommand);
|
||||||
|
// //var joinData = joinMap.Joins.FirstOrDefault(j => j.Key == cmd);
|
||||||
|
|
||||||
|
// //if (joinData.Value == null) continue;
|
||||||
|
|
||||||
|
// //joinData.Value.SetJoinOffset(joinStart);
|
||||||
|
|
||||||
|
// //Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'",
|
||||||
|
// // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description);
|
||||||
|
|
||||||
|
// //joinMap.Joins.Add(joinData.Key, joinData.Value);
|
||||||
|
|
||||||
|
// //trilist.SetBoolSigAction(joinData.Value.JoinNumber, (b) => Press(joinData.Key, b));
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands");
|
Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands");
|
||||||
|
|
||||||
|
joinMap.Joins.Clear();
|
||||||
|
|
||||||
for (uint i = 0; i < _port.IrFileCommands.Length; i++)
|
for (uint i = 0; i < _port.IrFileCommands.Length; i++)
|
||||||
{
|
{
|
||||||
var cmd = _port.IrFileCommands[i];
|
var cmd = _port.IrFileCommands[i];
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
||||||
|
UseBridgeJoinMap = config.Properties["control"].Value<bool>("useBridgeJoinMap");
|
||||||
AddPostActivationAction(() =>
|
AddPostActivationAction(() =>
|
||||||
{
|
{
|
||||||
IrPort = postActivationFunc(config);
|
IrPort = postActivationFunc(config);
|
||||||
|
|
||||||
if (IrPort == null)
|
if (IrPort == null)
|
||||||
{
|
{
|
||||||
@@ -65,14 +66,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UseBridgeJoinMap = config.Properties["control"]["useBridgeJoinMap"].Value<bool>();
|
|
||||||
|
|
||||||
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
||||||
Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath);
|
Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath);
|
||||||
|
|
||||||
LoadDriver(filePath);
|
LoadDriver(filePath);
|
||||||
|
|
||||||
PrintAvailableCommands();
|
if(!UseBridgeJoinMap) PrintAvailableCommands();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user