MIcrophone Privacy feature tested and working as far as relay switching. Needs someone to short the digital inputs on the office RMC and load to PRO3 or other versiport compatible processor to test mic button contact closure input.

This commit is contained in:
Neil Dorin
2017-11-03 17:13:44 -06:00
parent 43f0ae0533
commit d9013157ad
17 changed files with 276 additions and 66 deletions

View File

@@ -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; }
}
}

View File

@@ -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);

View File

@@ -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
{
/// <summary>
/// Represents a generic digital input deviced tied to a versiport
/// </summary>
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);

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.Crestron_IO
namespace PepperDash.Essentials.Core.CrestronIO
{
/// <summary>
/// Represents a device that provides digital input

View File

@@ -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
{
/// <summary>
/// Represents a generic device controlled by relays
/// </summary>
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);

View File

@@ -106,6 +106,7 @@
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
<Compile Include="Crestron IO\Inputs\IDigitalInput.cs" />
<Compile Include="Crestron IO\IOPortConfig.cs" />
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
<Compile Include="Devices\CodecInterfaces.cs" />
<Compile Include="Global\JobTimer.cs" />

View File

@@ -59,10 +59,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.24289, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll</HintPath>
</Reference>
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll</HintPath>
@@ -115,6 +111,12 @@
<Compile Include="VideoStatusHelpers.cs" />
<None Include="Properties\ControlSystem.cfg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj">
<Project>{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}</Project>
<Name>PepperDash_Essentials_Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

View File

@@ -61,7 +61,7 @@
<Reference Include="mscorlib" />
<Reference Include="PepperDash_Core, Version=1.0.6284.20368, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll</HintPath>
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
</Reference>
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -119,6 +119,8 @@
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
<Compile Include="Factory\DeviceFactory.cs" />
<Compile Include="Generic\GenericSource.cs" />
<Compile Include="MIcrophone\MicrophonePrivacyController.cs" />
<Compile Include="MIcrophone\MicrophonePrivacyControllerConfig.cs" />
<Compile Include="Occupancy\EssentialsGlsOccupancySensorBaseController.cs" />
<Compile Include="Occupancy\EssentialsOccupancyAggregator.cs" />
<Compile Include="Occupancy\iOccupancyStatusProvider.cs" />

View File

@@ -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<IOPortConfig>(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<IOPortConfig>(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<IOPortConfig>(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<Microphones.MicrophonePrivacyControllerConfig>(properties.ToString());
return new Microphones.MicrophonePrivacyController(key, props);
}
else if (groupName == "settopbox") //(typeName == "irstbbase")

View File

@@ -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
/// </summary>
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<IDigitalInput>();
}
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();
}
/// <summary>
/// If enabled, sets the actual state of the relays
/// </summary>
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
/// </summary>
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();
}
}
}
}

View File

@@ -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<KeyedDevice> Inputs { get; set; }
public KeyedDevice GreenLedRelay { get; set; }
public KeyedDevice RedLedRelay { get; set; }
}
public class KeyedDevice
{
public string DeviceKey { get; set; }
}
}

View File

@@ -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
{
}
}

View File

@@ -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();

View File

@@ -79,10 +79,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.18243, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Essentials_DM, Version=1.0.0.19343, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Essentials DM\Essentials_DM\bin\PepperDash_Essentials_DM.dll</HintPath>
@@ -198,6 +194,10 @@
<None Include="Properties\ControlSystem.cfg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj">
<Project>{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}</Project>
<Name>PepperDash_Essentials_Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj">
<Project>{892B761C-E479-44CE-BD74-243E9214AF13}</Project>
<Name>Essentials Devices Common</Name>

View File

@@ -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; }
}
/// <summary>