diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs new file mode 100644 index 00000000..e71fa3b2 --- /dev/null +++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class IOPortConfig + { + public string PortDeviceKey { get; set; } + public uint PortNumber { get; set; } + } + +} \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs index 8ca01833..a38c8207 100644 --- a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs +++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs @@ -5,9 +5,11 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -namespace PepperDash.Essentials.Core.Crestron_IO +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.CrestronIO { - public class GenericDigitalInputDevice : IDigitalInput + public class GenericDigitalInputDevice : Device, IDigitalInput { public DigitalInput InputPort { get; private set; } @@ -21,7 +23,8 @@ namespace PepperDash.Essentials.Core.Crestron_IO } } - public GenericDigitalInputDevice(DigitalInput inputPort) + public GenericDigitalInputDevice(string key, DigitalInput inputPort): + base(key) { InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs index 92a3e1ec..7a0c3a26 100644 --- a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs +++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -namespace PepperDash.Essentials.Core.Crestron_IO +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.CrestronIO { /// /// Represents a generic digital input deviced tied to a versiport /// - public class GenericVersiportInputDevice : IDigitalInput + public class GenericVersiportInputDevice : Device, IDigitalInput { public Versiport InputPort { get; private set; } @@ -24,7 +26,8 @@ namespace PepperDash.Essentials.Core.Crestron_IO } } - public GenericVersiportInputDevice(Versiport inputPort) + public GenericVersiportInputDevice(string key, Versiport inputPort): + base(key) { InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs index 4adc77f7..2bfe6ce5 100644 --- a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs +++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; -namespace PepperDash.Essentials.Core.Crestron_IO +namespace PepperDash.Essentials.Core.CrestronIO { /// /// Represents a device that provides digital input diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs index 35347c92..a169cab1 100644 --- a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs +++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs @@ -5,12 +5,14 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -namespace PepperDash.Essentials.Core.Crestron_IO +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.CrestronIO { /// /// Represents a generic device controlled by relays /// - public class GenericRelayDevice + public class GenericRelayDevice : Device { public Relay RelayOutput { get; private set; } @@ -24,7 +26,8 @@ namespace PepperDash.Essentials.Core.Crestron_IO } } - public GenericRelayDevice(Relay relay) + public GenericRelayDevice(string key, Relay relay): + base(key) { RelayStateFeedback = new BoolFeedback(RelayStateFeedbackFunc); diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index e5050466..04cafd98 100644 --- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -106,6 +106,7 @@ + diff --git a/Essentials DM/Essentials_DM/Essentials_DM.csproj b/Essentials DM/Essentials_DM/Essentials_DM.csproj index 0377548e..d40eff0c 100644 --- a/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -59,10 +59,6 @@ False ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - False - ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll - False ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll @@ -115,6 +111,12 @@ + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 87e24f6a..194e4332 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -61,7 +61,7 @@ False - ..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll + ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll False @@ -119,6 +119,8 @@ + + diff --git a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs index 570911f5..2d108e4d 100644 --- a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs +++ b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.CrestronIO; using PepperDash.Essentials.Devices.Common.DSP; using PepperDash.Essentials.Devices.Common.VideoCodec; @@ -118,11 +119,114 @@ namespace PepperDash.Essentials.Devices.Common else if (typeName == "versiportinput") { - var props = JsonConvert.DeserializeObject < PepperDash.Essentials.Core.Crestron_IO.GenericVersiportInputDeviceConfigProperties>(properties.ToString()); + var props = JsonConvert.DeserializeObject(properties.ToString()); + IIOPorts portDevice; - //Versiport inputPort = new Versiport(); - //return new PepperDash.Essentials.Core.Crestron_IO.GenericVersiportInputDevice(inputPort); + if (props.PortDeviceKey == "processor") + portDevice = Global.ControlSystem as IIOPorts; + else + portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IIOPorts; + + if(portDevice == null) + Debug.Console(0, "Unable to add versiport device with key '{0}'. Port Device does not support versiports", key); + else + { + var cs = (portDevice as CrestronControlSystem); + + if (cs != null) + if (cs.SupportsVersiport && props.PortNumber <= cs.NumberOfVersiPorts) + { + Versiport versiport = cs.VersiPorts[props.PortNumber]; + + if(!versiport.Registered) + { + if (versiport.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + return new GenericVersiportInputDevice(key, versiport); + else + Debug.Console(0, "Attempt to register versiport {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); + } + } + + // Future: Check if portDevice is 3-series card or other non control system that supports versiports + + } + } + + else if (typeName == "digitalinput") + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + + IDigitalInputPorts portDevice; + + if (props.PortDeviceKey == "processor") + portDevice = Global.ControlSystem as IDigitalInputPorts; + else + portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts; + + if (portDevice == null) + Debug.Console(0, "Unable to add digital input device with key '{0}'. Port Device does not support digital inputs", key); + else + { + var cs = (portDevice as CrestronControlSystem); + + if (cs != null) + if (cs.SupportsDigitalInput && props.PortNumber <= cs.NumberOfDigitalInputPorts) + { + DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber]; + + if (!digitalInput.Registered) + { + if(digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + return new GenericDigitalInputDevice(key, digitalInput); + else + Debug.Console(0, "Attempt to register digital input {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); + } + } + // Future: Check if portDevice is 3-series card or other non control system that supports versiports + } + } + + else if (typeName == "relayoutput") + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + + IRelayPorts portDevice; + + if (props.PortDeviceKey == "processor") + portDevice = Global.ControlSystem as IRelayPorts; + else + portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IRelayPorts; + + if (portDevice == null) + Debug.Console(0, "Unable to add relay device with key '{0}'. Port Device does not support relays", key); + else + { + var cs = (portDevice as CrestronControlSystem); + + if(cs != null) + if (cs.SupportsRelay && props.PortNumber <= cs.NumberOfRelayPorts) + { + Relay relay = cs.RelayPorts[props.PortNumber]; + + if (!relay.Registered) + { + if(relay.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + return new GenericRelayDevice(key, relay); + else + Debug.Console(0, "Attempt to register relay {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); + } + } + + // Future: Check if portDevice is 3-series card or other non control system that supports versiports + } + } + + else if (typeName == "microphoneprivacycontroller") + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + + return new Microphones.MicrophonePrivacyController(key, props); } else if (groupName == "settopbox") //(typeName == "irstbbase") diff --git a/Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyController.cs b/Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyController.cs similarity index 65% rename from Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyController.cs rename to Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyController.cs index 3918294e..4e9c1462 100644 --- a/Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyController.cs +++ b/Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyController.cs @@ -6,7 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Crestron_IO; +using PepperDash.Essentials.Core.CrestronIO; namespace PepperDash.Essentials.Devices.Common.Microphones @@ -17,6 +17,8 @@ namespace PepperDash.Essentials.Devices.Common.Microphones /// public class MicrophonePrivacyController : Device { + MicrophonePrivacyControllerConfig Config; + public bool EnableLeds { get @@ -25,11 +27,15 @@ namespace PepperDash.Essentials.Devices.Common.Microphones } set { + _enableLeds = value; + if (value) - SetLedRelayStates(); + { + CheckPrivacyMode(); + SetLedStates(); + } else TurnOffAllLeds(); - _enableLeds = value; } } bool _enableLeds; @@ -47,9 +53,40 @@ namespace PepperDash.Essentials.Devices.Common.Microphones public MicrophonePrivacyController(string key, MicrophonePrivacyControllerConfig config) : base(key) { + Config = config; + Inputs = new List(); } + public override bool CustomActivate() + { + foreach (var i in Config.Inputs) + { + var input = DeviceManager.GetDeviceForKey(i.DeviceKey) as IDigitalInput; + + if(input != null) + AddInput(input); + } + + var greenLed = DeviceManager.GetDeviceForKey(Config.GreenLedRelay.DeviceKey) as GenericRelayDevice; + + if (greenLed != null) + GreenLedRelay = greenLed; + else + Debug.Console(0, this, "Unable to add Green LED device"); + + var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice; + + if (redLed != null) + RedLedRelay = redLed; + else + Debug.Console(0, this, "Unable to add Red LED device"); + + CheckPrivacyMode(); + + return base.CustomActivate(); + } + public void SetPrivacyDevice(IPrivacy privacyDevice) { PrivacyDevice = privacyDevice; @@ -59,13 +96,20 @@ namespace PepperDash.Essentials.Devices.Common.Microphones void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e) { - var privacyState = (sender as IPrivacy).PrivacyModeIsOnFeedback.BoolValue; + CheckPrivacyMode(); + } - if (privacyState) - TurnOnRedLeds(); - else - TurnOnGreenLeds(); + void CheckPrivacyMode() + { + if (PrivacyDevice != null) + { + var privacyState = PrivacyDevice.PrivacyModeIsOnFeedback.BoolValue; + if (privacyState) + TurnOnRedLeds(); + else + TurnOnGreenLeds(); + } } void AddInput(IDigitalInput input) @@ -118,32 +162,24 @@ namespace PepperDash.Essentials.Devices.Common.Microphones { _greenLedRelayState = false; _redLedRelayState = true; - SetLedRelayStates(); + SetLedStates(); } void TurnOnGreenLeds() { _redLedRelayState = false; _greenLedRelayState = true; - SetLedRelayStates(); + SetLedStates(); } /// /// If enabled, sets the actual state of the relays /// - void SetLedRelayStates() + void SetLedStates() { if (_enableLeds) { - if (_redLedRelayState) - RedLedRelay.CloseRelay(); - else - RedLedRelay.OpenRelay(); - - if (_greenLedRelayState) - GreenLedRelay.CloseRelay(); - else - GreenLedRelay.OpenRelay(); + SetRelayStates(); } else TurnOffAllLeds(); @@ -154,8 +190,29 @@ namespace PepperDash.Essentials.Devices.Common.Microphones /// void TurnOffAllLeds() { - GreenLedRelay.OpenRelay(); - RedLedRelay.OpenRelay(); + _redLedRelayState = false; + _greenLedRelayState = false; + + SetRelayStates(); + } + + void SetRelayStates() + { + if (RedLedRelay != null) + { + if (_redLedRelayState) + RedLedRelay.CloseRelay(); + else + RedLedRelay.OpenRelay(); + } + + if(GreenLedRelay != null) + { + if (_greenLedRelayState) + GreenLedRelay.CloseRelay(); + else + GreenLedRelay.OpenRelay(); + } } } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyControllerConfig.cs b/Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyControllerConfig.cs new file mode 100644 index 00000000..18bfe11d --- /dev/null +++ b/Essentials Devices Common/Essentials Devices Common/MIcrophone/MicrophonePrivacyControllerConfig.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Core.CrestronIO; + +namespace PepperDash.Essentials.Devices.Common.Microphones +{ + public class MicrophonePrivacyControllerConfig + { + public List Inputs { get; set; } + public KeyedDevice GreenLedRelay { get; set; } + public KeyedDevice RedLedRelay { get; set; } + } + + public class KeyedDevice + { + public string DeviceKey { get; set; } + } +} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyControllerConfig.cs b/Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyControllerConfig.cs deleted file mode 100644 index 42651064..00000000 --- a/Essentials Devices Common/Essentials Devices Common/Microphones/MicrophonePrivacyControllerConfig.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Devices.Common.Microphones -{ - public class MicrophonePrivacyControllerConfig - { - - } -} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index abe0683d..10797e56 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -75,8 +75,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco new CodecCommandWithLabel("prominent","Prominent"), new CodecCommandWithLabel("single","Single") }; - - private CiscoCodecConfiguration.RootObject CodecConfiguration; + + private CiscoCodecConfiguration.RootObject CodecConfiguration = new CiscoCodecConfiguration.RootObject(); private CiscoCodecStatus.RootObject CodecStatus = new CiscoCodecStatus.RootObject(); @@ -272,9 +272,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco PortGather.IncludeDelimiter = true; PortGather.LineReceived += this.Port_LineReceived; - CodecConfiguration = new CiscoCodecConfiguration.RootObject(); - //CodecStatus = new CiscoCodecStatus.RootObject(); - CodecInfo = new CiscoCodecInfo(CodecStatus, CodecConfiguration); CallHistory = new CodecCallHistory(); diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index ec9505eb..530544f3 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -79,10 +79,6 @@ False ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - False - ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll - False ..\..\Essentials DM\Essentials_DM\bin\PepperDash_Essentials_DM.dll @@ -198,6 +194,10 @@ + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + {892B761C-E479-44CE-BD74-243E9214AF13} Essentials Devices Common diff --git a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs index 683a10da..fe7c4d9c 100644 --- a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs +++ b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs @@ -106,11 +106,25 @@ namespace PepperDash.Essentials.Room.Config if (microphonePrivacy != null) { // Get the MicrophonePrivacy device from the device manager - var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.Key) as PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController); + var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController); // Set this room as the IPrivacy device - mP.SetPrivacyDevice(room); + if (mP != null) + { + mP.SetPrivacyDevice(room); - return mP; + // Tie LED enable to room power state + room.OnFeedback.OutputChange += (o, a) => + { + if (room.OnFeedback.BoolValue) + mP.EnableLeds = true; + else + mP.EnableLeds = false; + }; + + mP.EnableLeds = room.OnFeedback.BoolValue; + + return mP; + } } return null; } @@ -138,7 +152,7 @@ namespace PepperDash.Essentials.Room.Config public class EssentialsRoomMicrophonePrivacyConfig { - public string Key { get; set; } + public string DeviceKey { get; set; } } /// diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index f1562bc5..89c5b022 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index d0ea2f17..9b672414 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ