From ef443bdfb07e9d62c472639f837ec9a0e00b0901 Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Fri, 10 Aug 2018 12:29:15 -0400 Subject: [PATCH] Created a device for TVOneCorio with online status and preset recall/FB Created a temp bridge for EiscApi --- .../Bridges/Bridges.BridgeFactory.cs | 153 +++++----- PepperDashEssentials/Bridges/EssentialDM.cs | 274 +++++++++--------- .../Bridges/EssentialTVOne.cs | 98 +++++++ .../PepperDashEssentials.csproj | 1 + essentials-framework | 2 +- 5 files changed, 316 insertions(+), 212 deletions(-) create mode 100644 PepperDashEssentials/Bridges/EssentialTVOne.cs diff --git a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs index 7d6ec88d..c09eb700 100644 --- a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs @@ -1,75 +1,80 @@ -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.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; - -namespace PepperDash.Essentials { - public class BridgeFactory { - public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { - // ? why is this static JTA 2018-06-13? - - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - var propAnon = new { }; - JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon); - - var typeName = dc.Type.ToLower(); - var groupName = dc.Group.ToLower(); - - Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); - if (typeName == "essentialdm") - { - return new EssentialDM(key, name, properties); - } - 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; - } - } - public class BridgeApiEisc { - public uint Ipid; - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc; - public BridgeApiEisc(string ipid) { - Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem); - Eisc.Register(); - Eisc.SigChange += Eisc_SigChange; - Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); - } - void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { - if (Debug.Level >= 1) - Debug.Console(2, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); - } - } - - } - - - +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.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; + +namespace PepperDash.Essentials { + public class BridgeFactory { + public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { + // ? why is this static JTA 2018-06-13? + + var key = dc.Key; + var name = dc.Name; + var type = dc.Type; + var properties = dc.Properties; + var propAnon = new { }; + JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon); + + var typeName = dc.Type.ToLower(); + var groupName = dc.Group.ToLower(); + + Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); + if (typeName == "essentialdm") + { + return new EssentialDM(key, name, properties); + } + 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); + } + else if (typeName == "essentialstvone") + { + Debug.Console(0, "Launch essentialstvone"); + return new EssentialsTVOne(key, name, properties); + } + return null; + } + } + public class BridgeApiEisc { + public uint Ipid; + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc; + public BridgeApiEisc(string ipid) { + Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); + Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem); + Eisc.Register(); + Eisc.SigChange += Eisc_SigChange; + Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); + } + void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { + if (Debug.Level >= 1) + Debug.Console(2, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } + } + + } + + + \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EssentialDM.cs b/PepperDashEssentials/Bridges/EssentialDM.cs index a5cd2aec..48f204e5 100644 --- a/PepperDashEssentials/Bridges/EssentialDM.cs +++ b/PepperDashEssentials/Bridges/EssentialDM.cs @@ -1,140 +1,140 @@ -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 EssentialDM : PepperDash.Core.Device { - public EssentialDMProperties Properties; - public List BridgeApiEiscs; - private PepperDash.Essentials.DM.DmChassisController DmSwitch; - private EssentialDMApiMap ApiMap = new EssentialDMApiMap(); - public EssentialDM(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); - DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController; - - } - - - else { - Debug.Console(2, "deviceKey {0} doesn't match", device.Key); - } - } - if (Properties.EiscApiIpids != null) { - - - foreach (string Ipid in Properties.EiscApiIpids) { - var ApiEisc = new BridgeApiEisc(Ipid); - for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) { - uint tempX = x; - Debug.Console(2, "Creating EiscActions {0}", tempX); - - - ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video)); +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 EssentialDM : PepperDash.Core.Device { + public EssentialDMProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.DM.DmChassisController DmSwitch; + private EssentialDMApiMap ApiMap = new EssentialDMApiMap(); + public EssentialDM(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); + DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController; + + } + + + else { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + } + } + if (Properties.EiscApiIpids != null) { + + + foreach (string Ipid in Properties.EiscApiIpids) { + var ApiEisc = new BridgeApiEisc(Ipid); + for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) { + uint tempX = x; + Debug.Console(2, "Creating EiscActions {0}", tempX); + + + ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video)); ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputAudioRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Audio)); - if (DmSwitch.TxDictionary.ContainsKey(tempX)) { - Debug.Console(2, "Creating Tx Feedbacks {0}", tempX); - var TxKey = DmSwitch.TxDictionary[tempX]; - var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; - TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]); - TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); - ApiEisc.Eisc.SetUShortSigAction(901, u => TxDevice.SetHdcpSupport((eHdcpSupportMode)(u))); - } else { - DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); - } - if (DmSwitch.RxDictionary.ContainsKey(tempX)) { - Debug.Console(2, "Creating Rx Feedbacks {0}", tempX); - var RxKey = DmSwitch.RxDictionary[tempX]; - var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; - RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]); - } - // DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]); - DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]); - DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]); - DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]); - DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]); - DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]); - } - DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]); - ApiEisc.Eisc.Register(); - } - } - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(2, "BRidge {0}", e); - return false; - } - } - } - public class EssentialDMProperties { - public string connectionDeviceKey; - public string[] EiscApiIpids; - - - } - - - public class EssentialDMApiMap { - public ushort ChassisOnline = 11; - public Dictionary OutputVideoRoutes; - public Dictionary OutputAudioRoutes; - public Dictionary TxOnlineStatus; - public Dictionary RxOnlineStatus; - public Dictionary TxVideoSyncStatus; - public Dictionary InputNames; - public Dictionary OutputNames; - public Dictionary OutputRouteNames; - - public EssentialDMApiMap() { - OutputVideoRoutes = new Dictionary(); - OutputAudioRoutes = new Dictionary(); - TxOnlineStatus = new Dictionary(); - RxOnlineStatus = new Dictionary(); - TxVideoSyncStatus = new Dictionary(); - InputNames = new Dictionary(); - OutputNames = new Dictionary(); - OutputRouteNames = new Dictionary(); - for (uint x = 1; x <= 200; x++) { - // Debug.Console(0, "Init Value {0}", x); - uint tempNum = x; - - OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100); - OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300); - TxOnlineStatus[tempNum] = (ushort)(tempNum + 500); - RxOnlineStatus[tempNum] = (ushort)(tempNum + 700); - TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100); - InputNames[tempNum] = (ushort)(tempNum + 100); - OutputNames[tempNum] = (ushort)(tempNum + 300); - OutputRouteNames[tempNum] = (ushort)(tempNum + 2000); - } - } - } - } + if (DmSwitch.TxDictionary.ContainsKey(tempX)) { + Debug.Console(2, "Creating Tx Feedbacks {0}", tempX); + var TxKey = DmSwitch.TxDictionary[tempX]; + var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; + TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]); + TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); + ApiEisc.Eisc.SetUShortSigAction(901, u => TxDevice.SetHdcpSupport((eHdcpSupportMode)(u))); + } else { + DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); + } + if (DmSwitch.RxDictionary.ContainsKey(tempX)) { + Debug.Console(2, "Creating Rx Feedbacks {0}", tempX); + var RxKey = DmSwitch.RxDictionary[tempX]; + var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; + RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]); + } + // DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]); + DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]); + DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]); + DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]); + DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]); + DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]); + } + DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]); + ApiEisc.Eisc.Register(); + } + } + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(2, "BRidge {0}", e); + return false; + } + } + } + public class EssentialDMProperties { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialDMApiMap { + public ushort ChassisOnline = 11; + public Dictionary OutputVideoRoutes; + public Dictionary OutputAudioRoutes; + public Dictionary TxOnlineStatus; + public Dictionary RxOnlineStatus; + public Dictionary TxVideoSyncStatus; + public Dictionary InputNames; + public Dictionary OutputNames; + public Dictionary OutputRouteNames; + + public EssentialDMApiMap() { + OutputVideoRoutes = new Dictionary(); + OutputAudioRoutes = new Dictionary(); + TxOnlineStatus = new Dictionary(); + RxOnlineStatus = new Dictionary(); + TxVideoSyncStatus = new Dictionary(); + InputNames = new Dictionary(); + OutputNames = new Dictionary(); + OutputRouteNames = new Dictionary(); + for (uint x = 1; x <= 200; x++) { + // Debug.Console(0, "Init Value {0}", x); + uint tempNum = x; + + OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100); + OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300); + TxOnlineStatus[tempNum] = (ushort)(tempNum + 500); + RxOnlineStatus[tempNum] = (ushort)(tempNum + 700); + TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100); + InputNames[tempNum] = (ushort)(tempNum + 100); + OutputNames[tempNum] = (ushort)(tempNum + 300); + OutputRouteNames[tempNum] = (ushort)(tempNum + 2000); + } + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EssentialTVOne.cs b/PepperDashEssentials/Bridges/EssentialTVOne.cs new file mode 100644 index 00000000..be2db474 --- /dev/null +++ b/PepperDashEssentials/Bridges/EssentialTVOne.cs @@ -0,0 +1,98 @@ +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 EssentialsTVOne : PepperDash.Core.Device + { + public EssentialTVOneProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.Devices.Common.TVOneCorio TVOneCorio; + private EssentialsTVOneApiMap ApiMap = new EssentialsTVOneApiMap(); + public EssentialsTVOne(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); + TVOneCorio = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.TVOneCorio; + break; + } + else + { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + + } + } + if (Properties.EiscApiIpids != null && TVOneCorio != null) + { + foreach (string Ipid in Properties.EiscApiIpids) + { + var ApiEisc = new BridgeApiEisc(Ipid); + Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name); + ushort x = 1; + TVOneCorio.OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); + ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => TVOneCorio.CallPreset(u)); + TVOneCorio.PresetFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.PresetFeedback]); + + } + } + + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(2, "BRidge {0}", e); + return false; + } + } + } + public class EssentialTVOneProperties + { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialsTVOneApiMap + { + public ushort CallPreset = 1; + public ushort PresetFeedback = 1; + public ushort Online = 1; + + public EssentialsTVOneApiMap() + { + + + } + + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 4c007252..df730319 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -106,6 +106,7 @@ + diff --git a/essentials-framework b/essentials-framework index c9d5cc34..69bb8bca 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit c9d5cc34a1ce5e2031a6a52f25a08dbd685c0f21 +Subproject commit 69bb8bcabd299e0491b1459e9d4e9b31417a4c49