Vgage Pro8 软件上位机三色灯设置

青禾大神
上位机
发布于 2025-04-27
29 阅读
23 评论
2.4k 点赞
#VGAGE #Visual Basic
K5vLyQbvxV_image

首先通过WAGO软件得到三色灯点位为40513模块中0,1,3点位。

设置Tags

在Vgage Pro8 中添加tag标签3个Boolean分别设置为
KxSdwvYe1U_image

  • Intol ‘结果合格’
  • Reject '结果超差'
  • Horn '蜂鸣器''

设置40513

p0y2zoDF04_image

代码编辑

代码如下

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

青禾大神

Vue技术专家 | 5年开发经验

专注前端技术领域,Vue生态贡献者,定期分享前沿技术文章。

评论 (128)

前端小白

这篇文章讲得太好了,解决了我很多疑惑!

资深开发者

对依赖收集部分的讲解很深入,期待更多原理分析文章!

相关推荐

Vue3组合式API最佳实践

3.2k阅读 · 86评论

Pinia状态管理深度解析

2.5k阅读 · 45评论