diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs index 3fac2cf7..bd6893ee 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs @@ -1,15 +1,17 @@ using System; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using PepperDash.Core; using PepperDash.Essentials.Core; namespace PepperDash_Essentials_DM.Chassis { - public class HdPsXxxAnalogAuxMixerController : IKeyed, IBasicVolumeWithFeedback + public class HdPsXxxAnalogAuxMixerController : IKeyed, + IHasVolumeControlWithFeedback, IHasMuteControlWithFeedback // || IBasicVolumeWithFeedback { public string Key { get; private set; } - public HdPsXxxAnalogAuxMixer Mixer { get; set; } + public HdPsXxxAnalogAuxMixer Mixer { get; private set; } public HdPsXxxAnalogAuxMixerController(string parent, uint mixer, HdPsXxx chassis) { @@ -17,10 +19,17 @@ namespace PepperDash_Essentials_DM.Chassis Mixer = chassis.AnalogAuxiliaryMixer[mixer]; + Mixer.AuxMixerPropertyChange += OnAuxMixerPropertyChange; + VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc); MuteFeedback = new BoolFeedback(MuteFeedbackFunc); } + private void OnAuxMixerPropertyChange(object sender, GenericEventArgs args) + { + Debug.Console(2, this, "AuxMixerPropertyChange: {0} > Index-{1}, EventId-{2}", sender.ToString(), args.Index, args.EventId); + } + #region Volume public IntFeedback VolumeLevelFeedback { get; private set; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 1cece4e4..a4bef385 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -83,10 +83,15 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - foreach (var mixer in _chassis.AnalogAuxiliaryMixer) + foreach (var item in _chassis.HdmiDmLiteOutputs) { - var mixerDevice = new HdPsXxxAnalogAuxMixerController(Key, mixer.MixerNumber, _chassis); - DeviceManager.AddDevice(mixerDevice); + var audioDevice = new HdPsXxxOutputAudioController(Key, item.Number, _chassis); + DeviceManager.AddDevice(audioDevice); + } + foreach (var item in _chassis.AnalogAuxiliaryMixer) + { + var audioDevice = new HdPsXxxAnalogAuxMixerController(Key, item.MixerNumber, _chassis); + DeviceManager.AddDevice(audioDevice); } } @@ -180,7 +185,7 @@ namespace PepperDash_Essentials_DM.Chassis var output = item; var index = item.Number; var name = string.IsNullOrEmpty(OutputNames[index]) - ? string.Format("Output {0}", index) + ? string.Format("Port {0}", index) : OutputNames[index]; output.Name.StringValue = name; @@ -191,7 +196,7 @@ namespace PepperDash_Essentials_DM.Chassis FeedbackMatchObject = output, Port = output.HdmiOutput.HdmiOutputPort }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, name); + Debug.Console(1, this, "Adding Port port: {0} - {1}", hdmiPort.Key, name); OutputPorts.Add(hdmiPort); var dmLiteKey = string.Format("dmLiteOut{0}", index); @@ -200,7 +205,7 @@ namespace PepperDash_Essentials_DM.Chassis FeedbackMatchObject = output, Port = output.DmLiteOutput.DmLiteOutputPort }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, name); + Debug.Console(1, this, "Adding Port port: {0} - {1}", dmLitePort.Key, name); OutputPorts.Add(dmLitePort); OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), @@ -237,7 +242,7 @@ Selector: {4} foreach (var port in OutputPorts) { - Debug.Console(0, this, @"Output Port Key: {0} + Debug.Console(0, this, @"Port Port Key: {0} Port: {1} Type: {2} ConnectionType: {3} diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs new file mode 100644 index 00000000..9716ba1e --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs @@ -0,0 +1,99 @@ +using System; +using Crestron.SimplSharpPro.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_DM.Chassis +{ + public class HdPsXxxOutputAudioController : IKeyed, + IHasVolumeControlWithFeedback, IHasMuteControlWithFeedback // || IBasicVolumeWithFeedback + { + public string Key { get; private set; } + + public HdPsXxxOutputPort Port { get; private set; } + + public HdPsXxxOutputAudioController(string parent, uint output, HdPsXxx chassis) + { + Key = string.Format("{0}-audioOut{1}", parent, output); + + Port = chassis.HdmiDmLiteOutputs[output].OutputPort; + + VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc); + MuteFeedback = new BoolFeedback(MuteFeedbackFunc); + } + + #region Volume + + public IntFeedback VolumeLevelFeedback { get; private set; } + + protected Func VolumeFeedbackFunc + { + get { return () => Port.AudioOutput.VolumeFeedback.UShortValue; } + } + + public void SetVolume(ushort level) + { + Port.AudioOutput.Volume.UShortValue = level; + } + + public void VolumeUp(bool pressRelease) + { + if (pressRelease) + { + var remainingRatio = (65535 - Port.AudioOutput.Volume.UShortValue)/65535; + Port.AudioOutput.Volume.CreateRamp(65535, 400); + } + else + { + Port.AudioOutput.Volume.StopRamp(); + } + } + + public void VolumeDown(bool pressRelease) + { + if (pressRelease) + { + var remainingRatio = Port.AudioOutput.Volume.UShortValue/65535; + Port.AudioOutput.Volume.CreateRamp(0, (uint)(400 * remainingRatio)); + } + else + { + Port.AudioOutput.Volume.StopRamp(); + } + } + + #endregion + + + #region Mute + + private bool _isMuted; + + public BoolFeedback MuteFeedback { get; private set; } + + protected Func MuteFeedbackFunc + { + get { return () => _isMuted = Port.MuteOnFeedback.BoolValue; } + } + + public void MuteOn() + { + Port.MuteOn(); + } + + public void MuteOff() + { + Port.MuteOff(); + } + + public void MuteToggle() + { + if (_isMuted) + MuteOff(); + else + MuteOn(); + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index 5840945f..41136d0d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -106,6 +106,7 @@ +