5 Replies Latest reply on Sep 3, 2013 1:11 PM by dhollebeek

    Horizontal Cursor for Processbook

    wpurrer

      Hi

       

      Our User requests a "horizontal cursor" for the processbook trend.
      (so more or less a rule where also the position in the Y - axis is displayed (transformed) into the scale ...  like the built in vertical curstor)

      Since it doesn't seem to happen that we get this change soon...  we like to develop an addin for this.

       

      there are two issues we have:

       

      a)  how do we calculate from the position the value with the right scale
      b) and how to best draw the ruler on this screen

       

      for b)  are two options

       

       -  directly draw into the trend (how can we do this - can we access some kind of canvas ?)
       -  let the user move some kind of ruler (which is a windows forms object) over the screen

       

      br

       

      Wolfgang

       

       

        • Re: Horizontal Cursor for Processbook

          Wolfgang, that is going to be a major hurdle without ProcessBook developing it directly.

           

          You'd have to take into account multiple traces, multiple scales, plot values, snapshot vs archive plot values (for snapshot trends), size/scale of the trend etc. I'll borrow from my thread on the trend max markers that culture settings, font size etc would all need to be taken into account to know whew the plot has been drawn on the trend symbol canvas. 

           

          My preference would be to use the trend cursor(s) and then draw on top of the trend symbol with a line object. However, with multiple scales you'd need to draw multiple horizontal lines and be accurate enough to shorten the line on the vertical axis line otherwise it'll look messy. You won't be able to draw directly in the trend, you'd have to draw on top of (symbol z-order) the trend...or do some trickery by dynamically adding a constant calculation dataset to the trend when using a cursor - when there is not cursor then remove the dataset trace. You could colour the trace to be the same as the trace(s) caught by the cursor.

           

          major hurdle doesn't mean impossible

            • Re: Horizontal Cursor for Processbook
              wpurrer

              Thanks for your reply Rhys!

               

              I decided to create a line object that i can move around using the mouse. But unfortunately i have no idea how to get the value of the y-axis by using the line's current position( top value).

               

              How do i access the values with C#, e.g. the scale?

                • Re: Horizontal Cursor for Processbook

                  Let me think about your question on the scale...tricky one.

                   

                  What about the manipulating datasets & Trend Symbol appearance to get what you need? For example, drop a trend on a display, "Trend1". Add a single trace, "sinusoid". Add a PI Calculation dataset with the expression of "0" and name it "HORIZONTAL_TRACE". Add below code to the display. Hover over the sinusoid trace at a particular value, you should see the horizontal line appear at that value (by manipulating the dataset and adding it to the trend's traces). Move the cursor away from the trend (or to another value on the trace) and it should then remove (or move) the horizontal line.

                   

                  Obviously you would want to make it much more clever by altering pen colours, name of datasets, multiple traces etc.

                   

                   Would something like that work? It would be compatible with vertically orientated trends too.

                   
                  Private Sub RemoveHorizontalTrace()
                      For i = 1 To Trend1.TraceCount
                          Trend1.CurrentTrace = i
                          If Trend1.GetTagName(i) = "HORIZONTAL_TRACE.Value" Then
                              Trend1.RemoveTrace i
                              Exit For
                          End If
                      Next i
                  End Sub
                  
                  Private Sub Trend1_MouseOut()
                      RemoveHorizontalTrace
                  End Sub
                  
                  Private Sub Trend1_ToolTipText(ToolTip As String)
                  
                  If ToolTip = "" Then
                      Exit Sub
                  End If
                  If Not InStr(1, ToolTip, "(") > 1 Then Exit Sub
                  
                  Dim sDate As String: sDate = Replace(Trim(Split(Split(ToolTip, "(")(1), ")")(0)), " ", "")
                  Dim sValue As String: sValue = Trim(Replace(Split(Split(ToolTip, "(")(0), "=")(1), " ", ""))
                  
                  Dim st As Variant
                  Dim ds As PIExpressionDataset
                  Set ds = Datasets.GetDataset("HORIZONTAL_TRACE")
                      ds.Expression = sValue
                  Call Datasets.SetDataset(ds)
                  
                  Dim bVisible As Boolean: bVisible = False
                      For i = 1 To Trend1.TraceCount
                          Trend1.CurrentTrace = i
                          If Trend1.GetTagName(i) = "HORIZONTAL_TRACE.Value" Then
                              bVisible = True
                              Exit For
                          End If
                      Next i
                  If Not bVisible Then
                      Call Trend1.AddTrace("HORIZONTAL_TRACE.Value")
                  End If
                  
                  End Sub
                  

                   

              • Re: Horizontal Cursor for Processbook
                dhollebeek

                Take a look at this thread: vcampus.osisoft.com/.../23335.aspx .  The trend automatically lays itself out using fairly complex rules, figuring out where a certain value on a scale is will be very difficult.  The best you could do is set up a fixed size trend and calculate the position by trial and error.  As far as directly drawing on a Trend (or PB display), no, there is no way to do this.

                 

                :D