andreas

PI ProcessBook: SetViewPort

Blog Post created by andreas Employee on Jul 10, 2009

SetViewPort

Another post on some small code snippets that might be of use for you.

 

ProcessBook displays can be huge and the amount of information overwhelming. With the help of VBA we can zoom the view to a certain area to catch the attention of the observer .

 

So what are we going to do?

  1. For demonstration we simply put a Value object on the PI ProcessBook. The example below uses the values of CDM158 - so adjust to your needs.
  2. Now we switch to VBA by hitting Alt+F11.
  3. Use the two combo boxes on the top of the code window to open the Value1_DataUpdate Sub.
  4. Type the following code into Value1_DataUpdate:
    Dim AspectRatio AsDouble
    AspectRatio = Me.ViewWidth / Me.ViewHeight
    SelectCaseMe.Value1.GetValue(vrDate, vrStatus)
      Case"Cascade"
          CallMe.SetViewPort(15000, -15000, 30000 / AspectRatio, 30000)
      Case"Program"
          CallMe.SetViewPort(15000, 0, 15000 / AspectRatio, 15000)
      Case"Prog-Auto"
          CallMe.SetViewPort(0, -15000, 15000 / AspectRatio, 15000)
      Case"Manual"
          CallMe.SetViewPort(0, 0, 15000 / AspectRatio, 15000)
      CaseElse
          CallMe.SetViewPort(15000, -15000, 30000 / AspectRatio, 30000)
    EndSelect

The result is a PI ProcessBook display that changes it's visible area dependent of the value of CDM158.

 

Note:
The top left corner of a PI ProcessBook display is (15000,-15000).

Outcomes