From 759635b36454dd75f12af529d0243163df6e711d Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Fri, 24 Aug 2018 14:12:53 -0400 Subject: [PATCH] WHAR-1436 - Add Vol control up/down buttons on the user page --- PepperDashEssentials/Bridges/EssentialDsp.cs | 254 ++++++++++--------- essentials-framework | 2 +- 2 files changed, 137 insertions(+), 119 deletions(-) diff --git a/PepperDashEssentials/Bridges/EssentialDsp.cs b/PepperDashEssentials/Bridges/EssentialDsp.cs index 34703410..700e0e9f 100644 --- a/PepperDashEssentials/Bridges/EssentialDsp.cs +++ b/PepperDashEssentials/Bridges/EssentialDsp.cs @@ -1,119 +1,137 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials { - public class EssentialDsp : PepperDash.Core.Device { - public EssentialDspProperties Properties; - public List BridgeApiEiscs; - private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp; - private EssentialDspApiMap ApiMap = new EssentialDspApiMap(); - public EssentialDsp(string key, string name, JToken properties) - : base(key, name) { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - - - } - public override bool CustomActivate() { - // Create EiscApis - try - { - foreach (var device in DeviceManager.AllDevices) - { - if (device.Key == this.Properties.connectionDeviceKey) - { - Debug.Console(2, "deviceKey {0} Matches", device.Key); - Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp; - break; - } - else - { - Debug.Console(2, "deviceKey {0} doesn't match", device.Key); - - } - } - if (Properties.EiscApiIpids != null && Dsp != null) - { - foreach (string Ipid in Properties.EiscApiIpids) - { - var ApiEisc = new BridgeApiEisc(Ipid); - Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name); - ushort x = 1; - foreach (var channel in Dsp.LevelControlPoints) - { - //var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl; - Debug.Console(2, "QscChannel {0} connect", x); - - var QscChannel = channel.Value as IBasicVolumeWithFeedback; - QscChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]); - QscChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => QscChannel.MuteToggle()); - ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => QscChannel.SetVolume(u)); - ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s)); - x++; - - } - x = 1; - foreach (var preset in Dsp.PresetList) - { - ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label; - ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x)); - x++; - } - - } - } - - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(0, "Bridge {0}", e); - return false; - } - } - } - public class EssentialDspProperties { - public string connectionDeviceKey; - public string[] EiscApiIpids; - - - } - - - public class EssentialDspApiMap { - public ushort presetString = 2000; - public Dictionary channelMuteToggle; - public Dictionary channelVolume; - public Dictionary presets; - - public EssentialDspApiMap() { - channelMuteToggle = new Dictionary(); - channelVolume = new Dictionary(); - presets = new Dictionary(); - for (uint x = 1; x <= 100; x++) { - uint tempNum = x; - presets[tempNum] = (ushort)(tempNum + 100); - channelMuteToggle[tempNum] = (ushort)(tempNum + 400); - channelVolume[tempNum] = (ushort)(tempNum + 200); - - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using Crestron.SimplSharpPro.DM; + +namespace PepperDash.Essentials { + public class EssentialDsp : PepperDash.Core.Device { + public EssentialDspProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp; + private EssentialDspApiMap ApiMap = new EssentialDspApiMap(); + public EssentialDsp(string key, string name, JToken properties) + : base(key, name) { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + + + } + public override bool CustomActivate() { + // Create EiscApis + try + { + foreach (var device in DeviceManager.AllDevices) + { + if (device.Key == this.Properties.connectionDeviceKey) + { + Debug.Console(2, "deviceKey {0} Matches", device.Key); + Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp; + break; + } + else + { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + + } + } + if (Properties.EiscApiIpids != null && Dsp != null) + { + foreach (string Ipid in Properties.EiscApiIpids) + { + var ApiEisc = new BridgeApiEisc(Ipid); + Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name); + ushort x = 1; + foreach (var channel in Dsp.LevelControlPoints) + { + //var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl; + Debug.Console(2, "QscChannel {0} connect", x); + + var QscChannel = channel.Value as IBasicVolumeWithFeedback; + QscChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]); + QscChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]); + + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => QscChannel.MuteToggle()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOn[x], () => QscChannel.MuteOn()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOff[x], () => QscChannel.MuteOff()); + + ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeUp[x], b => QscChannel.VolumeUp(b)); + ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeDown[x], b => QscChannel.VolumeDown(b)); + + ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => QscChannel.SetVolume(u)); + ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s)); + x++; + + } + x = 1; + foreach (var preset in Dsp.PresetList) + { + ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label; + ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x)); + x++; + } + + } + } + + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(0, "Bridge {0}", e); + return false; + } + } + } + public class EssentialDspProperties { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialDspApiMap { + public ushort presetString = 2000; + public Dictionary channelMuteToggle; + public Dictionary channelMuteOn; + public Dictionary channelMuteOff; + public Dictionary channelVolume; + public Dictionary channelVolumeUp; + public Dictionary channelVolumeDown; + public Dictionary presets; + + public EssentialDspApiMap() { + channelMuteToggle = new Dictionary(); + channelMuteOn = new Dictionary(); + channelMuteOff = new Dictionary(); + channelVolume = new Dictionary(); + presets = new Dictionary(); + channelVolumeUp = new Dictionary(); + channelVolumeDown = new Dictionary(); + for (uint x = 1; x <= 100; x++) { + uint tempNum = x; + presets[tempNum] = (ushort)(tempNum + 100); + channelMuteToggle[tempNum] = (ushort)(tempNum + 400); + channelMuteOn[tempNum] = (ushort)(tempNum + 600); + channelMuteOff[tempNum] = (ushort)(tempNum + 800); + channelVolume[tempNum] = (ushort)(tempNum + 200); + channelVolumeUp[tempNum] = (ushort)(tempNum + 1000); + channelVolumeDown[tempNum] = (ushort)(tempNum + 1200); + } + } + } + } \ No newline at end of file diff --git a/essentials-framework b/essentials-framework index 0db23f86..5fde7251 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit 0db23f86a7c4c6e1d156ee16a350ee02d6cf384e +Subproject commit 5fde72515cb1d55c30e8589971943f2f7f344113