mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-17 13:45:01 +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
|
||||
{
|
||||
void RunPreset(string name);
|
||||
|
||||
void RunPreset(int id);
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,15 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
public CommunicationGather PortGather { 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;
|
||||
|
||||
private CTimer SubscriptionTimer;
|
||||
|
||||
CrestronQueue CommandQueue;
|
||||
private CrestronQueue CommandQueue;
|
||||
|
||||
bool CommandQueueInProgress = false;
|
||||
private bool CommandQueueInProgress = false;
|
||||
|
||||
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
||||
|
||||
@@ -47,7 +47,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
CommandQueue = new CrestronQueue(100);
|
||||
@@ -68,12 +69,14 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
PortGather.LineReceived += this.Port_LineReceived;
|
||||
if (props.CommunicationMonitorProperties != null)
|
||||
{
|
||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
|
||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication,
|
||||
props.CommunicationMonitorProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
//#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>();
|
||||
@@ -88,15 +91,17 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
@@ -123,7 +128,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
/// <summary>
|
||||
/// Initiates the subscription process to the DSP
|
||||
/// </summary>
|
||||
void SubscribeToAttributes()
|
||||
private void SubscribeToAttributes()
|
||||
{
|
||||
SendLine("SESSION set verbose true");
|
||||
|
||||
@@ -141,7 +146,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
/// <summary>
|
||||
/// Resets or Sets the subscription timer
|
||||
/// </summary>
|
||||
void ResetSubscriptionTimer()
|
||||
private void ResetSubscriptionTimer()
|
||||
{
|
||||
isSubscribed = true;
|
||||
|
||||
@@ -158,7 +163,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
/// </summary>
|
||||
/// <param name="dev"></param>
|
||||
/// <param name="args"></param>
|
||||
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
|
||||
private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
|
||||
{
|
||||
if (Debug.Level == 2)
|
||||
Debug.Console(2, this, "RX: '{0}'",
|
||||
@@ -200,7 +205,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
|
||||
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);
|
||||
return;
|
||||
@@ -215,7 +221,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
}
|
||||
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;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -319,7 +342,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
/// <summary>
|
||||
/// Sends the next queued command to the DSP
|
||||
/// </summary>
|
||||
void SendNextQueuedCommand()
|
||||
private void SendNextQueuedCommand()
|
||||
{
|
||||
//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
|
||||
/// </summary>
|
||||
/// <param name="name">Preset Name</param>
|
||||
public override void RunPreset(string name)
|
||||
public void RunPreset(string 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
|
||||
{
|
||||
public abstract class DspBase : EssentialsDevice, IDspPreset
|
||||
public abstract class DspBase : EssentialsDevice, IHasDspPresets
|
||||
{
|
||||
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 abstract void RunPreset(string name);
|
||||
|
||||
public abstract void RunPreset(int data);
|
||||
|
||||
public DspBase(string key, string name) :
|
||||
base(key, name) { }
|
||||
base(key, name)
|
||||
{
|
||||
Presets = new List<IDspPreset>();
|
||||
}
|
||||
|
||||
|
||||
// in audio call feedback
|
||||
|
||||
// VOIP
|
||||
// Phone dialer
|
||||
|
||||
|
||||
public List<IDspPreset> Presets { get; set; }
|
||||
|
||||
|
||||
public void RecallPreset(IDspPreset preset)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Fusion
|
||||
|
||||
Reference in New Issue
Block a user