'!TITLE "KEYENCE_CVX_sample"
'
'Sample program for communication command which uses Keyence CV-X series
'

#Include "KEYENCE_CVX.pcs"		'Include syntax for communication

Sub Main
	Dim strResults as string
	Dim iLineNo as Integer
	Dim iProgNo as Integer
	Dim iTriggerNo as Integer
	Dim iSDNo as Integer

	iLineNo = 8			'Establish connection by line number 8
	iSDNo = 1			'SDNo. 1 
	iProgNo = 0		'Setting number 0
	iTriggerNo = 1		'Trigger number 1

	IF Not (ConnectCVX(iLineNo)) Then		'----@Establish connection
		PrintDbg "Connect NG"
		EXIT SUB
	End IF
	IF Not (X_PW(iLineNo, iSDNo, iProgNo)) Then 	'---@Change the setting number 
		PrintDbg "Change NG"
		EXIT SUB
	END IF
	IF Not(X_T(iLineNo, iTriggerNo, strResults)) Then	'Activate trigger ON
		PrintDBG "Trigger NG" 
		EXIT SUB
	else
		P[0] = ( D_dnCvxData(0), D_dnCvxData(1), D_dnCvxData(2) )
						'Insert the received data to the position data   
	End If

	DisConnectCVX iLineNo			'----@Communication disconnected

END Sub
