level 1
经纪人拐人
楼主
数据库文件是用备份恢复的,原来的备份文件报表缺少了几个数据。然后修改恢复的报表新增几个值,怎样都连接不上。不清楚哪里有问题。求大佬帮忙看看。万分感谢
Function action
'定义变量
Dim sCon
Dim sSql
Dim sSql1
Dim oRs
Dim conn
Dim oCom
Dim Count_Number,Record_Date_time
Dim Payoff_Current_Pad,Payoff_Full_Pad,Payoff_Empty_Pad
Dim Payoff_1_Tension,Payoff_1_Current_Pad,Payoff_1_Full_Pad,Payoff_1_Empty_Pad
Dim Payoff_2_Tension,Payoff_2_Current_Pad,Payoff_2_Full_Pad,Payoff_2_Empty_Pad
Dim Payoff_3_Tension,Payoff_3_Current_Pad,Payoff_3_Full_Pad,Payoff_3_Empty_Pad
Dim Payoff_4_Tension,Payoff_4_Current_Pad,Payoff_4_Full_Pad,Payoff_4_Empty_Pad
Dim Payoff_5_Tension,Payoff_5_Current_Pad,Payoff_5_Full_Pad,Payoff_5_Empty_Pad
Dim Payoff_6_Tension,Payoff_6_Current_Pad,Payoff_6_Full_Pad,Payoff_6_Empty_Pad
Dim Payoff_7_Tension,Payoff_7_Current_Pad,Payoff_7_Full_Pad,Payoff_7_Empty_Pad
Dim Payoff_8_Tension,Payoff_8_Current_Pad,Payoff_8_Full_Pad,Payoff_8_Empty_Pad
Dim Payoff_9_Tension,Payoff_9_Current_Pad,Payoff_9_Full_Pad,Payoff_9_Empty_Pad
Dim Payoff_10_Tension,Payoff_10_Current_Pad,Payoff_10_Full_Pad,Payoff_10_Empty_Pad
Dim Payoff_11_Tension,Payoff_11_Current_Pad,Payoff_11_Full_Pad,Payoff_11_Empty_Pad
Dim Payoff_12_Tension,Payoff_12_Current_Pad,Payoff_12_Full_Pad,Payoff_12_Empty_Pad
Dim Cage_1_RPM,Cage_1_Pitch,Cage_1_ZS,Cage_2_RPM,Cage_2_Pitch,Cage_2_ZS
Dim Whead_1_Pitch,Whead_1_Full_Pad,Whead_1_Empty_Pad,Whead_1_Current_Pad,Whead_1_RPM
Dim Whead_2_Pitch,Whead_2_Full_Pad,Whead_2_Empty_Pad,Whead_2_Current_Pad,Whead_2_RPM
Dim Wire_OD,Capstan_RPM,Take_up_Tension,Take_up_Pitch,Production_Length,Reel_Count,Bad_good'连接变量
Dim data '中间变量
Dim recordtime
Dim Sample_n
Dim objExcelApp
Dim n,i,j
Dim Payoff_13_Tension,Payoff_13_Current_Pad,Payoff_13_Full_Pad,Payoff_13_Empty_Pad
Dim Payoff_14_Tension,Payoff_14_Current_Pad,Payoff_14_Full_Pad,Payoff_14_Empty_Pad
Dim Payoff_15_Tension,Payoff_15_Current_Pad,Payoff_15_Full_Pad,Payoff_15_Empty_Pad
Dim Payoff_16_Tension,Payoff_16_Current_Pad,Payoff_16_Full_Pad,Payoff_16_Empty_Pad
Dim Payoff_17_Tension,Payoff_17_Current_Pad,Payoff_17_Full_Pad,Payoff_17_Empty_Pad
Dim Payoff_18_Tension,Payoff_18_Current_Pad,Payoff_18_Full_Pad,Payoff_18_Empty_Pad
'定义写入到EXCEL的中间变量
Dim Objectfs
Dim Recipe_NO,Order_NO
Dim Filename
Dim a,b,c,Report_Metric,Inch,d,err
'The next is record Report data
'Report_Metric=HMIRuntime.Tags("Report_inch_Metric_select").Read
'Inch=HMIRuntime.Tags("公制英制").Read
a=HMIRuntime.Tags("sample_n").Read
Count_Number=HMIRuntime.tags("Record_data").Read
Bad_good=HMIRuntime.Tags("质检确认信号").Read
'MsgBOX Bad_good
If (Bad_good=1) And (Count_Number=1) Then
HMIRuntime.Tags("Record_start").Write 1
End If
d=HMIRuntime.Tags("Record_start").read
'the next start recording data
If (HMIRuntime.Tags("主机运行辅助").Read =1) And (d=1) Then
Recipe_NO = HMIRuntime.Tags("Recipe_NO").Read
Order_NO = HMIRuntime.Tags("Order_NO").Read
If Order_NO="" Then
HMIRuntime.Tags("No_Order_NO").Write 1
Else
Filename ="E:\DAQ_File\"&Order_NO&"_"&Recipe_NO&".xls"
Sample_n=HMIRuntime.tags("sample_n").read
Record_Date_time=NoW '读取变量 编号 的值,并赋予datad
'HMIRuntime.tags("Record_Date_time").read '读取变量 a2 的值(样本长度值),并赋予a2
Payoff_Current_Pad=HMIRuntime.tags("中心放线张力显示").read '上限
Payoff_Full_Pad=HMIRuntime.tags("中心放线最大张力显示").read '
Payoff_Empty_Pad=HMIRuntime.tags("中心放线最小张力").read
Payoff_1_Tension=HMIRuntime.tags("笼绞1张力显示").read
Payoff_1_Current_Pad=HMIRuntime.tags("笼绞1张力显示#").read
Payoff_1_Full_Pad=HMIRuntime.tags("笼绞1最大张力显示").read
Payoff_1_Empty_Pad=HMIRuntime.tags("笼绞1最小张力").read
Payoff_2_Tension=HMIRuntime.tags("笼绞2张力显示").read
Payoff_2_Current_Pad=HMIRuntime.tags("笼绞2张力显示#").read
Payoff_2_Full_Pad=HMIRuntime.tags("笼绞2最大张力显示").read
Payoff_2_Empty_Pad=HMIRuntime.tags("笼绞2最小张力").read
Payoff_3_Tension=HMIRuntime.tags("笼绞3张力显示").read
Payoff_3_Current_Pad=HMIRuntime.tags("笼绞3张力显示#").read
Payoff_3_Full_Pad=HMIRuntime.tags("笼绞3最大张力显示").read
Payoff_3_Empty_Pad=HMIRuntime.tags("笼绞3最小张力").read
Payoff_4_Tension=HMIRuntime.tags("笼绞4张力显示").read
Payoff_4_Current_Pad=HMIRuntime.tags("笼绞4张力显示#").read
Payoff_4_Full_Pad=HMIRuntime.tags("笼绞4最大张力显示").read
Payoff_4_Empty_Pad=HMIRuntime.tags("笼绞4最小张力").read
Payoff_5_Tension=HMIRuntime.tags("笼绞5张力显示").read
Payoff_5_Current_Pad=HMIRuntime.tags("笼绞5张力显示#").read
Payoff_5_Full_Pad=HMIRuntime.tags("笼绞5最大张力显示").read
Payoff_5_Empty_Pad=HMIRuntime.tags("笼绞5最小张力").read
Payoff_6_Tension=HMIRuntime.tags("笼绞6张力显示").read
Payoff_6_Current_Pad=HMIRuntime.tags("笼绞6张力显示#").read
Payoff_6_Full_Pad=HMIRuntime.tags("笼绞6最大张力显示").read
Payoff_6_Empty_Pad=HMIRuntime.tags("笼绞6最小张力").read
Payoff_7_Tension=HMIRuntime.tags("笼绞7张力显示").read
Payoff_7_Current_Pad=HMIRuntime.tags("笼绞7张力显示#").read
Payoff_7_Full_Pad=HMIRuntime.tags("笼绞7最大张力显示").read
Payoff_7_Empty_Pad=HMIRuntime.tags("笼绞7最小张力").read
Payoff_8_Tension=HMIRuntime.tags("笼绞8张力显示").read
Payoff_8_Current_Pad=HMIRuntime.tags("笼绞8张力显示#").read
Payoff_8_Full_Pad=HMIRuntime.tags("笼绞8最大张力显示").read
Payoff_8_Empty_Pad=HMIRuntime.tags("笼绞8最小张力").read
Payoff_9_Tension=HMIRuntime.tags("笼绞9张力显示").read
Payoff_9_Current_Pad=HMIRuntime.tags("笼绞9张力显示#").read
Payoff_9_Full_Pad=HMIRuntime.tags("笼绞9最大张力显示").read
Payoff_9_Empty_Pad=HMIRuntime.tags("笼绞9最小张力").read
Payoff_10_Tension=HMIRuntime.tags("笼绞10张力显示").read
Payoff_10_Current_Pad=HMIRuntime.tags("笼绞10张力显示#").read
Payoff_10_Full_Pad=HMIRuntime.tags("笼绞10最大张力显示").read
Payoff_10_Empty_Pad=HMIRuntime.tags("笼绞10最小张力").read
Payoff_11_Tension=HMIRuntime.tags("笼绞11张力显示").read
Payoff_11_Current_Pad=HMIRuntime.tags("笼绞11张力显示#").read
Payoff_11_Full_Pad=HMIRuntime.tags("笼绞11最大张力显示").read
Payoff_11_Empty_Pad=HMIRuntime.tags("笼绞11最小张力").read
Payoff_12_Tension=HMIRuntime.tags("笼绞12张力显示").read
Payoff_12_Current_Pad=HMIRuntime.tags("笼绞12张力显示#").read
Payoff_12_Full_Pad=HMIRuntime.tags("笼绞12最大张力显示").read
Payoff_12_Empty_Pad=HMIRuntime.tags("笼绞12最小张力").read
'Whead_1_Pitch=HMIRuntime.tags("Taper_Head_1_pitch_setting").read
Cage_1_RPM=HMIRuntime.tags("6T笼绞转速显示").read
Cage_1_Pitch=HMIRuntime.tags("6T笼绞节距设定").read
Cage_1_ZS=HMIRuntime.tags("6T笼绞正反转").read
Cage_2_RPM=HMIRuntime.tags("18T笼绞转速显示").read
Cage_2_Pitch=HMIRuntime.tags("18T笼绞节距设定").read
Cage_2_ZS=HMIRuntime.tags("18T笼绞正反转").read
Whead_1_Pitch=HMIRuntime.tags("包带1节距设定").read
Whead_1_Empty_Pad=HMIRuntime.tags("包带1最小张力设定").read
Whead_1_Full_Pad=HMIRuntime.tags("包带1最大张力设定").read
Whead_1_Current_Pad=HMIRuntime.tags("包带1张力显示").read
Whead_1_RPM=HMIRuntime.tags("包带1转速显示").read
Whead_2_Pitch=HMIRuntime.tags("包带2节距设定").read
Whead_2_Empty_Pad=HMIRuntime.tags("包带2最小张力设定").read
Whead_2_Full_Pad=HMIRuntime.tags("包带2最大张力设定").read
Whead_2_Current_Pad=HMIRuntime.tags("包带2张力显示").read
Whead_2_RPM=HMIRuntime.tags("包带2转速显示").read
Wire_OD=HMIRuntime.tags("测径实际值").read
Capstan_RPM=HMIRuntime.tags("引取实测速度显示").read
Take_up_Tension=HMIRuntime.tags("收线张力显示").read
Take_up_Pitch=HMIRuntime.tags("收线机排距设定值").read
Production_Length=HMIRuntime.tags("收线计米实际显示值").read
Reel_Count=HMIRuntime.tags("换盘计数器").read
' Bad_good=HMIRuntime.tags("质检确认信号").read
Payoff_13_Tension=HMIRuntime.tags("笼绞13张力显示").read
Payoff_13_Current_Pad=HMIRuntime.tags("笼绞13张力显示#").read
Payoff_13_Full_Pad=HMIRuntime.tags("笼绞13最大张力显示").read
Payoff_13_Empty_Pad=HMIRuntime.tags("笼绞13最小张力").read
Payoff_14_Tension=HMIRuntime.tags("笼绞14张力显示").read
Payoff_14_Current_Pad=HMIRuntime.tags("笼绞14张力显示#").read
Payoff_14_Full_Pad=HMIRuntime.tags("笼绞14最大张力显示").read
Payoff_14_Empty_Pad=HMIRuntime.tags("笼绞14最小张力").read
Payoff_15_Tension=HMIRuntime.tags("笼绞15张力显示").read
Payoff_15_Current_Pad=HMIRuntime.tags("笼绞15张力显示#").read
Payoff_15_Full_Pad=HMIRuntime.tags("笼绞15最大张力显示").read
Payoff_15_Empty_Pad=HMIRuntime.tags("笼绞15最小张力").read
Payoff_16_Tension=HMIRuntime.tags("笼绞16张力显示").read
Payoff_16_Current_Pad=HMIRuntime.tags("笼绞16张力显示#").read
Payoff_16_Full_Pad=HMIRuntime.tags("笼绞16最大张力显示").read
Payoff_16_Empty_Pad=HMIRuntime.tags("笼绞16最小张力").read
Payoff_17_Tension=HMIRuntime.tags("笼绞17张力显示").read
Payoff_17_Current_Pad=HMIRuntime.tags("笼绞17张力显示#").read
Payoff_17_Full_Pad=HMIRuntime.tags("笼绞17最大张力显示").read
Payoff_17_Empty_Pad=HMIRuntime.tags("笼绞17最小张力").read
Payoff_18_Tension=HMIRuntime.tags("笼绞18张力显示").read
Payoff_18_Current_Pad=HMIRuntime.tags("笼绞18张力显示#").read
Payoff_18_Full_Pad=HMIRuntime.tags("笼绞18最大张力显示").read
Payoff_18_Empty_Pad=HMIRuntime.tags("笼绞18最小张力").read
If Payoff_1_Tension =0 Then
Payoff_1_Tension=HMIRuntime.Tags("张力1中间存储").Read
End If
If Payoff_2_Tension =0 Then
Payoff_2_Tension=HMIRuntime.Tags("张力2中间存储").Read
End If
If Payoff_3_Tension =0 Then
Payoff_3_Tension=HMIRuntime.Tags("张力3中间存储").Read
End If
If Payoff_4_Tension =0 Then
Payoff_4_Tension=HMIRuntime.Tags("张力4中间存储").Read
End If
If Payoff_5_Tension =0 Then
Payoff_5_Tension=HMIRuntime.Tags("张力5中间存储").Read
End If
If Payoff_6_Tension =0 Then
Payoff_6_Tension=HMIRuntime.Tags("张力6中间存储").Read
End If
If Payoff_7_Tension =0 Then
Payoff_7_Tension=HMIRuntime.Tags("张力7中间存储").Read
End If
If Payoff_8_Tension =0 Then
Payoff_8_Tension=HMIRuntime.Tags("张力8中间存储").Read
End If
If Payoff_9_Tension =0 Then
Payoff_9_Tension=HMIRuntime.Tags("张力9中间存储").Read
End If
If Payoff_10_Tension =0 Then
Payoff_10_Tension=HMIRuntime.Tags("张力10中间存储").Read
End If
If Payoff_11_Tension =0 Then
Payoff_11_Tension=HMIRuntime.Tags("张力11中间存储").Read
End If
If Payoff_12_Tension =0 Then
Payoff_12_Tension=HMIRuntime.Tags("张力12中间存储").Read
End If
If Payoff_13_Tension =0 Then
Payoff_13_Tension=HMIRuntime.Tags("张力13中间存储").Read
End If
If Payoff_14_Tension =0 Then
Payoff_14_Tension=HMIRuntime.Tags("张力14中间存储").Read
End If
If Payoff_15_Tension =0 Then
Payoff_15_Tension=HMIRuntime.Tags("张力15中间存储").Read
End If
If Payoff_16_Tension =0 Then
Payoff_16_Tension=HMIRuntime.Tags("张力16中间存储").Read
End If
If Payoff_17_Tension =0 Then
Payoff_17_Tension=HMIRuntime.Tags("张力17中间存储").Read
End If
If Payoff_18_Tension =0 Then
Payoff_18_Tension=HMIRuntime.Tags("张力18中间存储").Read
End If
'连接数据库
sCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Data_File;Data Source=.\WINCC"
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
'写数据到Data表
Dim sTrInsert
Dim sTr1,sTr2,sTr3,sTr4,sTr5,sTr6,sTr7,sTr8
Dim sSql2,sSql3,sSql4,sSql5,sSql6,sSq
Dim Table_name
If Bad_good=1 Then
Table_name="Data_detail"
sTr1="INSERT INTO "&Table_name&" VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Whead_1_Current_Pad&"','"&Whead_2_Current_Pad&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr5="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr6="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
'Incorrect syntax near ','.
Set oRs = oCom.Execute
End If
'Incorrect syntax near ','.
If Bad_good=1 Then
'Table_name="DAQ_Data"
sTr1="INSERT INTO DAQ_Data VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Whead_1_Current_Pad&"','"&Whead_2_Current_Pad&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr5="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr6="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
Set oRs = oCom.Execute
If Bad_good=1 Then
'记录数据到Reel_Report表中用来计算CPK及平均值
sTr1="INSERT INTO Reel_Report VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Cage_1_RPM&"','"&Cage_1_Pitch&"','"&Cage_2_RPM&"','"&Cage_2_Pitch&"','"&Whead_1_Current_Pad&"','"&Whead_1_RPM&"',"
sTr5="'"&Whead_1_Pitch&"','"&Whead_2_Current_Pad&"','"&Whead_2_RPM&"','"&Whead_2_Pitch&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr6="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr7="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6+sTr7
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
Set oRs = oCom.Execute
End If
Set oRs = Nothing
conn.Close
Set conn = Nothing
End If
If Count_Number=1 Then
Set objExcelApp = CreateObject("Excel.Application")
Set Objectfs = CreateObject("Scripting.FileSystemObject")
objExcelApp.visible=False
If Objectfs.FileExists(Filename) Then'//文件存在
objExcelApp.Workbooks.Open (Filename)
Else'//文件不存在
objExcelApp.Workbooks.Open "E:\Templet\DAQ_File.xls"
objExcelApp.ActiveWorkbook.saveas (filename)
End If
i=6
Do Until objExcelApp.Cells(i, 1)= ""
i=i+1
Loop
objExcelApp.Cells(i, 1)=Reel_Count
objExcelApp.Cells(i, 2)=Record_Date_time
objExcelApp.Cells(i, 3)=Payoff_Current_Pad
objExcelApp.Cells(i, 4)=Payoff_Full_Pad
objExcelApp.Cells(i, 5)=Payoff_Empty_Pad
objExcelApp.Cells(i, 6)=Payoff_1_Tension
objExcelApp.Cells(i, 7)=HMIRuntime.Tags("Cage_1_Tension_CPK").read
objExcelApp.Cells(i, 8)=Payoff_1_Current_Pad
objExcelApp.Cells(i, 9)=Payoff_1_Full_Pad
objExcelApp.Cells(i, 10)=Payoff_1_Empty_Pad
objExcelApp.Cells(i, 11)=Payoff_2_Tension
objExcelApp.Cells(i, 12)=HMIRuntime.Tags("Cage_2_Tension_CPK").read
objExcelApp.Cells(i, 13)=Payoff_2_Current_Pad
objExcelApp.Cells(i, 14)=Payoff_2_Full_Pad
objExcelApp.Cells(i, 15)=Payoff_2_Empty_Pad
objExcelApp.Cells(i, 16)=Payoff_3_Tension
objExcelApp.Cells(i, 17)=HMIRuntime.Tags("Cage_3_Tension_CPK").read
objExcelApp.Cells(i, 18)=Payoff_3_Current_Pad
objExcelApp.Cells(i, 19)=Payoff_3_Full_Pad
objExcelApp.Cells(i, 20)=Payoff_3_Empty_Pad
objExcelApp.Cells(i, 21)=Payoff_4_Tension
objExcelApp.Cells(i, 22)=HMIRuntime.Tags("Cage_4_Tension_CPK").read
objExcelApp.Cells(i, 23)=Payoff_4_Current_Pad
objExcelApp.Cells(i, 24)=Payoff_4_Full_Pad
objExcelApp.Cells(i, 25)=Payoff_4_Empty_Pad
objExcelApp.Cells(i, 26)=Payoff_5_Tension
objExcelApp.Cells(i, 27)=HMIRuntime.Tags("Cage_5_Tension_CPK").read
objExcelApp.Cells(i, 28)=Payoff_5_Current_Pad
objExcelApp.Cells(i, 29)=Payoff_5_Full_Pad
objExcelApp.Cells(i, 30)=Payoff_5_Empty_Pad
objExcelApp.Cells(i, 31)=Payoff_6_Tension
objExcelApp.Cells(i, 32)=HMIRuntime.Tags("Cage_6_Tension_CPK").read
objExcelApp.Cells(i, 33)=Payoff_6_Current_Pad
objExcelApp.Cells(i, 34)=Payoff_6_Full_Pad
objExcelApp.Cells(i, 35)=Payoff_6_Empty_Pad
objExcelApp.Cells(i, 36)=Payoff_7_Tension
objExcelApp.Cells(i, 37)=HMIRuntime.Tags("Cage_7_Tension_CPK").read
objExcelApp.Cells(i, 38)=Payoff_7_Current_Pad
objExcelApp.Cells(i, 39)=Payoff_7_Full_Pad
objExcelApp.Cells(i, 40)=Payoff_7_Empty_Pad
objExcelApp.Cells(i, 41)=Payoff_8_Tension
objExcelApp.Cells(i, 42)=HMIRuntime.Tags("Cage_8_Tension_CPK").read
objExcelApp.Cells(i, 43)=Payoff_8_Current_Pad
objExcelApp.Cells(i, 44)=Payoff_8_Full_Pad
objExcelApp.Cells(i, 45)=Payoff_8_Empty_Pad
objExcelApp.Cells(i, 46)=Payoff_9_Tension
objExcelApp.Cells(i, 47)=HMIRuntime.Tags("Cage_9_Tension_CPK").read
objExcelApp.Cells(i, 48)=Payoff_9_Current_Pad
objExcelApp.Cells(i, 49)=Payoff_9_Full_Pad
objExcelApp.Cells(i, 50)=Payoff_9_Empty_Pad
objExcelApp.Cells(i, 51)=Payoff_10_Tension
objExcelApp.Cells(i, 52)=HMIRuntime.Tags("Cage_10_Tension_CPK").read
objExcelApp.Cells(i, 53)=Payoff_10_Current_Pad
objExcelApp.Cells(i, 54)=Payoff_10_Full_Pad
objExcelApp.Cells(i, 55)=Payoff_10_Empty_Pad
objExcelApp.Cells(i, 56)=Payoff_11_Tension
objExcelApp.Cells(i, 57)=HMIRuntime.Tags("Cage_11_Tension_CPK").read
objExcelApp.Cells(i, 58)=Payoff_11_Current_Pad
objExcelApp.Cells(i, 59)=Payoff_11_Full_Pad
objExcelApp.Cells(i, 60)=Payoff_11_Empty_Pad
objExcelApp.Cells(i, 61)=Payoff_12_Tension
objExcelApp.Cells(i, 62)=HMIRuntime.Tags("Cage_12_Tension_CPK").read
objExcelApp.Cells(i, 63)=Payoff_12_Current_Pad
objExcelApp.Cells(i, 64)=Payoff_12_Full_Pad
objExcelApp.Cells(i, 65)=Payoff_12_Empty_Pad
objExcelApp.Cells(i, 66)=Cage_1_RPM
objExcelApp.Cells(i, 67)=Cage_1_Pitch
objExcelApp.Cells(i, 68)=Cage_1_ZS
objExcelApp.Cells(i, 69)=Cage_2_RPM
objExcelApp.Cells(i, 70)=Cage_2_Pitch
objExcelApp.Cells(i, 71)=Cage_2_ZS
objExcelApp.Cells(i, 72)=Whead_1_RPM
objExcelApp.Cells(i, 73)=Whead_1_Pitch
objExcelApp.Cells(i, 74)=Whead_1_Empty_Pad
objExcelApp.Cells(i, 75)=Whead_1_Full_Pad
objExcelApp.Cells(i, 76)=Whead_1_Current_Pad
objExcelApp.Cells(i, 77)=Whead_2_RPM
objExcelApp.Cells(i, 78)=Whead_2_Pitch
objExcelApp.Cells(i, 79)=Whead_2_Empty_Pad
objExcelApp.Cells(i, 80)=Whead_2_Full_Pad
objExcelApp.Cells(i, 81)=Whead_2_Current_Pad
objExcelApp.Cells(i, 82)=Wire_OD
objExcelApp.Cells(i, 83)=HMIRuntime.Tags("Wire_OD_CPK").read
objExcelApp.Cells(i, 84)=Capstan_RPM
objExcelApp.Cells(i, 85)=Take_up_Tension
objExcelApp.Cells(i, 86)=HMIRuntime.Tags("Take_Up_Tension_CPK").read
objExcelApp.Cells(i, 87)=Take_up_Pitch
objExcelApp.Cells(i, 88)=Production_Length
objExcelApp.Cells(i, 89)=Bad_good
objExcelApp.Cells(i, 90)=Payoff_13_Tension
objExcelApp.Cells(i, 91)=HMIRuntime.Tags("Cage_13_Tension_CPK").read
objExcelApp.Cells(i, 92)=Payoff_13_Current_Pad
objExcelApp.Cells(i, 93)=Payoff_13_Full_Pad
objExcelApp.Cells(i, 94)=Payoff_13_Empty_Pad
objExcelApp.Cells(i, 95)=Payoff_14_Tension
objExcelApp.Cells(i, 96)=HMIRuntime.Tags("Cage_14_Tension_CPK").read
objExcelApp.Cells(i, 97)=Payoff_14_Current_Pad
objExcelApp.Cells(i, 98)=Payoff_14_Full_Pad
objExcelApp.Cells(i, 99)=Payoff_14_Empty_Pad
objExcelApp.Cells(i, 100)=Payoff_15_Tension
objExcelApp.Cells(i, 101)=HMIRuntime.Tags("Cage_15_Tension_CPK").read
objExcelApp.Cells(i, 102)=Payoff_15_Current_Pad
objExcelApp.Cells(i, 103)=Payoff_15_Full_Pad
objExcelApp.Cells(i, 104)=Payoff_15_Empty_Pad
objExcelApp.Cells(i, 105)=Payoff_16_Tension
objExcelApp.Cells(i, 106)=HMIRuntime.Tags("Cage_16_Tension_CPK").read
objExcelApp.Cells(i, 107)=Payoff_16_Current_Pad
objExcelApp.Cells(i, 108)=Payoff_16_Full_Pad
objExcelApp.Cells(i, 109)=Payoff_16_Empty_Pad
objExcelApp.Cells(i, 110)=Payoff_17_Tension
objExcelApp.Cells(i, 111)=HMIRuntime.Tags("Cage_17_Tension_CPK").read
objExcelApp.Cells(i, 112)=Payoff_17_Current_Pad
objExcelApp.Cells(i, 113)=Payoff_17_Full_Pad
objExcelApp.Cells(i, 114)=Payoff_17_Empty_Pad
objExcelApp.Cells(i, 115)=Payoff_18_Tension
objExcelApp.Cells(i, 116)=HMIRuntime.Tags("Cage_18_Tension_CPK").read
objExcelApp.Cells(i, 117)=Payoff_18_Current_Pad
objExcelApp.Cells(i, 118)=Payoff_18_Full_Pad
objExcelApp.Cells(i, 119)=Payoff_18_Empty_Pad
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
End If'n=1
End If 'filename不等于空
End If '记录
If HMIRuntime.tags("trend_record1").read=1 Then
HMIRuntime.tags("trend_record1").Write 0
Else
HMIRuntime.tags("trend_record1").Write 1
End If
' Msgbox "hhb"
2021年03月07日 06点03分
1
Function action
'定义变量
Dim sCon
Dim sSql
Dim sSql1
Dim oRs
Dim conn
Dim oCom
Dim Count_Number,Record_Date_time
Dim Payoff_Current_Pad,Payoff_Full_Pad,Payoff_Empty_Pad
Dim Payoff_1_Tension,Payoff_1_Current_Pad,Payoff_1_Full_Pad,Payoff_1_Empty_Pad
Dim Payoff_2_Tension,Payoff_2_Current_Pad,Payoff_2_Full_Pad,Payoff_2_Empty_Pad
Dim Payoff_3_Tension,Payoff_3_Current_Pad,Payoff_3_Full_Pad,Payoff_3_Empty_Pad
Dim Payoff_4_Tension,Payoff_4_Current_Pad,Payoff_4_Full_Pad,Payoff_4_Empty_Pad
Dim Payoff_5_Tension,Payoff_5_Current_Pad,Payoff_5_Full_Pad,Payoff_5_Empty_Pad
Dim Payoff_6_Tension,Payoff_6_Current_Pad,Payoff_6_Full_Pad,Payoff_6_Empty_Pad
Dim Payoff_7_Tension,Payoff_7_Current_Pad,Payoff_7_Full_Pad,Payoff_7_Empty_Pad
Dim Payoff_8_Tension,Payoff_8_Current_Pad,Payoff_8_Full_Pad,Payoff_8_Empty_Pad
Dim Payoff_9_Tension,Payoff_9_Current_Pad,Payoff_9_Full_Pad,Payoff_9_Empty_Pad
Dim Payoff_10_Tension,Payoff_10_Current_Pad,Payoff_10_Full_Pad,Payoff_10_Empty_Pad
Dim Payoff_11_Tension,Payoff_11_Current_Pad,Payoff_11_Full_Pad,Payoff_11_Empty_Pad
Dim Payoff_12_Tension,Payoff_12_Current_Pad,Payoff_12_Full_Pad,Payoff_12_Empty_Pad
Dim Cage_1_RPM,Cage_1_Pitch,Cage_1_ZS,Cage_2_RPM,Cage_2_Pitch,Cage_2_ZS
Dim Whead_1_Pitch,Whead_1_Full_Pad,Whead_1_Empty_Pad,Whead_1_Current_Pad,Whead_1_RPM
Dim Whead_2_Pitch,Whead_2_Full_Pad,Whead_2_Empty_Pad,Whead_2_Current_Pad,Whead_2_RPM
Dim Wire_OD,Capstan_RPM,Take_up_Tension,Take_up_Pitch,Production_Length,Reel_Count,Bad_good'连接变量
Dim data '中间变量
Dim recordtime
Dim Sample_n
Dim objExcelApp
Dim n,i,j
Dim Payoff_13_Tension,Payoff_13_Current_Pad,Payoff_13_Full_Pad,Payoff_13_Empty_Pad
Dim Payoff_14_Tension,Payoff_14_Current_Pad,Payoff_14_Full_Pad,Payoff_14_Empty_Pad
Dim Payoff_15_Tension,Payoff_15_Current_Pad,Payoff_15_Full_Pad,Payoff_15_Empty_Pad
Dim Payoff_16_Tension,Payoff_16_Current_Pad,Payoff_16_Full_Pad,Payoff_16_Empty_Pad
Dim Payoff_17_Tension,Payoff_17_Current_Pad,Payoff_17_Full_Pad,Payoff_17_Empty_Pad
Dim Payoff_18_Tension,Payoff_18_Current_Pad,Payoff_18_Full_Pad,Payoff_18_Empty_Pad
'定义写入到EXCEL的中间变量
Dim Objectfs
Dim Recipe_NO,Order_NO
Dim Filename
Dim a,b,c,Report_Metric,Inch,d,err
'The next is record Report data
'Report_Metric=HMIRuntime.Tags("Report_inch_Metric_select").Read
'Inch=HMIRuntime.Tags("公制英制").Read
a=HMIRuntime.Tags("sample_n").Read
Count_Number=HMIRuntime.tags("Record_data").Read
Bad_good=HMIRuntime.Tags("质检确认信号").Read
'MsgBOX Bad_good
If (Bad_good=1) And (Count_Number=1) Then
HMIRuntime.Tags("Record_start").Write 1
End If
d=HMIRuntime.Tags("Record_start").read
'the next start recording data
If (HMIRuntime.Tags("主机运行辅助").Read =1) And (d=1) Then
Recipe_NO = HMIRuntime.Tags("Recipe_NO").Read
Order_NO = HMIRuntime.Tags("Order_NO").Read
If Order_NO="" Then
HMIRuntime.Tags("No_Order_NO").Write 1
Else
Filename ="E:\DAQ_File\"&Order_NO&"_"&Recipe_NO&".xls"
Sample_n=HMIRuntime.tags("sample_n").read
Record_Date_time=NoW '读取变量 编号 的值,并赋予datad
'HMIRuntime.tags("Record_Date_time").read '读取变量 a2 的值(样本长度值),并赋予a2
Payoff_Current_Pad=HMIRuntime.tags("中心放线张力显示").read '上限
Payoff_Full_Pad=HMIRuntime.tags("中心放线最大张力显示").read '
Payoff_Empty_Pad=HMIRuntime.tags("中心放线最小张力").read
Payoff_1_Tension=HMIRuntime.tags("笼绞1张力显示").read
Payoff_1_Current_Pad=HMIRuntime.tags("笼绞1张力显示#").read
Payoff_1_Full_Pad=HMIRuntime.tags("笼绞1最大张力显示").read
Payoff_1_Empty_Pad=HMIRuntime.tags("笼绞1最小张力").read
Payoff_2_Tension=HMIRuntime.tags("笼绞2张力显示").read
Payoff_2_Current_Pad=HMIRuntime.tags("笼绞2张力显示#").read
Payoff_2_Full_Pad=HMIRuntime.tags("笼绞2最大张力显示").read
Payoff_2_Empty_Pad=HMIRuntime.tags("笼绞2最小张力").read
Payoff_3_Tension=HMIRuntime.tags("笼绞3张力显示").read
Payoff_3_Current_Pad=HMIRuntime.tags("笼绞3张力显示#").read
Payoff_3_Full_Pad=HMIRuntime.tags("笼绞3最大张力显示").read
Payoff_3_Empty_Pad=HMIRuntime.tags("笼绞3最小张力").read
Payoff_4_Tension=HMIRuntime.tags("笼绞4张力显示").read
Payoff_4_Current_Pad=HMIRuntime.tags("笼绞4张力显示#").read
Payoff_4_Full_Pad=HMIRuntime.tags("笼绞4最大张力显示").read
Payoff_4_Empty_Pad=HMIRuntime.tags("笼绞4最小张力").read
Payoff_5_Tension=HMIRuntime.tags("笼绞5张力显示").read
Payoff_5_Current_Pad=HMIRuntime.tags("笼绞5张力显示#").read
Payoff_5_Full_Pad=HMIRuntime.tags("笼绞5最大张力显示").read
Payoff_5_Empty_Pad=HMIRuntime.tags("笼绞5最小张力").read
Payoff_6_Tension=HMIRuntime.tags("笼绞6张力显示").read
Payoff_6_Current_Pad=HMIRuntime.tags("笼绞6张力显示#").read
Payoff_6_Full_Pad=HMIRuntime.tags("笼绞6最大张力显示").read
Payoff_6_Empty_Pad=HMIRuntime.tags("笼绞6最小张力").read
Payoff_7_Tension=HMIRuntime.tags("笼绞7张力显示").read
Payoff_7_Current_Pad=HMIRuntime.tags("笼绞7张力显示#").read
Payoff_7_Full_Pad=HMIRuntime.tags("笼绞7最大张力显示").read
Payoff_7_Empty_Pad=HMIRuntime.tags("笼绞7最小张力").read
Payoff_8_Tension=HMIRuntime.tags("笼绞8张力显示").read
Payoff_8_Current_Pad=HMIRuntime.tags("笼绞8张力显示#").read
Payoff_8_Full_Pad=HMIRuntime.tags("笼绞8最大张力显示").read
Payoff_8_Empty_Pad=HMIRuntime.tags("笼绞8最小张力").read
Payoff_9_Tension=HMIRuntime.tags("笼绞9张力显示").read
Payoff_9_Current_Pad=HMIRuntime.tags("笼绞9张力显示#").read
Payoff_9_Full_Pad=HMIRuntime.tags("笼绞9最大张力显示").read
Payoff_9_Empty_Pad=HMIRuntime.tags("笼绞9最小张力").read
Payoff_10_Tension=HMIRuntime.tags("笼绞10张力显示").read
Payoff_10_Current_Pad=HMIRuntime.tags("笼绞10张力显示#").read
Payoff_10_Full_Pad=HMIRuntime.tags("笼绞10最大张力显示").read
Payoff_10_Empty_Pad=HMIRuntime.tags("笼绞10最小张力").read
Payoff_11_Tension=HMIRuntime.tags("笼绞11张力显示").read
Payoff_11_Current_Pad=HMIRuntime.tags("笼绞11张力显示#").read
Payoff_11_Full_Pad=HMIRuntime.tags("笼绞11最大张力显示").read
Payoff_11_Empty_Pad=HMIRuntime.tags("笼绞11最小张力").read
Payoff_12_Tension=HMIRuntime.tags("笼绞12张力显示").read
Payoff_12_Current_Pad=HMIRuntime.tags("笼绞12张力显示#").read
Payoff_12_Full_Pad=HMIRuntime.tags("笼绞12最大张力显示").read
Payoff_12_Empty_Pad=HMIRuntime.tags("笼绞12最小张力").read
'Whead_1_Pitch=HMIRuntime.tags("Taper_Head_1_pitch_setting").read
Cage_1_RPM=HMIRuntime.tags("6T笼绞转速显示").read
Cage_1_Pitch=HMIRuntime.tags("6T笼绞节距设定").read
Cage_1_ZS=HMIRuntime.tags("6T笼绞正反转").read
Cage_2_RPM=HMIRuntime.tags("18T笼绞转速显示").read
Cage_2_Pitch=HMIRuntime.tags("18T笼绞节距设定").read
Cage_2_ZS=HMIRuntime.tags("18T笼绞正反转").read
Whead_1_Pitch=HMIRuntime.tags("包带1节距设定").read
Whead_1_Empty_Pad=HMIRuntime.tags("包带1最小张力设定").read
Whead_1_Full_Pad=HMIRuntime.tags("包带1最大张力设定").read
Whead_1_Current_Pad=HMIRuntime.tags("包带1张力显示").read
Whead_1_RPM=HMIRuntime.tags("包带1转速显示").read
Whead_2_Pitch=HMIRuntime.tags("包带2节距设定").read
Whead_2_Empty_Pad=HMIRuntime.tags("包带2最小张力设定").read
Whead_2_Full_Pad=HMIRuntime.tags("包带2最大张力设定").read
Whead_2_Current_Pad=HMIRuntime.tags("包带2张力显示").read
Whead_2_RPM=HMIRuntime.tags("包带2转速显示").read
Wire_OD=HMIRuntime.tags("测径实际值").read
Capstan_RPM=HMIRuntime.tags("引取实测速度显示").read
Take_up_Tension=HMIRuntime.tags("收线张力显示").read
Take_up_Pitch=HMIRuntime.tags("收线机排距设定值").read
Production_Length=HMIRuntime.tags("收线计米实际显示值").read
Reel_Count=HMIRuntime.tags("换盘计数器").read
' Bad_good=HMIRuntime.tags("质检确认信号").read
Payoff_13_Tension=HMIRuntime.tags("笼绞13张力显示").read
Payoff_13_Current_Pad=HMIRuntime.tags("笼绞13张力显示#").read
Payoff_13_Full_Pad=HMIRuntime.tags("笼绞13最大张力显示").read
Payoff_13_Empty_Pad=HMIRuntime.tags("笼绞13最小张力").read
Payoff_14_Tension=HMIRuntime.tags("笼绞14张力显示").read
Payoff_14_Current_Pad=HMIRuntime.tags("笼绞14张力显示#").read
Payoff_14_Full_Pad=HMIRuntime.tags("笼绞14最大张力显示").read
Payoff_14_Empty_Pad=HMIRuntime.tags("笼绞14最小张力").read
Payoff_15_Tension=HMIRuntime.tags("笼绞15张力显示").read
Payoff_15_Current_Pad=HMIRuntime.tags("笼绞15张力显示#").read
Payoff_15_Full_Pad=HMIRuntime.tags("笼绞15最大张力显示").read
Payoff_15_Empty_Pad=HMIRuntime.tags("笼绞15最小张力").read
Payoff_16_Tension=HMIRuntime.tags("笼绞16张力显示").read
Payoff_16_Current_Pad=HMIRuntime.tags("笼绞16张力显示#").read
Payoff_16_Full_Pad=HMIRuntime.tags("笼绞16最大张力显示").read
Payoff_16_Empty_Pad=HMIRuntime.tags("笼绞16最小张力").read
Payoff_17_Tension=HMIRuntime.tags("笼绞17张力显示").read
Payoff_17_Current_Pad=HMIRuntime.tags("笼绞17张力显示#").read
Payoff_17_Full_Pad=HMIRuntime.tags("笼绞17最大张力显示").read
Payoff_17_Empty_Pad=HMIRuntime.tags("笼绞17最小张力").read
Payoff_18_Tension=HMIRuntime.tags("笼绞18张力显示").read
Payoff_18_Current_Pad=HMIRuntime.tags("笼绞18张力显示#").read
Payoff_18_Full_Pad=HMIRuntime.tags("笼绞18最大张力显示").read
Payoff_18_Empty_Pad=HMIRuntime.tags("笼绞18最小张力").read
If Payoff_1_Tension =0 Then
Payoff_1_Tension=HMIRuntime.Tags("张力1中间存储").Read
End If
If Payoff_2_Tension =0 Then
Payoff_2_Tension=HMIRuntime.Tags("张力2中间存储").Read
End If
If Payoff_3_Tension =0 Then
Payoff_3_Tension=HMIRuntime.Tags("张力3中间存储").Read
End If
If Payoff_4_Tension =0 Then
Payoff_4_Tension=HMIRuntime.Tags("张力4中间存储").Read
End If
If Payoff_5_Tension =0 Then
Payoff_5_Tension=HMIRuntime.Tags("张力5中间存储").Read
End If
If Payoff_6_Tension =0 Then
Payoff_6_Tension=HMIRuntime.Tags("张力6中间存储").Read
End If
If Payoff_7_Tension =0 Then
Payoff_7_Tension=HMIRuntime.Tags("张力7中间存储").Read
End If
If Payoff_8_Tension =0 Then
Payoff_8_Tension=HMIRuntime.Tags("张力8中间存储").Read
End If
If Payoff_9_Tension =0 Then
Payoff_9_Tension=HMIRuntime.Tags("张力9中间存储").Read
End If
If Payoff_10_Tension =0 Then
Payoff_10_Tension=HMIRuntime.Tags("张力10中间存储").Read
End If
If Payoff_11_Tension =0 Then
Payoff_11_Tension=HMIRuntime.Tags("张力11中间存储").Read
End If
If Payoff_12_Tension =0 Then
Payoff_12_Tension=HMIRuntime.Tags("张力12中间存储").Read
End If
If Payoff_13_Tension =0 Then
Payoff_13_Tension=HMIRuntime.Tags("张力13中间存储").Read
End If
If Payoff_14_Tension =0 Then
Payoff_14_Tension=HMIRuntime.Tags("张力14中间存储").Read
End If
If Payoff_15_Tension =0 Then
Payoff_15_Tension=HMIRuntime.Tags("张力15中间存储").Read
End If
If Payoff_16_Tension =0 Then
Payoff_16_Tension=HMIRuntime.Tags("张力16中间存储").Read
End If
If Payoff_17_Tension =0 Then
Payoff_17_Tension=HMIRuntime.Tags("张力17中间存储").Read
End If
If Payoff_18_Tension =0 Then
Payoff_18_Tension=HMIRuntime.Tags("张力18中间存储").Read
End If
'连接数据库
sCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Data_File;Data Source=.\WINCC"
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
'写数据到Data表
Dim sTrInsert
Dim sTr1,sTr2,sTr3,sTr4,sTr5,sTr6,sTr7,sTr8
Dim sSql2,sSql3,sSql4,sSql5,sSql6,sSq
Dim Table_name
If Bad_good=1 Then
Table_name="Data_detail"
sTr1="INSERT INTO "&Table_name&" VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Whead_1_Current_Pad&"','"&Whead_2_Current_Pad&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr5="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr6="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
'Incorrect syntax near ','.
Set oRs = oCom.Execute
End If
'Incorrect syntax near ','.
If Bad_good=1 Then
'Table_name="DAQ_Data"
sTr1="INSERT INTO DAQ_Data VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Whead_1_Current_Pad&"','"&Whead_2_Current_Pad&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr5="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr6="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
Set oRs = oCom.Execute
If Bad_good=1 Then
'记录数据到Reel_Report表中用来计算CPK及平均值
sTr1="INSERT INTO Reel_Report VALUES('"&Record_Date_time&"','"&Order_NO&"','"&Payoff_Current_Pad&"','"&Payoff_1_Tension&"','"&Payoff_2_Tension&"','"&Payoff_3_Tension&"','"&Payoff_4_Tension&"','"&Payoff_5_Tension&"',"
sTr2="'"&Payoff_6_Tension&"','"&Payoff_7_Tension&"','"&Payoff_8_Tension&"',"
sTr3="'"&Payoff_9_Tension&"','"&Payoff_10_Tension&"','"&Payoff_11_Tension&"','"&Payoff_12_Tension&"',"
sTr4="'"&Cage_1_RPM&"','"&Cage_1_Pitch&"','"&Cage_2_RPM&"','"&Cage_2_Pitch&"','"&Whead_1_Current_Pad&"','"&Whead_1_RPM&"',"
sTr5="'"&Whead_1_Pitch&"','"&Whead_2_Current_Pad&"','"&Whead_2_RPM&"','"&Whead_2_Pitch&"','"&Wire_OD&"','"&Take_up_Tension&"','"&Production_Length&"','"&Reel_Count&"','"&Bad_good&"')"
sTr6="'"&Payoff_13_Tension&"','"&Payoff_14_Tension&"','"&Payoff_15_Tension&"','"&Payoff_16_Tension&"',"
sTr7="'"&Payoff_17_Tension&"','"&Payoff_18_Tension&"',"
sTrInsert=sTr1+sTr2+sTr3+sTr4+sTr5+sTr6+sTr7
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
Set oCom.ActiveConnection = conn
oCom.CommandType = 1
oCom.CommandText = sTrInsert
Set oRs = oCom.Execute
End If
Set oRs = Nothing
conn.Close
Set conn = Nothing
End If
If Count_Number=1 Then
Set objExcelApp = CreateObject("Excel.Application")
Set Objectfs = CreateObject("Scripting.FileSystemObject")
objExcelApp.visible=False
If Objectfs.FileExists(Filename) Then'//文件存在
objExcelApp.Workbooks.Open (Filename)
Else'//文件不存在
objExcelApp.Workbooks.Open "E:\Templet\DAQ_File.xls"
objExcelApp.ActiveWorkbook.saveas (filename)
End If
i=6
Do Until objExcelApp.Cells(i, 1)= ""
i=i+1
Loop
objExcelApp.Cells(i, 1)=Reel_Count
objExcelApp.Cells(i, 2)=Record_Date_time
objExcelApp.Cells(i, 3)=Payoff_Current_Pad
objExcelApp.Cells(i, 4)=Payoff_Full_Pad
objExcelApp.Cells(i, 5)=Payoff_Empty_Pad
objExcelApp.Cells(i, 6)=Payoff_1_Tension
objExcelApp.Cells(i, 7)=HMIRuntime.Tags("Cage_1_Tension_CPK").read
objExcelApp.Cells(i, 8)=Payoff_1_Current_Pad
objExcelApp.Cells(i, 9)=Payoff_1_Full_Pad
objExcelApp.Cells(i, 10)=Payoff_1_Empty_Pad
objExcelApp.Cells(i, 11)=Payoff_2_Tension
objExcelApp.Cells(i, 12)=HMIRuntime.Tags("Cage_2_Tension_CPK").read
objExcelApp.Cells(i, 13)=Payoff_2_Current_Pad
objExcelApp.Cells(i, 14)=Payoff_2_Full_Pad
objExcelApp.Cells(i, 15)=Payoff_2_Empty_Pad
objExcelApp.Cells(i, 16)=Payoff_3_Tension
objExcelApp.Cells(i, 17)=HMIRuntime.Tags("Cage_3_Tension_CPK").read
objExcelApp.Cells(i, 18)=Payoff_3_Current_Pad
objExcelApp.Cells(i, 19)=Payoff_3_Full_Pad
objExcelApp.Cells(i, 20)=Payoff_3_Empty_Pad
objExcelApp.Cells(i, 21)=Payoff_4_Tension
objExcelApp.Cells(i, 22)=HMIRuntime.Tags("Cage_4_Tension_CPK").read
objExcelApp.Cells(i, 23)=Payoff_4_Current_Pad
objExcelApp.Cells(i, 24)=Payoff_4_Full_Pad
objExcelApp.Cells(i, 25)=Payoff_4_Empty_Pad
objExcelApp.Cells(i, 26)=Payoff_5_Tension
objExcelApp.Cells(i, 27)=HMIRuntime.Tags("Cage_5_Tension_CPK").read
objExcelApp.Cells(i, 28)=Payoff_5_Current_Pad
objExcelApp.Cells(i, 29)=Payoff_5_Full_Pad
objExcelApp.Cells(i, 30)=Payoff_5_Empty_Pad
objExcelApp.Cells(i, 31)=Payoff_6_Tension
objExcelApp.Cells(i, 32)=HMIRuntime.Tags("Cage_6_Tension_CPK").read
objExcelApp.Cells(i, 33)=Payoff_6_Current_Pad
objExcelApp.Cells(i, 34)=Payoff_6_Full_Pad
objExcelApp.Cells(i, 35)=Payoff_6_Empty_Pad
objExcelApp.Cells(i, 36)=Payoff_7_Tension
objExcelApp.Cells(i, 37)=HMIRuntime.Tags("Cage_7_Tension_CPK").read
objExcelApp.Cells(i, 38)=Payoff_7_Current_Pad
objExcelApp.Cells(i, 39)=Payoff_7_Full_Pad
objExcelApp.Cells(i, 40)=Payoff_7_Empty_Pad
objExcelApp.Cells(i, 41)=Payoff_8_Tension
objExcelApp.Cells(i, 42)=HMIRuntime.Tags("Cage_8_Tension_CPK").read
objExcelApp.Cells(i, 43)=Payoff_8_Current_Pad
objExcelApp.Cells(i, 44)=Payoff_8_Full_Pad
objExcelApp.Cells(i, 45)=Payoff_8_Empty_Pad
objExcelApp.Cells(i, 46)=Payoff_9_Tension
objExcelApp.Cells(i, 47)=HMIRuntime.Tags("Cage_9_Tension_CPK").read
objExcelApp.Cells(i, 48)=Payoff_9_Current_Pad
objExcelApp.Cells(i, 49)=Payoff_9_Full_Pad
objExcelApp.Cells(i, 50)=Payoff_9_Empty_Pad
objExcelApp.Cells(i, 51)=Payoff_10_Tension
objExcelApp.Cells(i, 52)=HMIRuntime.Tags("Cage_10_Tension_CPK").read
objExcelApp.Cells(i, 53)=Payoff_10_Current_Pad
objExcelApp.Cells(i, 54)=Payoff_10_Full_Pad
objExcelApp.Cells(i, 55)=Payoff_10_Empty_Pad
objExcelApp.Cells(i, 56)=Payoff_11_Tension
objExcelApp.Cells(i, 57)=HMIRuntime.Tags("Cage_11_Tension_CPK").read
objExcelApp.Cells(i, 58)=Payoff_11_Current_Pad
objExcelApp.Cells(i, 59)=Payoff_11_Full_Pad
objExcelApp.Cells(i, 60)=Payoff_11_Empty_Pad
objExcelApp.Cells(i, 61)=Payoff_12_Tension
objExcelApp.Cells(i, 62)=HMIRuntime.Tags("Cage_12_Tension_CPK").read
objExcelApp.Cells(i, 63)=Payoff_12_Current_Pad
objExcelApp.Cells(i, 64)=Payoff_12_Full_Pad
objExcelApp.Cells(i, 65)=Payoff_12_Empty_Pad
objExcelApp.Cells(i, 66)=Cage_1_RPM
objExcelApp.Cells(i, 67)=Cage_1_Pitch
objExcelApp.Cells(i, 68)=Cage_1_ZS
objExcelApp.Cells(i, 69)=Cage_2_RPM
objExcelApp.Cells(i, 70)=Cage_2_Pitch
objExcelApp.Cells(i, 71)=Cage_2_ZS
objExcelApp.Cells(i, 72)=Whead_1_RPM
objExcelApp.Cells(i, 73)=Whead_1_Pitch
objExcelApp.Cells(i, 74)=Whead_1_Empty_Pad
objExcelApp.Cells(i, 75)=Whead_1_Full_Pad
objExcelApp.Cells(i, 76)=Whead_1_Current_Pad
objExcelApp.Cells(i, 77)=Whead_2_RPM
objExcelApp.Cells(i, 78)=Whead_2_Pitch
objExcelApp.Cells(i, 79)=Whead_2_Empty_Pad
objExcelApp.Cells(i, 80)=Whead_2_Full_Pad
objExcelApp.Cells(i, 81)=Whead_2_Current_Pad
objExcelApp.Cells(i, 82)=Wire_OD
objExcelApp.Cells(i, 83)=HMIRuntime.Tags("Wire_OD_CPK").read
objExcelApp.Cells(i, 84)=Capstan_RPM
objExcelApp.Cells(i, 85)=Take_up_Tension
objExcelApp.Cells(i, 86)=HMIRuntime.Tags("Take_Up_Tension_CPK").read
objExcelApp.Cells(i, 87)=Take_up_Pitch
objExcelApp.Cells(i, 88)=Production_Length
objExcelApp.Cells(i, 89)=Bad_good
objExcelApp.Cells(i, 90)=Payoff_13_Tension
objExcelApp.Cells(i, 91)=HMIRuntime.Tags("Cage_13_Tension_CPK").read
objExcelApp.Cells(i, 92)=Payoff_13_Current_Pad
objExcelApp.Cells(i, 93)=Payoff_13_Full_Pad
objExcelApp.Cells(i, 94)=Payoff_13_Empty_Pad
objExcelApp.Cells(i, 95)=Payoff_14_Tension
objExcelApp.Cells(i, 96)=HMIRuntime.Tags("Cage_14_Tension_CPK").read
objExcelApp.Cells(i, 97)=Payoff_14_Current_Pad
objExcelApp.Cells(i, 98)=Payoff_14_Full_Pad
objExcelApp.Cells(i, 99)=Payoff_14_Empty_Pad
objExcelApp.Cells(i, 100)=Payoff_15_Tension
objExcelApp.Cells(i, 101)=HMIRuntime.Tags("Cage_15_Tension_CPK").read
objExcelApp.Cells(i, 102)=Payoff_15_Current_Pad
objExcelApp.Cells(i, 103)=Payoff_15_Full_Pad
objExcelApp.Cells(i, 104)=Payoff_15_Empty_Pad
objExcelApp.Cells(i, 105)=Payoff_16_Tension
objExcelApp.Cells(i, 106)=HMIRuntime.Tags("Cage_16_Tension_CPK").read
objExcelApp.Cells(i, 107)=Payoff_16_Current_Pad
objExcelApp.Cells(i, 108)=Payoff_16_Full_Pad
objExcelApp.Cells(i, 109)=Payoff_16_Empty_Pad
objExcelApp.Cells(i, 110)=Payoff_17_Tension
objExcelApp.Cells(i, 111)=HMIRuntime.Tags("Cage_17_Tension_CPK").read
objExcelApp.Cells(i, 112)=Payoff_17_Current_Pad
objExcelApp.Cells(i, 113)=Payoff_17_Full_Pad
objExcelApp.Cells(i, 114)=Payoff_17_Empty_Pad
objExcelApp.Cells(i, 115)=Payoff_18_Tension
objExcelApp.Cells(i, 116)=HMIRuntime.Tags("Cage_18_Tension_CPK").read
objExcelApp.Cells(i, 117)=Payoff_18_Current_Pad
objExcelApp.Cells(i, 118)=Payoff_18_Full_Pad
objExcelApp.Cells(i, 119)=Payoff_18_Empty_Pad
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
End If'n=1
End If 'filename不等于空
End If '记录
If HMIRuntime.tags("trend_record1").read=1 Then
HMIRuntime.tags("trend_record1").Write 0
Else
HMIRuntime.tags("trend_record1").Write 1
End If
' Msgbox "hhb"