回复:Wincc V7.5 VBS ——TrendTable 属性使用

已锁定

Vincent19993

  • 帖子

    5
  • 精华

    0
  • 被关注

    0

论坛等级:游民

注册时间:2019-06-24

普通 普通 如何晋级?

发布于 2022-12-22 20:55:56

2楼

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


评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32767条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。