MicrophonePrivacyController progress

This commit is contained in:
Neil Dorin
2017-10-31 13:17:00 -06:00
parent 8a9a8ac6a7
commit bc47c65e48
10 changed files with 203 additions and 64 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core.Crestron_IO
{
public class GenericDigitalInputDevice : IDigitalInput
{
DigitalInput InputPort { get; private set; }
BoolFeedback InputStateFeedback { get; private set; }
Func<bool> InputStateFeedbackFunc
{
get
{
return () => InputPort.State;
}
}
public GenericDigitalInputDevice(DigitalInput inputPort)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
InputPort = inputPort;
InputPort.StateChange += new DigitalInputEventHandler(InputPort_StateChange);
}
void InputPort_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args)
{
InputStateFeedback.FireUpdate();
}
}
}

View File

@@ -5,39 +5,38 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core.Crestron_IO namespace PepperDash.Essentials.Core.Crestron_IO
{ {
/// <summary> /// <summary>
/// Represents a generic digital input deviced tied to a versiport /// Represents a generic digital input deviced tied to a versiport
/// </summary> /// </summary>
public class GenericVersiportInputDevice public class GenericVersiportInputDevice : IDigitalInput
{ {
//Versiport InputPort {get; private set;} Versiport InputPort { get; private set; }
//BoolFeedback InputStateFeedback {get; private set;} BoolFeedback InputStateFeedback { get; private set; }
//Func<bool> InputStateFeedbackFunc Func<bool> InputStateFeedbackFunc
//{ {
// get get
// { {
// return () => InputPort.DigitalIn; return () => InputPort.DigitalIn;
// } }
//} }
//public GenericVersiportInputDevice(Versiport inputPort) public GenericVersiportInputDevice(Versiport inputPort)
//{ {
// InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
// InputPort = inputPort; InputPort = inputPort;
// InputPort.VersiportChange += new VersiportEventHandler(InputPort_VersiportChange); InputPort.VersiportChange += new VersiportEventHandler(InputPort_VersiportChange);
//} }
//void InputPort_VersiportChange(Versiport port, VersiportEventArgs args) void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
//{ {
// InputStateFeedback.FireUpdate(); InputStateFeedback.FireUpdate();
//} }
} }
} }

View File

@@ -6,8 +6,11 @@ using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.Crestron_IO namespace PepperDash.Essentials.Core.Crestron_IO
{ {
/// <summary>
/// Represents a device that provides digital input
/// </summary>
public interface IDigitalInput public interface IDigitalInput
{ {
BoolFeedback InputStateFeedback { get; }
} }
} }

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core.Crestron_IO namespace PepperDash.Essentials.Core.Crestron_IO
@@ -13,31 +12,49 @@ namespace PepperDash.Essentials.Core.Crestron_IO
/// </summary> /// </summary>
public class GenericRelayDevice public class GenericRelayDevice
{ {
//Relay RelayOutput { get; private set; } Relay RelayOutput { get; private set; }
//public boolfeedback relaystatefeedback { get; private set; } public BoolFeedback RelayStateFeedback { get; private set; }
//func<bool> relaystatefeedbackfunc Func<bool> RelayStateFeedbackFunc
//{ {
// get get
// { {
// return () => relayoutput.state; return () => RelayOutput.State;
// } }
//} }
//public genericrelaydevice(relay relay) public GenericRelayDevice(Relay relay)
//{ {
// relaystatefeedback = new boolfeedback(relaystatefeedbackfunc); RelayStateFeedback = new BoolFeedback(RelayStateFeedbackFunc);
// if(relay.availableforuse) if (relay.AvailableForUse)
// relayoutput = relay; RelayOutput = relay;
// relayoutput.statechange += new relayeventhandler(relayoutput_statechange); RelayOutput.StateChange += new RelayEventHandler(RelayOutput_StateChange);
//} }
//void relayoutput_statechange(relay relay, relayeventargs args) void RelayOutput_StateChange(Relay relay, RelayEventArgs args)
//{ {
// relaystatefeedback.fireupdate(); RelayStateFeedback.FireUpdate();
//} }
void OpenRelay()
{
RelayOutput.State = false;
}
void CloseRelay()
{
RelayOutput.State = true;
}
void ToggleRelayState()
{
if (RelayOutput.State == true)
OpenRelay();
else
CloseRelay();
}
} }
} }

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core.Crestron_IO;
namespace PepperDash.Essentials.Core.Microphone_Privacy
{
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)
}
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();
}
}
}

View File

@@ -103,11 +103,13 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" /> <Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
<Compile Include="Crestron IO\Inputs\IDigitalInput.cs" /> <Compile Include="Crestron IO\Inputs\IDigitalInput.cs" />
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" /> <Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
<Compile Include="Devices\CodecInterfaces.cs" /> <Compile Include="Devices\CodecInterfaces.cs" />
<Compile Include="Global\JobTimer.cs" /> <Compile Include="Global\JobTimer.cs" />
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
<Compile Include="Ramps and Increments\ActionIncrementer.cs" /> <Compile Include="Ramps and Increments\ActionIncrementer.cs" />
<Compile Include="Comm and IR\CommFactory.cs" /> <Compile Include="Comm and IR\CommFactory.cs" />
<Compile Include="Comm and IR\CommunicationExtras.cs" /> <Compile Include="Comm and IR\CommunicationExtras.cs" />

View File

@@ -38,4 +38,17 @@ namespace PepperDash.Essentials.Devices.Common.Codec
} }
} }
} }
/// <summary>
///
/// </summary>
public class CodecCallStatusItemChangeEventArgs : EventArgs
{
public CodecActiveCallItem CallItem { get; private set; }
public CodecCallStatusItemChangeEventArgs(CodecActiveCallItem item)
{
CallItem = item;
}
}
} }

View File

@@ -24,27 +24,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec
void RejectCall(CodecActiveCallItem item); void RejectCall(CodecActiveCallItem item);
void SendDtmf(string digit); void SendDtmf(string digit);
//BoolFeedback IncomingCallFeedback { get; } bool IsInCall { get; }
} }
/// <summary>
///
/// </summary>
public class CodecCallStatusItemChangeEventArgs : EventArgs
{
public CodecActiveCallItem CallItem { get; private set; }
//public eCodecCallStatus PreviousStatus { get; private set; }
//public eCodecCallStatus NewStatus { get; private set; }
public CodecCallStatusItemChangeEventArgs(/*eCodecCallStatus previousStatus,
eCodecCallStatus newStatus,*/ CodecActiveCallItem item)
{
//PreviousStatus = previousStatus;
//NewStatus = newStatus;
CallItem = item;
}
}
} }