yjf731222

关于趋势图应用的问题

Discussion created by yjf731222 on Apr 16, 2014
Latest reply on Apr 21, 2014 by yjf731222

8176.tuxiang.GIF我打算在趋势图中按照选定的TAG添加曲线,目前实现了在画面上的value的添加,现在想增加从EXCLE表格中读取TAGNAME和说明,然后用VALUE控件数组的方式动态添加到画面上让使用者点击添加或取消曲线。请问有没有合适的例程或一个实现说明的方法。程序如下:

 

 

 

Private Sub Display_Click(ByVal lvarX As Long, ByVal lvarY As Long)
'Option Explicit

 

 

 

Dim PIServername As String
Dim PITagname As String
Dim Description As String * 26
Dim PIPtNo As Long
Dim TrendStartTime As String
Dim TrendEndTime As String
Dim Status As Long
Dim Success As Boolean

 

 

 

Dim MySymbols As SelectedSymbols
Dim MySymbol As Symbol
Dim MySymbolType As Long
Dim N As Integer

 

 

 

Dim pbSymbols As SelectedSymbols
Dim pbSymbol As Symbol
Dim pbBar As PBCommandBar
Dim pbButton As PBCommandBarButton
Dim I As Integer
Dim A As Integer
        
        On Error GoTo ErrorHandler
   
Set MySymbols = ThisDisplay.SelectedSymbols

 

 

 

'Check to see how many are selected.
If MySymbols.Count = 0 Then
'If the count is zero, user clicked display background, do nothing.
Exit Sub
End If
For N = 1 To MySymbols.Count
'Attach to each individual symbol object.
Set MySymbol = MySymbols.Item(N)
'Get the symbols type, ie. Trend, Line, Value, etc..
MySymbolType = MySymbol.Type

 

 

 

'If symbol object is type 7, by definition its a value object.
If MySymbolType = 7 Then

 

 

 

'Get the tagname and trend it.
PITagname = MySymbol.GetTagName(1)
'Pick up the current trend time range.
TrendStartTime = Trend1.StartTime
TrendEndTime = Trend1.EndTime
For I = 1 To Trend1.TraceCount

 

 

 

'If selected tag is not the current one in trend, put it there.
If Not (Trend1.GetTagName(I) = PITagname) Then
    A = 0
   
Else
   A = 1
   Trend1.RemoveTrace (I)
   Exit For
End If
Next I
If A = 0 Then
Trend1.AddTrace (PITagname)
Else
'Removes old point trace from trend, ( ProcessBook 2.1 trends can
'   contain no traces ).
 Exit Sub
'Trend1.RemoveTrace (I)
End If

 

 

 

'Add trace for this tag to trend

 

 

 

'Refresh time range, setting
Trend1.SetStartAndEndTime TrendStartTime, TrendEndTime

 

 

 

'Trend1.TrendTitle = "趋势图"
Success = Trend1.SetTraceScale("Autorange", "Autorange")
Exit Sub
End If
Next N
ErrorHandler:
'Trend1.RemoveTrace (I)
End Sub

 

 

Outcomes