
' ----------------------------------------------
'  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"
' "EnableCollaborative
' "DisableCollaborative
' "AddNewPosition
' "SetHomePosition
' "SetCenterPosition
' "SetHoldingTorque nnn"
' "SetSafeTorqueLimit nnn"
' "SetTorque 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 Text ExitFromEdit

Button 3 Text StartExecution
Button 4 Text StopExecution

Button 6 Text GotoHome
Button 7 Text GotoCenter

Button 9 Text EnableRepeat
Button 10 Text DisableRepeat

Button 12 Text SelectLine3
Button 13 Text SelectLine6
Button 14 Text ExecuteSelectedLine

Button 17 Text EnableCollaborative
Button 18 Text DisableCollaborative
Button 20 Text AddNewPosition
Button 22 Text SetHomePosition
Button 23 Text SetCenterPosition

Button 25 Text SetHoldingTorque9
Button 26 Text SetSafeTorqueLimit9
Button 27 Text SetTorque9
Button 28 Text SetAcceleration9
Button 29 Text SetSpeed9

Button 31 Text SetAllparamsToMin
Button 32 Text 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 SendCommand
	Variable String SC1
	SlotText SlotCommands = SC1
	Wait SlotText(SlotCommands) = ""
Return

Label ExitFromEdit
	Gosub SendCommand(ExitFromEdit)
Return

Label StartExecution
	Gosub SendCommand(StartExecution)
Return
Label StopExecution
	Gosub SendCommand(StopExecution)
Return
Label EnableRepeat
	Gosub SendCommand(EnableRepeat)
Return
Label DisableRepeat
	Gosub SendCommand(DisableRepeat)
Return
Label GotoHome
	Gosub SendCommand(GotoHome)
Return
Label GotoCenter
	Gosub SendCommand(GotoCenter)
Return
Label SelectLine3
	Gosub SendCommand(SelectLine 3)
Return
Label SelectLine6
	Gosub SendCommand(SelectLine 6)
Return
Label ExecuteSelectedLine
	Gosub SendCommand(ExecuteSelectedLine)
Return

Label EnableCollaborative
	Gosub SendCommand(EnableCollaborative)
Return
Label DisableCollaborative
	Gosub SendCommand(DisableCollaborative)
Return
Label AddNewPosition
	Gosub SendCommand(AddNewPosition)
Return
Label SetHomePosition
	Gosub SendCommand(SetHomePosition)
Return
Label SetCenterPosition
	Gosub SendCommand(SetCenterPosition)
Return

Label SetHoldingTorque9
	Gosub SendCommand(SetHoldingTorque 9)
Return
Label SetSafeTorqueLimit9
	Gosub SendCommand(SetSafeTorqueLimit 9)
Return
Label SetTorque9
	Gosub SendCommand(SetTorque 9)
Return
Label SetAcceleration9
	Gosub SendCommand(SetAcceleration 9)
Return
Label SetSpeed9
	Gosub SendCommand(SetSpeed 9)
Return

Label SetAllparamsToMin
	Gosub SendCommand(SetHoldingTorque 0)
	Gosub SendCommand(SetSafeTorqueLimit 0)
	Gosub SendCommand(SetTorque 0)
	Gosub SendCommand(SetAcceleration 0)
	Gosub SendCommand(SetSpeed 0)
Return
Label SetAllparamsToMax
	Gosub SendCommand(SetHoldingTorque 999)
	Gosub SendCommand(SetSafeTorqueLimit 999)
	Gosub SendCommand(SetTorque 999)
	Gosub SendCommand(SetAcceleration 999)
	Gosub SendCommand(SetSpeed 99999)
Return


'WATCH v1
'EXEC DestX = 12
