mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
Working through queued command and the syncronous comms method in the BiampTesiraForteDsp class
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="PepperDash_Core, Version=1.0.0.16459, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Core, Version=1.0.0.16459, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|||||||
Binary file not shown.
@@ -57,7 +57,7 @@
|
|||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="PepperDash_Core, Version=1.0.0.15153, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Core, Version=1.0.0.15153, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.14500, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.14500, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|||||||
Binary file not shown.
@@ -21,33 +21,37 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
// ! "myLevelName" -77
|
// ! "myLevelName" -77
|
||||||
|
|
||||||
|
|
||||||
public class BiampTesiraForteDsp : DspBase
|
public class BiampTesiraForteDsp : DspBase
|
||||||
{
|
{
|
||||||
public IBasicCommunication Communication { get; private set; }
|
public IBasicCommunication Communication { get; private set; }
|
||||||
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; }
|
new public Dictionary<string, TesiraForteLevelControl> LevelControlPoints { get; private set; }
|
||||||
|
|
||||||
public bool isSubscribed;
|
public bool isSubscribed;
|
||||||
|
|
||||||
|
private CTimer SubscriptionTimer;
|
||||||
|
|
||||||
CrestronQueue CommandQueue;
|
CrestronQueue CommandQueue;
|
||||||
|
|
||||||
|
bool CommandQueueInProgress = false;
|
||||||
|
|
||||||
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
||||||
|
|
||||||
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows received lines as hex
|
/// Shows received lines as hex
|
||||||
/// </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(20);
|
CommandQueue = new CrestronQueue(100);
|
||||||
|
|
||||||
Communication = comm;
|
Communication = comm;
|
||||||
var socket = comm as ISocketStatus;
|
var socket = comm as ISocketStatus;
|
||||||
if (socket != null)
|
if (socket != null)
|
||||||
{
|
{
|
||||||
@@ -58,8 +62,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
{
|
{
|
||||||
// This instance uses RS-232 control
|
// This instance uses RS-232 control
|
||||||
}
|
}
|
||||||
PortGather = new CommunicationGather(Communication, '\x0a');
|
PortGather = new CommunicationGather(Communication, "\x0d\x0a");
|
||||||
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);
|
||||||
@@ -67,35 +71,50 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
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, "");
|
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "SESSION get aliases\x0d\x0a");
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelControlPoints = new Dictionary<string, TesiraForteLevelControl>();
|
LevelControlPoints = new Dictionary<string, TesiraForteLevelControl>();
|
||||||
|
|
||||||
foreach (KeyValuePair<string, BiampTesiraForteLevelControlBlockConfig> block in props.LevelControlBlocks)
|
foreach (KeyValuePair<string, BiampTesiraForteLevelControlBlockConfig> block in props.LevelControlBlocks)
|
||||||
{
|
{
|
||||||
this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Value, this));
|
this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Key, block.Value, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
|
||||||
{
|
{
|
||||||
|
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
|
||||||
|
|
||||||
if (e.Client.IsConnected)
|
if (e.Client.IsConnected)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
|
// Tasks on connect
|
||||||
// Maybe wait for message indicating valid TTP session
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Cleanup items from this session
|
||||||
|
|
||||||
|
if (SubscriptionTimer != null)
|
||||||
|
{
|
||||||
|
SubscriptionTimer.Stop();
|
||||||
|
SubscriptionTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSubscribed = false;
|
||||||
|
CommandQueue.Clear();
|
||||||
|
CommandQueueInProgress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,25 +123,32 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void SubscribeToAttributes()
|
void SubscribeToAttributes()
|
||||||
{
|
{
|
||||||
EnqueueCommand("SESSION set verbose true");
|
SendLine("SESSION set verbose true");
|
||||||
|
|
||||||
foreach (KeyValuePair<string, TesiraForteLevelControl> level in LevelControlPoints)
|
foreach (KeyValuePair<string, TesiraForteLevelControl> level in LevelControlPoints)
|
||||||
{
|
{
|
||||||
level.Value.Subscribe();
|
level.Value.Subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!CommandQueue.IsEmpty)
|
||||||
|
SendNextQueuedCommand();
|
||||||
|
|
||||||
ResetSubscriptionTimer();
|
ResetSubscriptionTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets or Sets the subscription timer
|
||||||
|
/// </summary>
|
||||||
void ResetSubscriptionTimer()
|
void ResetSubscriptionTimer()
|
||||||
{
|
{
|
||||||
#warning Add code to create/reset a CTimer to periodically check for subscribtion status
|
|
||||||
|
|
||||||
isSubscribed = true;
|
isSubscribed = true;
|
||||||
|
|
||||||
//CTimer SubscribtionTimer = new CTimer(
|
if (SubscriptionTimer != null)
|
||||||
|
{
|
||||||
|
SubscriptionTimer = new CTimer(o => SubscribeToAttributes(), 30000);
|
||||||
|
SubscriptionTimer.Reset();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -130,121 +156,127 @@ 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)
|
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}'",
|
||||||
ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text);
|
ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if (args.Text.IndexOf("Welcome to the Tesira Text Protocol Server...") > -1)
|
||||||
{
|
{
|
||||||
if (args.Text.IndexOf("Welcome to the Tesira Text Protocol Server...") > -1)
|
// Indicates a new TTP session
|
||||||
|
|
||||||
|
SubscribeToAttributes();
|
||||||
|
}
|
||||||
|
else if (args.Text.IndexOf("publishToken") > -1)
|
||||||
|
{
|
||||||
|
// response is from a subscribed attribute
|
||||||
|
|
||||||
|
string pattern = "! \"publishToken\":[\"](.*)[\"] \"value\":(.*)";
|
||||||
|
|
||||||
|
Match match = Regex.Match(args.Text, pattern);
|
||||||
|
|
||||||
|
if (match.Success)
|
||||||
{
|
{
|
||||||
// Indicates a new TTP session
|
|
||||||
|
|
||||||
SubscribeToAttributes();
|
string key;
|
||||||
}
|
|
||||||
else if (args.Text.IndexOf("publishToken") > -1)
|
|
||||||
{
|
|
||||||
// response is from a subscribed attribute
|
|
||||||
|
|
||||||
string pattern = "! \"publishToken\":[\"](.*)[\"] \"value\":(.*)";
|
string customName;
|
||||||
|
|
||||||
Match match = Regex.Match(args.Text, pattern);
|
string value;
|
||||||
|
|
||||||
if (match.Success)
|
customName = match.Groups[1].Value;
|
||||||
|
|
||||||
|
// Finds the key (everything before the '~' character
|
||||||
|
key = customName.Substring(0, customName.IndexOf("~", 0) - 1);
|
||||||
|
|
||||||
|
value = match.Groups[2].Value;
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, TesiraForteLevelControl> controlPoint in LevelControlPoints)
|
||||||
{
|
{
|
||||||
|
if (customName == controlPoint.Value.LevelCustomName || customName == controlPoint.Value.MuteCustomName)
|
||||||
string key;
|
|
||||||
|
|
||||||
string customName;
|
|
||||||
|
|
||||||
string value;
|
|
||||||
|
|
||||||
customName = match.Groups[1].Value;
|
|
||||||
|
|
||||||
// Finds the key (everything before the '~' character
|
|
||||||
key = customName.Substring(0, customName.IndexOf("~", 0) - 1);
|
|
||||||
|
|
||||||
value = match.Groups[2].Value;
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, TesiraForteLevelControl> controlPoint in LevelControlPoints)
|
|
||||||
{
|
{
|
||||||
if (customName == controlPoint.Value.LevelCustomName || customName == controlPoint.Value.MuteCustomName)
|
controlPoint.Value.ParseSubscriptionMessage(customName, value);
|
||||||
{
|
return;
|
||||||
controlPoint.Value.ParseSubscriptionMessage(customName, value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// same for dialers
|
|
||||||
/// same for switchers
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (args.Text.IndexOf("+OK") > -1)
|
|
||||||
{
|
|
||||||
if (args.Text.Length > 4) // Check for a simple "+OK" only 'ack' repsonse
|
|
||||||
return;
|
|
||||||
|
|
||||||
// response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command
|
|
||||||
|
|
||||||
if (!CommandQueue.IsEmpty)
|
|
||||||
{
|
|
||||||
if(CommandQueue.Peek() is QueuedCommand)
|
|
||||||
{
|
|
||||||
// Expected response belongs to a child class
|
|
||||||
QueuedCommand tempCommand = (QueuedCommand)CommandQueue.Dequeue();
|
|
||||||
|
|
||||||
tempCommand.ControlPoint.ParseGetMessage(tempCommand.AttributeCode, args.Text);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Expected response belongs to this class
|
|
||||||
string temp = (string)CommandQueue.Dequeue();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SendNextQueuedCommand();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args.Text.IndexOf("-ERR") > -1)
|
|
||||||
{
|
|
||||||
// Error response
|
|
||||||
|
|
||||||
if (args.Text == "-ERR ALREADY_SUBSCRIBED")
|
/// same for dialers
|
||||||
|
/// same for switchers
|
||||||
|
|
||||||
|
}
|
||||||
|
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
|
||||||
|
return;
|
||||||
|
|
||||||
|
// response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command
|
||||||
|
|
||||||
|
if (!CommandQueue.IsEmpty)
|
||||||
|
{
|
||||||
|
if (CommandQueue.Peek() is QueuedCommand)
|
||||||
{
|
{
|
||||||
// Subscription still valid
|
// Expected response belongs to a child class
|
||||||
ResetSubscriptionTimer();
|
QueuedCommand tempCommand = (QueuedCommand)CommandQueue.Dequeue();
|
||||||
|
Debug.Console(2, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count);
|
||||||
|
|
||||||
|
tempCommand.ControlPoint.ParseGetMessage(tempCommand.AttributeCode, args.Text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SubscribeToAttributes();
|
// Expected response belongs to this class
|
||||||
|
string temp = (string)CommandQueue.Dequeue();
|
||||||
|
Debug.Console(2, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (Debug.Level == 2)
|
|
||||||
Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
//if (CommandQueue.IsEmpty)
|
||||||
|
// CommandQueueInProgress = false;
|
||||||
|
//else
|
||||||
|
SendNextQueuedCommand();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (args.Text.IndexOf("-ERR") > -1)
|
||||||
|
{
|
||||||
|
// Error response
|
||||||
|
|
||||||
|
if (args.Text == "-ERR ALREADY_SUBSCRIBED")
|
||||||
|
{
|
||||||
|
// Subscription still valid
|
||||||
|
ResetSubscriptionTimer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SubscribeToAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (Debug.Level == 2)
|
||||||
|
Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a command to the DSP (with delimiter appended)
|
/// Sends a command to the DSP (with delimiter appended)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="s">Command to send</param>
|
/// <param name="s">Command to send</param>
|
||||||
public void SendLine(string s)
|
public void SendLine(string s)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "TX: '{0}'", s);
|
Debug.Console(2, this, "TX: '{0}'", s);
|
||||||
Communication.SendText(s + "\x0a");
|
Communication.SendText(s + "\x0a");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a command from a child module to the queue
|
/// Adds a command from a child module to the queue
|
||||||
@@ -253,6 +285,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
public void EnqueueCommand(QueuedCommand commandToEnqueue)
|
public void EnqueueCommand(QueuedCommand commandToEnqueue)
|
||||||
{
|
{
|
||||||
CommandQueue.Enqueue(commandToEnqueue);
|
CommandQueue.Enqueue(commandToEnqueue);
|
||||||
|
SendNextQueuedCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -262,6 +295,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
public void EnqueueCommand(string command)
|
public void EnqueueCommand(string command)
|
||||||
{
|
{
|
||||||
CommandQueue.Enqueue(command);
|
CommandQueue.Enqueue(command);
|
||||||
|
SendNextQueuedCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -269,19 +303,44 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void SendNextQueuedCommand()
|
void SendNextQueuedCommand()
|
||||||
{
|
{
|
||||||
if (CommandQueue.Peek() is QueuedCommand)
|
Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected);
|
||||||
|
if (!CommandQueueInProgress)
|
||||||
{
|
{
|
||||||
QueuedCommand nextCommand = new QueuedCommand();
|
if (CommandQueue.IsEmpty)
|
||||||
|
CommandQueueInProgress = false;
|
||||||
|
|
||||||
nextCommand = (QueuedCommand)CommandQueue.Peek();
|
Debug.Console(2, this, "CommandQueue has {0} Elements", CommandQueue.Count);
|
||||||
|
|
||||||
SendLine(nextCommand.Command);
|
foreach (object o in CommandQueue)
|
||||||
}
|
{
|
||||||
else
|
if (o is string)
|
||||||
{
|
Debug.Console(2, this, "{0}", o);
|
||||||
string nextCommand = (string)CommandQueue.Peek();
|
else if(o is QueuedCommand)
|
||||||
|
{
|
||||||
|
var item = (QueuedCommand)o;
|
||||||
|
Debug.Console(2, this, "{0}", item.Command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendLine(nextCommand);
|
if (Communication.IsConnected && !CommandQueue.IsEmpty)
|
||||||
|
{
|
||||||
|
CommandQueueInProgress = true;
|
||||||
|
|
||||||
|
if (CommandQueue.Peek() is QueuedCommand)
|
||||||
|
{
|
||||||
|
QueuedCommand nextCommand = new QueuedCommand();
|
||||||
|
|
||||||
|
nextCommand = (QueuedCommand)CommandQueue.Peek();
|
||||||
|
|
||||||
|
SendLine(nextCommand.Command);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string nextCommand = (string)CommandQueue.Peek();
|
||||||
|
|
||||||
|
SendLine(nextCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,10 +348,10 @@ 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 override void RunPreset(string name)
|
||||||
{
|
{
|
||||||
SendLine(string.Format("DEVICE recallPreset {0}", name));
|
SendLine(string.Format("DEVICE recallPreset {0}", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class QueuedCommand
|
public class QueuedCommand
|
||||||
{
|
{
|
||||||
@@ -300,5 +359,5 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
public string AttributeCode { get; set; }
|
public string AttributeCode { get; set; }
|
||||||
public TesiraForteControlPoint ControlPoint { get; set; }
|
public TesiraForteControlPoint ControlPoint { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,25 +84,25 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
|
|
||||||
bool LevelIsSubscribed;
|
bool LevelIsSubscribed;
|
||||||
|
|
||||||
public TesiraForteLevelControl(string label, string id, int index1, int index2, bool hasMute, bool hasLevel, BiampTesiraForteDsp parent)
|
//public TesiraForteLevelControl(string label, string id, int index1, int index2, bool hasMute, bool hasLevel, BiampTesiraForteDsp parent)
|
||||||
: base(id, index1, index2, parent)
|
// : base(id, index1, index2, parent)
|
||||||
{
|
//{
|
||||||
Initialize(label, hasMute, hasLevel);
|
// Initialize(label, hasMute, hasLevel);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public TesiraForteLevelControl(BiampTesiraForteLevelControlBlockConfig config, BiampTesiraForteDsp parent)
|
public TesiraForteLevelControl(string key, BiampTesiraForteLevelControlBlockConfig config, BiampTesiraForteDsp parent)
|
||||||
: base(config.InstanceTag, config.Index1, config.Index2, parent)
|
: base(config.InstanceTag, config.Index1, config.Index2, parent)
|
||||||
{
|
{
|
||||||
Initialize(config.Label, config.HasMute, config.HasLevel);
|
Initialize(key, config.Label, config.HasMute, config.HasLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes this attribute based on config values and generates subscriptions commands and adds commands to the parent's queue.
|
/// Initializes this attribute based on config values and generates subscriptions commands and adds commands to the parent's queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(string label, bool hasMute, bool hasLevel)
|
public void Initialize(string key, string label, bool hasMute, bool hasLevel)
|
||||||
{
|
{
|
||||||
Key = string.Format("{0}-{1}", Parent.Key, label);
|
Key = string.Format("{0}--{1}", Parent.Key, key);
|
||||||
|
|
||||||
DeviceManager.AddDevice(this);
|
DeviceManager.AddDevice(this);
|
||||||
|
|
||||||
@@ -210,20 +210,20 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Parse a "+OK" message
|
// Parse an "+OK" message
|
||||||
string pattern = "+OK \"value\":(.*)";
|
string pattern = @"\+OK ""value"":(.*)";
|
||||||
|
|
||||||
Match match = Regex.Match(message, pattern);
|
Match match = Regex.Match(message, pattern);
|
||||||
|
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
|
|
||||||
string value;
|
string value = match.Groups[1].Value;
|
||||||
|
|
||||||
|
Debug.Console(2, this, "{0} is {1}", attributeCode, value);
|
||||||
|
|
||||||
if (message.IndexOf("\"value\":") > -1)
|
if (message.IndexOf("\"value\":") > -1)
|
||||||
{
|
{
|
||||||
value = message.Substring(message.IndexOf(":"), message.Length - message.IndexOf(":"));
|
|
||||||
|
|
||||||
switch (attributeCode)
|
switch (attributeCode)
|
||||||
{
|
{
|
||||||
case "minLevel":
|
case "minLevel":
|
||||||
@@ -277,6 +277,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
/// <param name="level"></param>
|
/// <param name="level"></param>
|
||||||
public void SetVolume(ushort level)
|
public void SetVolume(ushort level)
|
||||||
{
|
{
|
||||||
|
Debug.Console(2, this, "volume: {0}", level);
|
||||||
// Unmute volume if new level is higher than existing
|
// Unmute volume if new level is higher than existing
|
||||||
if (level > _VolumeLevel && AutomaticUnmuteOnVolumeUp)
|
if (level > _VolumeLevel && AutomaticUnmuteOnVolumeUp)
|
||||||
if(!_IsMuted)
|
if(!_IsMuted)
|
||||||
@@ -284,7 +285,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP
|
|||||||
|
|
||||||
double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel);
|
double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel);
|
||||||
|
|
||||||
SendFullCommand("Set", "level", volumeLevel.ToString());
|
SendFullCommand("set", "level", volumeLevel.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Binary file not shown.
@@ -77,11 +77,11 @@
|
|||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="PepperDashCorePortalSync, Version=1.0.0.27069, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDashCorePortalSync, Version=1.0.0.27069, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\pepperdash-portal-sync\PepperDashCorePortalSync\PepperDashPortalSync\bin\PepperDashCorePortalSync.dll</HintPath>
|
<HintPath>..\..\..\pepperdash-portal-sync\SspPortalSync\SspPortalSync\bin\PepperDashCorePortalSync.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PepperDash_Core, Version=1.0.0.18868, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Core, Version=1.0.0.18868, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.12925, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.12925, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user