mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Updated Interface to be more genericized
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
namespace PepperDash.Essentials.Core
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
|
public interface IHasDspPresets
|
||||||
|
{
|
||||||
|
List<IDspPreset> Presets { get; }
|
||||||
|
|
||||||
|
void RecallPreset(IDspPreset preset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public interface IDspPreset
|
public interface IDspPreset
|
||||||
{
|
{
|
||||||
void RunPreset(string name);
|
string Name { get; }
|
||||||
|
|
||||||
void RunPreset(int id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,15 +28,15 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
public CommunicationGather PortGather { get; private set; }
|
public CommunicationGather PortGather { get; private set; }
|
||||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
||||||
|
|
||||||
new public Dictionary<string, TesiraForteLevelControl> LevelControlPoints { get; private set; }
|
public new Dictionary<string, TesiraForteLevelControl> LevelControlPoints { get; private set; }
|
||||||
|
|
||||||
public bool isSubscribed;
|
public bool isSubscribed;
|
||||||
|
|
||||||
private CTimer SubscriptionTimer;
|
private CTimer SubscriptionTimer;
|
||||||
|
|
||||||
CrestronQueue CommandQueue;
|
private CrestronQueue CommandQueue;
|
||||||
|
|
||||||
bool CommandQueueInProgress = false;
|
private bool CommandQueueInProgress = false;
|
||||||
|
|
||||||
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
||||||
|
|
||||||
@@ -47,7 +47,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowHexResponse { get; set; }
|
public bool ShowHexResponse { get; set; }
|
||||||
|
|
||||||
public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, BiampTesiraFortePropertiesConfig props) :
|
public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm,
|
||||||
|
BiampTesiraFortePropertiesConfig props) :
|
||||||
base(key, name)
|
base(key, name)
|
||||||
{
|
{
|
||||||
CommandQueue = new CrestronQueue(100);
|
CommandQueue = new CrestronQueue(100);
|
||||||
@@ -68,12 +69,14 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
PortGather.LineReceived += this.Port_LineReceived;
|
PortGather.LineReceived += this.Port_LineReceived;
|
||||||
if (props.CommunicationMonitorProperties != null)
|
if (props.CommunicationMonitorProperties != null)
|
||||||
{
|
{
|
||||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
|
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication,
|
||||||
|
props.CommunicationMonitorProperties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//#warning Need to deal with this poll string
|
//#warning Need to deal with this poll string
|
||||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "SESSION get aliases\x0d\x0a");
|
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000,
|
||||||
|
"SESSION get aliases\x0d\x0a");
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelControlPoints = new Dictionary<string, TesiraForteLevelControl>();
|
LevelControlPoints = new Dictionary<string, TesiraForteLevelControl>();
|
||||||
@@ -88,15 +91,17 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
Communication.Connect();
|
Communication.Connect();
|
||||||
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
|
CommunicationMonitor.StatusChange +=
|
||||||
|
(o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
|
||||||
CommunicationMonitor.Start();
|
CommunicationMonitor.Start();
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "",
|
||||||
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
|
private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
|
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
|
||||||
|
|
||||||
@@ -123,7 +128,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initiates the subscription process to the DSP
|
/// Initiates the subscription process to the DSP
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void SubscribeToAttributes()
|
private void SubscribeToAttributes()
|
||||||
{
|
{
|
||||||
SendLine("SESSION set verbose true");
|
SendLine("SESSION set verbose true");
|
||||||
|
|
||||||
@@ -141,7 +146,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets or Sets the subscription timer
|
/// Resets or Sets the subscription timer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void ResetSubscriptionTimer()
|
private void ResetSubscriptionTimer()
|
||||||
{
|
{
|
||||||
isSubscribed = true;
|
isSubscribed = true;
|
||||||
|
|
||||||
@@ -158,7 +163,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dev"></param>
|
/// <param name="dev"></param>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
|
private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
|
||||||
{
|
{
|
||||||
if (Debug.Level == 2)
|
if (Debug.Level == 2)
|
||||||
Debug.Console(2, this, "RX: '{0}'",
|
Debug.Console(2, this, "RX: '{0}'",
|
||||||
@@ -200,7 +205,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
|
|
||||||
foreach (KeyValuePair<string, TesiraForteLevelControl> controlPoint in LevelControlPoints)
|
foreach (KeyValuePair<string, TesiraForteLevelControl> controlPoint in LevelControlPoints)
|
||||||
{
|
{
|
||||||
if (customName == controlPoint.Value.LevelCustomName || customName == controlPoint.Value.MuteCustomName)
|
if (customName == controlPoint.Value.LevelCustomName ||
|
||||||
|
customName == controlPoint.Value.MuteCustomName)
|
||||||
{
|
{
|
||||||
controlPoint.Value.ParseSubscriptionMessage(customName, value);
|
controlPoint.Value.ParseSubscriptionMessage(customName, value);
|
||||||
return;
|
return;
|
||||||
@@ -215,7 +221,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
}
|
}
|
||||||
else if (args.Text.IndexOf("+OK") > -1)
|
else if (args.Text.IndexOf("+OK") > -1)
|
||||||
{
|
{
|
||||||
if (args.Text == "+OK" || args.Text.IndexOf("list\":") > -1 ) // Check for a simple "+OK" only 'ack' repsonse or a list response and ignore
|
if (args.Text == "+OK" || args.Text.IndexOf("list\":") > -1)
|
||||||
|
// Check for a simple "+OK" only 'ack' repsonse or a list response and ignore
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command
|
// response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command
|
||||||
@@ -298,9 +305,25 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
SendNextQueuedCommand();
|
SendNextQueuedCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunPreset(int data)
|
public void RecallPreset(IDspPreset preset)
|
||||||
{
|
{
|
||||||
SendLine(String.Format("Device recallPreset {0}", data ));
|
if (preset == null) return;
|
||||||
|
|
||||||
|
var tesiraPreset = preset as TesiraDspPreset;
|
||||||
|
|
||||||
|
if (tesiraPreset == null) return;
|
||||||
|
if (!String.IsNullOrEmpty(tesiraPreset.PresetName))
|
||||||
|
{
|
||||||
|
SendLine(String.Format("Device RecallPreset {0}", tesiraPreset.PresetName));
|
||||||
|
}
|
||||||
|
if (tesiraPreset.PresetId >= 1000)
|
||||||
|
{
|
||||||
|
SendLine(String.Format("Device RecallPreset {0}", tesiraPreset.PresetId));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "Preset {0} unable to be recalled, missing identifier", tesiraPreset.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -319,7 +342,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the next queued command to the DSP
|
/// Sends the next queued command to the DSP
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void SendNextQueuedCommand()
|
private void SendNextQueuedCommand()
|
||||||
{
|
{
|
||||||
//Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected);
|
//Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected);
|
||||||
|
|
||||||
@@ -367,7 +390,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// Sends a command to execute a preset
|
/// Sends a command to execute a preset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Preset Name</param>
|
/// <param name="name">Preset Name</param>
|
||||||
public override void RunPreset(string name)
|
public void RunPreset(string name)
|
||||||
{
|
{
|
||||||
SendLine(string.Format("DEVICE recallPreset {0}", name));
|
SendLine(string.Format("DEVICE recallPreset {0}", name));
|
||||||
}
|
}
|
||||||
@@ -397,4 +420,12 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TesiraDspPreset : IDspPreset
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public readonly string PresetName;
|
||||||
|
public readonly int PresetId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ using PepperDash.Essentials.Core;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.DSP
|
namespace PepperDash.Essentials.Devices.Common.DSP
|
||||||
{
|
{
|
||||||
public abstract class DspBase : EssentialsDevice, IDspPreset
|
public abstract class DspBase : EssentialsDevice, IHasDspPresets
|
||||||
{
|
{
|
||||||
public Dictionary<string, DspControlPoint> LevelControlPoints { get; private set; }
|
public Dictionary<string, DspControlPoint> LevelControlPoints { get; private set; }
|
||||||
|
|
||||||
@@ -17,18 +17,26 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
|
|
||||||
public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
||||||
|
|
||||||
public abstract void RunPreset(string name);
|
|
||||||
|
|
||||||
public abstract void RunPreset(int data);
|
|
||||||
|
|
||||||
public DspBase(string key, string name) :
|
public DspBase(string key, string name) :
|
||||||
base(key, name) { }
|
base(key, name)
|
||||||
|
{
|
||||||
|
Presets = new List<IDspPreset>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// in audio call feedback
|
// in audio call feedback
|
||||||
|
|
||||||
// VOIP
|
// VOIP
|
||||||
// Phone dialer
|
// Phone dialer
|
||||||
|
|
||||||
|
|
||||||
|
public List<IDspPreset> Presets { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public void RecallPreset(IDspPreset preset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fusion
|
// Fusion
|
||||||
|
|||||||
Reference in New Issue
Block a user