Fixes multiple issues

closes #474
closes #473
closes #470
This commit is contained in:
Neil Dorin
2020-11-09 15:14:47 -07:00
parent ad0cbba0b1
commit f5753109d5
7 changed files with 785 additions and 735 deletions

View File

@@ -14,16 +14,23 @@ using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// Defines the ability to power a device on and off
/// </summary>
public interface IPower
{
void PowerOn();
void PowerOff();
void PowerToggle();
BoolFeedback PowerIsOnFeedback { get; }
}
/// <summary>
/// Adds feedback for current power state
/// </summary>
public interface IPowerWithFeedback : IPower
{
BoolFeedback PowerIsOnFeedback { get; }
}
/// <summary>
///
/// </summary>
@@ -34,7 +41,12 @@ namespace PepperDash.Essentials.Core
triList.SetSigFalseAction(101, dev.PowerOn);
triList.SetSigFalseAction(102, dev.PowerOff);
triList.SetSigFalseAction(103, dev.PowerToggle);
dev.PowerIsOnFeedback.LinkInputSig(triList.BooleanInput[101]);
var fbdev = dev as IPowerWithFeedback;
if (fbdev != null)
{
fbdev.PowerIsOnFeedback.LinkInputSig(triList.BooleanInput[101]);
}
}
public static void UnlinkButtons(this IPower dev, BasicTriList triList)
@@ -42,7 +54,12 @@ namespace PepperDash.Essentials.Core
triList.ClearBoolSigAction(101);
triList.ClearBoolSigAction(102);
triList.ClearBoolSigAction(103);
dev.PowerIsOnFeedback.UnlinkInputSig(triList.BooleanInput[101]);
var fbdev = dev as IPowerWithFeedback;
if (fbdev != null)
{
fbdev.PowerIsOnFeedback.UnlinkInputSig(triList.BooleanInput[101]);
}
}
}
}