diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 272328ec..323a7166 100644 --- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -1,225 +1,225 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - Library - Properties - PepperDash.Essentials.Core - PepperDash_Essentials_Core - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + Library + Properties + PepperDash.Essentials.Core + PepperDash_Essentials_Core + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 053b261f..18afaf24 100644 Binary files a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo and b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo differ diff --git a/Essentials DM/Essentials_DM/Essentials_DM.csproj b/Essentials DM/Essentials_DM/Essentials_DM.csproj index bc34f0d1..a489cb40 100644 --- a/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -1,126 +1,126 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9199CE8A-0C9F-4952-8672-3EED798B284F} - Library - Properties - PepperDash.Essentials.DM - PepperDash_Essentials_DM - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - - False - ..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - - False - ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9199CE8A-0C9F-4952-8672-3EED798B284F} + Library + Properties + PepperDash.Essentials.DM + PepperDash_Essentials_DM + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + + False + ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + + + False + ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index e335bd1d..bbf70ee0 100644 Binary files a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo and b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo differ diff --git a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs index 324e0c5c..f5745ae3 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs @@ -18,287 +18,346 @@ namespace PepperDash.Essentials.Devices.Common.DSP // Verbose on subscriptions? // ! "publishToken":"name" "value":-77.0 - // ! "myLevelName" -77 - - - public class BiampTesiraForteDsp : DspBase - { - public IBasicCommunication Communication { get; private set; } - public CommunicationGather PortGather { get; private set; } - public StatusMonitorBase CommunicationMonitor { get; private set; } - - new public Dictionary LevelControlPoints { get; private set; } - - public bool isSubscribed; - - CrestronQueue CommandQueue; - - //new public Dictionary DialerControlPoints { get; private set; } - - //new public Dictionary SwitcherControlPoints { get; private set; } - - /// - /// Shows received lines as hex - /// - public bool ShowHexResponse { get; set; } - - public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, BiampTesiraFortePropertiesConfig props) : - base(key, name) - { - CommandQueue = new CrestronQueue(20); - - Communication = comm; - var socket = comm as ISocketStatus; - if (socket != null) - { - // This instance uses IP control - socket.ConnectionChange += new EventHandler(socket_ConnectionChange); - } - else - { - // This instance uses RS-232 control - } - PortGather = new CommunicationGather(Communication, '\x0a'); - PortGather.LineReceived += this.Port_LineReceived; - if (props.CommunicationMonitorProperties != null) - { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties); - } - else - { -#warning Need to deal with this poll string - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, ""); - } - - LevelControlPoints = new Dictionary(); - - foreach (KeyValuePair block in props.LevelControlBlocks) - { - this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Value, this)); - } - - } - - public override bool CustomActivate() - { - Communication.Connect(); - 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); - return true; - } - - void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) - { - if (e.Client.IsConnected) - { - Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); - // Maybe wait for message indicating valid TTP session - } - } - - /// - /// Initiates the subscription process to the DSP - /// - void SubscribeToAttributes() - { - EnqueueCommand("SESSION set verbose true"); - - foreach (KeyValuePair level in LevelControlPoints) - { - level.Value.Subscribe(); - } - - ResetSubscriptionTimer(); - } - - - - void ResetSubscriptionTimer() - { -#warning Add code to create/reset a CTimer to periodically check for subscribtion status - - isSubscribed = true; - - //CTimer SubscribtionTimer = new CTimer( - } - - /// - /// Handles a response message from the DSP - /// - /// - /// - void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) - { - if (Debug.Level == 2) - Debug.Console(2, this, "RX: '{0}'", - ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text); - - try - { - 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) - { - - 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 controlPoint in LevelControlPoints) - { - if (customName == controlPoint.Value.LevelCustomName || customName == controlPoint.Value.MuteCustomName) - { - 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") - { - // 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); - } - - } - - /// - /// Sends a command to the DSP (with delimiter appended) - /// - /// Command to send - public void SendLine(string s) - { - Debug.Console(2, this, "TX: '{0}'", s); - Communication.SendText(s + "\x0a"); - } - - /// - /// Adds a command from a child module to the queue - /// - /// Command object from child module - public void EnqueueCommand(QueuedCommand commandToEnqueue) - { - CommandQueue.Enqueue(commandToEnqueue); - } - - /// - /// Adds a raw string command to the queue - /// - /// - public void EnqueueCommand(string command) - { - CommandQueue.Enqueue(command); - } - - /// - /// Sends the next queued command to the DSP - /// - void SendNextQueuedCommand() - { - if (CommandQueue.Peek() is QueuedCommand) - { - QueuedCommand nextCommand = new QueuedCommand(); - - nextCommand = (QueuedCommand)CommandQueue.Peek(); - - SendLine(nextCommand.Command); - } - else - { - string nextCommand = (string)CommandQueue.Peek(); - - SendLine(nextCommand); - } - } - - /// - /// Sends a command to execute a preset - /// - /// Preset Name - public override void RunPreset(string name) - { - SendLine(string.Format("DEVICE recallPreset {0}", name)); - } - - public class QueuedCommand - { - public string Command { get; set; } - public string AttributeCode { get; set; } - public TesiraForteControlPoint ControlPoint { get; set; } - } - } + // ! "myLevelName" -77 + + + public class BiampTesiraForteDsp : DspBase + { + public IBasicCommunication Communication { get; private set; } + public CommunicationGather PortGather { get; private set; } + public StatusMonitorBase CommunicationMonitor { get; private set; } + + new public Dictionary LevelControlPoints { get; private set; } + + public bool isSubscribed; + + private CTimer SubscriptionTimer; + + CrestronQueue CommandQueue; + + bool CommandQueueInProgress = false; + + //new public Dictionary DialerControlPoints { get; private set; } + + //new public Dictionary SwitcherControlPoints { get; private set; } + + /// + /// Shows received lines as hex + /// + public bool ShowHexResponse { get; set; } + + public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, BiampTesiraFortePropertiesConfig props) : + base(key, name) + { + CommandQueue = new CrestronQueue(100); + + Communication = comm; + var socket = comm as ISocketStatus; + if (socket != null) + { + // This instance uses IP control + socket.ConnectionChange += new EventHandler(socket_ConnectionChange); + } + else + { + // This instance uses RS-232 control + } + PortGather = new CommunicationGather(Communication, "\x0d\x0a"); + PortGather.LineReceived += this.Port_LineReceived; + if (props.CommunicationMonitorProperties != null) + { + 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"); + } + + LevelControlPoints = new Dictionary(); + + foreach (KeyValuePair block in props.LevelControlBlocks) + { + this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Key, block.Value, this)); + } + + } + + public override bool CustomActivate() + { + Communication.Connect(); + 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); + return true; + } + + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + { + Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); + + if (e.Client.IsConnected) + { + // Tasks on connect + } + else + { + // Cleanup items from this session + + if (SubscriptionTimer != null) + { + SubscriptionTimer.Stop(); + SubscriptionTimer = null; + } + + isSubscribed = false; + CommandQueue.Clear(); + CommandQueueInProgress = false; + } + } + + /// + /// Initiates the subscription process to the DSP + /// + void SubscribeToAttributes() + { + SendLine("SESSION set verbose true"); + + foreach (KeyValuePair level in LevelControlPoints) + { + level.Value.Subscribe(); + } + + if (!CommandQueue.IsEmpty) + SendNextQueuedCommand(); + + ResetSubscriptionTimer(); + } + + /// + /// Resets or Sets the subscription timer + /// + void ResetSubscriptionTimer() + { + isSubscribed = true; + + if (SubscriptionTimer != null) + { + SubscriptionTimer = new CTimer(o => SubscribeToAttributes(), 30000); + SubscriptionTimer.Reset(); + + } + } + + /// + /// Handles a response message from the DSP + /// + /// + /// + void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) + { + if (Debug.Level == 2) + Debug.Console(2, this, "RX: '{0}'", + ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text); + + try + { + 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) + { + + 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 controlPoint in LevelControlPoints) + { + if (customName == controlPoint.Value.LevelCustomName || customName == controlPoint.Value.MuteCustomName) + { + controlPoint.Value.ParseSubscriptionMessage(customName, value); + return; + } + + } + } + + /// 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) + { + // Expected response belongs to a child class + QueuedCommand tempCommand = (QueuedCommand)CommandQueue.Dequeue(); + Debug.Console(2, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); + + tempCommand.ControlPoint.ParseGetMessage(tempCommand.AttributeCode, args.Text); + } + else + { + // Expected response belongs to this class + string temp = (string)CommandQueue.Dequeue(); + Debug.Console(2, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); + + } + + + //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); + } + + } + + /// + /// Sends a command to the DSP (with delimiter appended) + /// + /// Command to send + public void SendLine(string s) + { + Debug.Console(2, this, "TX: '{0}'", s); + Communication.SendText(s + "\x0a"); + } + + /// + /// Adds a command from a child module to the queue + /// + /// Command object from child module + public void EnqueueCommand(QueuedCommand commandToEnqueue) + { + CommandQueue.Enqueue(commandToEnqueue); + SendNextQueuedCommand(); + } + + /// + /// Adds a raw string command to the queue + /// + /// + public void EnqueueCommand(string command) + { + CommandQueue.Enqueue(command); + SendNextQueuedCommand(); + } + + /// + /// Sends the next queued command to the DSP + /// + void SendNextQueuedCommand() + { + Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected); + if (!CommandQueueInProgress) + { + if (CommandQueue.IsEmpty) + CommandQueueInProgress = false; + + Debug.Console(2, this, "CommandQueue has {0} Elements", CommandQueue.Count); + + foreach (object o in CommandQueue) + { + if (o is string) + Debug.Console(2, this, "{0}", o); + else if(o is QueuedCommand) + { + var item = (QueuedCommand)o; + Debug.Console(2, this, "{0}", item.Command); + } + } + + 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); + } + } + } + } + + /// + /// Sends a command to execute a preset + /// + /// Preset Name + public override void RunPreset(string name) + { + SendLine(string.Format("DEVICE recallPreset {0}", name)); + } + + public class QueuedCommand + { + public string Command { get; set; } + public string AttributeCode { get; set; } + public TesiraForteControlPoint ControlPoint { get; set; } + } + } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs index ec656b9f..18c6a98d 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs @@ -84,25 +84,25 @@ namespace PepperDash.Essentials.Devices.Common.DSP bool LevelIsSubscribed; - public TesiraForteLevelControl(string label, string id, int index1, int index2, bool hasMute, bool hasLevel, BiampTesiraForteDsp parent) - : base(id, index1, index2, parent) - { - Initialize(label, hasMute, hasLevel); - } + //public TesiraForteLevelControl(string label, string id, int index1, int index2, bool hasMute, bool hasLevel, BiampTesiraForteDsp parent) + // : base(id, index1, index2, parent) + //{ + // 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) { - Initialize(config.Label, config.HasMute, config.HasLevel); + Initialize(key, config.Label, config.HasMute, config.HasLevel); } /// /// Initializes this attribute based on config values and generates subscriptions commands and adds commands to the parent's queue. /// - 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); @@ -205,54 +205,54 @@ namespace PepperDash.Essentials.Devices.Common.DSP /// Parses a non subscription response /// /// The attribute code of the command - /// The message to parse - public override void ParseGetMessage(string attributeCode, string message) - { - try - { - // Parse a "+OK" message - string pattern = "+OK \"value\":(.*)"; - - Match match = Regex.Match(message, pattern); - - if (match.Success) - { - - string value; - - if (message.IndexOf("\"value\":") > -1) - { - value = message.Substring(message.IndexOf(":"), message.Length - message.IndexOf(":")); - - switch (attributeCode) - { - case "minLevel": - { - MinLevel = Double.Parse(value); - - break; - } - case "maxLevel": - { - MaxLevel = Double.Parse(value); - - break; - } - default: - { - Debug.Console(2, "Response does not match expected attribute codes: '{0}'", message); - - break; - } - } - } - } - } - catch (Exception e) - { - Debug.Console(2, "Unable to parse message: '{0}'\n{1}", message, e); - } - + /// The message to parse + public override void ParseGetMessage(string attributeCode, string message) + { + try + { + // Parse an "+OK" message + string pattern = @"\+OK ""value"":(.*)"; + + Match match = Regex.Match(message, pattern); + + if (match.Success) + { + + string value = match.Groups[1].Value; + + Debug.Console(2, this, "{0} is {1}", attributeCode, value); + + if (message.IndexOf("\"value\":") > -1) + { + switch (attributeCode) + { + case "minLevel": + { + MinLevel = Double.Parse(value); + + break; + } + case "maxLevel": + { + MaxLevel = Double.Parse(value); + + break; + } + default: + { + Debug.Console(2, "Response does not match expected attribute codes: '{0}'", message); + + break; + } + } + } + } + } + catch (Exception e) + { + Debug.Console(2, "Unable to parse message: '{0}'\n{1}", message, e); + } + } /// @@ -276,7 +276,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP /// /// public void SetVolume(ushort level) - { + { + Debug.Console(2, this, "volume: {0}", level); // Unmute volume if new level is higher than existing if (level > _VolumeLevel && AutomaticUnmuteOnVolumeUp) if(!_IsMuted) @@ -284,7 +285,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel); - SendFullCommand("Set", "level", volumeLevel.ToString()); + SendFullCommand("set", "level", volumeLevel.ToString()); } /// diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index a892acca..c30380a8 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -1,126 +1,126 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {892B761C-E479-44CE-BD74-243E9214AF13} - Library - Properties - PepperDash.Essentials.Devices.Common - Essentials Devices Common - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll - - - - False - ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - - False - ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {892B761C-E479-44CE-BD74-243E9214AF13} + Library + Properties + PepperDash.Essentials.Devices.Common + Essentials Devices Common + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll + + + + False + ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + + + False + ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo index a1bedf3a..22022933 100644 Binary files a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo and b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo differ diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index fc2e0b56..d3ed2e6f 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -1,188 +1,188 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {1BED5BA9-88C4-4365-9362-6F4B128071D3} - Library - Properties - PepperDash.Essentials - PepperDashEssentials - {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - False - ..\..\Essentials Devices Common\Essentials Devices Common\bin\Essentials Devices Common.dll - - - - False - ..\..\..\pepperdash-portal-sync\PepperDashCorePortalSync\PepperDashPortalSync\bin\PepperDashCorePortalSync.dll - - - False - ..\..\..\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll - - - False - ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll - - - False - ..\..\Essentials DM\Essentials_DM\bin\PepperDash_Essentials_DM.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {1BED5BA9-88C4-4365-9362-6F4B128071D3} + Library + Properties + PepperDash.Essentials + PepperDashEssentials + {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + False + ..\..\Essentials Devices Common\Essentials Devices Common\bin\Essentials Devices Common.dll + + + + False + ..\..\..\pepperdash-portal-sync\SspPortalSync\SspPortalSync\bin\PepperDashCorePortalSync.dll + + + False + ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + + + False + ..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll + + + False + ..\..\Essentials DM\Essentials_DM\bin\PepperDash_Essentials_DM.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index b6b3bbd2..eacd8d73 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ