Moved MicrophonePrivacyController to Devices Common. Fixed references

This commit is contained in:
Neil Dorin
2017-11-01 14:20:13 -06:00
parent bc47c65e48
commit a0817307b1
10 changed files with 50 additions and 23 deletions

View File

@@ -61,11 +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>
</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>
<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>
@@ -123,6 +119,7 @@
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
<Compile Include="Factory\DeviceFactory.cs" />
<Compile Include="Generic\GenericSource.cs" />
<Compile Include="Microphones\MicrophonePrivacyController.cs" />
<Compile Include="Occupancy\EssentialsGlsOccupancySensorBaseController.cs" />
<Compile Include="Occupancy\EssentialsOccupancyAggregator.cs" />
<Compile Include="Occupancy\iOccupancyStatusProvider.cs" />
@@ -154,6 +151,12 @@
<Compile Include="VideoCodec\VideoCodecBase.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

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Crestron_IO;
namespace PepperDash.Essentials.Devices.Common.Microphones
{
public class MicrophonePrivacyController
{
public List<IDigitalInput> Inputs { get; private set; }
public GenericRelayDevice RedLedRelay { get; private set; }
public GenericRelayDevice GreenLedRelay { get; private set; }
public IPrivacy PrivacyDevice { get; private set; }
public MicrophonePrivacyController(IPrivacy privacyDevice)
{
PrivacyDevice = privacyDevice;
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += new EventHandler<EventArgs>(PrivacyModeIsOnFeedback_OutputChange);
Inputs = new List<IDigitalInput>();
}
void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e)
{
var privacyState = (sender as IPrivacy).PrivacyModeIsOnFeedback.BoolValue;
if (privacyState)
TurnOnRedLeds();
else
TurnOnGreenLeds();
}
void AddInput(IDigitalInput input)
{
Inputs.Add(input);
input.InputStateFeedback.OutputChange += new EventHandler<EventArgs>(InputStateFeedback_OutputChange);
}
void RemoveInput(IDigitalInput input)
{
var tempInput = Inputs.FirstOrDefault(i => i.Equals(input));
if (tempInput != null)
tempInput.InputStateFeedback.OutputChange -= InputStateFeedback_OutputChange;
Inputs.Remove(input);
}
void SetRedLedRelay(GenericRelayDevice relay)
{
RedLedRelay = relay;
}
void SetGreenLedRelay(GenericRelayDevice relay)
{
GreenLedRelay = relay;
}
/// <summary>
/// Check the state of the input change and handle accordingly
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void InputStateFeedback_OutputChange(object sender, EventArgs e)
{
if ((sender as IDigitalInput).InputStateFeedback.BoolValue)
TogglePrivacyMute();
}
/// <summary>
/// Toggles the state of the privacy mute
/// </summary>
void TogglePrivacyMute()
{
PrivacyDevice.PrivacyModeToggle();
}
void TurnOnRedLeds()
{
GreenLedRelay.OpenRelay();
RedLedRelay.CloseRelay();
}
void TurnOnGreenLeds()
{
RedLedRelay.CloseRelay();
GreenLedRelay.OpenRelay();
}
void TurnOffAllLeds()
{
GreenLedRelay.OpenRelay();
RedLedRelay.OpenRelay();
}
}
}