技术论坛

Wincc V7.5 VBS ——TrendTable 属性使用

作者 主题
游民

经验值: 86
发帖数: 5
精华帖: 0
主题:【探讨】Wincc V7.5 VBS ——TrendTable 属性使用


只看楼主 楼主 2022-12-19 14:33:55

版本:Wincc V7.5 Sp1   编程语言:VBS

需求实现:把参数名称从mysql数据库中读取,然后在TrendTable关联显示

实现思路流程:每次打开画面时,我会把组件的窗口、时间轴、数值轴清空,然后我把数据库里的名称处理成字符串组,然后根据勾选情况把字符串赋给TrendTable的属性,当然同时组件的其他属性-----例如数据源是归档数据----也跟着赋值。然后做了一个刷新按钮,每点击一次就重新执行上面的流程。

Bug表现:每次打开画面都没什么问题,主要是点击刷新按钮几次后就会出现问题,参数名就无法连接服务器。打开组态框发现是组件已设置好参数名,但是无法设置窗口,数值轴以及时间轴,数据源里也是空的。


请问各位大神我这里可能出现了什么错误?


 
以下网友喜欢您的帖子:

  
重要声明:

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

帖子链接:https://www.ad.siemens.com.cn/club/bbs/post.aspx?a_id=1800106&b_id=5&s_id=0&num=2

侠圣

经验值: 3816
发帖数: 730
精华帖: 3
回复:Wincc V7.5 VBS ——TrendTable 属性使用


只看楼主 1楼 2022-12-19 17:37:26

看看你的脚本再说吧。


 
以下网友喜欢您的帖子:

  
游民

经验值: 86
发帖数: 5
精华帖: 0
回复:Wincc V7.5 VBS ——TrendTable 属性使用


只看楼主 楼主 2楼 2022-12-22 20:55:56

If count1 = 0 Then

Msgbox "请勾选参数,最多8个"

Elseif count1 > 8 Then

Msgbox "最多8个参数"   

Else


str = Split(str,";") '参数名字

str2 = Split(str2,";")'参数单位

str3 = Split(str3,";") '参数种类

'For i = 0 To UBound(str)

'Msgbox "i:"&i&"    str:"&str(i)&"    str2:"&str2(i)&"    str3:"&str3(i)              '调试用

'Next

Dim wcount '统计窗口个数

Dim wcount1,wcount2,wcount3 'kind = 1,2,3 的个数

wcount = 0

wcount1 = 0

wcount2 = 0

wcount3 = 0

For i = 0 To UBound(str3)-1

Select Case str3(i)

Case "1" wcount1 = wcount1 + 1

Case "2" wcount2 = wcount2 + 1

Case "3" wcount3 = wcount3 + 1

End Select

Next

If wcount1 > 0 Then 

wcount = wcount + 1

End If

If wcount2 > 0 Then 

wcount = wcount + 1

End If

If wcount3 > 0 Then 

wcount = wcount + 1

End If

'2.根据str,str2,str3 对趋势图进行设置

'2.1 清空原来设置

On Error Resume Next

Dim obj    

Dim trend 

obj = "Datashow"

Set trend = ScreenItems(obj)

'清空趋势图

For i = 0 To trend.TrendCount 

trend.TrendIndex = i

trend.TrendRemove = trend.TrendRename 

'trend.valueaxisRemove = trend.TrendRename 

Next

'清空窗口

For i = 0 To trend.Trendwindowcount

trend.TrendWindowIndex = i

trend.trendwindowremove = trend.trendwindowRename

Next

'清空时间轴

For i = 0 To trend.Timeaxiscount

trend.Timeaxisindex = i

trend.Timeaxisremove = trend.Timeaxisrename

Next

'清空数值轴

For i = 0  To trend.valueaxiscount

trend.valueaxisindex = i

trend.valueaxisremove = trend.valueaxisrename

Next

'2.2增加窗口

    If wcount1 > 0  Then

    With trend

    .trendwindowadd="检测仪参数"

    .TrendwindowCoarseGrid = True

    .trendwindowfinegrid = False

    .trendwindowhorizontalgrid = True

    .trendwindowverticalgrid = True

    .TimeAxisAdd = "时间1"      '增加时间轴

.TimeAxisTrendWindow = "检测仪参数" '把时间轴放到对应窗口

    '.trendwindowName = "检测仪参数"

    End With

    End if

If wcount2 > 0 Then

With trend

.trendwindowadd = "设备参数"

    .TrendwindowCoarseGrid = True

    .trendwindowfinegrid = False

    .trendwindowhorizontalgrid = True

    .trendwindowverticalgrid = True

    .TimeAxisAdd = "时间2"

    .TimeAxisTrendWindow = "设备参数"

    '.trendwindowName = "设备参数"

    End With

End If

If wcount3 > 0 Then

With trend

.Trendwindowadd = "其他"

    .TrendwindowCoarseGrid = True

    .trendwindowfinegrid = False

    .trendwindowhorizontalgrid = True

    .trendwindowverticalgrid = True

    .TimeAxisAdd = "时间3"

    .TimeAxisTrendWindow = "其他"

    '.trendwindowName = "其他"

    End With

End If

Dim stemp

For i = 0 To UBound(str3)

Select Case str3(i)

Case "1" '把趋势图都扔到这里去

With trend

.TrendAdd = str(i)

.TrendIndex = Trend.TrendCount

.TrendProvider = 1

.TrendTagName = "MES\"&str(i)

.TrendColor = color(i)

.TrendPointStyle = 0

.TrendTrendWindow = "检测仪参数"

.TrendTimeAxis = "时间1"

.TimeAxisRangeType = 1

.ValueAxisAdd = str(i)

.valueAxislabel = str2(i)

.valueAxisTrendWindow = "检测仪参数"

.valueaxisintrendcolor =True

.TrendLinewidth = 2

End With

Case "2"

With trend

.TrendAdd = str(i)

.TrendIndex = Trend.TrendCount

.TrendProvider = 1

.TrendTagName = "MES\"&str(i)

.TrendColor = color(i)

.TrendPointStyle = 0

.TrendTrendWindow = "设备参数"

.TrendTimeAxis = "时间2"

.TimeAxisRangeType = 1

.ValueAxisAdd = str(i)

.valueAxislabel = str2(i)

.valueAxisTrendWindow = "设备参数"

.ValueAxisintrendcolor = True

.TrendLinewidth = 2

End With

Case "3"

    With trend

.TrendAdd = str(i)

.TrendIndex = Trend.TrendCount

.TrendProvider = 1

.TrendTagName = "MES\"&str(i)

.TrendColor = color(i)

.TrendPointStyle = 0

.TrendTrendWindow = "其他"

.TrendTimeAxis = "时间3"

.TimeAxisRangeType = 1

.ValueAxisAdd = str(i)

.valueAxislabel = str2(i)

.valueAxisTrendWindow = "其他"

.ValueAxisintrendcolor = True

.TrendLinewidth = 2

End With

End Select

Next

'Msgbox "trendcount:"&trend.trendcount           '调试用

For i = 0 To Trend.trendcount

trend.trendindex = i

'Msgbox "i:"&i&"str(i):"&str(i) '调试用

trend.trendvalueaxis = str(i+1)

Next

//下面这段设定时间轴范围,测试时发现要最后写,还没知道原因。

If wcount1 > 0 Then

trend.TrendTimeaxis = "时间1"

trend.Timeaxisrangetype = 1

trend.TimeaxisbeginTime = ScreenItems("DTPStart").value

trend.TimeaxisendTime = ScreenItems("DTPEnd").value

End If

If wcount2 > 0 Then

trend.TrendTimeaxis = "时间2"

trend.timeaxisrangetype = 1

trend.TimeaxisbeginTime = ScreenItems("DTPStart").value

trend.TimeaxisendTime = ScreenItems("DTPEnd").value

End If

If wcount3 > 0 Then

trend.TrendTimeaxis = "时间3"

trend.timeaxisrangetype = 1

trend.TimeaxisbeginTime = ScreenItems("DTPStart").value

trend.TimeaxisendTime = ScreenItems("DTPEnd").value

End If

'更新开始和结束时间

Dim dev1

dev1 = Datediff("d",ScreenItems("DTPStart").value,ScreenItems("DTPEnd").value)

If dev1 > 3 Then

Msgbox "时间间隔超过3天,数据量庞大!"

End If

'数据库断开

Set com = Nothing

Set com2 = nothing

adoConn.close

Set adoConn = Nothing

End If



 
以下网友喜欢您的帖子:

  
  • 上一页
  • 1
  • 下一页
收起
Wincc V7.5 VBS ——TrendTable 属性使用
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。