发布于 2014-01-10 15:21:20
5楼
Dim fso,file,file1,filename,filename1,dev,rtdata,a,b
Dim i
filename="D:\yt090305bak\data\dev.txt"
filename1="D:\yt090305bak\data\rtdata.txt"
Const ForReading=1
Set fso=CreateObject("s cripting.FileSystemObject")
Set file=fso.opentextfile(filename,ForReading)
Set file1=fso.opentextfile(filename1,ForReading)
Do Until file.AtEndOfLine=-1
dev=file.ReadLine
rtdata=file1.ReadLine
i=i+1
Select Case i
case 1
b= Split(rtdata, ",")
HMIRuntime.Tags("时间").Write b(1)
Case 2
a = Split(dev, ",")
b = Split(rtdata, ",")
HMIRuntime.Tags("当前值2").Write b(1)
HMIRuntime.Tags("测点编号2").Write a(1)
HMIRuntime.Tags("传感器安装地点2").Write a(2)
HMIRuntime.Tags("传感器名称2").Write a(3)
HMIRuntime.Tags("传感器类型编码2").Write a(4)
HMIRuntime.Tags("单位2").Write a(5)
HMIRuntime.Tags("量程上限2").Write a(7)
HMIRuntime.Tags("解警值2").Write a(8)
HMIRuntime.Tags("报警值2").Write a(9)
HMIRuntime.Tags("断电值2").Write a(10)
HMIRuntime.Tags("复电值2").Write a(11)
If a(11)=1 Then
HMIRuntime.Tags("模拟量_2").Write 1
HMIRuntime.Tags("控制量_2").Write 0
Else
HMIRuntime.Tags("模拟量_2").Write 0
HMIRuntime.Tags("控制量_2").Write 1
End if
Case 3
a = Split(dev, ",")
b = Split(rtdata, ",")
HMIRuntime.Tags("瓦斯当前值3").Write b(1)
HMIRuntime.Tags("测点编号3").Write a(1)
HMIRuntime.Tags("传感器安装地点3").Write a(2)
HMIRuntime.Tags("传感器名称3").Write a(3)
HMIRuntime.Tags("传感器类型编码3").Write a(4)
HMIRuntime.Tags("单位3").Write a(5)
HMIRuntime.Tags("量程上限3").Write a(7)
HMIRuntime.Tags("解警值3").Write a(8)
HMIRuntime.Tags("报警值3").Write a(9)
HMIRuntime.Tags("断电值3").Write a(10)
HMIRuntime.Tags("复电值3").Write a(11)
If a(11)=1 Then
HMIRuntime.Tags("模拟量_3").Write 1
HMIRuntime.Tags("控制量_3").Write 0
Else
HMIRuntime.Tags("模拟量_3").Write 0
HMIRuntime.Tags("控制量_3").Write 1
End if
End Select
Loop
file.Close
活到老,学到老!为了生活学习吧!