From 172e2fb7445e66afa07b49954a4ee1c7ad734b90 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 28 Aug 2019 11:45:03 -0600 Subject: [PATCH] Adds feedbacks to DmpsAudioOutputController --- .../Chassis/DmpsAudioOutputController.cs | 84 +++++++++++++++++-- .../Essentials_DM/Essentials_DM.csproj | 1 + 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs index 1fd909e6..a10c73b2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs @@ -15,9 +15,12 @@ using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM { - public class DmpsAudioOutputController : Device, IHasFeedback + /// + /// Exposes the volume levels for Program, Aux1 or Aux2 outputs on a DMPS3 chassis + /// + public class DmpsAudioOutputController : Device { - Card.Dmps3OutputBase Card; + Card.Dmps3OutputBase OutputCard; public DmpsAudioOutput MasterVolumeLevel { get; private set; } public DmpsAudioOutput SourceVolumeLevel { get; private set; } @@ -28,25 +31,73 @@ namespace PepperDash.Essentials.DM public DmpsAudioOutputController(string key, string name, Card.Dmps3OutputBase card) : base(key, name) { - Card = card; + OutputCard = card; + + OutputCard.BaseDevice.DMOutputChange += new DMOutputEventHandler(BaseDevice_DMOutputChange); MasterVolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Master); SourceVolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Source); if (card is Card.Dmps3ProgramOutput) + { + Codec1VolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Codec1); + Codec2VolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Codec2); + } + else if (card is Card.Dmps3Aux1Output) + { + Codec2VolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Codec2); + } + else if (card is Card.Dmps3Aux2Output) { Codec1VolumeLevel = new DmpsAudioOutput(card, eDmpsLevelType.Codec1); } } - #region IHasFeedback Members - - public FeedbackCollection Feedbacks + void BaseDevice_DMOutputChange(Switch device, DMOutputEventArgs args) { - get { throw new NotImplementedException(); } + switch (args.EventId) + { + case DMOutputEventIds.MasterVolumeFeedBackEventId: + { + MasterVolumeLevel.VolumeLevelFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.MasterMuteOnFeedBackEventId: + { + MasterVolumeLevel.MuteFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.SourceLevelFeedBackEventId: + { + SourceVolumeLevel.VolumeLevelFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.Codec1LevelFeedBackEventId: + { + if(Codec1VolumeLevel != null) + Codec1VolumeLevel.VolumeLevelFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.Codec1MuteOnFeedBackEventId: + { + if (Codec1VolumeLevel != null) + Codec1VolumeLevel.MuteFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.Codec2LevelFeedBackEventId: + { + if (Codec2VolumeLevel != null) + Codec2VolumeLevel.VolumeLevelFeedback.FireUpdate(); + break; + } + case DMOutputEventIds.Codec2MuteOnFeedBackEventId: + { + if (Codec2VolumeLevel != null) + Codec2VolumeLevel.MuteFeedback.FireUpdate(); + break; + } + } } - - #endregion } public class DmpsAudioOutput : IBasicVolumeWithFeedback @@ -81,6 +132,21 @@ namespace PepperDash.Essentials.DM MuteOffAction = new Action(Output.MasterMuteOff); VolumeUpAction = new Action((b) => Output.MasterVolumeUp.BoolValue = b); VolumeDownAction = new Action((b) => Output.MasterVolumeDown.BoolValue = b); + + + break; + } + case eDmpsLevelType.MicsMaster: + { + Level = output.MicMasterLevel; + + MuteFeedback = new BoolFeedback(new Func(() => Output.MicMasterMuteOnFeedBack.BoolValue)); + VolumeLevelFeedback = new IntFeedback(new Func(() => Output.MicMasterLevelFeedBack.UShortValue)); + MuteOnAction = new Action(Output.MicMasterMuteOn); + MuteOffAction = new Action(Output.MicMasterMuteOff); + VolumeUpAction = new Action((b) => Output.MicMasterLevelUp.BoolValue = b); + VolumeDownAction = new Action((b) => Output.MicMasterLevelDown.BoolValue = b); + break; } case eDmpsLevelType.Source: diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj index f266c842..4bdf5174 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -97,6 +97,7 @@ +