diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs new file mode 100644 index 00000000..3fac2cf7 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs @@ -0,0 +1,98 @@ +using System; +using Crestron.SimplSharpPro.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_DM.Chassis +{ + public class HdPsXxxAnalogAuxMixerController : IKeyed, IBasicVolumeWithFeedback + { + public string Key { get; private set; } + + public HdPsXxxAnalogAuxMixer Mixer { get; set; } + + public HdPsXxxAnalogAuxMixerController(string parent, uint mixer, HdPsXxx chassis) + { + Key = string.Format("{0}-analogMixer{1}", parent, mixer); + + Mixer = chassis.AnalogAuxiliaryMixer[mixer]; + + VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc); + MuteFeedback = new BoolFeedback(MuteFeedbackFunc); + } + + #region Volume + + public IntFeedback VolumeLevelFeedback { get; private set; } + + protected Func VolumeFeedbackFunc + { + get { return () => Mixer.VolumeFeedback.UShortValue; } + } + + public void SetVolume(ushort level) + { + Mixer.Volume.UShortValue = level; + } + + public void VolumeUp(bool pressRelease) + { + if (pressRelease) + { + var remainingRatio = (65535 - Mixer.Volume.UShortValue)/65535; + Mixer.Volume.CreateRamp(65535, 400); + } + else + { + Mixer.Volume.StopRamp(); + } + } + + public void VolumeDown(bool pressRelease) + { + if (pressRelease) + { + var remainingRatio = Mixer.Volume.UShortValue/65535; + Mixer.Volume.CreateRamp(0, (uint)(400 * remainingRatio)); + } + else + { + Mixer.Volume.StopRamp(); + } + } + + #endregion + + + #region Mute + + private bool _isMuted; + + public BoolFeedback MuteFeedback { get; private set; } + + protected Func MuteFeedbackFunc + { + get { return () => _isMuted = Mixer.AuxiliaryMuteControl.MuteOnFeedback.BoolValue; } + } + + public void MuteOn() + { + Mixer.AuxiliaryMuteControl.MuteOn(); + } + + public void MuteOff() + { + Mixer.AuxiliaryMuteControl.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/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 9a2a17f4..1cece4e4 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Runtime.InteropServices; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; @@ -17,11 +16,9 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IRoutingHasVideoInputSyncFeedbacks, IHasVolumeControlWithFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IRoutingHasVideoInputSyncFeedbacks { private readonly HdPsXxx _chassis; - private readonly string _defaultAudioKey = ""; - public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -86,8 +83,11 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - if (!string.IsNullOrEmpty(props.DefaultAudioKey)) - _defaultAudioKey = props.DefaultAudioKey; + foreach (var mixer in _chassis.AnalogAuxiliaryMixer) + { + var mixerDevice = new HdPsXxxAnalogAuxMixerController(Key, mixer.MixerNumber, _chassis); + DeviceManager.AddDevice(mixerDevice); + } } // get input priorities @@ -208,14 +208,13 @@ namespace PepperDash_Essentials_DM.Chassis VideoOutputRouteFeedbacks.Add(new IntFeedback(index.ToString(CultureInfo.InvariantCulture), () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + } - var audioKey = string.Format("audioOut{0}", index); - var audioPort = new RoutingOutputPort(audioKey, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - output, this) - { - FeedbackMatchObject = output, - Port = output.OutputPort.AudioOutput; - }; + Debug.Console(0, this, "----> AnalogAuxillaryMixer.Count-{0}", _chassis.AnalogAuxiliaryMixer.Count); + foreach (var item in _chassis.AnalogAuxiliaryMixer) + { + Debug.Console(0, this, "----> AnalogAuxillaryMixer[{0}].LineMuteVolumeControl.Count-{1}", item.MixerNumber, item.LineMuteVolumeControl.Count); + Debug.Console(0, this, "----> AnalogAuxillaryMixer[{0}].SourceMuteVolumeControl.Count-{1}", item.MixerNumber, item.SourceMuteVolumeControl.Count); } _chassis.DMOutputChange += _chassis_OutputChange; @@ -427,29 +426,6 @@ Selector: {4} _chassis.AutoRouteOff(); } - #region IHasVolumeWithFeedback Members - - public void VolumeUp(bool pressRelease) - { - - } - - public void VolumeDown(bool pressRelease) - { - throw new NotImplementedException(); - } - - public void SetVolume(ushort level) - { - throw new NotImplementedException(); - } - - public IntFeedback VolumeLevelFeedback { get; private set; } - - - - #endregion - #region Events @@ -564,7 +540,7 @@ Selector: {4} { public HdSp401ControllerFactory() { - TypeNames = new List() { "hdps401", "hdps402", "hdps621", "hdps622" }; + TypeNames = new List { "hdps401", "hdps402", "hdps621", "hdps622" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs index 9b988dd1..f5eb9d39 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs @@ -15,8 +15,8 @@ namespace PepperDash_Essentials_DM.Config [JsonProperty("outputs")] public Dictionary Outputs { get; set; } - [JsonProperty("defaultAudioKey")] - public string DefaultAudioKey { get; set; } + [JsonProperty("volumeMixerId")] + public uint VolumeMixerId { get; set; } // "inputPriorities": "1,4,3,2" [JsonProperty("inputPriorities")] 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 0011c305..5840945f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -104,6 +104,7 @@ +