Announcement

Collapse
No announcement yet.

Shutter: Open and Close in a single feature

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    I did add the slider in http://mcsSprinklers.com/HSPI_mcsMQTT_5_9_3_1.zip. I am not able to reproduce the 101/102 problem you are having. As close as I could come is if one of t the topics was a button rather than a toggle and in that case only 101 could be defined. The mcsMQTTHS4_2020.dll source is at http://mcsSprinklers.com/mcsMQTTHS4Source_5_9_3_1.zip. There is a dll for BLE tracking that you will need to include in the references to be able to compile with the remainder of the project. You can pick it up from any of the recent binary zip files. The place where the VSP is hard-coded to 101/102 is the procedure SliderButtonType in the MqttAppModule.vb file.

    Comment


      #32
      Hi Michael, sorry for the delay. Life got in the way. And to be honest, it took me some time to get all the pieces and dependencies of the code together in a good working debug environment. But thanks for sharing the latest code, it took me some time understanding what was going on but I think I found it.

      At line 6019 you iterate through oMQTTButton and modifying each oMQTT2 with the correct values. I wasn't unable to find anything wrong with that code, however, after iterating through the oMQTTButtons, all buttons seemed to have the same (the last) value. I was able to track this down to MqttReport.ClearVGP and .AddVGP. I don't understand why, but after calling those functions, all buttons in the oMQTTButton array were updated instead of just the relevant one.

      I was able to "fix" this by replacing this (line 6082):
      oMQTT2.ClearVGP()
      oMQTT2.AddVGP(vgpOff)
      oMQTT2.AddVGP(vgpOn)

      with:
      oMQTTButton(iIteration - 1).ClearVGP()
      oMQTTButton(iIteration - 1).AddVGP(vgpOff)
      oMQTTButton(iIteration - 1).AddVGP(vgpOn)

      Just don't understand why it works for you. Are you using Windows or Linux?

      Also, as a suggestion, test if oMQTTButton is null before the iteration, to avoid a null pointer error (when creating the initial Slider topic, no buttons exist yet). So before line 6019, "If Not IsNothing(oMQTTButton) ...".
      stefxx

      Comment


        #33
        One minor thing; it would be best if the Close value had a ControlUse value of _Off. Now Open and Close both have a ControlValue of _On.
        stefxx

        Comment


          #34
          I made the updates that you suggested. I also changed the second for/each using MQTT2 to an for/next using iIteration to be consistent. I use the for/each often and have not noticed problems before, but I'm glad you were able to get to the bottom for this case. I did all my work on Windows. The update including the control use is at http://mcsSprinklers.com/HSPI_mcsMQTT_5_9_3_4.zip

          Sorry about the difficulty with the references. I should have also given you the actual plugin projects.

          When I was away I uploaded the 5.9.3.1 package to the updater so it should be hitting the streets next week. Something changed in my ability to use the plugin portal upload the past few months which looks to be an expectation by the portal of bandwidths greater than my 15 kilobyte/sec rate. It gives up before the file is uploaded.

          Comment


            #35
            Hi Michael, the issue seems to have returned with the latest version. Both Open and Close are getting VSP 102, and 101 is missing again. Did you make (or revert) any changes? Or do I go crazy?
            stefxx

            Comment


              #36
              No intentional changes made since I incorporated you iteration technique change. Current is at http://mcsSprinklers.com/mcsMQTTHS42020_5944.zip

              For the comma/period issue look in function SetDeviceValueString. gDecimal is a good keyword to search. Yours should have a value of ",". You can see where the period is replaced with this before storing into HS DeviceValue.

              Comment


                #37
                I tried (again) to figure out what is happening, and I am starting to understand. The issue is with GetVGP, ClearVGP and AddVGP, as they seem to share the same VGPList variable between multiple (in this case 2) instances of the object. For instance, when when oMQTTButton(iIteration - 1).ClearVGP() is being called for the second button, the MqttReport.GetVSP is being cleared on both entries in the oMQTTButton array.

                I think it can be resolved by changed the VGPList variable in the MqttReport class to "Private". Actually, I changed all variables in that class to Private.
                stefxx

                Comment


                  #38
                  I was not aware that a public variable inside a Class had scope across multiple instances of the Class. I though global scope only existed when declared in Modules. I need to look other places where this may have been done.

                  Comment


                    #39
                    I am certainly no expert on this, I found this by trail-and-error...
                    stefxx

                    Comment


                      #40
                      The prior definition, if I understand what you are telling me, for the variables in this class were are declared with Dim. Dim should also be local, but easy enough to change to Private. Am I correct on what you have found?

                      Comment


                        #41
                        Yes. Somehow the GetVSP values of the MqttReport array are being shared or pointing to the same memory address. I wish I fully understood why, but changing the variables inside the MqttReport class from Dim to Private fixed it. I changed all variables inside MqttReport.vb from Dim to Private (line 6 - 40).
                        stefxx

                        Comment


                          #42
                          Did you look into gDecimal use in SetDeviceValueString?

                          Comment


                            #43
                            Thanks. I looked into the routine that sets gDecimal, but I don't understand.

                            If 1.234 < CType(2, Double) Then
                            gDecimal = "."
                            Else
                            gDecimal = ","
                            End If

                            How can 1.234 ever by larger than 2?

                            Why don't you use Globalization.CultureInfo.CurrentCulture.NumberFormat.Number DecimalSeparator instead?
                            stefxx

                            Comment


                              #44
                              I did not use it because I did not know about it. For places where the period is used to separate 1000's then 1.234 is treated as 1234 which will be greater than 2. For the US 1.234 the number is less than 2.

                              Was the problem in your case that gDecimal was showing up as period? If you change it to use Globalization namespace then do the numbers with periods update correctly in HS device?

                              Comment


                                #45
                                Ah, I understand your thinking. However, in the .Net programming language there is no support for a decimal comma. It will always be a period regardless of the regional settings. So the gDecimal will always be set to ".".

                                This worked for me: "If CType("1.234", Double) < 2 Then", however, I suggest using the Globalization option instead.

                                And yes, adding "gDecimal = Globalization.CultureInfo.CurrentCulture.NumberFormat.Number DecimalSeparator" worked for me, with decimals as expected.
                                stefxx

                                Comment

                                Working...
                                X