3 Replies Latest reply on Aug 13, 2014 3:22 PM by Gregor

    VBA Double Variable Overflow Error


      Hi There,


      I am developing some screens for a customer in ProcessBook. These screens are related to compressors and are to show a plot of compressor performance in terms of flow vs. head (representing the work done in compressing the gas).


      The requirement is to have overlaid on top of the actual data a set of six static curves to represent the manufacturer ideal performance of the compressor running at different speeds. My customer has 21 compressors and does not use AF so I have built a structure in the MDB and am working with module relative displays in ProcessBook version


      I have used and extended the approach described by Andreas here: https://vcampus.osisoft.com/bloggers_place/b/andreas/archive/2010/06/30/overlay-a-characteristic-curve-in-an-xy-plot.aspx I have the static curve data stored in an Excel file rather than an Access database and its accessed by 6 ODBC datasets. I have seven XY plots, one for the actual data and one each for the characteristic curves. The code works fine to combine the XY plots but I am having an issue with getting them to all zoom in sync.


      I have the 6th static curve always on top and hook on to its 'zoom' event. Then I am trying to get the new absolute max and min scales from it and passing them down to the other XY plots in the stack. the problem I having now is that, intermittently one of the double variables holding the min and max scale setting is showing "Overflow" when I'm debugging and causes an "Overflow" error when I'm trying to assign it to the other curves in the stack.


      I just wanted to see if anyone has had this problem before, maybe in a different context or maybe with the same code. It does happen with the unaltered code from the original vCampus article and also my modified version. Also the code from the original vCampus article produces an intermittent error with a pop up saying "Invalid Argument". I have checked the event log and there are no matching events to these. Also there is nothing I can see in the PI logs (however I have no way to view the contents of the *.dat files in the "PIPC\LOG" directory due to the customer laptop being so locked down).


      I have attached screenshots of the ProcessBook file in action and also the errors describe above. I have also attached the MDB structure config file, excel file for the static curve data and the ProcessBook file itself.


      Any input would be greatly appreciated.























        • Re: VBA Double Variable Overflow Error

          Hello Mike,


          I am doing a little hard reproducing what you are doing. Could you try simplifying your display? I don't believe the issue is related to Module Relative Display. Hence, can you create a simple display with just some XY-Plots on it using some standard tags? As far as I understand your code produces the overflow when the user zooms in to a XY-Plot and the other XY-Plots are becoming adjusted and it appears the overflow is originating from either



          myMin = myXYPlot6Definition.Tags(myTag).AutorangeMin




          myMin = myXYPlot6Definition.Tags(myTag).AbsoluteMin

          Did you check for the values of AutorangeMin and AbsoluteMin when the error occurs?


          Also I recognized that you are defining variables inside the For-Next loop what doesn't appear optimal to me or at least worth to try it outside.



                  Dim myMin As Double
                  Dim myMax As Double
                  Dim maxScale As pbMinMaxEnum
                  Dim minScale As pbMinMaxEnum
                  For myTag = 1 To 2
                      minScale = myXYPlot6Definition.Tags(myTag).Min
                      maxScale = myXYPlot6Definition.Tags(myTag).Max
                      Select Case maxScale
                          Case pbScaleAutorange
                              myMax = myXYPlot6Definition.Tags(myTag).AutorangeMax
                          Case pbScaleAbsolute
                              myMax = myXYPlot6Definition.Tags(myTag).AbsoluteMax
                          Case pbScaleDatabase
                              MsgBox "ERROR: Unable to max scale component trends"
                      End Select
                      Select Case minScale
                          Case pbScaleAutorange
                              myMin = myXYPlot6Definition.Tags(myTag).AutorangeMin
                          Case pbScaleAbsolute
                              myMin = myXYPlot6Definition.Tags(myTag).AbsoluteMin
                          Case pbScaleDatabase
                              MsgBox "ERROR: Unable to min scale component trends"
                      End Select
                      myXYPlot1Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot2Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot3Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot4Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot5Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot6Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                      myXYPlot7Definition.Tags(myTag).SetScaleConfiguration False, pbScaleAbsolute, myMin, pbScaleAbsolute, myMax
                  Next myTag