'---------------采集--------------------------------
Dim dt As Date = Functions.Execute("服务器时间") '"服务器时间"是自定义函数
Dim Str00 As String
Dim cs As String = e.Form.Controls("NumericComboBox1").Value '流水号
'Dim rt As Row = Tables(DateSt0).Current '-----------------------------------
Dim rt As Row
If Forms("业务管理窗口").Opened Then
rt = Tables(DateSt0).Current '-----------------------------------
Str00 = rt("报告编号")
If User.IsRole("所长")Or User.Name = "开发者" Or User.Type = UserTypeEnum.Developer Or User.Name = rt("检验部门负责人") Or User.Name = rt("检验主检") Or User.Name = rt("检验辅检") Then
Else
MessageBox.Show("你不是本项目检验人员,不能采集")
Return
End If
Else
Str00 = "test"
End If
If CJTDNum <= 0 Then'采集通道数
MessageBox.Show("采集卡打开的通道数为0,不能采集" )
Return
End If
e.Form.Controls("TabControl1").SelectedIndex = 0
e.Form.Controls("Button8").PerformClick() '确定设置
'---------------SaveTofilename--------------------------------
Dim Str1 As String = Str00 & "-" '= DateSt
Dim Str2 As String = e.Form.Controls("ComboBox10").Value & "-" '腔体
Dim Str3 As String = e.Form.Controls("ComboBox11").Value & "-" '气体
Dim Value As String = e.Form.Controls("ComboBox09").Value '试验项目
Dim Result As String
Select Case Value
Case "参考压力"
Result = "C"
Case "过压试验"
Result = "G"
Case "内部点燃不传爆试验"
Result = "N"
Case Else
Result = "X"
End Select
Dim Str4 As String = Result
Dim alpha As String = e.Form.Controls("TextBox7").Value '滤波器的平滑因子
Dim Str5 As String = e.Form.Controls("NumericComboBox1").Value '流水号
'---------------保存前判断文件路径及名称波形是否存在--------------------------------
Dim filename As String = "C:\项目\" & Str00 & "\" & Str1 & Str2 & Str3 & Str4 & Str5 & ".bmp" '文件路径及名称
If ftp1.FileExists(filename.Replace("C:", "")) Or FileSys.FileExists(filename) Then '如果存在则
Messagebox.Show("本图片文件已经存在,请更名后保存!", "提示")
Return
End If
'---------------SaveToCSV-----保存前判断文件路径及名称波形是否存在---------------------------
filename = "C:\项目\" & Str00 & "\" & Str1 & Str2 & Str3 & Str4 & Str5 & ".CSV" '文件路径及名称
If ftp1.FileExists(filename.Replace("C:", "")) Or FileSys.FileExists(filename) Then '如果存在则
Messagebox.Show("本CSV文件已经存在,请更名后保存!", "提示")
Return
End If
'---------------Chart设置--------------------------------
Dim Chart As WinForm.Chart = e.Form.Controls("Chart1")
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart.SeriesList.Clear() '清除图表原来的图系
'--------------------Y值自动、固定切换-----------------------
If e.Form.Controls("CheckBox12").Checked = True Then
Chart.AxisY.Min = -0.1 '指定Y轴的最小值
Chart.AxisY.Max = 1.5 '指定Y轴的最大值
'Chart.AxisY.Major = 0.2 '主刻度间隔值
'Chart.AxisY.Minor = 0.1'副刻度间隔值
Else
'程序将自动决定最佳的Y轴范围
'Chart.AxisY.Min = 0 '指定Y轴的最小值
'Chart.AxisY.Max = 0 '指定Y轴的最大值
End If
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 10 '新增图系包括10个数据点
For i As Integer = 0 To 9 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = 0 'i + Rand.Next(5) '垂直坐标用随机数生成
Next
Dim readContent As Integer
Dim Time3 As Integer = e.Form.Controls("TextBox13").Value '超时时间,以 ms 为单位,当达到所设定的超时时间后,如果采集卡还没有采集到足够 Points点的数据,函数退出,返回错误代码 - 7。
Dim tb14 As WinForm.TextBox = e.Form.Controls("TextBox14") '错误
Dim Val1 As Integer = CJShotPoints \ CJTDNum '每通道采集点数
Dim Val3 As Integer = e.Form.Controls("TextBox3").Value '波形间距3
Dim Values(200000) As Single '用来存放采集得到的模拟输入数据的数组指针:最大2M。
'---------------读取校准系数数组到与使用通道对应的数组--------------------------------
Dim jzxs1(7) As Single '用来存放使用通道校准系数。
Functions.Execute("ratio", jzxs1, e)
readContent = SetUSB3ClrAiFifo(CJDevIndex) '清空指定设备的模拟输入 Fifo 缓存清空指定设备的模拟输入 Fifo 缓存---------------------2-9
If readContent <> 0 Then
Functions.Execute("RepError", readContent, e)
Return
End If
readContent = SetUSB3AiSoftTrig(CJDevIndex) '模拟输入软件触发----------------------------------------------------3-1
If readContent <> 0 Then
Functions.Execute("RepError", readContent, e)
Return
End If
'MessageBox.Show("222222222222222222")
readContent = USB3GetAi(CJDevIndex, Val1, Values, Time3) '每通道需要读取的点数。--------------------------3-2
If readContent <> 0 Then
Functions.Execute("RepError", readContent, e)
'Return
End If
'---------------最大压力-图表的上标题-------------------------------
Dim Str() As Single = Functions.Execute("max", Values, jzxs1, CJTDNum, Val1, alpha) '最大压力
Dim Str0 As String = "CheckBox0"
Dim Str22(6) As String
Str22(0) = dt
Str22(1) = User.Name
Str22(2) = e.Form.Controls("ComboBox09").Value '试验项目
Str22(3) = e.Form.Controls("ComboBox11").Value '试验气体
Str22(4) = e.Form.Controls("ComboBox10").Value '试验部位
Str22(5) = "最大压力:" & Format(Str(0), "f") & " MPa "
Str22(6) = "报告编号:" & Str00
Dim Str33 As String = ""
For i As Integer = 0 To 5
If e.Form.Controls(Str0 & CStr(i + 1)).checked Then
Str33 = Str33 & Str22(i) & " "
End If
Next
Chart.HeaderText = Str33 '图表的上标题
e.Form.Controls("TextBox9").Value = Format(Str(0), "f") 'Str(0) '最大压力
'---------------显示波形--------------------------------
Functions.Execute("display", Chart, Val3 , Values, jzxs1, e.Form.Controls("CheckBox12").Checked, alpha) '固定或自动Y e.Form.Controls("CheckBox12")
'---------------保存波形--------------------------------
filename = "C:\项目\" & Str00 & "\" & Str1 & Str2 & Str3 & Str4 & Str5 & ".bmp" '文件路径及名称
Chart.SaveImage(filename) '保存图片文件
'---------------SaveToCSV-----在这里保存为CSV文件---------------------------
filename = "C:\项目\" & Str00 & "\" & Str1 & Str2 & Str3 & Str4 & Str5 & ".CSV" '文件路径及名称
Functions.Execute("SaveToCSV", Values, jzxs1, filename)
'---------------自动上传--------------------------------
If e.Form.Controls("CheckBox9").Checked Then '自动保存
e.Form.Controls("Button5").PerformClick() '保存
End If
e.Form.Controls("NumericComboBox1").Value = cs + 1 '流水号增加1