From 061505706df89a23e1ffbebc642590c3126cdfb0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 22 Mar 2017 16:02:36 -0600 Subject: [PATCH] DSP volume/mute control now fully working. Resolved ESC-305 issues with command queueing --- .../PepperDash_Essentials_Core.projectinfo | Bin 1282 -> 1280 bytes .../Essentials_DM/Essentials_DM.projectinfo | Bin 1139 -> 1140 bytes .../DSP/BiampTesira/BiampTesiraForteDsp.cs | 68 ++++++++++-------- .../BiampTesira/BiampTesiraForteDspLevel.cs | 65 ++++++++++------- .../BiampTesira/TesiraForteControlPoint.cs | 13 +++- .../Essentials Devices Common.projectinfo | Bin 1163 -> 1163 bytes .../PepperDashEssentials.projectinfo | Bin 1876 -> 1872 bytes 7 files changed, 92 insertions(+), 54 deletions(-) diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 18afaf24c132a00a86010bd3d4223906f428d72c..055fcd97b6fe75e0e8dedecd290f6db21389e3ac 100644 GIT binary patch delta 1106 zcmV-Y1g-mm3V;fby?@@D-TRO3fBI;5Z~XAygHLx49&Yb^`eC>Xlr)^aidGq`JzOKLD_xFAM+7b? z7cT_KjZ;M9x~Q|o+3Zbram%)gyp{<)p3RE3sFqm?vdCvA)nY~TnSHsua3(Ci(1jwXUc6aXpI#ln`r#JG4p~M$i zu{@@)7L)SYf!L>Syjj}-W>%KeHlPIkx3{Q(_Nfu~uP?@#vk?mx`3 z^G|ml?%aQPzLVwm_V*v$o1D+~d;-4*bb06YecWzl9=!(!KjbOwPto^BAHB*OrUU=^ zOGakWK7YO4qAn4j4|X5k-`(HI^H0xr zC;RzidjH<}{XBbci+S4EO)z)2=4cK5_ZUOwg=ViF-|2I$2y`c$u{S(i>otM>zt^aBsFhd2oMk_rd+0-RWfVU|@a*p$5})3)t^HJ%c^}zi)OrAK1C-Bufh1 z*q&x>HlAgzo1KHboyn)W)BS_#LAE!g!5-{Ay#FB2XT*}Woi?ii<^{goKWwywF2xxA=a3u&8gntkrde%_)?X{V@*Vj#( zFJ1_e8>fiIbx~)Fv)P;M;+Aa}c`XxqJew75Q7y9)WRcHKs>O=vGy8IR%h@(B{1B;n z%gH}oO!C?5YF$tB<9a$TE_2HbC)MiuP4%oQXL;Rx^vDR(-bcS=^wAf^vRJGa&x(3+ zmDTxAQVXIH#D8qOv-6PtzxR-Uf4Oc~>-J^V{_Jx*_4Y-!EY9<$b*SE>PjBQ8Ly0f4 zVtGtoEhgo)1F=uvc(b+v%&aV_Z9ob7Z*On+AxP07SeH`YCWz>5cjsVd_x}0$?EcPl zx;xv??mhT4yEnP_>HYmrcd{w9l)1Xqh?MX*H+)`Avw!l3GEF!0rI7JyzRH)gd^x4A zKYH{%GaL8A**K|by6b8=eqAh9ALO&iBs*fBInm;9wHC(YFB`%*!o+zxTWhcm4n73A#5lL9c(}`M2|udKs9X^PTDa zo%^#{KAjz84-W3l_9qYS@9jRgzq31?Odbr(&mh!bdTs&xy{Bie=l}Q3PUizVS52Kn zfg9V?tj)%=taY<Pao|bjQ0=rKYe&`f3d|f0WLm0I5_yIN1rZXzD@AZ z*MkQ;56|}wCj0jv+q_dfloN1rZXzD@Ax zv-5|$=aZe;-u>CZ{=MDvESucBf3QEDJvcwV|6sN|lO+PMfA34Q!yOW2rg9i`p-G6v+|9t;^l9P(Le}B3+xxddgD5hgP zKmoyT0q#}=k9YO|E;1k7#uW4^zQ4P3u(Nyr{CswwxN>*4pWS=#X?AaN@6-GHpYCM0 z(CS0PzXjy?X(fKV*Z+6T!^3bMoQS^2ui9$aROcN_@Nl~GaC(1sZ)cX}v)SzY;Nku0 zy-&00bpBbWPg>Pm+-Kw<=L{$YY-r$e}3=$ a{2-rACK-7% -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 220229331aac4e516b15822cb237272a46a00567..15fe75a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5Jx`qv?5yn#%~0CYtj)%=tabBru(vb$ba%RcFg?ijrZjGH zr0ze+^BIZ2y$25hE3}!Kx21ZAs1f9T$@hQBFX33NI4`Cdq=!biE?XJ&{{sp*Szb&M F00377Jf#2t delta 983 zcmV;|11S8935yAk!hhX2yPrPVfAHwu?)c!|?)?Y%4z_nbeYCSf?dH_(HG0? zRsMjGDlB1M*40lFK4;7G>RD0d%WRSVa1kEHbtR}3gc_lI)_)Kp?X{W5*Vj#(FJ1_` zn*k|JMzHoi`X!@}z9^Q(V!e1))QhXE z&VQ0x5Vat7eU{-Dc`MqZ)-tGT4Cg@=}K~Cgf=A^xmi0baI|e^PO2>=r=$MCgm0|Z#O9$I{g2}bnNa7&Bv?!yhLzO zEq~9JZC-;i;l$+k&d(3>*<_L(>`$k&2fO$0PaZxz*v~(Guzzqc2^@plfDLBo7Qo+k zhK76o|HxGB4o%hTpLqW5yd>-fX6k%rdVlBsY?e=F2ib#zd$aw?gZq2C5AN^mPA8KG z12Z)UHJGSdz<%F}8tnN0)$`Q(z|Pv<&`_*B&Dv}{%UU;22YWk{Pj{#L2h)RWZ%X4P zN9z8AJfD#W+#~(W|350;O_fX% F0076XI2`~0 diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index eacd8d73c573bb621f0e72913a98f1f4f6ca3d07..8496cf17706efa54235b57ce6549e98e1e08bbfb 100644 GIT binary patch delta 1490 zcmV;@1ugp24$uyewtu}hyZ0a6|Mbz`-gxKXgL}JspKkAb`eC>Xlr)^aidGq`JzOJX=_xFAM`fIPve1E*YZrXhDLa-X3J`Lfb z&K760H`&FFtrmGLvvfS06>U*1vl3&M&rYhviij}#a(T-sG%x(@lkTP&JzY%l+3RXu zPxIq?IxjABJH;o}>iSLftSV=D-F)=ONWk7lzhv~$7sawztQXIUdU2K2`A<>{q6y?< zytDI={=fH-fPa6vZddE}W!Cz24(}#;mdF|fa zr*FJjiM~H8OKKI2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