Expanded the event to include RoutingPorts

Triggers for events are now based on FeedbackMatchObject
This commit is contained in:
Trevor Payne
2020-11-04 13:32:28 -06:00
parent e27c041256
commit e879aba801
17 changed files with 796 additions and 440 deletions

View File

@@ -17,8 +17,8 @@ namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking
/// </summary>
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking
{
public event SourceInfoChangeHandler CurrentSourceChange;
@@ -258,13 +258,14 @@ namespace PepperDash.Essentials.Core
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]);
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]);
volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]);
}
}
}
}
/// <summary>
///
/// </summary>
public abstract class TwoWayDisplayBase : DisplayBase
/// </summary>
public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback
{
public StringFeedback CurrentInputFeedback { get; private set; }
@@ -293,7 +294,20 @@ namespace PepperDash.Essentials.Core
Feedbacks.Add(CurrentInputFeedback);
}
}
public event EventHandler<RoutingNumericEventArgs> NumericSwitchChange;
/// <summary>
/// Raise an event when the status of a switch object changes.
/// </summary>
/// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param>
protected void OnSwitchChange(RoutingNumericEventArgs e)
{
var newEvent = NumericSwitchChange;
if (newEvent != null) newEvent(this, e);
}
}
}

View File

@@ -115,14 +115,14 @@ namespace PepperDash.Essentials.Core
/// <summary>
/// Defines an IRmcRouting with a feedback event
/// </summary>
public interface ITxRoutingWithFeedback : ITxRouting, IRoutingNumericFeedback
public interface ITxRoutingWithFeedback : ITxRouting
{
}
/// <summary>
/// Defines an IRmcRouting with a feedback event
/// </summary>
public interface IRmcRoutingWithFeedback : IRmcRouting, IRoutingNumericFeedback
public interface IRmcRoutingWithFeedback : IRmcRouting
{
}
@@ -136,45 +136,62 @@ namespace PepperDash.Essentials.Core
/// <summary>
/// Defines an event structure for reporting output route data
/// </summary>
public interface IRoutingNumericFeedback : IKeyName
public interface IRoutingFeedback : IKeyName
{
event EventHandler NumericSwitchChange;
event EventHandler<RoutingNumericEventArgs> NumericSwitchChange;
//void OnSwitchChange(RoutingNumericEventArgs e);
}
/// <summary>
/// Defines an IRoutingNumeric with a feedback event
/// </summary>
public interface IRoutingNumericWithFeedback : IRoutingNumeric, IRoutingNumericFeedback
public interface IRoutingNumericWithFeedback : IRoutingNumeric, IRoutingFeedback
{
}
/// <summary>
/// Defines an IRouting with a feedback event
/// </summary>
public interface IRoutingWithFeedback : IRouting, IRoutingFeedback
{
}
public class RoutingNumericEventArgs : EventArgs
{
private readonly uint _output;
private readonly uint _input;
private readonly eRoutingSignalType _sigType;
public uint Output
public uint? Output { get; set; }
public uint? Input { get; set; }
public eRoutingSignalType SigType { get; set; }
public RoutingInputPort InputPort { get; set; }
public RoutingOutputPort OutputPort { get; set; }
public RoutingNumericEventArgs(uint output, uint input, eRoutingSignalType sigType) : this(output, input, null, null, sigType)
{
get { return _output; }
}
public uint Input
public RoutingNumericEventArgs(RoutingOutputPort outputPort, RoutingInputPort inputPort,
eRoutingSignalType sigType)
: this(null, null, outputPort, inputPort, sigType)
{
get { return _input; }
}
public eRoutingSignalType SigType
public RoutingNumericEventArgs()
: this(null, null, null, null, 0)
{
get { return _sigType; }
}
public RoutingNumericEventArgs(uint output, uint input, eRoutingSignalType sigType)
public RoutingNumericEventArgs(uint? output, uint? input, RoutingOutputPort outputPort,
RoutingInputPort inputPort, eRoutingSignalType sigType)
{
_output = output;
_input = input;
_sigType = sigType;
OutputPort = outputPort;
InputPort = inputPort;
Output = output;
Input = input;
SigType = sigType;
}
}
}