diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 18afaf24..055fcd97 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.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index bbf70ee0..17eff8be 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 f5745ae3..e2cc6c27 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs @@ -70,7 +70,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP } 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"); } @@ -130,7 +130,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP level.Value.Subscribe(); } - if (!CommandQueue.IsEmpty) + if (!CommandQueueInProgress) SendNextQueuedCommand(); ResetSubscriptionTimer(); @@ -162,6 +162,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP Debug.Console(2, this, "RX: '{0}'", ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text); + Debug.Console(1, this, "RX: '{0}'", args.Text); + try { if (args.Text.IndexOf("Welcome to the Tesira Text Protocol Server...") > -1) @@ -221,23 +223,22 @@ namespace PepperDash.Essentials.Devices.Common.DSP 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); + QueuedCommand tempCommand = (QueuedCommand)CommandQueue.TryToDequeue(); + Debug.Console(1, 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); + string temp = (string)CommandQueue.TryToDequeue(); + Debug.Console(1, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); } - - //if (CommandQueue.IsEmpty) - // CommandQueueInProgress = false; - //else + if (CommandQueue.IsEmpty) + CommandQueueInProgress = false; + else SendNextQueuedCommand(); } @@ -248,14 +249,18 @@ namespace PepperDash.Essentials.Devices.Common.DSP { // Error response - if (args.Text == "-ERR ALREADY_SUBSCRIBED") + switch (args.Text) { - // Subscription still valid - ResetSubscriptionTimer(); - } - else - { - SubscribeToAttributes(); + case "-ERR ALREADY_SUBSCRIBED": + { + ResetSubscriptionTimer(); + break; + } + default: + { + Debug.Console(0, this, "Error From DSP: '{0}'", args.Text); + break; + } } } @@ -274,7 +279,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP /// Command to send public void SendLine(string s) { - Debug.Console(2, this, "TX: '{0}'", s); + Debug.Console(1, this, "TX: '{0}'", s); Communication.SendText(s + "\x0a"); } @@ -285,7 +290,10 @@ namespace PepperDash.Essentials.Devices.Common.DSP public void EnqueueCommand(QueuedCommand commandToEnqueue) { CommandQueue.Enqueue(commandToEnqueue); - SendNextQueuedCommand(); + Debug.Console(1, this, "Command (QueuedCommand) Enqueued '{0}'. CommandQueue has '{1}' Elements.", commandToEnqueue.Command, CommandQueue.Count); + + if(!CommandQueueInProgress) + SendNextQueuedCommand(); } /// @@ -295,7 +303,10 @@ namespace PepperDash.Essentials.Devices.Common.DSP public void EnqueueCommand(string command) { CommandQueue.Enqueue(command); - SendNextQueuedCommand(); + Debug.Console(1, this, "Command (string) Enqueued '{0}'. CommandQueue has '{1}' Elements.", command, CommandQueue.Count); + + if (!CommandQueueInProgress) + SendNextQueuedCommand(); } /// @@ -304,24 +315,25 @@ namespace PepperDash.Essentials.Devices.Common.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); + //if (CommandQueue.IsEmpty) + // CommandQueueInProgress = false; + + Debug.Console(1, this, "CommandQueue has {0} Elements:\n", CommandQueue.Count); foreach (object o in CommandQueue) { if (o is string) - Debug.Console(2, this, "{0}", o); + Debug.Console(1, this, "{0}", o); else if(o is QueuedCommand) { var item = (QueuedCommand)o; - Debug.Console(2, this, "{0}", item.Command); + Debug.Console(1, this, "{0}", item.Command); } } + Debug.Console(1, this, "End of CommandQueue"); + if (Communication.IsConnected && !CommandQueue.IsEmpty) { CommandQueueInProgress = true; @@ -341,7 +353,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP SendLine(nextCommand); } } - } + } /// 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 18c6a98d..8ddbac0e 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs @@ -192,7 +192,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP var _value = Double.Parse(value); - _VolumeLevel = (ushort)Scale(_value, MinLevel, MaxLevel, 0, 65536); + _VolumeLevel = (ushort)Scale(_value, MinLevel, MaxLevel, 0, 65535); LevelIsSubscribed = true; @@ -220,7 +220,7 @@ namespace PepperDash.Essentials.Devices.Common.DSP string value = match.Groups[1].Value; - Debug.Console(2, this, "{0} is {1}", attributeCode, value); + //Debug.Console(1, this, "{0} is {1}", attributeCode, value); if (message.IndexOf("\"value\":") > -1) { @@ -230,12 +230,16 @@ namespace PepperDash.Essentials.Devices.Common.DSP { MinLevel = Double.Parse(value); + Debug.Console(1, this, "MinLevel is '{0}'", MinLevel); + break; } case "maxLevel": { MaxLevel = Double.Parse(value); + Debug.Console(1, this, "MaxLevel is '{0}'", MinLevel); + break; } default: @@ -277,15 +281,15 @@ namespace PepperDash.Essentials.Devices.Common.DSP /// public void SetVolume(ushort level) { - Debug.Console(2, this, "volume: {0}", level); + Debug.Console(1, this, "volume: {0}", level); // Unmute volume if new level is higher than existing if (level > _VolumeLevel && AutomaticUnmuteOnVolumeUp) if(!_IsMuted) MuteOff(); - double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel); - - SendFullCommand("set", "level", volumeLevel.ToString()); + double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel); + + SendFullCommand("set", "level", string.Format("{0:0.000000}", volumeLevel)); } /// @@ -318,25 +322,29 @@ namespace PepperDash.Essentials.Devices.Common.DSP MuteOff(); } - /// - /// Scales the input from the input range to the output range - /// - /// - /// - /// - /// - /// - /// - int Scale(int input, int inMin, int inMax, int outMin, int outMax) - { - int inputRange = inMax - inMin; + ///// + ///// Scales the input from the input range to the output range + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //int Scale(int input, int inMin, int inMax, int outMin, int outMax) + //{ + // Debug.Console(1, this, "Scaling (int) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax); - int outputRange = outMax - outMin; + // int inputRange = inMax - inMin; - var output = (((input-inMin) * outputRange) / inputRange ) - outMin; + // int outputRange = outMax - outMin; - return output; - } + // var output = (((input-inMin) * outputRange) / inputRange ) - outMin; + + // Debug.Console(1, this, "Scaled output '{0}'", output); + + // return output; + //} /// /// Scales the input from the input range to the output range @@ -349,11 +357,20 @@ namespace PepperDash.Essentials.Devices.Common.DSP /// double Scale(double input, double inMin, double inMax, double outMin, double outMax) { - double inputRange = inMax - inMin; + Debug.Console(1, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'",input ,inMin ,inMax ,outMin, outMax); + + double inputRange = inMax - inMin; + + if (inputRange <= 0) + { + throw new ArithmeticException(string.Format("Invalid Input Range '{0}' for Scaling. Min '{1}' Max '{2}'.", inputRange, inMin, inMax)); + } double outputRange = outMax - outMin; - var output = (((input - inMin) * outputRange) / inputRange) - outMin; + var output = (((input - inMin) * outputRange) / inputRange) + outMin; + + Debug.Console(1, this, "Scaled output '{0}'", output); return output; } diff --git a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs index cd076139..d75dffe2 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs @@ -70,10 +70,19 @@ namespace PepperDash.Essentials.Devices.Common.DSP { cmd = string.Format("{0} {1} {2}", InstanceTag, command, attributeCode); } + } + + if (command == "get") + { + // This command will generate a return value response so it needs to be queued + Parent.EnqueueCommand(new BiampTesiraForteDsp.QueuedCommand{ Command = cmd, AttributeCode = attributeCode, ControlPoint = this }); + } + else + { + // This command will generate a simple "+OK" response and doesn't need to be queued + Parent.SendLine(cmd); } - - Parent.EnqueueCommand(new BiampTesiraForteDsp.QueuedCommand{ Command = cmd, AttributeCode = attributeCode, ControlPoint = this }); } virtual public void ParseGetMessage(string attributeCode, string message) 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 22022933..15fe75a7 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.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index eacd8d73..8496cf17 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ