|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Ever wanted the standard ProcessBook Bar control to appear in 3D? Well the following guide will deomnstrate a 3D version of the Bar control and show how with some simple VBA and the ProcessBook object model you can pretty much create what you like.
The following 3D Bar Chart is purely an example, it has limitations and is intended to show users how to use the object model to your advantage. All bar charts are built using the Polygon object to give a 3D appearance.
To show the difference between the 2 types look at the following:

The standard ProcessBook Bar control is on the right and our VBA generated 3D bar is on the left. Note, the 3D bar updates at the same rate as the standard Bar control by hooking into the Display_DataUpdate event.
Code to achieve this is simple but does contain a few lines, to avoid explaining every line (some of which are repetetive) I will leave it to your own curiosity to review the code.
To achieve this add a reference to the PISDK Type Library (this is used to pass a PointList object to the VBA routine) and add a Module to the VBA Project for a display, name the module how you like. Copy the following code into your module:
Code: Private Tag As PISDK.PIPoint
Private Const Width_3DBar As Integer = 50 Private Const Height_3DBar As Integer = 300
Private Const Name_RectBackSuffix As String = "_BACK" Private Const Name_RectFloorSuffix As String = "_FLOOR"
Public Sub UpdateChart_3DBars(ByVal ChartName As String, ByVal ChartX As Integer, ByVal ChartY As Integer, ByVal Tags As PointList) Call Chart_3DBars(ChartName, ChartX, ChartY, Tags, False) End Sub
Private Sub Chart_3DBars(ByVal ChartName As String, ByVal ChartX As Integer, ByVal ChartY As Integer, ByVal Tags As PointList, ByVal CreateChart As Boolean)
Dim Rect As Rectangle, Poly As Polygon
If CreateChart Then ' CREATE BACKGROUND AND FLOOR ' FLOOR: ' 1- - - - - -2 ' / / ' / / ' 4- - - - - -3 Set Poly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Poly.LineColor = pbBlack: Poly.FillColor = pbWhite Poly.Name = ChartName & Name_RectFloorSuffix Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1 ' REMOVE STARTING ENDPOINTS ADDED BY DEFAULT Poly.Endpoints.Add x, y + (Width_3DBar / 2) ' POSITION 1 Poly.Endpoints.Add x + ((Tags.Count + 1) * (Width_3DBar * 1.75)), y + (Width_3DBar / 2) ' POSITION 2 Poly.Endpoints.Add x + ((Tags.Count + 1) * (Width_3DBar * 1.75)) - (Width_3DBar * 1.5), y - Width_3DBar ' POSITION 3 Poly.Endpoints.Add x - (Width_3DBar * 1.5), y - Width_3DBar ' POSITION 4 Poly.Endpoints.Add x, y + (Width_3DBar / 2) ' BACK TO POSITION 1 Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1 ' REMOVE REMAINING ENDPOINTS Set Poly = Nothing ' BACKGROUND: Set Rect = ThisDisplay.Symbols.Add(pbSymbolRectangle) Rect.LineColor = pbBlack: Rect.FillColor = pbBlack Rect.Name = ChartName & Name_RectBackSuffix Rect.Height = Height_3DBar * 1.25 Rect.Width = ((Tags.Count + 1) * (Width_3DBar * 1.75)) Rect.Left = ChartX Rect.Top = ThisDisplay.Symbols(ChartName & Name_RectFloorSuffix).Top + Rect.Height Set Rect = Nothing Else ' DOUBLE CHECK TO ENSURE CHART EXISTS On Error Resume Next: Err.Clear Set Rect = ThisDisplay.Symbols(ChartName & Name_RectBackSuffix) If Not Err.Number = 0 Then ' DOESN'T EXIST SO RECALL ROUTINE WITH CREATECHART=TRUE On Error GoTo 0: Call Chart_3DBars(ChartName, ChartX, ChartY, Tags, True) End If Set Rect = Nothing On Error GoTo 0 End If
Dim iTag As Integer: iTag = 1 ' PIPoint.PointAttributes("SPAN").Value to Height_3DBar ratio Dim TheRatio As Double: TheRatio = 0 Dim Left_3DBar As Double: Left_3DBar = 0 Dim HeightValue As Double: HeightValue = 0 Dim EmptyHeightValue As Double: EmptyHeightValue = 0
For Each Tag In Tags TheRatio = Height_3DBar / Tag.PointAttributes("SPAN").Value HeightValue = Tag.Data.Snapshot.Value If HeightValue > Tag.PointAttributes("SPAN").Value Then HeightValue = Tag.PointAttributes("SPAN").Value If HeightValue < Tag.PointAttributes("ZERO").Value Then HeightValue = Tag.PointAttributes("ZERO").Value HeightValue = (HeightValue * TheRatio) Left_3DBar = ChartX + ((iTag - 1) * Width_3DBar) + (iTag * (Width_3DBar * 0.75))
EmptyHeightValue = (Tag.PointAttributes("SPAN").Value - Tag.Data.Snapshot.Value) * TheRatio ' PIPOINT.VALUE BAR Call Chart_3DBar(ChartName, iTag, Left_3DBar, ChartY, Width_3DBar, HeightValue, pbYellow, pbDkYellow, CreateChart) ' EMPTY BAR (WHITE) Call Chart_3DBar(ChartName, iTag & "B", Left_3DBar, ChartY + HeightValue, Width_3DBar, EmptyHeightValue, pbWhite, pbLtGray, CreateChart) iTag = iTag + 1 Next Tag
End Sub
Private Sub Chart_3DBar(ByVal ChartName As String, ByVal BarPosition As String, ByVal StartX As Double, ByVal StartY As Double, ByVal Width As Double, ByVal Height As Double, ByVal FirstColor As Long, ByVal SecondColor As Long, ByVal CreateBar As Boolean)
' 3D BAR FROM POLYGONS: ' X---X ' / 3 /| ' X---X | ' | | | ' | | | ' | |2| ' | 1 | | ' | | | ' | | X ' | |/ ' X---X
Dim Polly As Polygon ' (1) FRONT: ' 4---3 ' | | ' | | ' | | ' 1---2 If CreateBar Then ' CREATE THE BAR AND SET THE HEIGHT Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_FRONT" Polly.FillColor = FirstColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX, StartY) '1 Call Polly.Endpoints.Add(StartX + Width, StartY) '2 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '3 Call Polly.Endpoints.Add(StartX, StartY + Height) '4 Call Polly.Endpoints.Add(StartX, StartY) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else ' READJUST THE HEIGHT OF THE BAR Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_FRONT") Polly.Endpoints(1).x = StartX: Polly.Endpoints(1).y = StartY Polly.Endpoints(2).x = StartX + Width: Polly.Endpoints(2).y = StartY Polly.Endpoints(3).x = StartX + Width: Polly.Endpoints(3).y = StartY + Height Polly.Endpoints(4).x = StartX: Polly.Endpoints(4).y = StartY + Height Polly.Endpoints(5).x = StartX: Polly.Endpoints(5).y = StartY Set Polly = Nothing End If ' (2) SIDE: ' 3 ' /| ' 4 | ' | | ' | 2 ' |/ ' 1 If CreateBar Then Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_RIGHT" Polly.FillColor = SecondColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX + Width, StartY) '1 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + (Width / 2)) '2 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + (Width / 2) + Height) '3 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '4 Call Polly.Endpoints.Add(StartX + Width, StartY) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_RIGHT") Polly.Endpoints(1).x = StartX + Width: Polly.Endpoints(1).y = StartY Polly.Endpoints(2).x = StartX + (Width * 1.5): Polly.Endpoints(2).y = StartY + (Width / 2) Polly.Endpoints(3).x = StartX + (Width * 1.5): Polly.Endpoints(3).y = StartY + (Width / 2) + Height Polly.Endpoints(4).x = StartX + Width: Polly.Endpoints(4).y = StartY + Height Polly.Endpoints(5).x = StartX + Width: Polly.Endpoints(5).y = StartY Set Polly = Nothing End If
' (3) TOP ' 4---3 ' / / ' 1---2 If bCreate Then Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_TOP" Polly.FillColor = FirstColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX, StartY + Height) '1 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '2 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + Height + (Width / 2)) '3 Call Polly.Endpoints.Add(StartX + (Width / 2), StartY + Height + (Width / 2)) '4 Call Polly.Endpoints.Add(StartX, StartY + Height) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_TOP") Polly.Endpoints(1).x = StartX: Polly.Endpoints(1).y = StartY + Height Polly.Endpoints(2).x = StartX + Width: Polly.Endpoints(2).y = StartY + Height Polly.Endpoints(3).x = StartX + (Width * 1.5): Polly.Endpoints(3).y = StartY + (Width / 2) + Height Polly.Endpoints(4).x = StartX + (Width / 2): Polly.Endpoints(4).y = StartY + Height + (Width / 2) Polly.Endpoints(5).x = StartX: Polly.Endpoints(5).y = StartY + Height Set Polly = Nothing End If
End Sub
Once you have had time to digest the code you just need to implement it on your display. Start by adding a standard Bar control with the PI Tag set to "SINUSOID" (or tag of your choice) so you have a comparison. Next switch to the VBA code for your display (ThisDisplay) and add the following code:
* This code uses reusable connect to PI routine: ConnectToPI
Code:Private Function GatherPoints() As PISDK.PointList
Call ConnectToPI Dim ThePoints As PISDK.PointList Set ThePoints = New PISDK.PointList ThePoints.Add PIServer.PIPoints("SINFAST") ThePoints.Add PIServer.PIPoints("SINUSOID")
Set GatherPoints = ThePoints Set ThePoints = Nothing
End Function
Private Sub Display_DataUpdate() If Application.RunMode Then Call UpdateChart_3DBars("CHART1", -14500, 14500, GatherPoints) ThisDisplay.Modified = False End If End Sub
What happens here is a PointList object is created and passed as the Points to be used to draw the Bars. Switch the display to RunMode and watch as the 3D chart is drawn on the screen for the passed points and watch as the bars update as the data changes.
As mentioned the 3D bars do have limitations but feel free to expand/develop the code to suit your needs. Some ideas for expanding this (we will provide updates to this code periodically with new functionality): - Include other charting types (e.g. Pie Charts) only using built in symbols. - Add MultiState configuration for 3D Bars - Add ToolTips to display values - Manipulate the 3D "faces" to show different but related values (front face of bar = value, side face is multistated quality or other property)
Enjoy!
Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
Hi,
This is what brought me to these forums. Are there any updates as mentioned? The ideas of making the 3D "faces" to show different but related values (front face of bar = value, side face is multistated quality or other property) is of particular interest.
Thanks.
.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Hi ThePIman....welcome! Answer is yes, I developed this along a bit further but before I post the updated version I will ensure it is bug free. Keep an eye out for the updated version... Rhys. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/14/2009 Posts: 35 Location: UK
|
That's good news because we had trouble getting the top to draw with the code above. Thanks
.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Here is updated code. Note, Multistating is "hardcoded" but shows how it is done. This part just needs to be made configurable. The "side" part of the 3D bar is multistated based on the PI tag the bar is drawn for, as this is sinusoid I added some dummy states baring in mind the range is typically 0 - 100. Code:Private Tag As PISDK.PIPoint
Private Const Width_3DBar As Integer = 50 Private Const Height_3DBar As Integer = 300
Private Const Name_RectBackSuffix As String = "_BACK" Private Const Name_RectFloorSuffix As String = "_FLOOR"
Public Sub UpdateChart_3DBars(ByVal ChartName As String, ByVal ChartX As Integer, ByVal ChartY As Integer, ByVal Tags As PointList) Call Chart_3DBars(ChartName, ChartX, ChartY, Tags, False) End Sub
Public Sub Chart_3DBars(ByVal ChartName As String, ByVal ChartX As Integer, ByVal ChartY As Integer, ByVal Tags As PointList, ByVal CreateChart As Boolean)
Dim Rect As Rectangle, Poly As Polygon
If CreateChart Then ' CREATE BACKGROUND AND FLOOR ' FLOOR: ' 1- - - - - -2 ' / / ' / / ' 4- - - - - -3 Set Poly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Poly.LineColor = pbBlack: Poly.FillColor = pbWhite Poly.Name = ChartName & Name_RectFloorSuffix Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1 ' REMOVE STARTING ENDPOINTS ADDED BY DEFAULT Poly.Endpoints.Add ChartX, ChartY + (Width_3DBar / 2) ' POSITION 1 Poly.Endpoints.Add ChartX + ((Tags.Count + 1) * (Width_3DBar * 1.75)), ChartY + (Width_3DBar / 2) ' POSITION 2 Poly.Endpoints.Add ChartX + ((Tags.Count + 1) * (Width_3DBar * 1.75)) - (Width_3DBar * 1.5), ChartY - Width_3DBar ' POSITION 3 Poly.Endpoints.Add ChartX - (Width_3DBar * 1.5), ChartY - Width_3DBar ' POSITION 4 Poly.Endpoints.Add ChartX, ChartY + (Width_3DBar / 2) ' BACK TO POSITION 1 Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1: Poly.Endpoints.Remove 1 ' REMOVE REMAINING ENDPOINTS Set Poly = Nothing ' BACKGROUND: Set Rect = ThisDisplay.Symbols.Add(pbSymbolRectangle) Rect.LineColor = pbBlack: Rect.FillColor = pbBlack Rect.Name = ChartName & Name_RectBackSuffix Rect.Height = Height_3DBar * 1.25 Rect.Width = ((Tags.Count + 1) * (Width_3DBar * 1.75)) Rect.Left = ChartX Rect.Top = ThisDisplay.Symbols(ChartName & Name_RectFloorSuffix).Top + Rect.Height Set Rect = Nothing Else ' DOUBLE CHECK TO ENSURE CHART EXISTS On Error Resume Next: Err.Clear Set Rect = ThisDisplay.Symbols(ChartName & Name_RectBackSuffix) If Not Err.Number = 0 Then ' DOESN'T EXIST SO RECALL ROUTINE WITH CREATECHART=TRUE On Error GoTo 0: Call Chart_3DBars(ChartName, ChartX, ChartY, Tags, True) End If Set Rect = Nothing On Error GoTo 0 End If
Dim iTag As Integer: iTag = 1 ' PIPoint.PointAttributes("SPAN").Value to Height_3DBar ratio Dim TheRatio As Double: TheRatio = 0 Dim Left_3DBar As Double: Left_3DBar = 0 Dim HeightValue As Double: HeightValue = 0 Dim EmptyHeightValue As Double: EmptyHeightValue = 0
For Each Tag In Tags TheRatio = Height_3DBar / Tag.PointAttributes("SPAN").Value HeightValue = Tag.Data.Snapshot.Value If HeightValue > Tag.PointAttributes("SPAN").Value Then HeightValue = Tag.PointAttributes("SPAN").Value If HeightValue < Tag.PointAttributes("ZERO").Value Then HeightValue = Tag.PointAttributes("ZERO").Value HeightValue = (HeightValue * TheRatio) Left_3DBar = ChartX + ((iTag - 1) * Width_3DBar) + (iTag * (Width_3DBar * 0.75))
EmptyHeightValue = (Tag.PointAttributes("SPAN").Value - Tag.Data.Snapshot.Value) * TheRatio ' PIPOINT.VALUE BAR Call Chart_3DBar(ChartName, iTag, Left_3DBar, ChartY, Width_3DBar, HeightValue, pbYellow, pbDkYellow, CreateChart) If CreateChart Then Call MultiState3DBarElement(ChartName & "_POLY_POS_" & iTag & "_RIGHT", Tag, 3, "20,80", "255,32896,255") End If ' EMPTY BAR (WHITE) Call Chart_3DBar(ChartName, iTag & "B", Left_3DBar, ChartY + HeightValue, Width_3DBar, EmptyHeightValue, pbWhite, pbLtGray, CreateChart) iTag = iTag + 1 Next Tag
End Sub Private Sub MultiState3DBarElement(ByVal SymbolName As String, ByVal TheTag As PISDK.PIPoint, ByVal iStates As Integer, ByVal sStates As String, ByVal sColors As String)
Dim Sym As Symbol, MS As MultiState, vStates As Variant, i As Integer
Set Sym = ThisDisplay.Symbols(SymbolName) Set MS = Sym.CreateMultiState("\\" & TheTag.Server & "\" & TheTag.Name) MS.StateCount = iStates vStates = Split(sStates, ",") For i = LBound(Split(sColors, ",")) To UBound(Split(sColors, ",")) Dim MStat As MSState Set MStat = MS.GetState(i + 1) MStat.Color = Split(sColors, ",")(i) If i = LBound(Split(sColors, ",")) Then MStat.UpperValue = CDbl(vStates(i)) ElseIf i = UBound(Split(sColors, ",")) Then MStat.LowerValue = CDbl(vStates(i - 1)) Else MStat.LowerValue = CDbl(vStates(i - 1)) MStat.UpperValue = CDbl(vStates(i)) End If Set MStat = Nothing Next
Call Sym.SetMultiState(MS) Set MS = Nothing Set Sym = Nothing
End Sub Private Sub Chart_3DBar(ByVal ChartName As String, ByVal BarPosition As String, ByVal StartX As Double, ByVal StartY As Double, ByVal Width As Double, ByVal Height As Double, ByVal FirstColor As Long, ByVal SecondColor As Long, ByVal CreateBar As Boolean)
' 3D BAR FROM POLYGONS: ' X---X ' / 3 /| ' X---X | ' | | | ' | | | ' | |2| ' | 1 | | ' | | | ' | | X ' | |/ ' X---X
Dim Polly As Polygon ' (1) FRONT: ' 4---3 ' | | ' | | ' | | ' 1---2 If CreateBar Then ' CREATE THE BAR AND SET THE HEIGHT Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_FRONT" Polly.FillColor = FirstColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX, StartY) '1 Call Polly.Endpoints.Add(StartX + Width, StartY) '2 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '3 Call Polly.Endpoints.Add(StartX, StartY + Height) '4 Call Polly.Endpoints.Add(StartX, StartY) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else ' READJUST THE HEIGHT OF THE BAR Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_FRONT") Polly.Endpoints(1).x = StartX: Polly.Endpoints(1).y = StartY Polly.Endpoints(2).x = StartX + Width: Polly.Endpoints(2).y = StartY Polly.Endpoints(3).x = StartX + Width: Polly.Endpoints(3).y = StartY + Height Polly.Endpoints(4).x = StartX: Polly.Endpoints(4).y = StartY + Height Polly.Endpoints(5).x = StartX: Polly.Endpoints(5).y = StartY Set Polly = Nothing End If ' (2) SIDE: ' 3 ' /| ' 4 | ' | | ' | 2 ' |/ ' 1 If CreateBar Then Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_RIGHT" Polly.FillColor = SecondColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX + Width, StartY) '1 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + (Width / 2)) '2 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + (Width / 2) + Height) '3 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '4 Call Polly.Endpoints.Add(StartX + Width, StartY) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_RIGHT") Polly.Endpoints(1).x = StartX + Width: Polly.Endpoints(1).y = StartY Polly.Endpoints(2).x = StartX + (Width * 1.5): Polly.Endpoints(2).y = StartY + (Width / 2) Polly.Endpoints(3).x = StartX + (Width * 1.5): Polly.Endpoints(3).y = StartY + (Width / 2) + Height Polly.Endpoints(4).x = StartX + Width: Polly.Endpoints(4).y = StartY + Height Polly.Endpoints(5).x = StartX + Width: Polly.Endpoints(5).y = StartY Set Polly = Nothing End If
' (3) TOP ' 4---3 ' / / ' 1---2 If CreateBar Then Set Polly = ThisDisplay.Symbols.Add(pbSymbolPolygon) Polly.Name = ChartName & "_POLY_POS_" & BarPosition & "_TOP" Polly.FillColor = FirstColor: Polly.LineColor = pbBlack Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Call Polly.Endpoints.Add(StartX, StartY + Height) '1 Call Polly.Endpoints.Add(StartX + Width, StartY + Height) '2 Call Polly.Endpoints.Add(StartX + (Width * 1.5), StartY + Height + (Width / 2)) '3 Call Polly.Endpoints.Add(StartX + (Width / 2), StartY + Height + (Width / 2)) '4 Call Polly.Endpoints.Add(StartX, StartY + Height) '1 Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1: Polly.Endpoints.Remove 1 Set Polly = Nothing Else Set Polly = ThisDisplay.Symbols(ChartName & "_POLY_POS_" & BarPosition & "_TOP") Polly.Endpoints(1).x = StartX: Polly.Endpoints(1).y = StartY + Height Polly.Endpoints(2).x = StartX + Width: Polly.Endpoints(2).y = StartY + Height Polly.Endpoints(3).x = StartX + (Width * 1.5): Polly.Endpoints(3).y = StartY + (Width / 2) + Height Polly.Endpoints(4).x = StartX + (Width / 2): Polly.Endpoints(4).y = StartY + Height + (Width / 2) Polly.Endpoints(5).x = StartX: Polly.Endpoints(5).y = StartY + Height Set Polly = Nothing End If
End Sub
To create a chart call: Code:Private Sub AddChart() Call Chart_3DBars("CHART1", -14500, 14500, GatherPoints, True) End Sub
Private Function GatherPoints() As PISDK.PointList
Call ConnectToPI Dim ThePoints As PISDK.PointList Set ThePoints = New PISDK.PointList ThePoints.Add PIServer.PIPoints("SINFAST") ThePoints.Add PIServer.PIPoints("SINUSOID")
Set GatherPoints = ThePoints Set ThePoints = Nothing
End Function
Private Sub Display_DataUpdate() If Application.RunMode Then Call UpdateChart_3DBars("CHART1", -14500, 14500, GatherPoints) ThisDisplay.Modified = False End If End Sub What you should see:   Feel free to modify as you wish... Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 1/15/2010 Posts: 13 Location: us
|
I am trying to get this code to work; however, when I put the above code in as listed, I get the following error. Run time error 424 object required. When I hit debug it goes to the following line: ThePoints.Add PIServer.PIPoints("SINFAST"). Please let me know what I am doing wrong. I would really like to get this working. Thanks for your help.
|
|
|
Rank: Newbie Groups: Member
Joined: 11/24/2010 Posts: 1 Location: Mexico
|
blitzclipse wrote:I am trying to get this code to work; however, when I put the above code in as listed, I get the following error. Run time error 424 object required. When I hit debug it goes to the following line: ThePoints.Add PIServer.PIPoints("SINFAST"). Please let me know what I am doing wrong. I would really like to get this working. Thanks for your help. maybe the references on vb are incomplete. This code works very good!
|
|
|
|
Guest
|