
' ----------------------------------------------
'  COMMANDS
' ----------------------------------------------
' "ExitFromEdit"      (exit from editing state)
' "StartExecution"    (auto-exit from editing)
' "StopExecution"     (auto-exit from editing)
' "GotoHome"          (auto-exit from editing)
' "GotoCenter"        (auto-exit from editing)
' "EnableRepeat"
' "DisableRepeat"
' "SelectLine nnn"
' "ExecuteSelectedLine"
' "ArrowUP"           (auto-exit from run mode)
' "ArrowDOWN"		  (auto-exit from run mode)
' "EnableCollaborative
' "DisableCollaborative
' "AddNewPosition
' "SetHomePosition
' "SetCenterPosition
' "SetSpeedToTorque n.nn"    (0.00 to 1.00)
' "SetHoldingTorque nnn"
' "SetTorqueMin nnn"
' "SetTorqueMax nnn"
' "SetAcceleration nnn"
' "SetSpeed nnn"
' "LoadSequence SeqName.seq" (without spaces)

' ----------------------------------------------
'  RESPONSES
' ----------------------------------------------
' "Ready"
' "Execution running at line nnn"
' "Motors disconnected"
' "Human detected - Speed reduced"
' "Human too near - Execution stopped"
' "Too much torque - Execution stopped"
' "Motors disconnected - Execution stopped"

' ----------------------------------------------
'  SLOT TEXT for COMMANDS and RESPONSES
' ----------------------------------------------
Variable Numeric SlotCommands = 51
Variable Numeric SlotResponses = 52

' ----------------------------------------------
'  BUTTONS
' ----------------------------------------------
Button 1 Label ExitFromEdit

Button 3 Label StartExecution
Button 4 Label StopExecution

Button 6 Label GotoHome
Button 7 Label GotoCenter

Button 9 Label EnableRepeat
Button 10 Label DisableRepeat

Button 17 Label SelectLine3
Button 18 Label SelectLine6
Button 19 Label ExecuteSelectedLine

Button 21 Label ArrowUP
Button 22 Label ArrowDOWN

Button 24 Label EnableCollaborative
Button 25 Label DisableCollaborative
Button 26 Label AddNewPosition
Button 27 Label SetHomePosition
Button 28 Label SetCenterPosition

Button 33 Label SetHoldingTorque9
Button 34 Label SetSafeTorqueLimit9
Button 35 Label SetTorqueMin9
Button 36 Label SetTorqueMax9
Button 37 Label SetAcceleration9
Button 38 Label SetSpeed9

Button 40 Label SetTorqueCoeff
Button 41 Label SetAllparamsToMin
Button 42 Label SetAllparamsToMax



Gosub Loop
Stop

' ----------------------------------------------
'  LOOP
' ----------------------------------------------
Label Loop
	Variable String Response
	Response = SlotText(SlotResponses)
	Print Response
	Wait Seconds 0.1
	' ------------------------------- how to test partial strings
	If StringContains(Response, "stopped")
		Beep
	EndIf
Goto Loop

' ----------------------------------------------
'  COMMANDS
' ----------------------------------------------
Label WaitExecution
	Wait SlotText(SlotCommands) = ""
Return

Label ExitFromEdit
	SlotText SlotCommands = "ExitFromEdit"
	WaitExecution
Return

Label StartExecution
	SlotText SlotCommands = "StartExecution"
	WaitExecution
Return

Label StopExecution
	SlotText SlotCommands = "StopExecution"
	WaitExecution
Return

Label EnableRepeat
	SlotText SlotCommands = "EnableRepeat"
	WaitExecution
Return

Label DisableRepeat
	SlotText SlotCommands = "DisableRepeat"
	WaitExecution
Return

Label GotoHome
	SlotText SlotCommands = "GotoHome"
	WaitExecution
Return

Label GotoCenter
	SlotText SlotCommands = "GotoCenter"
	WaitExecution
Return

Label SelectLine3
	SlotText SlotCommands = "SelectLine 3"
	WaitExecution
Return

Label SelectLine6
	SlotText SlotCommands = "SelectLine 6"
	WaitExecution
Return

Label ExecuteSelectedLine
	SlotText SlotCommands = "ExecuteSelectedLine"
	WaitExecution
Return

Label ArrowUP
	SlotText SlotCommands = "ArrowUP"
Return

Label ArrowDOWN
	SlotText SlotCommands = "ArrowDOWN"
Return

' -----------------------------------------------------
Label EnableCollaborative
	SlotText SlotCommands = "EnableCollaborative"
	WaitExecution
Return

Label DisableCollaborative
	SlotText SlotCommands = "DisableCollaborative"
	WaitExecution
Return

Label AddNewPosition
	SlotText SlotCommands = "AddNewPosition"
	WaitExecution
Return

Label SetHomePosition
	SlotText SlotCommands = "SetHomePosition"
	WaitExecution
Return

Label SetCenterPosition
	SlotText SlotCommands = "SetCenterPosition"
	WaitExecution
Return

' ---------------------------------------------------------
Label SetHoldingTorque9
	SlotText SlotCommands = "SetHoldingTorque 9"
	WaitExecution
Return

Label SetSafeTorqueLimit9
	SlotText SlotCommands = "SetSafeTorqueLimit 9"
	WaitExecution
Return

Label SetTorque9
	SlotText SlotCommands = "SetTorque 9"
	WaitExecution
Return

Label SetAcceleration9
	SlotText SlotCommands = "SetAcceleration 9"
	WaitExecution
Return

Label SetSpeed9
	SlotText SlotCommands = "SetSpeed 9"
	WaitExecution
Return

Label SetTorqueCoeff
	SlotText SlotCommands = SetSpeedToTorqueCoefficient 0.22
	WaitExecution
Return

Label SetAllparamsToMin
	SlotText SlotCommands = "SetHoldingTorque 0"
	WaitExecution
	SlotText SlotCommands = "SetTorqueMin 0"
	WaitExecution
	SlotText SlotCommands = "SetTorqueMax 0"
	WaitExecution
	SlotText SlotCommands = "SetAcceleration 0"
	WaitExecution
	SlotText SlotCommands = "SetSpeed 0"
	WaitExecution
	SlotText SlotCommands = "SetSpeedToTorqueCoefficient 0"
	WaitExecution
Return

Label SetAllparamsToMax
	SlotText SlotCommands = "SetHoldingTorque 999"
	WaitExecution
	SlotText SlotCommands = "SetTorqueMin 999"
	WaitExecution
	SlotText SlotCommands = "SetTorqueMax 999"
	WaitExecution
	SlotText SlotCommands = "SetAcceleration 999"
	WaitExecution
	SlotText SlotCommands = "SetSpeed 99999"
	WaitExecution
	SlotText SlotCommands = "SetSpeedToTorqueCoefficient 1"
	WaitExecution
Return


'WATCH v1
'EXEC DestX = 12
