
首先通过WAGO软件得到三色灯点位为40513模块中0,1,3点位。
设置Tags
在Vgage Pro8 中添加tag标签3个Boolean分别设置为
- Intol ‘结果合格’
- Reject '结果超差'
- Horn '蜂鸣器''
设置40513

代码编辑
代码如下
VB
#region "三色灯结果状态"
Private Sub ResultStadus '三色灯结果状态
Dim Cycle As GageCycle = VGA.CurrentCycle
If Cycle Is Nothing Then
'当前步骤为空将状态都设置为False并且退出
Intol.Value = False
Reject.Value = False
Exit Sub
End If
Dim GageStatus As VGAGE.VGA.Status = Cycle.Status
If GageStatus.IsReject Then
'检测不合格红灯两,绿灯灭
Intol.Value = False
Reject.Value = True
ElseIf GageStatus.IsBeyondApproaching Then
' 接近预警范围显示合格
Intol.Value = True
Reject.Value = False
ElseIf GageStatus.IsInTol Then
'检测合格绿灯亮,红灯灭
Intol.Value = True
Reject.Value = False
Else
End If
End Sub
#end region
页面初始化
VB
Private Sub SetInitialState()
VGA.Prompting.Reset
SerialNumberTextBox.Focus
DisplayStep
Intol.Value = False '状态为FALSE
Reject.Value = False '状态为FALSE
End Sub
当前步骤刷新
vb
Private Sub DisplayStep()
' 显示当前步骤的指令
UpdateInstructionsTop
UpdateInstructionsBottom
UpdateProgress
If VGA.Prompting.AtBeginning Then
Intol.Value = False '开始测量前将状态都置False
Reject.Value = False '开始测量前将状态都置False
SelectionPanel.Visible = True
PartGrid.Visible = False
ElseIf VGA.Prompting.AtEnd Then
ResultStadus '指示灯结束时候显示合格不合格
SelectionPanel.Visible = False
PartGrid.Visible = True
Else
SelectionPanel.Visible = False
PartGrid.Visible = False
End If
GoNoGoButtons.GoChecked = True
AttributeTag.Value = 0
OnOff = True
Stopwatch = Now.AddSeconds(VGA.Prompting.FlashRate)
Me.Invalidate
EnableBackNext
ShowCurrentGage
ShowToolGroup
ShowGoNoGo
ShowColumn
End Sub
Refresh
VB
Public Sub Refresh()
If VGA.OperatingMode <> OperatingMode.Production Then
Exit Sub
End If
If VGA.SelectedUser.CanEditPrompting Then
PromptingButton.Visible = True
Else
PromptingButton.Visible = False
End If
' Flash Dots & Arrows
If Now > Stopwatch Then
OnOff = Not OnOff
Me.Invalidate
If VGA.Prompting.InstructionTopFlash Then
UpdateInstructionsTop
End If
If VGA.Prompting.InstructionBottomFlash Then
UpdateInstructionsBottom
End If
Stopwatch = Now.AddSeconds(VGA.Prompting.FlashRate)
End If
AIR_ONOFF_MAIN
'这里如果显示不合格,蜂鸣器进行响应
If Reject.Value=True Then
Hom.Value = Onoff
Else
Hom.Value=False
End If
End Sub
改变输入框类型
VB
Private Sub SerialNumberTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SerialNumberTextBox.TextChanged
SerialNumberTextBox.ImeMode = ImeMode.Disable
End Sub