From be5b23e9d1551e480c3393e323d1d1e40684bf3d Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Wed, 18 Jul 2018 12:13:35 -0400 Subject: [PATCH] Qsc and EssentialsDspBridge with Functional vol, mute, and preset control...still needs more work though --- .../Bridges/Bridges.BridgeFactory.cs | 16 ++- PepperDashEssentials/Bridges/EssentialDsp.cs | 116 ++++++++++++++++++ .../PepperDashEssentials.csproj | 1 + essentials-framework | 2 +- 4 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 PepperDashEssentials/Bridges/EssentialDsp.cs diff --git a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs index d84e30ee..7d6ec88d 100644 --- a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs @@ -28,14 +28,20 @@ namespace PepperDash.Essentials { var groupName = dc.Group.ToLower(); Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); - if (typeName == "essentialdm") { + if (typeName == "essentialdm") + { return new EssentialDM(key, name, properties); - } else if (typeName == "essentialcomm") { - + } + else if (typeName == "essentialcomm") + { Debug.Console(0, "Launch Essential Comm"); return new EssentialComm(key, name, properties); - - } + } + else if (typeName == "essentialdsp") + { + Debug.Console(0, "Launch EssentialDsp"); + return new EssentialDsp(key, name, properties); + } return null; } } diff --git a/PepperDashEssentials/Bridges/EssentialDsp.cs b/PepperDashEssentials/Bridges/EssentialDsp.cs new file mode 100644 index 00000000..b0946bcf --- /dev/null +++ b/PepperDashEssentials/Bridges/EssentialDsp.cs @@ -0,0 +1,116 @@ +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++; + + } + + } + } + + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(2, "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 TxOnlineStatus; + public Dictionary RxOnlineStatus; + public Dictionary TxVideoSyncStatus; + public Dictionary InputNames; + public Dictionary OutputNames; + public Dictionary OutputRouteNames; + + public EssentialDspApiMap() { + channelMuteToggle = new Dictionary(); + channelVolume = new Dictionary(); + for (uint x = 1; x <= 100; x++) { + uint tempNum = x; + + channelMuteToggle[tempNum] = (ushort)(tempNum + 400); + channelVolume[tempNum] = (ushort)(tempNum + 200); + + } + } + } + } + \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 347b89c0..4c007252 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -106,6 +106,7 @@ + diff --git a/essentials-framework b/essentials-framework index 13a51fcb..7ff3263f 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit 13a51fcbf6466dede91bf7cc66184a557ba98996 +Subproject commit 7ff3263f37b9dc74b61f9aa8b385532573afb528