'!TITLE "ACube_4xAct_Basic_Cmd"

' Author: Asyril
' This program shows the typical commands to pilot a Asycube. 
' The provider works exclusively with TCP/IP communication. For the Asycube models that integrate only a RS232/485 interface, 
' a TCP/IP <-> RS232/485 converter is required
' ********************************************************************************************************
' The Asycube is not configured via the script and must be tuned for vibration settings using the Asyril's user interface .
' ********************************************************************************************************

Sub Main 
	
 	Dim feeder as Object

    On Error Goto ErrorMgmt
	' Creating  an intance of the Asycube controller
	' Feeder with RS232/485 interface will need the "Nodeno" argument. Matching the physical rotary switch at the rear of the device.
    
	' Creating a feeder object for a feeder that integrates TCP/IP
    'feeder = cao.AddController("Feeder1", "CaoProv.Asyril.Asycube", "", "conn=TCP:192.168.127.253:4001,Timeout=2000")
    ' Creating a feeder object for a feeder that integrates RS232/485
    feeder = cao.AddController("Feeder1", "CaoProv.Asyril.Asycube", "", "conn=TCP:192.168.127.253:4001,Timeout=2000,NodeNo=1")

	' Querying and displaying the provider version
	Dim providerVersion as String
	providerVersion = feeder.Execute("GetLibVersion")
	PrintMsg providerVersion

	' Feed the parts from the bulk
	' These commands are effective only if the feeder integrates a bulk
	' The second arguemnt is the vibration duration. Unit = milisecond
	call feeder.Execute("Feed.Forward",500)     
	call feeder.Execute("Feed.Backward",500)  


	' Spreading or moving the part with the 11 standard directions
	' The second argument is the move direction. Unit = milisecond
	call feeder.Execute("Move.Left",500)
	call feeder.Execute("Move.Right",500)
	call feeder.Execute("Move.Forward",500)
	call feeder.Execute("Move.ForwardLeft",500)
	call feeder.Execute("Move.ForwardRight",500)
	call feeder.Execute("Move.Backward",500)
	call feeder.Execute("Move.BackwardLeft",500)
	call feeder.Execute("Move.BackwardRight",500)
	call feeder.Execute("Move.CenterShort",500)		' available for 4 actuators feeder only
	call feeder.Execute("Move.CenterLong",500)	    ' available for 4 actuators feeder only
	call feeder.Execute("Move.Flip",500)
	
	' Using the backlight
	call feeder.Execute("Backlight.Flash.Set",300)  'for performance reason. It's recomended to call the set command only when the flash duration needs to change.
	call feeder.Execute("Backlight.Flash","")


   ' Disconnect
	Disconnect:
	cao.Controllers.Remove feeder.Index

	feeder = Nothing
	Exit Sub

	ErrorMgmt:
	' Treat the errors here
	PrintMsg "Error..."

End Sub