diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index 9cf6456f..1d2914dc 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -8,7 +8,7 @@ using Crestron.SimplSharpPro.EthernetCommunication; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Bridges; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.AppServer.Messengers diff --git a/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs b/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs index 9ee7407e..9ced28dd 100644 --- a/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs +++ b/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; -using PepperDash.Essentials.Bridges; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.AppServer.Messengers { diff --git a/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs b/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs index 6d819c7b..869c5614 100644 --- a/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs +++ b/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.DM.AirMedia; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class AirMediaControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/AppleTvBridge.cs b/PepperDashEssentials/Bridges/AppleTvBridge.cs index 99501baa..3c2bb0af 100644 --- a/PepperDashEssentials/Bridges/AppleTvBridge.cs +++ b/PepperDashEssentials/Bridges/AppleTvBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.Devices.Common; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class AppleTvApiExtensions { diff --git a/PepperDashEssentials/Bridges/BridgeFactory.cs b/PepperDashEssentials/Bridges/BridgeFactory.cs index 38cd117e..d9b34755 100644 --- a/PepperDashEssentials/Bridges/BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/BridgeFactory.cs @@ -9,7 +9,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Core; using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Bridges; +using PepperDash.Essentials.Core.Bridges; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.EthernetCommunication; diff --git a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs b/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs index 13b78bae..931ee231 100644 --- a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs +++ b/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs @@ -4,7 +4,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.CrestronIO; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class C2nRthsControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/CameraControllerBridge.cs b/PepperDashEssentials/Bridges/CameraControllerBridge.cs index 732fee2e..6a3771d3 100644 --- a/PepperDashEssentials/Bridges/CameraControllerBridge.cs +++ b/PepperDashEssentials/Bridges/CameraControllerBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.Devices.Common.Cameras; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class CameraControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs b/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs deleted file mode 100644 index 7d3fab3d..00000000 --- a/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Bridges -{ - public static class DigitalLoggerApiExtensions - { - public static void LinkToApi(this DigitalLogger DigitalLogger, BasicTriList trilist, uint joinStart, string joinMapKey) - { - DigitalLoggerJoinMap joinMap = new DigitalLoggerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, DigitalLogger, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - for (uint i = 1; i <= DigitalLogger.CircuitCount; i++) - { - var circuit = i; - DigitalLogger.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); - DigitalLogger.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); - DigitalLogger.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); - trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => DigitalLogger.CycleCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => DigitalLogger.TurnOnCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => DigitalLogger.TurnOffCircuit(circuit - 1)); - - } - } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs b/PepperDashEssentials/Bridges/DisplayControllerBridge.cs deleted file mode 100644 index c94b3691..00000000 --- a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; - -using Newtonsoft.Json; - - -namespace PepperDash.Essentials.Bridges -{ - public static class DisplayControllerApiExtensions - { - public static void LinkToApi(this PepperDash.Essentials.Core.DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) - { - int inputNumber = 0; - IntFeedback inputNumberFeedback; - List inputKeys = new List(); - - DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if(!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, "Linking to Trilist '{0}'",trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); - - trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name; - - var commMonitor = displayDevice as ICommunicationMonitor; - if (commMonitor != null) - { - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - } - - inputNumberFeedback = new IntFeedback(() => { return inputNumber; }); - - // Two way feedbacks - var twoWayDisplay = displayDevice as PepperDash.Essentials.Core.TwoWayDisplayBase; - if (twoWayDisplay != null) - { - trilist.SetBool(joinMap.IsTwoWayDisplay, true); - - twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler(CurrentInputFeedback_OutputChange); - - - inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]); - } - - // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff, () => - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOff(); - }); - - displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler( (o,a) => { - if (!a.BoolValue) - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - - } - else - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - } - }); - - displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); - - // PowerOn - trilist.SetSigTrueAction(joinMap.PowerOn, () => - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOn(); - }); - - - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); - - int count = 1; - foreach (var input in displayDevice.InputPorts) - { - inputKeys.Add(input.Key.ToString()); - var tempKey = inputKeys.ElementAt(count - 1); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector); }); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString(); - count++; - } - - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); - trilist.SetUShortSigAction(joinMap.InputSelect, (a) => - { - if (a == 0) - { - displayDevice.PowerOff(); - inputNumber = 0; - } - else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) - { - displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); - inputNumber = a; - } - else if (a == 102) - { - displayDevice.PowerToggle(); - - } - if (twoWayDisplay != null) - inputNumberFeedback.FireUpdate(); - }); - - - var volumeDisplay = displayDevice as IBasicVolumeControls; - if (volumeDisplay != null) - { - trilist.SetBoolSigAction(joinMap.VolumeUp, (b) => volumeDisplay.VolumeUp(b)); - trilist.SetBoolSigAction(joinMap.VolumeDown, (b) => volumeDisplay.VolumeDown(b)); - trilist.SetSigTrueAction(joinMap.VolumeMute, () => volumeDisplay.MuteToggle()); - - var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; - if(volumeDisplayWithFeedback != null) - { - trilist.SetUShortSigAction(joinMap.VolumeLevel, new Action((u) => volumeDisplayWithFeedback.SetVolume(u))); - volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); - } - } - } - - static void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - - Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", e.StringValue); - - } - - } - -} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs deleted file mode 100644 index 221745e8..00000000 --- a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Bridges { - public static class DmBladeChassisControllerApiExtentions { - public static void LinkToApi(this DmBladeChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey) { - DmBladeChassisControllerJoinMap joinMap = new DmBladeChassisControllerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - var chassis = dmChassis.Chassis as BladeSwitch; - - dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - - - // Link up outputs - for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs; i++) { - var ioSlot = i; - - // Control - trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); - - if (dmChassis.TxDictionary.ContainsKey(ioSlot)) { - Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var txKey = dmChassis.TxDictionary[ioSlot]; - var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; - - var advancedTxDevice = basicTxDevice as DmTxControllerBase; - - if (dmChassis.Chassis is DmMd128x128 || dmChassis.Chassis is DmMd64x64) { - dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); - } - else { - if (advancedTxDevice != null) { - advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); - Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); - } - else if (dmChassis.InputEndpointOnlineFeedbacks[ioSlot] != null) { - Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); - dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); - } - } - - if (basicTxDevice != null && advancedTxDevice == null) - trilist.BooleanInput[joinMap.TxAdvancedIsPresent + ioSlot].BoolValue = true; - - if (advancedTxDevice != null) { - advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); - } - else if (advancedTxDevice == null || basicTxDevice != null) { - Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); - dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); - - var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) { - Debug.Console(1, "Port value for input card {0} is set", ioSlot); - var port = inputPort.Port; - - if (port != null) { - if (port is HdmiInputWithCEC) { - Debug.Console(1, "Port is HdmiInputWithCec"); - - var hdmiInPortWCec = port as HdmiInputWithCEC; - - if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) { - SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); - } - - dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); - - if (dmChassis.InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)dmChassis.InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; - } - } - } - else { - inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; - - if (inputPort != null) { - var port = inputPort.Port; - - if (port is DMInputPortWithCec) { - Debug.Console(1, "Port is DMInputPortWithCec"); - - var dmInPortWCec = port as DMInputPortWithCec; - - if (dmInPortWCec != null) { - SetHdcpStateAction(dmChassis.PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); - } - - dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); - - if (dmChassis.InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)dmChassis.InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; - } - } - } - } - } - else { - dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); - - var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) { - var hdmiPort = inputPort.Port as EndpointHdmiInput; - - if (hdmiPort != null) { - SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState + ioSlot, trilist); - dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); - } - } - } - if (dmChassis.RxDictionary.ContainsKey(ioSlot)) { - Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - //var rxKey = dmChassis.RxDictionary[ioSlot]; - //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - //if (hdBaseTDevice != null) { - dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - //} - //else if (rxDevice != null) { - // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - //} - } - - // Feedback - dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); - - - dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); - dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); - dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); - } - } - - static void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) { - if (hdcpTypeSimple) { - trilist.SetUShortSigAction(join, - new Action(s => { - if (s == 0) { - port.HdcpSupportOff(); - } - else if (s > 0) { - port.HdcpSupportOn(); - } - })); - } - else { - trilist.SetUShortSigAction(join, - new Action(u => { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - })); - } - } - - static void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) { - if (hdcpTypeSimple) { - trilist.SetUShortSigAction(join, - new Action(s => { - if (s == 0) { - port.HdcpSupportOff(); - } - else if (s > 0) { - port.HdcpSupportOn(); - } - })); - } - else { - trilist.SetUShortSigAction(join, - new Action(u => { - port.HdcpCapability = (eHdcpCapabilityType)u; - })); - } - } - - static void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) { - if (!supportsHdcp2) { - trilist.SetUShortSigAction(join, - new Action(s => { - if (s == 0) { - port.HdcpSupportOff(); - } - else if (s > 0) { - port.HdcpSupportOn(); - } - })); - } - else { - trilist.SetUShortSigAction(join, - new Action(u => { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - })); - } - } - - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs index 9c8c8551..6522a5f0 100644 --- a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs @@ -15,7 +15,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class DmChassisControllerApiExtentions { diff --git a/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs b/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs index 1e99b734..5609cf03 100644 --- a/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class DmRmcControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs index 9b28611e..c565f41e 100644 --- a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs @@ -14,7 +14,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class DmTxControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs index f721b44f..eec058da 100644 --- a/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class DmpsAudioOutputControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs index eb359dd9..ea775039 100644 --- a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class DmpsRoutingControllerApiExtentions { diff --git a/PepperDashEssentials/Bridges/GenericLightingBridge.cs b/PepperDashEssentials/Bridges/GenericLightingBridge.cs index d76bbebb..5365b813 100644 --- a/PepperDashEssentials/Bridges/GenericLightingBridge.cs +++ b/PepperDashEssentials/Bridges/GenericLightingBridge.cs @@ -10,7 +10,7 @@ using PepperDash.Essentials.Devices.Common; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class GenericLightingApiExtensions { diff --git a/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs b/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs index 684a5550..8175f115 100644 --- a/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs +++ b/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.Core.CrestronIO; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class GenericRelayDeviceApiExtensions { diff --git a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs index a49061b7..b073750c 100644 --- a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs +++ b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs @@ -12,7 +12,7 @@ using PepperDash.Core; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class GlsOccupancySensorBaseControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs index 52bacfec..bf6fdb54 100644 --- a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs +++ b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs @@ -14,7 +14,7 @@ using PepperDash.Essentials.DM; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class HdMdxxxCEControllerApiExtensions { diff --git a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs index 6ae9334c..b23860d3 100644 --- a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs +++ b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs @@ -10,7 +10,7 @@ using PepperDash.Essentials.Core; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class IBasicCommunicationApiExtensions { diff --git a/PepperDashEssentials/Bridges/IDigitalInputBridge.cs b/PepperDashEssentials/Bridges/IDigitalInputBridge.cs index 54c48e1a..078e0b13 100644 --- a/PepperDashEssentials/Bridges/IDigitalInputBridge.cs +++ b/PepperDashEssentials/Bridges/IDigitalInputBridge.cs @@ -11,7 +11,7 @@ using PepperDash.Essentials.Core.CrestronIO; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class IDigitalInputApiExtenstions { diff --git a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs index 0f7b5786..76e5b5ee 100644 --- a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs +++ b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs @@ -10,7 +10,7 @@ using PepperDash.Essentials.Devices.Common; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class IRSetTopBoxBaseApiExtensions { diff --git a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs b/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs index 860f070d..0b35677d 100644 --- a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs +++ b/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs @@ -4,7 +4,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.CrestronIO; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class StatusSignDeviceApiExtensions { diff --git a/PepperDashEssentials/Bridges/SystemMonitorBridge.cs b/PepperDashEssentials/Bridges/SystemMonitorBridge.cs index d048b493..5999c500 100644 --- a/PepperDashEssentials/Bridges/SystemMonitorBridge.cs +++ b/PepperDashEssentials/Bridges/SystemMonitorBridge.cs @@ -6,7 +6,7 @@ using PepperDash.Essentials.Core.Monitoring; using Newtonsoft.Json; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public static class SystemMonitorBridge { diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f158fc1f..3b603038 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -51,7 +51,7 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(Core.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index b2830e4e..5b500425 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -124,51 +124,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs similarity index 50% rename from PepperDashEssentials/Bridges/BridgeBase.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs index b3f131c3..c0afb5f9 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs @@ -1,407 +1,407 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.EthernetCommunication; - -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Lighting; -using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Devices.Common; -using PepperDash.Essentials.Devices.Common.Cameras; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.CrestronIO; -using PepperDash.Essentials.DM; -//using PepperDash.Essentials.Devices.Common.Cameras; - -namespace PepperDash.Essentials.Bridges -{ - /// - /// Helper methods for bridges - /// - public static class BridgeHelper - { - public static void PrintJoinMap(string command) - { - string bridgeKey = ""; - string deviceKey = ""; - - var targets = command.Split(' '); - - bridgeKey = targets[0].Trim(); - - var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi; - - if (bridge == null) - { - Debug.Console(0, "Unable to find bridge with key: '{0}'", bridgeKey); - return; - } - - if (targets.Length > 1) - { - deviceKey = targets[1].Trim(); - - if (!string.IsNullOrEmpty(deviceKey)) - { - bridge.PrintJoinMapForDevice(deviceKey); - return; - } - } - else - { - bridge.PrintJoinMaps(); - } - } - } - - - /// - /// Base class for all bridge class variants - /// - public class BridgeBase : Device - { - public BridgeApi Api { get; private set; } - - public BridgeBase(string key) : - base(key) - { - - } - - } - - /// - /// Base class for bridge API variants - /// - public abstract class BridgeApi : Device - { - public BridgeApi(string key) : - base(key) - { - - } - } - - /// - /// Bridge API using EISC - /// - public class EiscApi : BridgeApi - { - public EiscApiPropertiesConfig PropertiesConfig { get; private set; } - - protected Dictionary JoinMaps { get; private set; } - - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } - - public EiscApi(DeviceConfig dc) : - base(dc.Key) - { - JoinMaps = new Dictionary(); - - PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); - - Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange); - - Eisc.Register(); - - AddPostActivationAction( () => - { - Debug.Console(1, this, "Linking Devices..."); - - foreach (var d in PropertiesConfig.Devices) - { - var device = DeviceManager.GetDeviceForKey(d.DeviceKey); - - if (device != null) - { - Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - - - if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. - { - (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is IBridgeAdvanced) - { - Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); - (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); - } - else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) - { - (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is GenericComm) - { - (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is CameraBase) - { - (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); - continue; - } - else if (device is PepperDash.Essentials.Core.DisplayBase) - { - (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmChassisController) - { - (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmBladeChassisController) - { - (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmpsRoutingController) - { - (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmpsAudioOutputController) - { - (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmTxControllerBase) - { - (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmRmcControllerBase) - { - (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is GenericRelayDevice) - { - (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is IRSetTopBoxBase) - { - (device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is IDigitalInput) - { - (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is AppleTV) - { - (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is HdMdxxxCEController) - { - (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is LightingBase) - { - (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DigitalLogger) - { - (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController) - { - (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is StatusSignController) - { - (device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is C2nRthsController) - { - (device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - } - } - - Debug.Console(1, this, "Devices Linked."); - }); - } - - /// - /// Adds a join map - /// - /// - /// - public void AddJoinMap(string deviceKey, JoinMapBaseAdvanced joinMap) - { - if (!JoinMaps.ContainsKey(deviceKey)) - { - JoinMaps.Add(deviceKey, joinMap); - } - else - { - Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); - } - } - - /// - /// Prints all the join maps on this bridge - /// - public void PrintJoinMaps() - { - Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); - - foreach (var joinMap in JoinMaps) - { - Debug.Console(0, "Join map for device '{0}':", joinMap.Key); - joinMap.Value.PrintJoinMapInfo(); - } - } - - /// - /// Prints the join map for a device by key - /// - /// - public void PrintJoinMapForDevice(string deviceKey) - { - var joinMap = JoinMaps[deviceKey]; - - if (joinMap == null) - { - Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); - return; - } - - Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, this.Key); - joinMap.PrintJoinMapInfo(); - } - - /// - /// Used for debugging to trigger an action based on a join number and type - /// - /// - /// - public void ExecuteJoinAction(uint join, string type, object state) - { - try - { - switch (type.ToLower()) - { - case "digital": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToBoolean(state)); - } - else - Debug.Console(1, this, "User Action is null. Nothing to Execute"); - break; - } - case "analog": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToUInt16(state)); - } - else - Debug.Console(1, this, "User Action is null. Nothing to Execute"); break; - } - case "serial": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToString(state)); - } - else - Debug.Console(1, this, "User Action is null. Nothing to Execute"); - break; - } - default: - { - Debug.Console(1, "Unknown join type. Use digital/serial/analog"); - break; - } - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error: {0}", e); - } - - } - - /// - /// Handles incoming sig changes - /// - /// - /// - void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) - { - try - { - if (Debug.Level >= 1) - Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - if (uo != null) - { - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - 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); - } - } - catch (Exception e) - { - Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); - } - } - } - - public class EiscApiPropertiesConfig - { - [JsonProperty("control")] - public EssentialsControlPropertiesConfig Control { get; set; } - - [JsonProperty("devices")] - public List Devices { get; set; } - - - public class ApiDevicePropertiesConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("joinStart")] - public uint JoinStart { get; set; } - - [JsonProperty("joinMapKey")] - public string JoinMapKey { get; set; } - } - - } - - +using System; +using System.Collections.Generic; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; + +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +//using PepperDash.Essentials.Devices.Common.Cameras; + +namespace PepperDash.Essentials.Core.Bridges +{ + /// + /// Helper methods for bridges + /// + public static class BridgeHelper + { + public static void PrintJoinMap(string command) + { + var targets = command.Split(' '); + + var bridgeKey = targets[0].Trim(); + + var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi; + + if (bridge == null) + { + Debug.Console(0, "Unable to find bridge with key: '{0}'", bridgeKey); + return; + } + + if (targets.Length > 1) + { + var deviceKey = targets[1].Trim(); + + if (string.IsNullOrEmpty(deviceKey)) return; + bridge.PrintJoinMapForDevice(deviceKey); + } + else + { + bridge.PrintJoinMaps(); + } + } + } + + + /// + /// Base class for all bridge class variants + /// + public class BridgeBase : EssentialsDevice + { + public BridgeApi Api { get; protected set; } + + public BridgeBase(string key) : + base(key) + { + + } + } + + /// + /// Base class for bridge API variants + /// + public abstract class BridgeApi : EssentialsDevice + { + protected BridgeApi(string key) : + base(key) + { + + } + } + + /// + /// Bridge API using EISC + /// + public class EiscApi : BridgeApi + { + public EiscApiPropertiesConfig PropertiesConfig { get; private set; } + + protected Dictionary JoinMaps { get; private set; } + + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } + + public EiscApi(DeviceConfig dc) : + base(dc.Key) + { + JoinMaps = new Dictionary(); + + PropertiesConfig = dc.Properties.ToObject(); + //PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); + + Eisc.SigChange += Eisc_SigChange; + + Eisc.Register(); + + AddPostActivationAction( () => + { + Debug.Console(1, this, "Linking Devices..."); + + foreach (var d in PropertiesConfig.Devices) + { + var device = DeviceManager.GetDeviceForKey(d.DeviceKey); + + if (device == null) continue; + + Debug.Console(1, this, "Linking Device: '{0}'", device.Key); + + if (device.GetType().GetCType().IsAssignableFrom(typeof (IBridge))) + { + var bridge = device as IBridge; + + if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } + + if (device.GetType().GetCType().IsAssignableFrom(typeof (IBridgeAdvanced))) + { + var bridge = device as IBridgeAdvanced; + if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + } + + //if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. + //{ + // (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is IBridgeAdvanced) + //{ + // Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); + // (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + //} + //else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) + //{ + // (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is GenericComm) + //{ + // (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is CameraBase) + //{ + // (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + // continue; + //} + //else if (device is PepperDash.Essentials.Core.DisplayBase) + //{ + // (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmChassisController) + //{ + // (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmBladeChassisController) + //{ + // (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmpsRoutingController) + //{ + // (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmpsAudioOutputController) + //{ + // (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmTxControllerBase) + //{ + // (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DmRmcControllerBase) + //{ + // (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is GenericRelayDevice) + //{ + // (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is IRSetTopBoxBase) + //{ + // (device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is IDigitalInput) + //{ + // (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is AppleTV) + //{ + // (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is HdMdxxxCEController) + //{ + // (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is LightingBase) + //{ + // (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is DigitalLogger) + //{ + // (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController) + //{ + // (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is StatusSignController) + //{ + // (device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + //else if (device is C2nRthsController) + //{ + // (device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + // continue; + //} + } + + Debug.Console(1, this, "Devices Linked."); + }); + } + + /// + /// Adds a join map + /// + /// + /// + public void AddJoinMap(string deviceKey, JoinMapBaseAdvanced joinMap) + { + if (!JoinMaps.ContainsKey(deviceKey)) + { + JoinMaps.Add(deviceKey, joinMap); + } + else + { + Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); + } + } + + /// + /// Prints all the join maps on this bridge + /// + public void PrintJoinMaps() + { + Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); + + foreach (var joinMap in JoinMaps) + { + Debug.Console(0, "Join map for device '{0}':", joinMap.Key); + joinMap.Value.PrintJoinMapInfo(); + } + } + + /// + /// Prints the join map for a device by key + /// + /// + public void PrintJoinMapForDevice(string deviceKey) + { + var joinMap = JoinMaps[deviceKey]; + + if (joinMap == null) + { + Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + return; + } + + Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); + joinMap.PrintJoinMapInfo(); + } + + /// + /// Used for debugging to trigger an action based on a join number and type + /// + /// + /// + /// + public void ExecuteJoinAction(uint join, string type, object state) + { + try + { + switch (type.ToLower()) + { + case "digital": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToBoolean(state)); + } + else + Debug.Console(1, this, "User Action is null. Nothing to Execute"); + break; + } + case "analog": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToUInt16(state)); + } + else + Debug.Console(1, this, "User Action is null. Nothing to Execute"); break; + } + case "serial": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToString(state)); + } + else + Debug.Console(1, this, "User Action is null. Nothing to Execute"); + break; + } + default: + { + Debug.Console(1, "Unknown join type. Use digital/serial/analog"); + break; + } + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error: {0}", e); + } + + } + + /// + /// Handles incoming sig changes + /// + /// + /// + void Eisc_SigChange(object currentDevice, SigEventArgs args) + { + try + { + if (Debug.Level >= 1) + Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + + if (uo == null) return; + + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + 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); + } + catch (Exception e) + { + Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); + } + } + } + + public class EiscApiPropertiesConfig + { + [JsonProperty("control")] + public EssentialsControlPropertiesConfig Control { get; set; } + + [JsonProperty("devices")] + public List Devices { get; set; } + + + public class ApiDevicePropertiesConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("joinStart")] + public uint JoinStart { get; set; } + + [JsonProperty("joinMapKey")] + public string JoinMapKey { get; set; } + } + + } + + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs similarity index 82% rename from PepperDashEssentials/Bridges/IBridge.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs index f2b959ed..a4e09c8e 100644 --- a/PepperDashEssentials/Bridges/IBridge.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { /// /// Defines a device that uses the legacy JoinMapBase for its join map diff --git a/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs similarity index 98% rename from PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs index 042a3bf3..1c091233 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class AirMediaControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs similarity index 97% rename from PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs index 8945d9c9..aae9e37b 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class AppleTvJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs similarity index 93% rename from PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs index be0f002e..2ef315b5 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs @@ -1,43 +1,43 @@ -using System.Linq; -using Crestron.SimplSharp.Reflection; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Bridges -{ - public class C2nRthsControllerJoinMap:JoinMapBase - { - public uint IsOnline { get; set; } - public uint Name { get; set; } - public uint Temperature { get; set; } - public uint Humidity { get; set; } - public uint TemperatureFormat { get; set; } - - public C2nRthsControllerJoinMap() - { - //digital - IsOnline = 1; - TemperatureFormat = 2; - - //Analog - Temperature = 2; - Humidity = 3; - - //serial - Name = 1; - - - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - var properties = - GetType().GetCType().GetProperties().Where(p => p.PropertyType == typeof(uint)).ToList(); - - foreach (var propertyInfo in properties) - { - propertyInfo.SetValue(this, (uint)propertyInfo.GetValue(this, null) + joinOffset, null); - } - } - } +using System.Linq; +using Crestron.SimplSharp.Reflection; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class C2nRthsControllerJoinMap:JoinMapBase + { + public uint IsOnline { get; set; } + public uint Name { get; set; } + public uint Temperature { get; set; } + public uint Humidity { get; set; } + public uint TemperatureFormat { get; set; } + + public C2nRthsControllerJoinMap() + { + //digital + IsOnline = 1; + TemperatureFormat = 2; + + //Analog + Temperature = 2; + Humidity = 3; + + //serial + Name = 1; + + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + var properties = + GetType().GetCType().GetProperties().Where(p => p.PropertyType == typeof(uint)).ToList(); + + foreach (var propertyInfo in properties) + { + propertyInfo.SetValue(this, (uint)propertyInfo.GetValue(this, null) + joinOffset, null); + } + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs similarity index 99% rename from PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs index 5a37892f..187978d1 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -6,7 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { /// /// Join map for CameraBase devices diff --git a/PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs similarity index 96% rename from PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs index 2b0a1c15..df90a18b 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs @@ -6,7 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DigitalLoggerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs similarity index 98% rename from PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs index ddbec182..c2fe8573 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DisplayControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs similarity index 96% rename from PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs index 29ee6471..001d6f94 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs @@ -1,109 +1,109 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Bridges { - public class DmBladeChassisControllerJoinMap : JoinMapBase { - #region Digital/Analogs - #endregion - - #region Digitals - /// - /// High when device is online - /// - public uint IsOnline { get; set; } - /// - /// Range reports video sync feedback for each input - /// - public uint VideoSyncStatus { get; set; } - /// - /// Range reports high if corresponding input's endpoint is online - /// - public uint InputEndpointOnline { get; set; } - /// - /// Range reports high if corresponding output's endpoint is online - /// - public uint OutputEndpointOnline { get; set; } - /// - /// Range reports high if corresponding input's transmitter supports bridging as a separate device for detailed AV switching, HDCP control, etc. - /// - public uint TxAdvancedIsPresent { get; set; } // indicates that there is an attached transmitter that should be bridged to be interacted with - #endregion - - #region Analogs - /// - /// Range sets and reports the current video source for the corresponding output - /// - public uint OutputVideo { get; set; } - /// - /// Range sets and reports the current HDCP state for the corresponding input card - /// - public uint HdcpSupportState { get; set; } - /// - /// Range reports the highest supported HDCP state level for the corresponding input card - /// - public uint HdcpSupportCapability { get; set; } - #endregion - - #region Serials - /// - /// Range sets and reports the name for the corresponding input card - /// - public uint InputNames { get; set; } - /// - /// Range sets and reports the name for the corresponding output card - /// - public uint OutputNames { get; set; } - /// - /// Range reports the name of the current video source for the corresponding output card - /// - public uint OutputCurrentVideoInputNames { get; set; } - /// - /// Range reports the current input resolution for each corresponding input card - /// - public uint InputCurrentResolution { get; set; } - #endregion - - public DmBladeChassisControllerJoinMap() { - //Digital/Analog - - //Digital - IsOnline = 11; - VideoSyncStatus = 100; //101-299 - InputEndpointOnline = 500; //501-699 - OutputEndpointOnline = 700; //701-899 - TxAdvancedIsPresent = 1000; //1001-1199 - - //Analog - OutputVideo = 100; //101-299 - HdcpSupportState = 1000; //1001-1199 - HdcpSupportCapability = 1200; //1201-1399 - - - //Serial - InputNames = 100; //101-299 - OutputNames = 300; //301-499 - OutputCurrentVideoInputNames = 2000; //2001-2199 - InputCurrentResolution = 2400; // 2401-2599 - } - - public override void OffsetJoinNumbers(uint joinStart) { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - OutputVideo = OutputVideo + joinOffset; - VideoSyncStatus = VideoSyncStatus + joinOffset; - InputNames = InputNames + joinOffset; - OutputNames = OutputNames + joinOffset; - OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset; - InputCurrentResolution = InputCurrentResolution + joinOffset; - InputEndpointOnline = InputEndpointOnline + joinOffset; - OutputEndpointOnline = OutputEndpointOnline + joinOffset; - HdcpSupportState = HdcpSupportState + joinOffset; - HdcpSupportCapability = HdcpSupportCapability + joinOffset; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges { + public class DmBladeChassisControllerJoinMap : JoinMapBase { + #region Digital/Analogs + #endregion + + #region Digitals + /// + /// High when device is online + /// + public uint IsOnline { get; set; } + /// + /// Range reports video sync feedback for each input + /// + public uint VideoSyncStatus { get; set; } + /// + /// Range reports high if corresponding input's endpoint is online + /// + public uint InputEndpointOnline { get; set; } + /// + /// Range reports high if corresponding output's endpoint is online + /// + public uint OutputEndpointOnline { get; set; } + /// + /// Range reports high if corresponding input's transmitter supports bridging as a separate device for detailed AV switching, HDCP control, etc. + /// + public uint TxAdvancedIsPresent { get; set; } // indicates that there is an attached transmitter that should be bridged to be interacted with + #endregion + + #region Analogs + /// + /// Range sets and reports the current video source for the corresponding output + /// + public uint OutputVideo { get; set; } + /// + /// Range sets and reports the current HDCP state for the corresponding input card + /// + public uint HdcpSupportState { get; set; } + /// + /// Range reports the highest supported HDCP state level for the corresponding input card + /// + public uint HdcpSupportCapability { get; set; } + #endregion + + #region Serials + /// + /// Range sets and reports the name for the corresponding input card + /// + public uint InputNames { get; set; } + /// + /// Range sets and reports the name for the corresponding output card + /// + public uint OutputNames { get; set; } + /// + /// Range reports the name of the current video source for the corresponding output card + /// + public uint OutputCurrentVideoInputNames { get; set; } + /// + /// Range reports the current input resolution for each corresponding input card + /// + public uint InputCurrentResolution { get; set; } + #endregion + + public DmBladeChassisControllerJoinMap() { + //Digital/Analog + + //Digital + IsOnline = 11; + VideoSyncStatus = 100; //101-299 + InputEndpointOnline = 500; //501-699 + OutputEndpointOnline = 700; //701-899 + TxAdvancedIsPresent = 1000; //1001-1199 + + //Analog + OutputVideo = 100; //101-299 + HdcpSupportState = 1000; //1001-1199 + HdcpSupportCapability = 1200; //1201-1399 + + + //Serial + InputNames = 100; //101-299 + OutputNames = 300; //301-499 + OutputCurrentVideoInputNames = 2000; //2001-2199 + InputCurrentResolution = 2400; // 2401-2599 + } + + public override void OffsetJoinNumbers(uint joinStart) { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + OutputVideo = OutputVideo + joinOffset; + VideoSyncStatus = VideoSyncStatus + joinOffset; + InputNames = InputNames + joinOffset; + OutputNames = OutputNames + joinOffset; + OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset; + InputCurrentResolution = InputCurrentResolution + joinOffset; + InputEndpointOnline = InputEndpointOnline + joinOffset; + OutputEndpointOnline = OutputEndpointOnline + joinOffset; + HdcpSupportState = HdcpSupportState + joinOffset; + HdcpSupportCapability = HdcpSupportCapability + joinOffset; + } + } +} diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs similarity index 99% rename from PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs index ff6a42d9..5059333f 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DmChassisControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs similarity index 97% rename from PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index 7aa8081a..0bdedbbf 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DmRmcControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs similarity index 94% rename from PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs index ff673cab..49bd7ac5 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DmTxControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs similarity index 98% rename from PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs index faa30775..125700b2 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DmpsAudioOutputControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs similarity index 99% rename from PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs index ba3a8cd0..b58611fe 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class DmpsRoutingControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs similarity index 96% rename from PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs index df5606d0..242be651 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs @@ -7,7 +7,7 @@ using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class GenericLightingJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs similarity index 93% rename from PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs index 5c91a358..e4ccdfbd 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class GenericRelayControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs similarity index 97% rename from PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs index 6e19dff2..6e2cd175 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs @@ -1,238 +1,238 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Bridges -{ - public class GlsOccupancySensorBaseJoinMap : JoinMapBase - { - #region Digitals - - /// - /// High when device is online - /// - public uint IsOnline { get; set; } - /// - /// Forces the device to report occupied status - /// - public uint ForceOccupied { get; set; } - /// - /// Forces the device to report vacant status - /// - public uint ForceVacant { get; set; } - /// - /// Enables raw status reporting - /// - public uint EnableRawStates { get; set; } - /// - /// High when raw occupancy is detected - /// - public uint RawOccupancyFeedback { get; set; } - /// - /// High when PIR sensor detects motion - /// - public uint RawOccupancyPirFeedback { get; set; } - /// - /// High when US sensor detects motion - /// - public uint RawOccupancyUsFeedback { get; set; } - /// - /// High when occupancy is detected - /// - public uint RoomOccupiedFeedback { get; set; } - /// - /// Hich when occupancy is detected in the grace period - /// - public uint GraceOccupancyDetectedFeedback { get; set; } - /// - /// High when vacancy is detected - /// - public uint RoomVacantFeedback { get; set; } - - /// - /// Enables the LED Flash when set high - /// - public uint EnableLedFlash { get; set; } - /// - /// Disables the LED flash when set high - /// - public uint DisableLedFlash { get; set; } - /// - /// Enables the Short Timeout - /// - public uint EnableShortTimeout { get; set; } - /// - /// Disables the Short Timout - /// - public uint DisableShortTimeout { get; set; } - /// - /// Set high to enable one technology to trigger occupancy - /// - public uint OrWhenVacated { get; set; } - /// - /// Set high to require both technologies to trigger occupancy - /// - public uint AndWhenVacated { get; set; } - /// - /// Enables Ultrasonic Sensor A - /// - public uint EnableUsA { get; set; } - /// - /// Disables Ultrasonic Sensor A - /// - public uint DisableUsA { get; set; } - /// - /// Enables Ultrasonic Sensor B - /// - public uint EnableUsB { get; set; } - /// - /// Disables Ultrasonic Sensor B - /// - public uint DisableUsB { get; set; } - /// - /// Enables Pir - /// - public uint EnablePir { get; set; } - /// - /// Disables Pir - /// - public uint DisablePir { get; set; } - public uint IncrementUsInOccupiedState { get; set; } - public uint DecrementUsInOccupiedState { get; set; } - public uint IncrementUsInVacantState { get; set; } - public uint DecrementUsInVacantState { get; set; } - public uint IncrementPirInOccupiedState { get; set; } - public uint DecrementPirInOccupiedState { get; set; } - public uint IncrementPirInVacantState { get; set; } - public uint DecrementPirInVacantState { get; set; } - #endregion - - #region Analogs - /// - /// Sets adn reports the remote timeout value - /// - public uint Timeout { get; set; } - /// - /// Reports the local timeout value - /// - public uint TimeoutLocalFeedback { get; set; } - /// - /// Sets the minimum internal photo sensor value and reports the current level - /// - public uint InternalPhotoSensorValue { get; set; } - /// - /// Sets the minimum external photo sensor value and reports the current level - /// - public uint ExternalPhotoSensorValue { get; set; } - - public uint UsSensitivityInOccupiedState { get; set; } - - public uint UsSensitivityInVacantState { get; set; } - - public uint PirSensitivityInOccupiedState { get; set; } - - public uint PirSensitivityInVacantState { get; set; } - #endregion - - #region Serial - public uint Name { get; set; } - #endregion - - public GlsOccupancySensorBaseJoinMap() - { - IsOnline = 1; - ForceOccupied = 2; - ForceVacant = 3; - EnableRawStates = 4; - RoomOccupiedFeedback = 2; - GraceOccupancyDetectedFeedback = 3; - RoomVacantFeedback = 4; - RawOccupancyFeedback = 5; - RawOccupancyPirFeedback = 6; - RawOccupancyUsFeedback = 7; - EnableLedFlash = 11; - DisableLedFlash = 12; - EnableShortTimeout = 13; - DisableShortTimeout = 14; - OrWhenVacated = 15; - AndWhenVacated = 16; - EnableUsA = 17; - DisableUsA = 18; - EnableUsB = 19; - DisableUsB = 20; - EnablePir = 21; - DisablePir = 22; - IncrementUsInOccupiedState = 23; - DecrementUsInOccupiedState = 24; - IncrementUsInVacantState = 25; - DecrementUsInVacantState = 26; - IncrementPirInOccupiedState = 27; - DecrementPirInOccupiedState = 28; - IncrementPirInVacantState = 29; - DecrementPirInVacantState = 30; - - Timeout = 1; - TimeoutLocalFeedback = 2; - InternalPhotoSensorValue = 3; - ExternalPhotoSensorValue = 4; - UsSensitivityInOccupiedState = 5; - UsSensitivityInVacantState = 6; - PirSensitivityInOccupiedState = 7; - PirSensitivityInVacantState = 8; - - Name = 1; - - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - ForceOccupied = ForceOccupied + joinOffset; - ForceVacant = ForceVacant + joinOffset; - EnableRawStates = EnableRawStates + joinOffset; - RoomOccupiedFeedback = RoomOccupiedFeedback + joinOffset; - GraceOccupancyDetectedFeedback = GraceOccupancyDetectedFeedback + joinOffset; - RoomVacantFeedback = RoomVacantFeedback + joinOffset; - RawOccupancyFeedback = RawOccupancyFeedback + joinOffset; - RawOccupancyPirFeedback = RawOccupancyPirFeedback + joinOffset; - RawOccupancyUsFeedback = RawOccupancyUsFeedback + joinOffset; - EnableLedFlash = EnableLedFlash + joinOffset; - DisableLedFlash = DisableLedFlash + joinOffset; - EnableShortTimeout = EnableShortTimeout + joinOffset; - DisableShortTimeout = DisableShortTimeout + joinOffset; - OrWhenVacated = OrWhenVacated + joinOffset; - AndWhenVacated = AndWhenVacated + joinOffset; - EnableUsA = EnableUsA + joinOffset; - DisableUsA = DisableUsA + joinOffset; - EnableUsB = EnableUsB + joinOffset; - DisableUsB = DisableUsB + joinOffset; - EnablePir = EnablePir + joinOffset; - DisablePir = DisablePir + joinOffset; - IncrementUsInOccupiedState = IncrementUsInOccupiedState + joinOffset; - DecrementUsInOccupiedState = DecrementUsInOccupiedState + joinOffset; - IncrementUsInVacantState = IncrementUsInVacantState + joinOffset; - DecrementUsInVacantState = DecrementUsInVacantState + joinOffset; - IncrementPirInOccupiedState = IncrementPirInOccupiedState + joinOffset; - DecrementPirInOccupiedState = DecrementPirInOccupiedState + joinOffset; - IncrementPirInVacantState = IncrementPirInVacantState + joinOffset; - DecrementPirInVacantState = DecrementPirInVacantState + joinOffset; - - Timeout = Timeout + joinOffset; - TimeoutLocalFeedback = TimeoutLocalFeedback + joinOffset; - InternalPhotoSensorValue = InternalPhotoSensorValue + joinOffset; - ExternalPhotoSensorValue = ExternalPhotoSensorValue + joinOffset; - UsSensitivityInOccupiedState = UsSensitivityInOccupiedState + joinOffset; - UsSensitivityInVacantState = UsSensitivityInVacantState + joinOffset; - PirSensitivityInOccupiedState = PirSensitivityInOccupiedState + joinOffset; - PirSensitivityInVacantState = PirSensitivityInVacantState + joinOffset; - - Name = Name + joinOffset; - } - } - -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class GlsOccupancySensorBaseJoinMap : JoinMapBase + { + #region Digitals + + /// + /// High when device is online + /// + public uint IsOnline { get; set; } + /// + /// Forces the device to report occupied status + /// + public uint ForceOccupied { get; set; } + /// + /// Forces the device to report vacant status + /// + public uint ForceVacant { get; set; } + /// + /// Enables raw status reporting + /// + public uint EnableRawStates { get; set; } + /// + /// High when raw occupancy is detected + /// + public uint RawOccupancyFeedback { get; set; } + /// + /// High when PIR sensor detects motion + /// + public uint RawOccupancyPirFeedback { get; set; } + /// + /// High when US sensor detects motion + /// + public uint RawOccupancyUsFeedback { get; set; } + /// + /// High when occupancy is detected + /// + public uint RoomOccupiedFeedback { get; set; } + /// + /// Hich when occupancy is detected in the grace period + /// + public uint GraceOccupancyDetectedFeedback { get; set; } + /// + /// High when vacancy is detected + /// + public uint RoomVacantFeedback { get; set; } + + /// + /// Enables the LED Flash when set high + /// + public uint EnableLedFlash { get; set; } + /// + /// Disables the LED flash when set high + /// + public uint DisableLedFlash { get; set; } + /// + /// Enables the Short Timeout + /// + public uint EnableShortTimeout { get; set; } + /// + /// Disables the Short Timout + /// + public uint DisableShortTimeout { get; set; } + /// + /// Set high to enable one technology to trigger occupancy + /// + public uint OrWhenVacated { get; set; } + /// + /// Set high to require both technologies to trigger occupancy + /// + public uint AndWhenVacated { get; set; } + /// + /// Enables Ultrasonic Sensor A + /// + public uint EnableUsA { get; set; } + /// + /// Disables Ultrasonic Sensor A + /// + public uint DisableUsA { get; set; } + /// + /// Enables Ultrasonic Sensor B + /// + public uint EnableUsB { get; set; } + /// + /// Disables Ultrasonic Sensor B + /// + public uint DisableUsB { get; set; } + /// + /// Enables Pir + /// + public uint EnablePir { get; set; } + /// + /// Disables Pir + /// + public uint DisablePir { get; set; } + public uint IncrementUsInOccupiedState { get; set; } + public uint DecrementUsInOccupiedState { get; set; } + public uint IncrementUsInVacantState { get; set; } + public uint DecrementUsInVacantState { get; set; } + public uint IncrementPirInOccupiedState { get; set; } + public uint DecrementPirInOccupiedState { get; set; } + public uint IncrementPirInVacantState { get; set; } + public uint DecrementPirInVacantState { get; set; } + #endregion + + #region Analogs + /// + /// Sets adn reports the remote timeout value + /// + public uint Timeout { get; set; } + /// + /// Reports the local timeout value + /// + public uint TimeoutLocalFeedback { get; set; } + /// + /// Sets the minimum internal photo sensor value and reports the current level + /// + public uint InternalPhotoSensorValue { get; set; } + /// + /// Sets the minimum external photo sensor value and reports the current level + /// + public uint ExternalPhotoSensorValue { get; set; } + + public uint UsSensitivityInOccupiedState { get; set; } + + public uint UsSensitivityInVacantState { get; set; } + + public uint PirSensitivityInOccupiedState { get; set; } + + public uint PirSensitivityInVacantState { get; set; } + #endregion + + #region Serial + public uint Name { get; set; } + #endregion + + public GlsOccupancySensorBaseJoinMap() + { + IsOnline = 1; + ForceOccupied = 2; + ForceVacant = 3; + EnableRawStates = 4; + RoomOccupiedFeedback = 2; + GraceOccupancyDetectedFeedback = 3; + RoomVacantFeedback = 4; + RawOccupancyFeedback = 5; + RawOccupancyPirFeedback = 6; + RawOccupancyUsFeedback = 7; + EnableLedFlash = 11; + DisableLedFlash = 12; + EnableShortTimeout = 13; + DisableShortTimeout = 14; + OrWhenVacated = 15; + AndWhenVacated = 16; + EnableUsA = 17; + DisableUsA = 18; + EnableUsB = 19; + DisableUsB = 20; + EnablePir = 21; + DisablePir = 22; + IncrementUsInOccupiedState = 23; + DecrementUsInOccupiedState = 24; + IncrementUsInVacantState = 25; + DecrementUsInVacantState = 26; + IncrementPirInOccupiedState = 27; + DecrementPirInOccupiedState = 28; + IncrementPirInVacantState = 29; + DecrementPirInVacantState = 30; + + Timeout = 1; + TimeoutLocalFeedback = 2; + InternalPhotoSensorValue = 3; + ExternalPhotoSensorValue = 4; + UsSensitivityInOccupiedState = 5; + UsSensitivityInVacantState = 6; + PirSensitivityInOccupiedState = 7; + PirSensitivityInVacantState = 8; + + Name = 1; + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + ForceOccupied = ForceOccupied + joinOffset; + ForceVacant = ForceVacant + joinOffset; + EnableRawStates = EnableRawStates + joinOffset; + RoomOccupiedFeedback = RoomOccupiedFeedback + joinOffset; + GraceOccupancyDetectedFeedback = GraceOccupancyDetectedFeedback + joinOffset; + RoomVacantFeedback = RoomVacantFeedback + joinOffset; + RawOccupancyFeedback = RawOccupancyFeedback + joinOffset; + RawOccupancyPirFeedback = RawOccupancyPirFeedback + joinOffset; + RawOccupancyUsFeedback = RawOccupancyUsFeedback + joinOffset; + EnableLedFlash = EnableLedFlash + joinOffset; + DisableLedFlash = DisableLedFlash + joinOffset; + EnableShortTimeout = EnableShortTimeout + joinOffset; + DisableShortTimeout = DisableShortTimeout + joinOffset; + OrWhenVacated = OrWhenVacated + joinOffset; + AndWhenVacated = AndWhenVacated + joinOffset; + EnableUsA = EnableUsA + joinOffset; + DisableUsA = DisableUsA + joinOffset; + EnableUsB = EnableUsB + joinOffset; + DisableUsB = DisableUsB + joinOffset; + EnablePir = EnablePir + joinOffset; + DisablePir = DisablePir + joinOffset; + IncrementUsInOccupiedState = IncrementUsInOccupiedState + joinOffset; + DecrementUsInOccupiedState = DecrementUsInOccupiedState + joinOffset; + IncrementUsInVacantState = IncrementUsInVacantState + joinOffset; + DecrementUsInVacantState = DecrementUsInVacantState + joinOffset; + IncrementPirInOccupiedState = IncrementPirInOccupiedState + joinOffset; + DecrementPirInOccupiedState = DecrementPirInOccupiedState + joinOffset; + IncrementPirInVacantState = IncrementPirInVacantState + joinOffset; + DecrementPirInVacantState = DecrementPirInVacantState + joinOffset; + + Timeout = Timeout + joinOffset; + TimeoutLocalFeedback = TimeoutLocalFeedback + joinOffset; + InternalPhotoSensorValue = InternalPhotoSensorValue + joinOffset; + ExternalPhotoSensorValue = ExternalPhotoSensorValue + joinOffset; + UsSensitivityInOccupiedState = UsSensitivityInOccupiedState + joinOffset; + UsSensitivityInVacantState = UsSensitivityInVacantState + joinOffset; + PirSensitivityInOccupiedState = PirSensitivityInOccupiedState + joinOffset; + PirSensitivityInVacantState = PirSensitivityInVacantState + joinOffset; + + Name = Name + joinOffset; + } + } + +} diff --git a/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs similarity index 98% rename from PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs index e88980fe..d3769838 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class HdMdxxxCEControllerJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs similarity index 97% rename from PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs index 953bae37..3669738e 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class IBasicCommunicationJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs similarity index 93% rename from PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs index 65d4ada4..ba9bcc0f 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs @@ -5,7 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class IDigitalInputJoinMap : JoinMapBase { diff --git a/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs similarity index 96% rename from PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs index aa23cb7a..dc634ab3 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs @@ -1,212 +1,212 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; -using Crestron.SimplSharp.Reflection; - - -namespace PepperDash.Essentials.Bridges -{ - public class SetTopBoxControllerJoinMap : JoinMapBase - { - #region Digitals - public uint DvrList { get; set; } // - public uint Replay { get; set; } - public uint Up { get; set; } // - public uint Down { get; set; } // - public uint Left { get; set; } // - public uint Right { get; set; } // - public uint Select { get; set; } // - public uint Menu { get; set; } // - public uint Exit { get; set; } // - public uint Digit0 { get; set; } // - public uint Digit1 { get; set; } // - public uint Digit2 { get; set; } // - public uint Digit3 { get; set; } // - public uint Digit4 { get; set; } // - public uint Digit5 { get; set; } // - public uint Digit6 { get; set; } // - public uint Digit7 { get; set; } // - public uint Digit8 { get; set; } // - public uint Digit9 { get; set; } // - public uint Dash { get; set; } // - public uint KeypadEnter { get; set; } // - public uint ChannelUp { get; set; } // - public uint ChannelDown { get; set; } // - public uint LastChannel { get; set; } // - public uint Guide { get; set; } // - public uint Info { get; set; } // - public uint Red { get; set; } // - public uint Green { get; set; } // - public uint Yellow { get; set; } // - public uint Blue { get; set; } // - public uint ChapMinus { get; set; } - public uint ChapPlus { get; set; } - public uint FFwd { get; set; } // - public uint Pause { get; set; } // - public uint Play { get; set; } // - public uint Record { get; set; } - public uint Rewind { get; set; } // - public uint Stop { get; set; } // - - public uint PowerOn { get; set; } // - public uint PowerOff { get; set; } // - public uint PowerToggle { get; set; } // - - public uint HasKeypadAccessoryButton1 { get; set; } - public uint HasKeypadAccessoryButton2 { get; set; } - - public uint KeypadAccessoryButton1Press { get; set; } - public uint KeypadAccessoryButton2Press { get; set; } - - - public uint HasDvr { get; set; } - public uint HasPresets { get; set; } - public uint HasNumeric { get; set; } - public uint HasDpad { get; set; } - - - #endregion - - #region Analogs - - #endregion - - #region Strings - public uint Name { get; set; } - public uint LoadPresets { get; set; } - public uint KeypadAccessoryButton1Label { get; set; } - public uint KeypadAccessoryButton2Label { get; set; } - - #endregion - - public SetTopBoxControllerJoinMap() - { - PowerOn = 1; - PowerOff = 2; - PowerToggle = 3; - - HasDpad = 4; - Up = 4; - Down = 5; - Left = 6; - Right = 7; - Select = 8; - Menu = 9; - Exit = 10; - - HasNumeric = 11; - Digit0 = 11; - Digit1 = 12; - Digit2 = 13; - Digit3 = 14; - Digit4 = 15; - Digit5 = 16; - Digit6 = 17; - Digit7 = 18; - Digit8 = 19; - Digit9 = 20; - Dash = 21; - KeypadEnter = 22; - ChannelUp = 23; - ChannelDown = 24; - LastChannel = 25; - - Guide = 26; - Info = 27; - Red = 28; - Green = 29; - Yellow = 30; - Blue = 31; - - HasDvr = 32; - DvrList = 32; - Play = 33; - Pause = 34; - Stop = 35; - FFwd = 36; - Rewind = 37; - ChapPlus = 38; - ChapMinus = 39; - Replay = 40; - Record = 41; - HasKeypadAccessoryButton1 = 42; - KeypadAccessoryButton1Press = 42; - HasKeypadAccessoryButton2 = 43; - KeypadAccessoryButton2Press = 43; - - Name = 1; - KeypadAccessoryButton1Label = 42; - KeypadAccessoryButton2Label = 43; - - LoadPresets = 50; - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - PowerOn += joinOffset; - PowerOff += joinOffset; - PowerToggle += joinOffset; - - HasDpad += joinOffset; - Up += joinOffset; - Down += joinOffset; - Left += joinOffset; - Right += joinOffset; - Select += joinOffset; - Menu += joinOffset; - Exit += joinOffset; - - HasNumeric += joinOffset; - Digit0 += joinOffset; - Digit1 += joinOffset; - Digit2 += joinOffset; - Digit3 += joinOffset; - Digit4 += joinOffset; - Digit5 += joinOffset; - Digit6 += joinOffset; - Digit7 += joinOffset; - Digit8 += joinOffset; - Digit9 += joinOffset; - Dash += joinOffset; - KeypadEnter += joinOffset; - ChannelUp += joinOffset; - ChannelDown += joinOffset; - LastChannel += joinOffset; - - Guide += joinOffset; - Info += joinOffset; - Red += joinOffset; - Green += joinOffset; - Yellow += joinOffset; - Blue += joinOffset; - - HasDvr += joinOffset; - DvrList += joinOffset; - Play += joinOffset; - Pause += joinOffset; - Stop += joinOffset; - FFwd += joinOffset; - Rewind += joinOffset; - ChapPlus += joinOffset; - ChapMinus += joinOffset; - Replay += joinOffset; - Record += joinOffset; - HasKeypadAccessoryButton1 += joinOffset; - KeypadAccessoryButton1Press += joinOffset; - HasKeypadAccessoryButton2 += joinOffset; - KeypadAccessoryButton2Press += joinOffset; - - Name += joinOffset; - KeypadAccessoryButton1Label += joinOffset; - KeypadAccessoryButton2Label += joinOffset; - - LoadPresets += joinOffset; - } - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; +using Crestron.SimplSharp.Reflection; + + +namespace PepperDash.Essentials.Core.Bridges +{ + public class SetTopBoxControllerJoinMap : JoinMapBase + { + #region Digitals + public uint DvrList { get; set; } // + public uint Replay { get; set; } + public uint Up { get; set; } // + public uint Down { get; set; } // + public uint Left { get; set; } // + public uint Right { get; set; } // + public uint Select { get; set; } // + public uint Menu { get; set; } // + public uint Exit { get; set; } // + public uint Digit0 { get; set; } // + public uint Digit1 { get; set; } // + public uint Digit2 { get; set; } // + public uint Digit3 { get; set; } // + public uint Digit4 { get; set; } // + public uint Digit5 { get; set; } // + public uint Digit6 { get; set; } // + public uint Digit7 { get; set; } // + public uint Digit8 { get; set; } // + public uint Digit9 { get; set; } // + public uint Dash { get; set; } // + public uint KeypadEnter { get; set; } // + public uint ChannelUp { get; set; } // + public uint ChannelDown { get; set; } // + public uint LastChannel { get; set; } // + public uint Guide { get; set; } // + public uint Info { get; set; } // + public uint Red { get; set; } // + public uint Green { get; set; } // + public uint Yellow { get; set; } // + public uint Blue { get; set; } // + public uint ChapMinus { get; set; } + public uint ChapPlus { get; set; } + public uint FFwd { get; set; } // + public uint Pause { get; set; } // + public uint Play { get; set; } // + public uint Record { get; set; } + public uint Rewind { get; set; } // + public uint Stop { get; set; } // + + public uint PowerOn { get; set; } // + public uint PowerOff { get; set; } // + public uint PowerToggle { get; set; } // + + public uint HasKeypadAccessoryButton1 { get; set; } + public uint HasKeypadAccessoryButton2 { get; set; } + + public uint KeypadAccessoryButton1Press { get; set; } + public uint KeypadAccessoryButton2Press { get; set; } + + + public uint HasDvr { get; set; } + public uint HasPresets { get; set; } + public uint HasNumeric { get; set; } + public uint HasDpad { get; set; } + + + #endregion + + #region Analogs + + #endregion + + #region Strings + public uint Name { get; set; } + public uint LoadPresets { get; set; } + public uint KeypadAccessoryButton1Label { get; set; } + public uint KeypadAccessoryButton2Label { get; set; } + + #endregion + + public SetTopBoxControllerJoinMap() + { + PowerOn = 1; + PowerOff = 2; + PowerToggle = 3; + + HasDpad = 4; + Up = 4; + Down = 5; + Left = 6; + Right = 7; + Select = 8; + Menu = 9; + Exit = 10; + + HasNumeric = 11; + Digit0 = 11; + Digit1 = 12; + Digit2 = 13; + Digit3 = 14; + Digit4 = 15; + Digit5 = 16; + Digit6 = 17; + Digit7 = 18; + Digit8 = 19; + Digit9 = 20; + Dash = 21; + KeypadEnter = 22; + ChannelUp = 23; + ChannelDown = 24; + LastChannel = 25; + + Guide = 26; + Info = 27; + Red = 28; + Green = 29; + Yellow = 30; + Blue = 31; + + HasDvr = 32; + DvrList = 32; + Play = 33; + Pause = 34; + Stop = 35; + FFwd = 36; + Rewind = 37; + ChapPlus = 38; + ChapMinus = 39; + Replay = 40; + Record = 41; + HasKeypadAccessoryButton1 = 42; + KeypadAccessoryButton1Press = 42; + HasKeypadAccessoryButton2 = 43; + KeypadAccessoryButton2Press = 43; + + Name = 1; + KeypadAccessoryButton1Label = 42; + KeypadAccessoryButton2Label = 43; + + LoadPresets = 50; + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + PowerOn += joinOffset; + PowerOff += joinOffset; + PowerToggle += joinOffset; + + HasDpad += joinOffset; + Up += joinOffset; + Down += joinOffset; + Left += joinOffset; + Right += joinOffset; + Select += joinOffset; + Menu += joinOffset; + Exit += joinOffset; + + HasNumeric += joinOffset; + Digit0 += joinOffset; + Digit1 += joinOffset; + Digit2 += joinOffset; + Digit3 += joinOffset; + Digit4 += joinOffset; + Digit5 += joinOffset; + Digit6 += joinOffset; + Digit7 += joinOffset; + Digit8 += joinOffset; + Digit9 += joinOffset; + Dash += joinOffset; + KeypadEnter += joinOffset; + ChannelUp += joinOffset; + ChannelDown += joinOffset; + LastChannel += joinOffset; + + Guide += joinOffset; + Info += joinOffset; + Red += joinOffset; + Green += joinOffset; + Yellow += joinOffset; + Blue += joinOffset; + + HasDvr += joinOffset; + DvrList += joinOffset; + Play += joinOffset; + Pause += joinOffset; + Stop += joinOffset; + FFwd += joinOffset; + Rewind += joinOffset; + ChapPlus += joinOffset; + ChapMinus += joinOffset; + Replay += joinOffset; + Record += joinOffset; + HasKeypadAccessoryButton1 += joinOffset; + KeypadAccessoryButton1Press += joinOffset; + HasKeypadAccessoryButton2 += joinOffset; + KeypadAccessoryButton2Press += joinOffset; + + Name += joinOffset; + KeypadAccessoryButton1Label += joinOffset; + KeypadAccessoryButton2Label += joinOffset; + + LoadPresets += joinOffset; + } + + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs similarity index 93% rename from PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs index d3a95383..7efd049b 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs @@ -1,49 +1,49 @@ -using System.Linq; -using Crestron.SimplSharp.Reflection; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Bridges -{ - public class StatusSignControllerJoinMap:JoinMapBase - { - public uint IsOnline { get; set; } - public uint Name { get; set; } - public uint RedLed { get; set; } - public uint GreenLed { get; set; } - public uint BlueLed { get; set; } - public uint RedControl { get; set; } - public uint GreenControl { get; set; } - public uint BlueControl { get; set; } - - public StatusSignControllerJoinMap() - { - //digital - IsOnline = 1; - RedControl = 2; - GreenControl = 3; - BlueControl = 4; - - //Analog - RedLed = 2; - GreenLed = 3; - BlueLed = 4; - - //string - Name = 1; - - - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - var properties = - GetType().GetCType().GetProperties().Where(p => p.PropertyType == typeof (uint)).ToList(); - - foreach (var propertyInfo in properties) - { - propertyInfo.SetValue(this, (uint) propertyInfo.GetValue(this, null) + joinOffset, null); - } - } - } +using System.Linq; +using Crestron.SimplSharp.Reflection; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class StatusSignControllerJoinMap:JoinMapBase + { + public uint IsOnline { get; set; } + public uint Name { get; set; } + public uint RedLed { get; set; } + public uint GreenLed { get; set; } + public uint BlueLed { get; set; } + public uint RedControl { get; set; } + public uint GreenControl { get; set; } + public uint BlueControl { get; set; } + + public StatusSignControllerJoinMap() + { + //digital + IsOnline = 1; + RedControl = 2; + GreenControl = 3; + BlueControl = 4; + + //Analog + RedLed = 2; + GreenLed = 3; + BlueLed = 4; + + //string + Name = 1; + + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + var properties = + GetType().GetCType().GetProperties().Where(p => p.PropertyType == typeof (uint)).ToList(); + + foreach (var propertyInfo in properties) + { + propertyInfo.SetValue(this, (uint) propertyInfo.GetValue(this, null) + joinOffset, null); + } + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs similarity index 99% rename from PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs index b2b66263..b2fd3dfd 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs @@ -1,6 +1,6 @@ using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Bridges +namespace PepperDash.Essentials.Core.Bridges { public class SystemMonitorJoinMap : JoinMapBase { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs index 45657e3e..83861dc8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs @@ -2,11 +2,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; - +using Crestron.SimplSharp.CrestronSockets; +using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.Config; @@ -16,7 +17,7 @@ namespace PepperDash.Essentials.Core /// /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports /// - public class GenericComm : ReconfigurableDevice + public class GenericComm : ReconfigurableBridgableDevice { EssentialsControlPropertiesConfig PropertiesConfig; @@ -43,7 +44,7 @@ namespace PepperDash.Essentials.Core try { PropertiesConfig = JsonConvert.DeserializeObject - (portConfig.ToString()); + (portConfig); } catch (Exception e) { @@ -57,9 +58,59 @@ namespace PepperDash.Essentials.Core ConfigWriter.UpdateDeviceConfig(config); } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new IBasicCommunicationJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + joinMap.OffsetJoinNumbers(joinStart); + + if (CommPort == null) + { + Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); + return; + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // this is a permanent event handler. This cannot be -= from event + CommPort.TextReceived += (s, a) => + { + Debug.Console(2, this, "RX: {0}", a.Text); + trilist.SetString(joinMap.TextReceived, a.Text); + }; + trilist.SetStringSigAction(joinMap.SendText, s => CommPort.SendText(s)); + trilist.SetStringSigAction(joinMap.SetPortConfig, SetPortConfig); + + + var sComm = this as ISocketStatus; + if (sComm == null) return; + sComm.ConnectionChange += (s, a) => + { + trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus)); + trilist.SetBool(joinMap.Connected, a.Client.ClientStatus == + SocketStatus.SOCKET_STATUS_CONNECTED); + }; + + trilist.SetBoolSigAction(joinMap.Connect, b => + { + if (b) + { + sComm.Connect(); + } + else + { + sComm.Disconnect(); + } + }); + } } - public class GenericCommFactory : Essentials.Core.EssentialsDeviceFactory + public class GenericCommFactory : EssentialsDeviceFactory { public GenericCommFactory() { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs index 865acd1c..43684eb2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs @@ -1,14 +1,15 @@ -using System; -using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Core.CrestronIO { - public class C2nRthsController:CrestronGenericBaseDevice + public class C2nRthsController:CrestronGenericBridgeableBaseDevice { - private C2nRths _device; + private readonly C2nRths _device; public IntFeedback TemperatureFeedback { get; private set; } public IntFeedback HumidityFeedback { get; private set; } @@ -20,7 +21,7 @@ namespace PepperDash.Essentials.Core.CrestronIO TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue); HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue); - _device.BaseEvent += DeviceOnBaseEvent; + if (_device != null) _device.BaseEvent += DeviceOnBaseEvent; } private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args) @@ -40,5 +41,28 @@ namespace PepperDash.Essentials.Core.CrestronIO { _device.TemperatureFormat.BoolValue = setToC; } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new C2nRthsControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + + trilist.SetBoolSigAction(joinMap.TemperatureFormat, SetTemperatureFormat); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + TemperatureFeedback.LinkInputSig(trilist.UShortInput[joinMap.Temperature]); + HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity]); + + trilist.StringInput[joinMap.Name].StringValue = Name; + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs index 3c1849f9..7abda21e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs @@ -4,12 +4,15 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.CrestronIO { - public class GenericDigitalInputDevice : Device, IDigitalInput + public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput { public DigitalInput InputPort { get; private set; } @@ -30,7 +33,7 @@ namespace PepperDash.Essentials.Core.CrestronIO InputPort = inputPort; - InputPort.StateChange += new DigitalInputEventHandler(InputPort_StateChange); + InputPort.StateChange += InputPort_StateChange; } @@ -39,5 +42,29 @@ namespace PepperDash.Essentials.Core.CrestronIO InputStateFeedback.FireUpdate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new IDigitalInputJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + try + { + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // Link feedback for input state + InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState]); + } + catch (Exception e) + { + Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); + Debug.Console(1, this, "Error: {0}", e); + } + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs index 4786cb2b..95d64976 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs @@ -4,15 +4,18 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.CrestronIO { /// /// Represents a generic device controlled by relays /// - public class GenericRelayDevice : Device, ISwitchedOutput + public class GenericRelayDevice : EssentialsBridgeableDevice, ISwitchedOutput { public Relay RelayOutput { get; private set; } @@ -65,5 +68,37 @@ namespace PepperDash.Essentials.Core.CrestronIO } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new GenericRelayControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + if (RelayOutput == null) + { + Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key); + return; + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + trilist.SetBoolSigAction(joinMap.Relay, b => + { + if (b) + CloseRelay(); + else + OpenRelay(); + }); + + // feedback for relay state + + OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs index b83eae37..7835db7e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs @@ -2,13 +2,15 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Core.CrestronIO { - public class StatusSignController:CrestronGenericBaseDevice + public class StatusSignController:CrestronGenericBridgeableBaseDevice { - private StatusSign _device; + private readonly StatusSign _device; public BoolFeedback RedLedEnabledFeedback { get; private set; } public BoolFeedback GreenLedEnabledFeedback { get; private set; } @@ -45,7 +47,7 @@ namespace PepperDash.Essentials.Core.CrestronIO BlueLedBrightnessFeedback = new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Blue].BrightnessFeedback); - _device.BaseEvent += _device_BaseEvent; + if (_device != null) _device.BaseEvent += _device_BaseEvent; } void _device_BaseEvent(GenericBase device, BaseEventArgs args) @@ -103,5 +105,57 @@ namespace PepperDash.Essentials.Core.CrestronIO Debug.Console(1, this, "Error converting value to Blue LED brightness. value: {0}", blue); } } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new StatusSignControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + trilist.SetBoolSigAction(joinMap.RedControl, b => EnableControl(trilist, joinMap, this)); + trilist.SetBoolSigAction(joinMap.GreenControl, b => EnableControl(trilist, joinMap, this)); + trilist.SetBoolSigAction(joinMap.BlueControl, b => EnableControl(trilist, joinMap, this)); + + trilist.SetUShortSigAction(joinMap.RedLed, u => SetColor(trilist, joinMap, this)); + trilist.SetUShortSigAction(joinMap.GreenLed, u => SetColor(trilist, joinMap, this)); + trilist.SetUShortSigAction(joinMap.BlueLed, u => SetColor(trilist, joinMap, this)); + + trilist.StringInput[joinMap.Name].StringValue = Name; + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl]); + BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl]); + GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl]); + + RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed]); + BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed]); + GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed]); + } + + private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redEnable = triList.BooleanOutput[joinMap.RedControl].BoolValue; + var greenEnable = triList.BooleanOutput[joinMap.GreenControl].BoolValue; + var blueEnable = triList.BooleanOutput[joinMap.BlueControl].BoolValue; + device.EnableLedControl(redEnable, greenEnable, blueEnable); + } + + private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redBrightness = triList.UShortOutput[joinMap.RedLed].UShortValue; + var greenBrightness = triList.UShortOutput[joinMap.GreenLed].UShortValue; + var blueBrightness = triList.UShortOutput[joinMap.BlueLed].UShortValue; + + device.SetColor(redBrightness, greenBrightness, blueBrightness); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs index 6d6a5fb4..0dbba8c4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs @@ -1,19 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; +using System.Linq; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; - using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core { /// /// A bridge class to cover the basic features of GenericBase hardware /// - public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking + public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking { public virtual GenericBase Hardware { get; protected set; } @@ -32,7 +29,7 @@ namespace PepperDash.Essentials.Core /// public bool PreventRegistration { get; protected set; } - public CrestronGenericBaseDevice(string key, string name, GenericBase hardware) + protected CrestronGenericBaseDevice(string key, string name, GenericBase hardware) : base(key, name) { Feedbacks = new FeedbackCollection(); @@ -40,13 +37,7 @@ namespace PepperDash.Essentials.Core Hardware = hardware; IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); - IpConnectionsText = new StringFeedback("IpConnectionsText", () => - { - if (Hardware.ConnectedIpList != null) - return string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()); - else - return string.Empty; - }); + IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty); AddToFeedbackList(IsOnline, IpConnectionsText); CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); @@ -78,7 +69,7 @@ namespace PepperDash.Essentials.Core f.FireUpdate(); } - Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange); + Hardware.OnlineStatusChange += Hardware_OnlineStatusChange; CommunicationMonitor.Start(); return true; @@ -99,8 +90,8 @@ namespace PepperDash.Essentials.Core return success; } - - /// + + /// /// Adds feedback(s) to the list /// /// @@ -108,12 +99,11 @@ namespace PepperDash.Essentials.Core { foreach (var f in newFbs) { - if (f != null) + if (f == null) continue; + + if (!Feedbacks.Contains(f)) { - if (!Feedbacks.Contains(f)) - { - Feedbacks.Add(f); - } + Feedbacks.Add(f); } } } @@ -140,6 +130,17 @@ namespace PepperDash.Essentials.Core #endregion } + public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced + { + protected CrestronGenericBridgeableBaseDevice(string key, string name, GenericBase hardware) : base(key, name, hardware) + { + } + + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); + } + + //*********************************************************************************** public class CrestronGenericBaseDeviceEventIds { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs new file mode 100644 index 00000000..36c5c692 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs @@ -0,0 +1,19 @@ +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash_Essentials_Core.Devices +{ + public abstract class EssentialsBridgeableDevice:EssentialsDevice, IBridgeAdvanced + { + protected EssentialsBridgeableDevice(string key) : base(key) + { + } + + protected EssentialsBridgeableDevice(string key, string name) : base(key, name) + { + } + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs index b19b40b5..6719ae06 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.Devices @@ -18,7 +19,7 @@ namespace PepperDash.Essentials.Core.Devices public DeviceConfig Config { get; private set; } - public ReconfigurableDevice(DeviceConfig config) + protected ReconfigurableDevice(DeviceConfig config) : base(config.Key) { SetNameHelper(config); @@ -60,4 +61,13 @@ namespace PepperDash.Essentials.Core.Devices ConfigWriter.UpdateDeviceConfig(config); } } + + public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced + { + protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config) + { + } + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs index 3ffd0bf4..740c241d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.Core @@ -201,5 +202,10 @@ namespace PepperDash.Essentials.Core } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs index 98659ab2..4e5a177c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -4,11 +4,14 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - +using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core @@ -16,7 +19,7 @@ namespace PepperDash.Essentials.Core /// /// /// - public abstract class DisplayBase : Device, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking + public abstract class DisplayBase : EssentialsBridgeableDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking { public event SourceInfoChangeHandler CurrentSourceChange; @@ -71,7 +74,7 @@ namespace PepperDash.Essentials.Core #endregion - public DisplayBase(string key, string name) + protected DisplayBase(string key, string name) : base(key, name) { PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); @@ -113,6 +116,132 @@ namespace PepperDash.Essentials.Core public abstract void ExecuteSwitch(object selector); + protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApi bridge) + { + var inputNumber = 0; + var inputKeys = new List(); + + var joinMap = new DisplayControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); + + trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name; + + var commMonitor = displayDevice as ICommunicationMonitor; + if (commMonitor != null) + { + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + } + + var inputNumberFeedback = new IntFeedback(() => inputNumber); + + // Two way feedbacks + var twoWayDisplay = displayDevice as TwoWayDisplayBase; + + if (twoWayDisplay != null) + { + trilist.SetBool(joinMap.IsTwoWayDisplay, true); + + twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); + + + inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]); + } + + // Power Off + trilist.SetSigTrueAction(joinMap.PowerOff, () => + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOff(); + }); + + displayDevice.PowerIsOnFeedback.OutputChange += (o, a) => + { + if (!a.BoolValue) + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + + } + else + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + } + }; + + displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); + + // PowerOn + trilist.SetSigTrueAction(joinMap.PowerOn, () => + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOn(); + }); + + + displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); + + var count = 1; + foreach (var input in displayDevice.InputPorts) + { + inputKeys.Add(input.Key); + var tempKey = inputKeys.ElementAt(count - 1); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); + Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString(); + count++; + } + + Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + trilist.SetUShortSigAction(joinMap.InputSelect, (a) => + { + if (a == 0) + { + displayDevice.PowerOff(); + inputNumber = 0; + } + else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) + { + displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); + inputNumber = a; + } + else if (a == 102) + { + displayDevice.PowerToggle(); + + } + if (twoWayDisplay != null) + inputNumberFeedback.FireUpdate(); + }); + + + var volumeDisplay = displayDevice as IBasicVolumeControls; + if (volumeDisplay == null) return; + + trilist.SetBoolSigAction(joinMap.VolumeUp, volumeDisplay.VolumeUp); + trilist.SetBoolSigAction(joinMap.VolumeDown, volumeDisplay.VolumeDown); + trilist.SetSigTrueAction(joinMap.VolumeMute, volumeDisplay.MuteToggle); + + var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; + + if (volumeDisplayWithFeedback == null) return; + + trilist.SetUShortSigAction(joinMap.VolumeLevel, volumeDisplayWithFeedback.SetVolume); + volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); + } } /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs index bf728e8a..fc43174c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; @@ -174,5 +176,10 @@ namespace PepperDash.Essentials.Core } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs index af779c16..0d8d8f6f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs @@ -4,12 +4,15 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.Lighting { - public abstract class LightingBase : Device, ILightingScenes + public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes { #region ILightingScenes Members @@ -23,8 +26,7 @@ namespace PepperDash.Essentials.Core.Lighting #endregion - - public LightingBase(string key, string name) + protected LightingBase(string key, string name) : base(key, name) { LightingScenes = new List(); @@ -69,6 +71,41 @@ namespace PepperDash.Essentials.Core.Lighting } } + protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart, + string joinMapKey, EiscApi bridge) + { + var joinMap = new GenericLightingJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); + + // GenericLighitng Actions & FeedBack + trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); + + var sceneIndex = 1; + foreach (var scene in lightingDevice.LightingScenes) + { + var tempIndex = sceneIndex - 1; + trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex])); + scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); + trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; + trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; + sceneIndex++; + } + + + + return joinMap; + } + } public class LightingScene diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs index 495a4a58..7ede2a52 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs @@ -1,10 +1,13 @@ using System; using System.Collections.Generic; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.Diagnostics; using PepperDash.Core; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.Monitoring { @@ -12,7 +15,7 @@ namespace PepperDash.Essentials.Core.Monitoring /// Wrapper for the static SystemMonitor class to extend functionality and provide external access /// to SystemMonitor via APIs /// - public class SystemMonitorController : Device + public class SystemMonitorController : EssentialsBridgeableDevice { private const long UptimePollTime = 300000; private CTimer _uptimePollTimer; @@ -198,6 +201,101 @@ namespace PepperDash.Essentials.Core.Monitoring return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new SystemMonitorJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(2, this, "Linking API starting at join: {0}", joinStart); + + TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone]); + TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName]); + + IoControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.IOControllerVersion]); + SnmpVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.SnmpAppVersion]); + BaCnetAppVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.BACnetAppVersion]); + ControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.ControllerVersion]); + SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumber]); + ModelFeedback.LinkInputSig(trilist.StringInput[joinMap.Model]); + UptimeFeedback.LinkInputSig(trilist.StringInput[joinMap.Uptime]); + LastStartFeedback.LinkInputSig(trilist.StringInput[joinMap.LastBoot]); + + // iterate the program status feedback collection and map all the joins + LinkProgramInfoJoins(this, trilist, joinMap); + + LinkEthernetInfoJoins(this, trilist, joinMap); + } + + private static void LinkEthernetInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, SystemMonitorJoinMap joinMap) + { + var ethernetSlotJoinStart = joinMap.EthernetStartJoin; + + foreach (var fb in systemMonitorController.EthernetStatusFeedbackCollection) + { + fb.Value.CurrentIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentIpAddress]); + fb.Value.CurrentSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentSubnetMask]); + fb.Value.CurrentDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentDefaultGateway]); + fb.Value.StaticIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticIpAddress]); + fb.Value.StaticSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticSubnetMask]); + fb.Value.StaticDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticDefaultGateway]); + fb.Value.HostNameFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.HostName]); + fb.Value.MacAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.MacAddress]); + fb.Value.DomainFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.Domain]); + fb.Value.DnsServerFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DnsServer]); + fb.Value.DhcpStatusFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DhcpStatus]); + + ethernetSlotJoinStart += joinMap.EthernetOffsetJoin; + } + } + + private static void LinkProgramInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, + SystemMonitorJoinMap joinMap) + { + var programSlotJoinStart = joinMap.ProgramStartJoin; + + foreach (var p in systemMonitorController.ProgramStatusFeedbackCollection) + { + var programNumber = p.Value.Program.Number; + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStart, + b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Start); + p.Value.ProgramStartedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStart]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStop, + b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Stop); + p.Value.ProgramStoppedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStop]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramRegister, + b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Register); + p.Value.ProgramRegisteredFeedback.LinkInputSig( + trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramRegister]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramUnregister, + b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Unregister); + p.Value.ProgramUnregisteredFeedback.LinkInputSig( + trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramUnregister]); + + p.Value.ProgramNameFeedback.LinkInputSig(trilist.StringInput[programSlotJoinStart + joinMap.ProgramName]); + p.Value.ProgramCompileTimeFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramCompiledTime]); + p.Value.CrestronDataBaseVersionFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramCrestronDatabaseVersion]); + p.Value.EnvironmentVersionFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramEnvironmentVersion]); + p.Value.AggregatedProgramInfoFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.AggregatedProgramInfo]); + + programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin; + } + } + //// Sets the time zone //public void SetTimeZone(int timeZone) //{ diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index de778fc5..e7a5a8ac 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -111,6 +111,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -132,6 +155,7 @@ + diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index 28358a51..ad2309c0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -1,220 +1,263 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.DeviceSupport.Support; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM.AirMedia -{ - public class AirMediaController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IIROutputPorts, IComPorts - { - public AmX00 AirMedia { get; private set; } - - public DeviceConfig DeviceConfig { get; private set; } - - AirMediaPropertiesConfig PropertiesConfig; - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - public BoolFeedback IsInSessionFeedback { get; private set; } - public IntFeedback ErrorFeedback { get; private set; } - public IntFeedback NumberOfUsersConnectedFeedback { get; set; } - public IntFeedback LoginCodeFeedback { get; set; } - public StringFeedback ConnectionAddressFeedback { get; set; } - public StringFeedback HostnameFeedback { get; set; } - public IntFeedback VideoOutFeedback { get; private set; } - public BoolFeedback HdmiVideoSyncDetectedFeedback { get; private set; } - public StringFeedback SerialNumberFeedback { get; private set; } - public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } - - public AirMediaController(string key, string name, AmX00 device, DeviceConfig dc, AirMediaPropertiesConfig props) - :base(key, name, device) - { - AirMedia = device; - - DeviceConfig = dc; - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.DeviceSupport.Support; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.AirMedia; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.DM.AirMedia +{ + public class AirMediaController : CrestronGenericBridgeableBaseDevice, IRoutingInputsOutputs, IIROutputPorts, IComPorts + { + public AmX00 AirMedia { get; private set; } + + public DeviceConfig DeviceConfig { get; private set; } + + AirMediaPropertiesConfig PropertiesConfig; + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + public BoolFeedback IsInSessionFeedback { get; private set; } + public IntFeedback ErrorFeedback { get; private set; } + public IntFeedback NumberOfUsersConnectedFeedback { get; set; } + public IntFeedback LoginCodeFeedback { get; set; } + public StringFeedback ConnectionAddressFeedback { get; set; } + public StringFeedback HostnameFeedback { get; set; } + public IntFeedback VideoOutFeedback { get; private set; } + public BoolFeedback HdmiVideoSyncDetectedFeedback { get; private set; } + public StringFeedback SerialNumberFeedback { get; private set; } + public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } + + public AirMediaController(string key, string name, AmX00 device, DeviceConfig dc, AirMediaPropertiesConfig props) + :base(key, name, device) + { + AirMedia = device; + + DeviceConfig = dc; + PropertiesConfig = props; InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this)); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this)); - - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this)); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.Video, - eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this)); - - if (AirMedia is Am300) - { - InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this)); - } - - AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); - - IsInSessionFeedback = new BoolFeedback( new Func(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0 )); - ErrorFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.ErrorFeedback.UShortValue)); - NumberOfUsersConnectedFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue)); - LoginCodeFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue)); - ConnectionAddressFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue)); - HostnameFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.HostNameFeedback.StringValue)); - - // TODO: Figure out if we can actually get the TSID/Serial - SerialNumberFeedback = new StringFeedback(new Func(() => "unknown")); - - AirMedia.DisplayControl.DisplayControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(DisplayControl_DisplayControlChange); - - VideoOutFeedback = new IntFeedback(new Func(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback))); - AutomaticInputRoutingEnabledFeedback = new BoolFeedback(new Func(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue)); - - AirMedia.HdmiIn.StreamChange += new Crestron.SimplSharpPro.DeviceSupport.StreamEventHandler(HdmiIn_StreamChange); - - HdmiVideoSyncDetectedFeedback = new BoolFeedback(new Func(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue)); - } - - public override bool CustomActivate() - { - if (PropertiesConfig.AutoSwitchingEnabled) - AirMedia.DisplayControl.EnableAutomaticRouting(); - else - AirMedia.DisplayControl.DisableAutomaticRouting(); - - return base.CustomActivate(); - } - - void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - if (args.EventId == AirMediaInputSlot.AirMediaStatusFeedbackEventId) - IsInSessionFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaErrorFeedbackEventId) - ErrorFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId) - NumberOfUsersConnectedFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaLoginCodeEventId) - LoginCodeFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId) - ConnectionAddressFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaHostNameFeedbackEventId) - HostnameFeedback.FireUpdate(); - } - - void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - if (args.EventId == AmX00.VideoOutFeedbackEventId) - VideoOutFeedback.FireUpdate(); - else if (args.EventId == AmX00.EnableAutomaticRoutingFeedbackEventId) - AutomaticInputRoutingEnabledFeedback.FireUpdate(); - } - - void HdmiIn_StreamChange(Crestron.SimplSharpPro.DeviceSupport.Stream stream, Crestron.SimplSharpPro.DeviceSupport.StreamEventArgs args) - { - if (args.EventId == DMInputEventIds.SourceSyncEventId) - HdmiVideoSyncDetectedFeedback.FireUpdate(); - } - - /// - /// Sets the VideoOut source ( 0 = PinpointUX, 1 = AirMedia, 2 = HDMI, 3 = DM, 4 = Airboard ) - /// - /// source number - public void SelectVideoOut(uint source) - { - AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource)source; - } - - /// - /// Selects the PinPointUXLandingPage input - /// - public void SelectPinPointUxLandingPage() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.PinPointUxLandingPage; - } - - /// - /// Selects the AirMedia input - /// - public void SelectAirMedia() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirMedia; - } - - /// - /// Selects the DM input - /// - public void SelectDmIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.HDMI; - } - - /// - /// Selects the HDMI INput - /// - public void SelectHdmiIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.DM; - } - - public void SelectAirboardIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirBoard; - } - - /// - /// Reboots the device - /// - public void RebootDevice() - { - AirMedia.AirMedia.DeviceReboot(); - } - - #region IIROutputPorts Members - - public CrestronCollection IROutputPorts - { - get { return AirMedia.IROutputPorts; } - } - - public int NumberOfIROutputPorts - { - get { return AirMedia.NumberOfIROutputPorts; } - } - - - - #endregion - - - - #region IComPorts Members - - public CrestronCollection ComPorts - { - get { return AirMedia.ComPorts; } - } - - public int NumberOfComPorts - { - get { return AirMedia.NumberOfComPorts; } - } - - #endregion - - - } + OutputPorts = new RoutingPortCollection(); + + InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this)); + + InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this)); + + InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this)); + + InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.Video, + eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this)); + + if (AirMedia is Am300) + { + InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this)); + } + + AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); + + IsInSessionFeedback = new BoolFeedback( new Func(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0 )); + ErrorFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.ErrorFeedback.UShortValue)); + NumberOfUsersConnectedFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue)); + LoginCodeFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue)); + ConnectionAddressFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue)); + HostnameFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.HostNameFeedback.StringValue)); + + // TODO: Figure out if we can actually get the TSID/Serial + SerialNumberFeedback = new StringFeedback(new Func(() => "unknown")); + + AirMedia.DisplayControl.DisplayControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(DisplayControl_DisplayControlChange); + + VideoOutFeedback = new IntFeedback(new Func(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback))); + AutomaticInputRoutingEnabledFeedback = new BoolFeedback(new Func(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue)); + + AirMedia.HdmiIn.StreamChange += new Crestron.SimplSharpPro.DeviceSupport.StreamEventHandler(HdmiIn_StreamChange); + + HdmiVideoSyncDetectedFeedback = new BoolFeedback(new Func(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue)); + } + + public override bool CustomActivate() + { + if (PropertiesConfig.AutoSwitchingEnabled) + AirMedia.DisplayControl.EnableAutomaticRouting(); + else + AirMedia.DisplayControl.DisableAutomaticRouting(); + + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new AirMediaControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Airmedia: {0}", Name); + + trilist.StringInput[joinMap.Name].StringValue = Name; + + var commMonitor = this as ICommunicationMonitor; + + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + + IsInSessionFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsInSession]); + HdmiVideoSyncDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiVideoSync]); + + trilist.SetSigTrueAction(joinMap.AutomaticInputRoutingEnabled, AirMedia.DisplayControl.EnableAutomaticRouting); + trilist.SetSigFalseAction(joinMap.AutomaticInputRoutingEnabled, AirMedia.DisplayControl.DisableAutomaticRouting); + AutomaticInputRoutingEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutomaticInputRoutingEnabled]); + + trilist.SetUShortSigAction(joinMap.VideoOut, (u) => SelectVideoOut(u)); + + VideoOutFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoOut]); + ErrorFeedback.LinkInputSig(trilist.UShortInput[joinMap.ErrorFB]); + NumberOfUsersConnectedFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfUsersConnectedFB]); + + trilist.SetUShortSigAction(joinMap.LoginCode, (u) => AirMedia.AirMedia.LoginCode.UShortValue = u); + LoginCodeFeedback.LinkInputSig(trilist.UShortInput[joinMap.LoginCode]); + + ConnectionAddressFeedback.LinkInputSig(trilist.StringInput[joinMap.ConnectionAddressFB]); + HostnameFeedback.LinkInputSig(trilist.StringInput[joinMap.HostnameFB]); + SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumberFeedback]); + } + + void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + if (args.EventId == AirMediaInputSlot.AirMediaStatusFeedbackEventId) + IsInSessionFeedback.FireUpdate(); + else if (args.EventId == AirMediaInputSlot.AirMediaErrorFeedbackEventId) + ErrorFeedback.FireUpdate(); + else if (args.EventId == AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId) + NumberOfUsersConnectedFeedback.FireUpdate(); + else if (args.EventId == AirMediaInputSlot.AirMediaLoginCodeEventId) + LoginCodeFeedback.FireUpdate(); + else if (args.EventId == AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId) + ConnectionAddressFeedback.FireUpdate(); + else if (args.EventId == AirMediaInputSlot.AirMediaHostNameFeedbackEventId) + HostnameFeedback.FireUpdate(); + } + + void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + if (args.EventId == AmX00.VideoOutFeedbackEventId) + VideoOutFeedback.FireUpdate(); + else if (args.EventId == AmX00.EnableAutomaticRoutingFeedbackEventId) + AutomaticInputRoutingEnabledFeedback.FireUpdate(); + } + + void HdmiIn_StreamChange(Crestron.SimplSharpPro.DeviceSupport.Stream stream, Crestron.SimplSharpPro.DeviceSupport.StreamEventArgs args) + { + if (args.EventId == DMInputEventIds.SourceSyncEventId) + HdmiVideoSyncDetectedFeedback.FireUpdate(); + } + + /// + /// Sets the VideoOut source ( 0 = PinpointUX, 1 = AirMedia, 2 = HDMI, 3 = DM, 4 = Airboard ) + /// + /// source number + public void SelectVideoOut(uint source) + { + AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource)source; + } + + /// + /// Selects the PinPointUXLandingPage input + /// + public void SelectPinPointUxLandingPage() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.PinPointUxLandingPage; + } + + /// + /// Selects the AirMedia input + /// + public void SelectAirMedia() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirMedia; + } + + /// + /// Selects the DM input + /// + public void SelectDmIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.HDMI; + } + + /// + /// Selects the HDMI INput + /// + public void SelectHdmiIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.DM; + } + + public void SelectAirboardIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirBoard; + } + + /// + /// Reboots the device + /// + public void RebootDevice() + { + AirMedia.AirMedia.DeviceReboot(); + } + + #region IIROutputPorts Members + + public CrestronCollection IROutputPorts + { + get { return AirMedia.IROutputPorts; } + } + + public int NumberOfIROutputPorts + { + get { return AirMedia.NumberOfIROutputPorts; } + } + + + + #endregion + + + + #region IComPorts Members + + public CrestronCollection ComPorts + { + get { return AirMedia.ComPorts; } + } + + public int NumberOfComPorts + { + get { return AirMedia.NumberOfComPorts; } + } + + #endregion + + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 7d57127a..15860c90 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -4,15 +4,16 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Cards; using Crestron.SimplSharpPro.DM.Blades; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; - +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM { @@ -20,7 +21,7 @@ namespace PepperDash.Essentials.DM { /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// /// - public class DmBladeChassisController : CrestronGenericBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback { + public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback { public DMChassisPropertiesConfig PropertiesConfig { get; set; } public Switch Chassis { get; private set; } @@ -570,6 +571,243 @@ namespace PepperDash.Essentials.DM { #endregion + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DmBladeChassisControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + + // Link up outputs + for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) + { + var ioSlot = i; + + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)); + + if (TxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + var txKey = TxDictionary[ioSlot]; + var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as DmTxControllerBase; + + var advancedTxDevice = basicTxDevice as DmTxControllerBase; + + if (Chassis is DmMd128x128 || Chassis is DmMd64x64) + { + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + else + { + if (advancedTxDevice != null) + { + advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); + } + else if (InputEndpointOnlineFeedbacks[ioSlot] != null) + { + Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + } + + if (basicTxDevice != null && advancedTxDevice == null) + trilist.BooleanInput[joinMap.TxAdvancedIsPresent + ioSlot].BoolValue = true; + + if (advancedTxDevice != null) + { + advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + } + else + { + Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + Debug.Console(1, "Port value for input card {0} is set", ioSlot); + var port = inputPort.Port; + + if (port != null) + { + if (port is HdmiInputWithCEC) + { + Debug.Console(1, "Port is HdmiInputWithCec"); + + var hdmiInPortWCec = port as HdmiInputWithCEC; + + if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) + { + SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + } + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + else + { + inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; + + if (inputPort != null) + { + var port = inputPort.Port; + + if (port is DMInputPortWithCec) + { + Debug.Console(1, "Port is DMInputPortWithCec"); + + var dmInPortWCec = port as DMInputPortWithCec; + + SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + } + } + else + { + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + var hdmiPort = inputPort.Port as EndpointHdmiInput; + + if (hdmiPort != null) + { + SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState + ioSlot, trilist); + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + } + } + } + if (RxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + //var rxKey = RxDictionary[ioSlot]; + //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + //if (hdBaseTDevice != null) { + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + //} + //else if (rxDevice != null) { + // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + //} + } + + // Feedback + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + + + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } } /* diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 033d6a54..e546b842 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -2,10 +2,14 @@ using System; using System.Collections.Generic; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Endpoints; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -14,7 +18,7 @@ namespace PepperDash.Essentials.DM /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// /// - public class DmChassisController : CrestronGenericBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback + public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback { public DMChassisPropertiesConfig PropertiesConfig { get; set; } @@ -985,6 +989,277 @@ namespace PepperDash.Essentials.DM } } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DmChassisControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + var chassis = Chassis as DmMDMnxn; + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + + trilist.SetUShortSigAction(joinMap.SystemId, o => + { + if (chassis != null) + chassis.SystemId.UShortValue = o; + }); + + trilist.SetSigTrueAction(joinMap.SystemId, () => { + if (chassis != null) chassis.ApplySystemId(); + }); + + SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId]); + SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId]); + + // Link up outputs + for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) + { + var ioSlot = i; + + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)); + trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)); + trilist.SetUShortSigAction(joinMap.OutputUsb + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.UsbOutput)); + trilist.SetUShortSigAction(joinMap.InputUsb + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.UsbInput)); + + if (TxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + var txKey = TxDictionary[ioSlot]; + var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as DmTxControllerBase; + + var advancedTxDevice = basicTxDevice; + + if (Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps + || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps + || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps) + { + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + else + { + if (advancedTxDevice != null) + { + advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); + } + else if (InputEndpointOnlineFeedbacks[ioSlot] != null) + { + Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + } + + if (basicTxDevice != null && advancedTxDevice == null) + trilist.BooleanInput[joinMap.TxAdvancedIsPresent + ioSlot].BoolValue = true; + + if (advancedTxDevice != null) + { + advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + } + else if (advancedTxDevice == null || basicTxDevice != null) + { + Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + Debug.Console(1, "Port value for input card {0} is set", ioSlot); + var port = inputPort.Port; + + if (port != null) + { + if (port is HdmiInputWithCEC) + { + Debug.Console(1, "Port is HdmiInputWithCec"); + + var hdmiInPortWCec = port as HdmiInputWithCEC; + + if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) + { + SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + } + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + else + { + inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; + + if (inputPort != null) + { + var port = inputPort.Port; + + if (port is DMInputPortWithCec) + { + Debug.Console(1, "Port is DMInputPortWithCec"); + + var dmInPortWCec = port as DMInputPortWithCec; + + if (dmInPortWCec != null) + { + SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + } + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + } + } + else + { + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + var hdmiPort = inputPort.Port as EndpointHdmiInput; + + if (hdmiPort != null) + { + SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState + ioSlot, trilist); + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + } + } + } + + if (RxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + var rxKey = RxDictionary[ioSlot]; + var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + if (Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps + || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps + || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps || hdBaseTDevice != null) + { + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + else if (rxDevice != null) + { + rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + } + + // Feedback + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); + UsbOutputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputUsb + ioSlot]); + UsbInputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.InputUsb + ioSlot]); + + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); + + OutputDisabledByHdcpFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputDisabledByHdcp + ioSlot]); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } } public struct PortNumberType diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs index 8856be01..45e1d0ee 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs @@ -4,21 +4,22 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Cards; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; - +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.DM { /// /// Exposes the volume levels for Program, Aux1 or Aux2 outputs on a DMPS3 chassis /// - public class DmpsAudioOutputController : Device + public class DmpsAudioOutputController : EssentialsBridgeableDevice { Card.Dmps3OutputBase OutputCard; @@ -100,6 +101,62 @@ namespace PepperDash.Essentials.DM } } } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DmpsAudioOutputControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + if (MasterVolumeLevel != null) + { + SetUpDmpsAudioOutputJoins(trilist, MasterVolumeLevel, joinMap.MasterVolume); + } + + if (SourceVolumeLevel != null) + { + SetUpDmpsAudioOutputJoins(trilist, SourceVolumeLevel, joinMap.SourceVolume); + } + + if (Codec1VolumeLevel != null) + { + SetUpDmpsAudioOutputJoins(trilist, Codec1VolumeLevel, joinMap.Codec1Volume); + } + + if (Codec2VolumeLevel != null) + { + SetUpDmpsAudioOutputJoins(trilist, Codec2VolumeLevel, joinMap.Codec2Volume); + } + + } + + static void SetUpDmpsAudioOutputJoins(BasicTriList trilist, DmpsAudioOutput output, uint joinStart) + { + var volumeLevelJoin = joinStart; + var muteOnJoin = joinStart; + var muteOffJoin = joinStart + 1; + var volumeUpJoin = joinStart + 2; + var volumeDownJoin = joinStart + 3; + + + trilist.SetUShortSigAction(volumeLevelJoin, output.SetVolume); + output.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[volumeLevelJoin]); + + trilist.SetSigTrueAction(muteOnJoin, output.MuteOn); + output.MuteFeedback.LinkInputSig(trilist.BooleanInput[muteOnJoin]); + trilist.SetSigTrueAction(muteOffJoin, output.MuteOff); + output.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[muteOffJoin]); + + trilist.SetBoolSigAction(volumeUpJoin, output.VolumeUp); + trilist.SetBoolSigAction(volumeDownJoin, output.VolumeDown); + } } public class DmpsAudioOutput : IBasicVolumeWithFeedback diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 6ed0e63b..c9b545c9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -4,19 +4,22 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Cards; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; - +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; +using PepperDash_Essentials_Core.Devices; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.DM { - public class DmpsRoutingController : Device, IRoutingInputsOutputs, IRouting, IHasFeedback + public class DmpsRoutingController : EssentialsBridgeableDevice, IRouting, IHasFeedback { public CrestronControlSystem Dmps { get; set; } public ISystemControl SystemControl { get; private set; } @@ -151,6 +154,114 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DmpsRoutingControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // Link up outputs + for (uint i = 1; i <= Dmps.NumberOfSwitcherInputs; i++) + { + Debug.Console(2, this, "Linking Input Card {0}", i); + + var ioSlot = i; + + //if (TxDictionary.ContainsKey(ioSlot)) + //{ + // Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + // var TxKey = TxDictionary[ioSlot]; + // var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; + // //TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + // // TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + // // trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); + // // TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]); + // // trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability; + //} + //else + //{ + // // dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]); + //} + + if (VideoInputSyncFeedbacks[ioSlot] != null) + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + if (InputNameFeedbacks[ioSlot] != null) + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + + trilist.SetStringSigAction(joinMap.InputNames + ioSlot, new Action(s => + { + var inputCard = Dmps.SwitcherInputs[ioSlot] as DMInput; + + if (inputCard != null) + { + if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) && inputCard.NameFeedback.StringValue != s) + if (inputCard.Name != null) + inputCard.Name.StringValue = s; + } + })); + + + if (InputEndpointOnlineFeedbacks[ioSlot] != null) + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + + for (uint i = 1; i <= Dmps.NumberOfSwitcherOutputs; i++) + { + Debug.Console(2, this, "Linking Output Card {0}", i); + + var ioSlot = i; + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)); + trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)); + + trilist.SetStringSigAction(joinMap.OutputNames + ioSlot, s => + { + var outputCard = Dmps.SwitcherOutputs[ioSlot] as DMOutput; + + //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); + + if (outputCard != null) + { + //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); + + if (!(outputCard is Card.Dmps3CodecOutput) && outputCard.NameFeedback != null) + { + if (!string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) + { + //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); + + if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) + { + outputCard.Name.StringValue = s; + } + } + } + } + }); + + // Feedback + if (VideoOutputFeedbacks[ioSlot] != null) + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + if (AudioOutputFeedbacks[ioSlot] != null) + AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); + if (OutputNameFeedbacks[ioSlot] != null) + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + if (OutputVideoRouteNameFeedbacks[ioSlot] != null) + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + if (OutputAudioRouteNameFeedbacks[ioSlot] != null) + OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); + if (OutputEndpointOnlineFeedbacks[ioSlot] != null) + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + } /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs b/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs index 8113c218..0d002dbf 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs @@ -4,19 +4,21 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { /// /// Represent both a transmitter and receiver pair of the HD-MD-400-C-E / HD-MD-300-C-E / HD-MD-200-C-E kits /// - public class HdMdxxxCEController : CrestronGenericBaseDevice, IRouting//, IComPorts + public class HdMdxxxCEController : CrestronGenericBridgeableBaseDevice, IRouting//, IComPorts { /// ///// DmLite Ports @@ -217,6 +219,49 @@ namespace PepperDash.Essentials.DM //public CrestronCollection ComPorts { get { return TxRxPair.ComPorts as CrestronCollection; } } //public int NumberOfComPorts { get { return 1; } } //#endregion + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new HdMdxxxCEControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + RemoteEndDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RemoteEndDetected]); + + trilist.SetSigTrueAction(joinMap.AutoRouteOn, AutoRouteOn); + AutoRouteOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoRouteOn]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff, AutoRouteOff); + AutoRouteOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoRouteOff]); + + trilist.SetSigTrueAction(joinMap.PriorityRoutingOn, PriorityRouteOn); + PriorityRoutingOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOn]); + trilist.SetSigTrueAction(joinMap.PriorityRoutingOff, PriorityRouteOff); + PriorityRoutingOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOff]); + + trilist.SetSigTrueAction(joinMap.InputOnScreenDisplayEnabled, OnScreenDisplayEnable); + InputOnScreenDisplayEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayEnabled]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff, OnScreenDisplayDisable); + InputOnScreenDisplayEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayDisabled]); + + trilist.SetUShortSigAction(joinMap.VideoSource, (i) => ExecuteSwitch(i, null, eRoutingSignalType.Video | eRoutingSignalType.Audio)); + VideoSourceFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoSource]); + + trilist.UShortInput[joinMap.SourceCount].UShortValue = (ushort)InputPorts.Count; + + foreach (var input in InputPorts) + { + var number = Convert.ToUInt16(input.Selector); + SyncDetectedFeedbacks[number].LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected + number]); + trilist.StringInput[joinMap.SourceNames + number].StringValue = input.Key; + } + } } public class HdMdxxxCEPropertiesConfig diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs index 49034fab..3ce6dee0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -56,6 +58,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs index e5d5a7df..ea17b8aa 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,6 +97,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs index 7fbef021..a5e977c7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,7 +97,12 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } - #region IIROutputPorts Members + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs index ec2ead98..8ac18c49 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,6 +97,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs index 9f2a5251..957efb56 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,7 +97,12 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } - #region IIROutputPorts Members + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs index e12aa8e6..b9d61e34 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -102,7 +104,12 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } - #region IIROutputPorts Members + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs index 1d614854..5be4ab41 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -102,6 +104,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index f8ad5cf6..09ace234 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -8,14 +8,15 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM { - public abstract class DmRmcControllerBase : CrestronGenericBaseDevice + public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice { public virtual StringFeedback VideoOutputResolutionFeedback { get; protected set; } public virtual StringFeedback EdidManufacturerFeedback { get; protected set; } @@ -33,6 +34,32 @@ namespace PepperDash.Essentials.DM } AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); } + + protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DmRmcControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + if (rmc.VideoOutputResolutionFeedback != null) + rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution]); + if (rmc.EdidManufacturerFeedback != null) + rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer]); + if (rmc.EdidNameFeedback != null) + rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName]); + if (rmc.EdidPreferredTimingFeedback != null) + rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming]); + if (rmc.EdidSerialNumberFeedback != null) + rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber]); + } } public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs index c488864e..a43c7ec7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,7 +97,12 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } - #region IIROutputPorts Members + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs index 29ba7789..e85a7c0a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,6 +97,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs index 0371f765..7da65899 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -95,6 +97,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs index 33bb6fce..ad77df49 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { @@ -56,7 +58,12 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } - #region IIROutputPorts Members + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs index 42ecf5c6..4c2e4ef9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs @@ -4,12 +4,14 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -216,6 +218,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + /// /// Enables or disables free run /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs index 37ee38b3..2231494b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs @@ -4,12 +4,14 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -218,6 +220,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + /// /// Enables or disables free run /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs index 18e91fbe..8765fd73 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; //using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -215,6 +217,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs index a6f41c95..dcd2c4e0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs @@ -1,24 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro; //using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Config; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM { - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; + using eVst = eX02VideoSourceType; + using eAst = eX02AudioSourceType; - public class DmTx4k100Controller : BasicDmTxControllerBase, IRoutingInputsOutputs, IHasFeedback, + public class DmTx4k100Controller : DmTxControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { public DmTx4K100C1G Tx { get; private set; } @@ -37,7 +30,7 @@ namespace PepperDash.Essentials.DM /// /// Helps get the "real" inputs, including when in Auto /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + public eX02VideoSourceType ActualActiveVideoInput { get { @@ -77,17 +70,11 @@ namespace PepperDash.Essentials.DM } - - public override bool CustomActivate() + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) { - // Link up all of these damned events to the various RoutingPorts via a helper handler - - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); } - #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } @@ -101,5 +88,7 @@ namespace PepperDash.Essentials.DM #region ICec Members public Cec StreamCec { get { return Tx.StreamCec; } } #endregion + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs index fce45926..073807b6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; //using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -186,6 +188,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs index baaac013..010fd06b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; //using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -223,6 +225,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + /// /// Enables or disables free run /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index 2f7dfafd..541b9fe8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; //using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -199,6 +201,11 @@ namespace PepperDash.Essentials.DM return base.CustomActivate(); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDmTxToApi(this, trilist, joinStart, joinMapKey, bridge); + } + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index f438b37b..6a648ea3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -4,12 +4,14 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM @@ -23,7 +25,7 @@ namespace PepperDash.Essentials.DM /// /// /// - public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) + public static DmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) { // switch on type name... later... @@ -141,26 +143,17 @@ namespace PepperDash.Essentials.DM } } - public abstract class BasicDmTxControllerBase : CrestronGenericBaseDevice - { - public BasicDmTxControllerBase(string key, string name, GenericBase hardware) - : base(key, name, hardware) - { - - } - } - /// /// /// - public abstract class DmTxControllerBase : BasicDmTxControllerBase + public abstract class DmTxControllerBase : CrestronGenericBridgeableBaseDevice { public virtual void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } public virtual eHdcpCapabilityType HdcpSupportCapability { get; protected set; } public abstract StringFeedback ActiveVideoInputFeedback { get; protected set; } public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } - public DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) + protected DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) : base(key, name, hardware) { // if wired to a chassis, skip registration step in base class @@ -170,6 +163,161 @@ namespace PepperDash.Essentials.DM } AddToFeedbackList(ActiveVideoInputFeedback); } + + protected DmTxControllerBase(string key, string name, DmHDBasedTEndPoint hardware) : base(key, name, hardware) + { + } + + protected void LinkDmTxToApi(DmTxControllerBase tx, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApi bridge) + { + var joinMap = new DmTxControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + if (tx.Hardware is DmHDBasedTEndPoint) + { + Debug.Console(1, tx, "No properties to link. Skipping device {0}", tx.Name); + return; + } + + Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus]); + tx.AnyVideoInput.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution]); + trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.HdcpSupportCapability; + + bool hdcpTypeSimple; + + if (tx.Hardware is DmTx4kX02CBase) + hdcpTypeSimple = false; + else + hdcpTypeSimple = true; + + if (tx is ITxRouting) + { + var txR = tx as ITxRouting; + + trilist.SetUShortSigAction(joinMap.VideoInput, + i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Video)); + trilist.SetUShortSigAction(joinMap.AudioInput, + i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Audio)); + + txR.VideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoInput]); + txR.AudioSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioInput]); + + trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.HdcpSupportCapability; + + if (txR.InputPorts[DmPortName.HdmiIn] != null) + { + var inputPort = txR.InputPorts[DmPortName.HdmiIn]; + + if (tx.Feedbacks["HdmiInHdcpCapability"] != null) + { + var intFeedback = tx.Feedbacks["HdmiInHdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]); + } + + if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) + { + var port = inputPort.Port as EndpointHdmiInput; + + SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist); + } + } + + if (txR.InputPorts[DmPortName.HdmiIn1] != null) + { + var inputPort = txR.InputPorts[DmPortName.HdmiIn1]; + + if (tx.Feedbacks["HdmiIn1HdcpCapability"] != null) + { + var intFeedback = tx.Feedbacks["HdmiIn1HdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]); + } + + if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) + { + var port = inputPort.Port as EndpointHdmiInput; + + SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist); + } + } + + if (txR.InputPorts[DmPortName.HdmiIn2] != null) + { + var inputPort = txR.InputPorts[DmPortName.HdmiIn2]; + + if (tx.Feedbacks["HdmiIn2HdcpCapability"] != null) + { + var intFeedback = tx.Feedbacks["HdmiIn2HdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]); + } + + if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) + { + var port = inputPort.Port as EndpointHdmiInput; + + SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port2HdcpState, trilist); + } + } + + } + + var txFreeRun = tx as IHasFreeRun; + if (txFreeRun != null) + { + txFreeRun.FreeRunEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.FreeRunEnabled]); + trilist.SetBoolSigAction(joinMap.FreeRunEnabled, new Action(txFreeRun.SetFreeRunEnabled)); + } + + var txVga = tx as IVgaBrightnessContrastControls; + { + if (txVga == null) return; + + txVga.VgaBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.VgaBrightness]); + txVga.VgaContrastFeedback.LinkInputSig(trilist.UShortInput[joinMap.VgaContrast]); + + trilist.SetUShortSigAction(joinMap.VgaBrightness, txVga.SetVgaBrightness); + trilist.SetUShortSigAction(joinMap.VgaContrast, txVga.SetVgaContrast); + } + } + + private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + s => + { + port.HdcpCapability = (eHdcpCapabilityType)s; + }); + } + } } //public enum ePdtHdcpSupport //{ diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs index 8e2af6cb..24fe2c77 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs @@ -5,13 +5,15 @@ using System.Text; using System.Text.RegularExpressions; using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Devices.Common.Codec; using Newtonsoft.Json; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Devices.Common.Cameras { @@ -24,7 +26,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras Focus = 8 } - public abstract class CameraBase : Device, IRoutingOutputs + public abstract class CameraBase : EssentialsBridgeableDevice, IRoutingOutputs { public eCameraControlMode ControlMode { get; protected set; } @@ -69,13 +71,166 @@ namespace PepperDash.Essentials.Devices.Common.Cameras // A bitmasked value to indicate the movement capabilites of this camera protected eCameraCapabilities Capabilities { get; set; } - public CameraBase(string key, string name) : + protected CameraBase(string key, string name) : base(key, name) { OutputPorts = new RoutingPortCollection(); ControlMode = eCameraControlMode.Manual; - } + } + + protected void LinkCameraToApi(CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApi bridge) + { + CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart); + + // Adds the join map to the bridge + bridge.AddJoinMap(cameraDevice.Key, joinMap); + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); + + var commMonitor = cameraDevice as ICommunicationMonitor; + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + var ptzCamera = cameraDevice as IHasCameraPtzControl; + + if (ptzCamera != null) + { + trilist.SetBoolSigAction(joinMap.PanLeft.JoinNumber, (b) => + { + if (b) + { + ptzCamera.PanLeft(); + } + else + { + ptzCamera.PanStop(); + } + }); + trilist.SetBoolSigAction(joinMap.PanRight.JoinNumber, (b) => + { + if (b) + { + ptzCamera.PanRight(); + } + else + { + ptzCamera.PanStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.TiltUp.JoinNumber, (b) => + { + if (b) + { + ptzCamera.TiltUp(); + } + else + { + ptzCamera.TiltStop(); + } + }); + trilist.SetBoolSigAction(joinMap.TiltDown.JoinNumber, (b) => + { + if (b) + { + ptzCamera.TiltDown(); + } + else + { + ptzCamera.TiltStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.ZoomIn.JoinNumber, (b) => + { + if (b) + { + ptzCamera.ZoomIn(); + } + else + { + ptzCamera.ZoomStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.ZoomOut.JoinNumber, (b) => + { + if (b) + { + ptzCamera.ZoomOut(); + } + else + { + ptzCamera.ZoomStop(); + } + }); + } + + if (cameraDevice is IPower) + { + var powerCamera = cameraDevice as IPower; + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn()); + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff()); + + powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); + } + + if (cameraDevice is ICommunicationMonitor) + { + var monitoredCamera = cameraDevice as ICommunicationMonitor; + monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + if (cameraDevice is IHasCameraPresets) + { + // Set the preset lables when they change + var presetsCamera = cameraDevice as IHasCameraPresets; + presetsCamera.PresetsListHasChanged += new EventHandler((o, a) => + { + for (int i = 1; i <= joinMap.NumberOfPresets.JoinNumber; i++) + { + int tempNum = i - 1; + + string label = ""; + + var preset = presetsCamera.Presets.FirstOrDefault(p => p.ID.Equals(i)); + + if (preset != null) + label = preset.Description; + + trilist.SetString((ushort) (joinMap.PresetLabelStart.JoinNumber + tempNum), label); + } + }); + + for (int i = 0; i < joinMap.NumberOfPresets.JoinNumber; i++) + { + int tempNum = i; + + trilist.SetSigTrueAction((ushort) (joinMap.PresetRecallStart.JoinNumber + tempNum), () => + { + presetsCamera.PresetSelect(tempNum); + }); + trilist.SetSigTrueAction((ushort) (joinMap.PresetSaveStart.JoinNumber + tempNum), () => + { + var label = trilist.GetString((ushort) (joinMap.PresetLabelStart.JoinNumber + tempNum)); + + presetsCamera.PresetStore(tempNum, label); + }); + } + } + } } public class CameraPreset : PresetBase diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs index 3d50079b..7d5fa182 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.Codec; using System.Text.RegularExpressions; using Crestron.SimplSharp.Reflection; @@ -78,7 +80,13 @@ namespace PepperDash.Essentials.Devices.Common.Cameras CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator); return true; } - void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs index 22226e74..805a3a12 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs @@ -5,9 +5,12 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.Devices.Displays { @@ -199,7 +202,12 @@ namespace PepperDash.Essentials.Devices.Displays return true; } - void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { if (e.Client.IsConnected) StatusGet(); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs index 61349632..316d0ed7 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs @@ -4,9 +4,12 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.Devices.Displays { @@ -150,7 +153,12 @@ namespace PepperDash.Essentials.Devices.Displays return true; } - public override FeedbackCollection Feedbacks + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + public override FeedbackCollection Feedbacks { get { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs index 34263818..919b0e94 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs @@ -4,9 +4,10 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Displays { @@ -218,5 +219,9 @@ namespace PepperDash.Essentials.Devices.Displays } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs index 5781f134..a493b517 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs @@ -4,9 +4,12 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.Devices.Displays { @@ -142,7 +145,12 @@ namespace PepperDash.Essentials.Devices.Displays return true; } - public override FeedbackCollection Feedbacks + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + public override FeedbackCollection Feedbacks { get { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 975487e0..4fbce220 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -5,9 +5,12 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.Devices.Displays { @@ -146,7 +149,12 @@ namespace PepperDash.Essentials.Devices.Displays return true; } - public override FeedbackCollection Feedbacks + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + public override FeedbackCollection Feedbacks { get { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs index adcceb4f..a752a5b4 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs @@ -3,9 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Lighting; +using LightingBase = PepperDash.Essentials.Core.Lighting.LightingBase; namespace PepperDash.Essentials.Devices.Common.Environment.Lutron { @@ -77,6 +80,14 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron return true; } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = LinkLightingToApi(this, trilist, joinStart, joinMapKey, bridge); + + CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => IntegrationId = s); + } + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs index 380a090a..5fe0c8df 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs @@ -3,14 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Common.Occupancy { - public class GlsOccupancySensorBaseController : CrestronGenericBaseDevice, IOccupancyStatusProvider + public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider { public GlsOccupancySensorBase OccSensor { get; private set; } @@ -251,5 +253,116 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy { OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; } + + + + protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, + uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new GlsOccupancySensorBaseJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + #region Single and Dual Sensor Stuff + occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + + trilist.OnlineStatusChange += (d, args) => + { + if (args.DeviceOnLine) + { + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + } + }; + + // Occupied status + trilist.SetSigTrueAction(joinMap.ForceOccupied, occController.ForceOccupied); + trilist.SetSigTrueAction(joinMap.ForceVacant, occController.ForceVacant); + occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]); + occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]); + occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]); + trilist.SetBoolSigAction(joinMap.EnableRawStates, occController.EnableRawStates); + + // Timouts + trilist.SetUShortSigAction(joinMap.Timeout, occController.SetRemoteTimeout); + occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout]); + occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback]); + + // LED Flash + trilist.SetSigTrueAction(joinMap.EnableLedFlash, () => occController.SetLedFlashEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableLedFlash, () => occController.SetLedFlashEnable(false)); + occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash]); + + // Short Timeout + trilist.SetSigTrueAction(joinMap.EnableShortTimeout, () => occController.SetShortTimeoutState(true)); + trilist.SetSigTrueAction(joinMap.DisableShortTimeout, () => occController.SetShortTimeoutState(false)); + occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout]); + + // PIR Sensor + trilist.SetSigTrueAction(joinMap.EnablePir, () => occController.SetPirEnable(true)); + trilist.SetSigTrueAction(joinMap.DisablePir, () => occController.SetPirEnable(false)); + occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir]); + + // PIR Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState, occController.IncrementPirSensitivityInOccupiedState); + trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState, occController.DecrementPirSensitivityInOccupiedState); + occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState]); + + // PIR Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState, occController.IncrementPirSensitivityInVacantState); + trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState, occController.DecrementPirSensitivityInVacantState); + occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState]); + #endregion + + #region Dual Technology Sensor Stuff + var odtOccController = occController as GlsOdtOccupancySensorController; + + if (odtOccController == null) return; + // OR When Vacated + trilist.SetBoolSigAction(joinMap.OrWhenVacated, odtOccController.SetOrWhenVacatedState); + odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated]); + + // AND When Vacated + trilist.SetBoolSigAction(joinMap.AndWhenVacated, odtOccController.SetAndWhenVacatedState); + odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated]); + + // Ultrasonic A Sensor + trilist.SetSigTrueAction(joinMap.EnableUsA, () => odtOccController.SetUsAEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableUsA, () => odtOccController.SetUsAEnable(false)); + odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA]); + + // Ultrasonic B Sensor + trilist.SetSigTrueAction(joinMap.EnableUsB, () => odtOccController.SetUsBEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableUsB, () => odtOccController.SetUsBEnable(false)); + odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB]); + + // US Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState, odtOccController.IncrementUsSensitivityInOccupiedState); + trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState, odtOccController.DecrementUsSensitivityInOccupiedState); + odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState]); + + // US Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState, odtOccController.IncrementUsSensitivityInVacantState); + trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState, odtOccController.DecrementUsSensitivityInVacantState); + odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState]); + + //Sensor Raw States + odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback]); + odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback]); + + #endregion + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs index 16e449bf..37a2acb4 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Common.Occupancy { @@ -117,16 +119,8 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy /// public void SetUsAEnable(bool state) { - if (state) - { - OccSensor.EnableUsA.BoolValue = state; - OccSensor.DisableUsA.BoolValue = !state; - } - else - { - OccSensor.EnableUsA.BoolValue = state; - OccSensor.DisableUsA.BoolValue = !state; - } + OccSensor.EnableUsA.BoolValue = state; + OccSensor.DisableUsA.BoolValue = !state; } @@ -136,16 +130,8 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy /// public void SetUsBEnable(bool state) { - if (state) - { - OccSensor.EnableUsB.BoolValue = state; - OccSensor.DisableUsB.BoolValue = !state; - } - else - { - OccSensor.EnableUsB.BoolValue = state; - OccSensor.DisableUsB.BoolValue = !state; - } + OccSensor.EnableUsB.BoolValue = state; + OccSensor.DisableUsB.BoolValue = !state; } public void IncrementUsSensitivityInOccupiedState(bool pressRelease) @@ -167,5 +153,10 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy { OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs index 358c63cb..ce9536ef 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs @@ -3,18 +3,21 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using System.Text.RegularExpressions; using Crestron.SimplSharp.Net.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Devices.Common { - public class DigitalLogger : Device + public class DigitalLogger : EssentialsBridgeableDevice { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -134,6 +137,31 @@ namespace PepperDash.Essentials.Devices.Common return true; } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new DigitalLoggerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + for (uint i = 1; i <= CircuitCount; i++) + { + var circuit = i; + CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); + CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); + CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); + trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => CycleCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => TurnOnCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => TurnOffCircuit(circuit - 1)); + + } + } + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs index 78e2ac22..5e25fce9 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs @@ -4,15 +4,18 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; - +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Core.Routing; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Devices.Common { - public class IRSetTopBoxBase : Device, ISetTopBoxControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking, IPower + public class IRSetTopBoxBase : EssentialsBridgeableDevice, ISetTopBoxControls, IRoutingOutputs, IUsageTracking, IPower { public IrOutputPortController IrPort { get; private set; } @@ -367,5 +370,96 @@ namespace PepperDash.Essentials.Devices.Common } #endregion - } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new SetTopBoxControllerJoinMap(); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", Name); + + trilist.StringInput[joinMap.Name].StringValue = Name; + + var stbBase = this as ISetTopBoxControls; + + trilist.BooleanInput[joinMap.HasDpad].BoolValue = stbBase.HasDpad; + trilist.BooleanInput[joinMap.HasNumeric].BoolValue = stbBase.HasNumeric; + trilist.BooleanInput[joinMap.HasDvr].BoolValue = stbBase.HasDvr; + trilist.BooleanInput[joinMap.HasPresets].BoolValue = stbBase.HasPresets; + + trilist.SetBoolSigAction(joinMap.DvrList, stbBase.DvrList); + trilist.SetBoolSigAction(joinMap.Replay, stbBase.Replay); + + trilist.SetStringSigAction(joinMap.LoadPresets, stbBase.LoadPresets); + + var stbPower = this as IPower; + + trilist.SetSigTrueAction(joinMap.PowerOn, stbPower.PowerOn); + trilist.SetSigTrueAction(joinMap.PowerOff, stbPower.PowerOff); + trilist.SetSigTrueAction(joinMap.PowerToggle, stbPower.PowerToggle); + + var stbDPad = this as IDPad; + + trilist.SetBoolSigAction(joinMap.Up, stbDPad.Up); + trilist.SetBoolSigAction(joinMap.Down, stbDPad.Down); + trilist.SetBoolSigAction(joinMap.Left, stbDPad.Left); + trilist.SetBoolSigAction(joinMap.Right, stbDPad.Right); + trilist.SetBoolSigAction(joinMap.Select, stbDPad.Select); + trilist.SetBoolSigAction(joinMap.Menu, stbDPad.Menu); + trilist.SetBoolSigAction(joinMap.Exit, stbDPad.Exit); + + var stbChannel = this as IChannel; + trilist.SetBoolSigAction(joinMap.ChannelUp, stbChannel.ChannelUp); + trilist.SetBoolSigAction(joinMap.ChannelDown, stbChannel.ChannelDown); + trilist.SetBoolSigAction(joinMap.LastChannel, stbChannel.LastChannel); + trilist.SetBoolSigAction(joinMap.Guide, stbChannel.Guide); + trilist.SetBoolSigAction(joinMap.Info, stbChannel.Info); + trilist.SetBoolSigAction(joinMap.Exit, stbChannel.Exit); + + var stbColor = this as IColor; + trilist.SetBoolSigAction(joinMap.Red, stbColor.Red); + trilist.SetBoolSigAction(joinMap.Green, stbColor.Green); + trilist.SetBoolSigAction(joinMap.Yellow, stbColor.Yellow); + trilist.SetBoolSigAction(joinMap.Blue, stbColor.Blue); + + var stbKeypad = this as ISetTopBoxNumericKeypad; + + trilist.StringInput[joinMap.KeypadAccessoryButton1Label].StringValue = stbKeypad.KeypadAccessoryButton1Label; + trilist.StringInput[joinMap.KeypadAccessoryButton2Label].StringValue = stbKeypad.KeypadAccessoryButton2Label; + + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1].BoolValue = stbKeypad.HasKeypadAccessoryButton1; + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2].BoolValue = stbKeypad.HasKeypadAccessoryButton2; + + trilist.SetBoolSigAction(joinMap.Digit0, stbKeypad.Digit0); + trilist.SetBoolSigAction(joinMap.Digit1, stbKeypad.Digit1); + trilist.SetBoolSigAction(joinMap.Digit2, stbKeypad.Digit2); + trilist.SetBoolSigAction(joinMap.Digit3, stbKeypad.Digit3); + trilist.SetBoolSigAction(joinMap.Digit4, stbKeypad.Digit4); + trilist.SetBoolSigAction(joinMap.Digit5, stbKeypad.Digit5); + trilist.SetBoolSigAction(joinMap.Digit6, stbKeypad.Digit6); + trilist.SetBoolSigAction(joinMap.Digit7, stbKeypad.Digit7); + trilist.SetBoolSigAction(joinMap.Digit8, stbKeypad.Digit8); + trilist.SetBoolSigAction(joinMap.Digit9, stbKeypad.Digit9); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press, stbKeypad.KeypadAccessoryButton1); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press, stbKeypad.KeypadAccessoryButton1); + trilist.SetBoolSigAction(joinMap.Dash, stbKeypad.Dash); + trilist.SetBoolSigAction(joinMap.KeypadEnter, stbKeypad.KeypadEnter); + + var stbTransport = this as ITransport; + trilist.SetBoolSigAction(joinMap.Play, stbTransport.Play); + trilist.SetBoolSigAction(joinMap.Pause, stbTransport.Pause); + trilist.SetBoolSigAction(joinMap.Rewind, stbTransport.Rewind); + trilist.SetBoolSigAction(joinMap.FFwd, stbTransport.FFwd); + trilist.SetBoolSigAction(joinMap.ChapMinus, stbTransport.ChapMinus); + trilist.SetBoolSigAction(joinMap.ChapPlus, stbTransport.ChapPlus); + trilist.SetBoolSigAction(joinMap.Stop, stbTransport.Stop); + trilist.SetBoolSigAction(joinMap.Record, stbTransport.Record); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 596c16dd..83d2073b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -5,14 +5,16 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; - +using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Devices.Common { - public class AppleTV : Device, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs + public class AppleTV : EssentialsBridgeableDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs { public IrOutputPortController IrPort { get; private set; } @@ -141,5 +143,28 @@ namespace PepperDash.Essentials.Devices.Common public RoutingPortCollection OutputPorts { get; private set; } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + var joinMap = new AppleTvJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); + + trilist.SetBoolSigAction(joinMap.UpArrow, Up); + trilist.SetBoolSigAction(joinMap.DnArrow, Down); + trilist.SetBoolSigAction(joinMap.LeftArrow, Left); + trilist.SetBoolSigAction(joinMap.RightArrow, Right); + trilist.SetBoolSigAction(joinMap.Select, Select); + trilist.SetBoolSigAction(joinMap.Menu, Menu); + trilist.SetBoolSigAction(joinMap.PlayPause, Play); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs index 12819336..0faa5934 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs @@ -3,7 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco @@ -98,6 +99,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Stop CallId: {0}", CallId)); } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } } public class CiscoSparkCamera : CameraBase, IHasCameraPtzControl, IHasCameraFocusControl @@ -308,5 +314,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs index c404ac89..8bd444ee 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.VideoCodec; namespace PepperDash.Essentials.Devices.Common.Cameras @@ -111,6 +112,11 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } } public class MockFarEndVCCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera @@ -191,5 +197,10 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs index 209cfdd9..037b5104 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs @@ -3,7 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom @@ -198,6 +199,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } } public class ZoomRoomFarEndCamera : ZoomRoomCamera, IAmFarEndCamera