'╔═════════════════════════════════════════════════════════╗
'║   Name: Meti_SCARA_V11.txt            Date: 18 Aug 2022 ║
'║ Author: Leonardo                                        ║
'║  Scope: Test overall functionality                      ║
'╠═════════════════════════════════════════════════════════╣
'║Hardware: BLDC motor with encoder                        ║
'╟─────────────────────────────────────────────────────────╢
'║ Note: COBOT update                          14 Jul 2022 ║
'║                                                         ║
'╚═════════════════════════════════════════════════════════╝
Option Speed 9
'Beep "2500 100, 1500 100"

'Variable Numeric Debug = 0 ' 1 = DEBUG   0 = NORMAL

RestoreVars

Load images\Meti_SCARA_PVC.jpg
'Beep "2500 200, 1500 200, 2500 300, 0500, 1500 300"
'TTS SelectVoice Language
TTS SetVolume  100    '0 = mute
TTS SetSpeed -1

'Window MinSize

' ╔══════════════════════════════════════════╗
' ║ SLOT TEXT for COMMANDS and RESPONSES     ║
' ╚══════════════════════════════════════════╝
Variable Numeric Slot_CommandsToCobot    = 51
Variable Numeric Slot_ResponsesFromCobot = 52
Variable Numeric Slot_CommandsFromCobot  = 53

' ╔══════════════════════════════════════════╗ █   █ █▀▀█ █▀▀▀█
' ║ VARIABLE INITIALIZATIONS & ASSIGNEMENTS  ║ █   █ █▄▄█ █▄▄▄█
' ╚══════════════════════════════════════════╝  ▀▄▀  █  █ █  ▀▄
Variable Numeric Slot_M_1       = 101   'vertical
Variable Numeric Slot_M_2       = 201   'arm 1
Variable Numeric Slot_M_3       = 301   'arm 2
Variable Numeric Slot_M_4       = 401   'rotating clamp
Variable Numeric Slot_M_5       = 501	'clamp open/close command

Variable Numeric Slot_LedR_Scara =  7
Variable Numeric Slot_LedG_Scara =  8
Variable Numeric Slot_LedB_Scara =  9

'Variable Numeric Slot_LedR_Clamp = 19
'Variable Numeric Slot_LedG_Clamp = 20
'Variable Numeric Slot_LedB_Clamp = 21
'
Variable Numeric Slot_SignScope  =  13

' -------------------------------------- Software limits
Variable Numeric M1max =   360
Variable Numeric M1min =     0
Variable Numeric M2max =   360
Variable Numeric M2min =     0
Variable Numeric M3max =   360
Variable Numeric M3min =     0
Variable Numeric M4max =   265
Variable Numeric M4min =    95

Key 1 BtnCoord_M1
Key 2 BtnCoord_M2
Key 3 BtnCoord_M3
Key 4 BtnCoord_M4

' ╔══════════════════════════════════════════╗ █▀▀▄ █  █ ▀▀█▀▀
' ║ BUTTONS                                  ║ █▀▀█ █  █   █
' ╚══════════════════════════════════════════╝ █▄▄█ █▄▄█   █
Button 1 Label Home
Button Home Text "Home"
Button Home Color MediumBlue

Button 2 Label "BtnCoord_M1"
Button BtnCoord_M1 Text "M1 = ?"
Button BtnCoord_M1 Color LightBlue
Button 3 Label "BtnCoord_M2"
Button BtnCoord_M2 Text "M2 = ?"
Button BtnCoord_M2 Color LightBlue
Button 4 Label "BtnCoord_M3"
Button BtnCoord_M3 Text "M3 = ?"
Button BtnCoord_M3 Color LightBlue
Button 5 Label "BtnCoord_M4"
Button BtnCoord_M4 Text "M4 = ?"
Button BtnCoord_M4 Color LightBlue

Button 12 Label OpenGripper
Button OpenGripper Text "Open Gripper"
Button OpenGripper Color Bisque
Button 13 Label CloseGripper
Button CloseGripper Text "Close Gripper"
Button CloseGripper Color Bisque

'Button 4 Label "BtnAbsoluteCoord_M1"
'Button BtnAbsoluteCoord_M1 Text "Abs M1= ?"
'Button BtnAbsoluteCoord_M1 Color LightBlue
'Button 5 Label "BtnAbsoluteCoord_M2"
'Button BtnAbsoluteCoord_M2 Text "Abs M2 = ?"
'Button BtnAbsoluteCoord_M2 Color LightBlue
'Button 6 Label "BtnAbsoluteCoord_M3"
'Button BtnAbsoluteCoord_M3 Text "Abs M3 = ?"
'Button BtnAbsoluteCoord_M3 Color LightBlue

'Button 7 Label TempM1
'Button TempM1 Text "TempM1= "
'Button TempM1 Color MistyRose
'Button 8 Label TempM2
'Button TempM2 Text "TempM2= "
'Button TempM2 Color MistyRose
'Button 9 Label TempM3
'Button TempM3 Text "TempM3= "
'Button TempM3 Color MistyRose
'
'Button 11 Label VoltM1
'Button VoltM1 Text "VoltM1="
'Button VoltM1 Color LightGreen
'Button 12 Label VoltM2
'Button VoltM2 Text "VoltM2="
'Button VoltM2 Color LightGreen
'Button 13 Label VoltM3
'Button VoltM3 Text "VoltM3="
'Button VoltM3 Color LightGreen
'
Button 16 Label CloseAll
Button CloseAll Text "CLOSE ALL"
Button CloseAll Color Red

Button 17 Label ExecCobot
Button ExecCobot Text "Exec Cobot"
Button ExecCobot Color SteelBlue
Button 18 Label SelectSequence
Button SelectSequence Text "Select COBOT sequence"
Button SelectSequence Color SteelBlue

Button 20 Label MotorTest
Button MotorTest Text "MotorTest"
Button MotorTest Color Orange

'Button 16 Text Emergency
'Button Emergency Text "EMERGENCY"
'Button Emergency Color Red
'Button Emergency Slot  Slot_Emergency

Button 22 Label RedOn
Button RedOn Color Red
Button 23 Label GreenOn
Button GreenOn Color Green
Button 24 Label YellowOn
Button YellowOn Color Yellow
Button 25 Label BlueOn
Button BlueOn Color MediumBlue
Button 26 Label WhiteOn
Button GreenOn Color Green
Button 27 Label RgbOff
Button RgbOff Color Black

Button 28 Label EnableVoice
Button EnableVoice Text "Enable Voice"
Button EnableVoice Color SkyBlue
Button 29 Label DisableVoice
Button DisableVoice Text "Disable Voice"
Button DisableVoice Color SkyBlue

' -------------------------------------- KEYS
Key Right		 ExecKeys
Key Left 		 ExecKeys
Key Up 			 ExecKeys
Key Down 		 ExecKeys
Key Pageup		 ExecKeys
Key Pagedown	 ExecKeys

' ╔══════════════════════════════════════════╗ █   █▀▀█ █▀▀█ █▀▀▄
' ║ LOAD APPS                                ║ █   █  █ █▄▄█ █  █
' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █  █ █▄▄█
Load Theremino_ModBus.exe
Load Theremino_HAL.exe
Load Theremino_SlotViewer.exe
Load CLAMP.exe
Load Theremino_SlotViewer_Strings.exe
Load Theremino_Cobot.exe
Load Theremino_SignalScope.exe
'Load Terminal_Transmit.exe
'Load Terminal_Receive.exe

' ╔══════════════════════════════════════════╗  █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀
' ║  START FROM HERE                         ║  ▀▀▀█   █   █▀▀▀█ █▀█▀▀   █
' ╚══════════════════════════════════════════╝  ▄▄▄█   █   █   █ █  ▀▄   █
Home
'Controls OpenTextBox
DisableAllButtons
Controls ClearTextBox
TTS Speak "Ready, waiting command."
Print TTSvoices
EnableAllButtons
UpdateButtons
ShowSequenceName
Load Hide
EnableVoice
'DisableVoice
OpenGripper
Loop
Stop

' ╔══════════════════════════════════════════╗ █▀▀ █   █▀▀█ █▀▀▀ █▀▀▀
' ║ CLOSE ALL                                ║ █   █   █  █ ▀▀▀█ █▀▀
' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄
Label CloseAll
	RedOn
	SaveVars
	StopCobot
	Window Sizable
	OpenGripper
	Slot(Slot_SignScope) = 0
	TTS Speak "End Of Program."
	Load CloseApps
Return

' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█
' ║ STOP EVENT (when pressing stop button)     ║ ▀▀▀█   █   █  █ █▄▄█
' ╚════════════════════════════════════════════╝ ▄▄▄█   █   █▄▄█ █
Label EventStop
	SaveVars
	RedOn
	StopCobot
	OpenGripper
	EnableAllButtons
	Window Sizable
	Slot(Slot_SignScope) = 0
	TTS Speak "End Of Program."
End

' ╔══════════════════════════════════════════╗ █   █▀▀█ █▀▀█ █▀▀█
' ║ LOOP                                     ║ █   █  █ █  █ █▄▄█
' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █
Label Loop
	UpdateButtons
	' ------------------------------------------
	' 0.02 sec. or more to allow time for keys and other tasks
	Wait Seconds 0.02
	' ---------------------------------------------------------
Goto Loop

' ╔══════════════════════════════════════════╗
' ║ ENABLE/DISABLE BUTTONS                   ║
' ╚══════════════════════════════════════════╝
Label EnableAllButtons
	For v1 = 1 To 16
		Button v1 Enabled
	Next
Return

Label DisableAllButtons
	For v1 = 1 To 16
		Button v1 Disabled
	Next
Return

' ╔══════════════════════════════════════════╗
' ║ SAVE LOAD VARS                           ║
' ╚══════════════════════════════════════════╝
Label SaveVars
	s11 = SequenceName
	Save Vars
	Print CRLF + "SAVED SEQUENCENAME = " + SequenceName + CRLF
Return

Label RestoreVars
	Load Vars
	SequenceName = s11
Return

' ╔════════════════════════════════════════════╗ █   █ █▀▀█ █▀▄▀█ █▀▀▀
' ║ 3 MOTORS 57AIM16 HOME                      ║ █▀▀▀█ █  █ █   █ █▀▀
' ╚════════════════════════════════════════════╝ █   █ █▄▄█ █   █ █▄▄▄
Label Home
	TTS Speak "Going to Home."
	Slot(Slot_M_4) = 109 			'degree
	Slot(Slot_M_5) = 1000     		'close
	
	Slot 70 = 0
	Wait Seconds 0.5
	Slot 70 = 1
	Wait Seconds 0.5
	WaitZeroPos
	Slot 70 = 0
	Wait Seconds 0.5
	
	Slot(Slot_M_1) = Reset
	Wait Seconds 0.1
	Slot(Slot_M_1) = 300    		'mm
	Wait Seconds 0.1
	
	Slot(Slot_M_2) = Reset
	Wait Seconds 0.1
	Slot(Slot_M_2) = 250    		'degree
	Wait Seconds 0.1
	
	Slot(Slot_M_3) = Reset
	Wait Seconds 0.1
	Slot(Slot_M_3) = 40     		'degree
	Wait Seconds 0.1
	
	Slot(Slot_M_1) = 298			'mm
	Slot(Slot_M_2) = 248     		'degree
	Slot(Slot_M_3) = 42     		'degree
Return

Label WaitZeroPos
	Wait Abs(Slot(150)) < 50
	Wait Abs(Slot(250)) < 50
	Wait Abs(Slot(350)) < 50
Return

' ╔══════════════════════════════════════════╗ █   █ █▀▀█ █ ▀▀█▀▀
' ║ WAIT ALL MOTOR until stopped             ║ █   █ █▄▄█ █   █
' ╚══════════════════════════════════════════╝ ▀▄▀▄▀ █  █ █   █
Label WaitAllMotors
	Variable Numeric WAM1
	Wait Seconds 0.1
	For WAM1 = 1 To Infinity
		If Abs(Slot(Slot_M_1 + 1)) < 0.01
			Exit
		EndIf
		Wait Seconds 0.05
		UpdateButtons
	Next
Return

' ╔══════════════════════════════════════════╗ █   █ █▀▀█ █ ▀▀█▀▀
' ║ GRIPPER                             ║ █   █ █▄▄█ █   █
' ╚══════════════════════════════════════════╝ ▀▄▀▄▀ █  █ █   █
Label OpenGripper
	Slot(Slot_M_5) = 0
	Button OpenGripper Disabled
	Button CloseGripper Enabled
Return

Label CloseGripper
	Slot(Slot_M_5) = 1000
	Button OpenGripper Enabled
	Button CloseGripper Disabled
Return

' ╔══════════════════════════════════════════╗
' ║ EMERGENCY                                ║
' ╚══════════════════════════════════════════╝
Label Emergency
'	DisableAllButtons
'	Button 15 Enabled
'	Button 15 Color Flashing7 Yellow Red
'	For v1 = 1 To Infinity
'		RedOn
'		Wait Seconds 0.4
'		RgbOff
'		Wait Seconds 0.4
'		Load sound\Alarm10b.wav
'	Next
Stop

' ╔════════════════════════════════════════════╗ █▀▀▀ █  █ █▀█
' ║  S U B R O U T I N E   A R E A             ║ ▀▀▀█ █  █ █▀▀█
' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█
Label EnableVoice
	TTS SetVolume 100
	Button EnableVoice Disabled
	Button DisableVoice Enabled
Return

Label DisableVoice
	TTS SetVolume 0
	Button EnableVoice Enabled
	Button DisableVoice Disabled
Return

' ╔══════════════════════════════════════════╗ █   █▀▀ █▀▀▄
' ║ LED COLORS                               ║ █   █▀  █  █
' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█
Label RedOn
	TTS Speak "Status red."
	Slot Slot_LedR_Scara = 1000
	Slot Slot_LedG_Scara = 0
	Slot Slot_LedB_Scara = 0
	Wait TTSready
Return

Label MagentaOn
	TTS Speak "Status magenta."
	Slot Slot_LedR_Scara = 1000
	Slot Slot_LedG_Scara = 0
	Slot Slot_LedB_Scara = 1000
Return

Label YellowOn
	TTS Speak "Status yellow."
	Slot Slot_LedR_Scara = 900
	Slot Slot_LedG_Scara = 400
	Slot Slot_LedB_Scara = 0
	Wait TTSready
Return

Label GreenOn
	TTS Speak "Status green."
	Slot Slot_LedR_Scara = 0
	Slot Slot_LedG_Scara = 1000
	Slot Slot_LedB_Scara = 0
	Wait TTSready
Return

Label BlueOn
	TTS Speak "Status blue."
	Slot Slot_LedR_Scara = 0
	Slot Slot_LedG_Scara = 0
	Slot Slot_LedB_Scara = 1000
	Wait TTSready
Return

Label WhiteOn
	TTS Speak "Status white."
	Slot Slot_LedR_Scara = 1000
	Slot Slot_LedG_Scara = 1000
	Slot Slot_LedB_Scara = 1000
	Wait TTSready
Return

Label RgbOff
	TTS Speak "Status black."
	Slot Slot_LedR_Scara = 0
	Slot Slot_LedG_Scara = 0
	Slot Slot_LedB_Scara = 0
	Wait TTSready
Return

Label RedBlink
	RedOn
	WhiteOn
Return

' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █   █
' ║  SAY                                     ║ ▀▀▀█ █▀▀█  ▀▄▀
' ╚══════════════════════════════════════════╝ ▄▄▄█ █  █   █

Label SayGlueShoe
	TTS Speak "Start glue the shoe demo."
	Wait TTSready
Return

Label SayYellow
	TTS Speak "Going Yellow target."
	Wait TTSready
Return

Label SayGreen
	TTS Speak "Going Green target, time interpolate 1 second."
	Wait TTSready
Return

Label SayBlue
	TTS Speak "RobotANNO Going Blue target."
	Wait TTSready
	ClearCommand
Return

Label SayRed
	TTS Speak "Going Red target, time interpolate 2 value."
	Wait TTSready
Return

Label SayWhite
	TTS Speak "Going White target, time interpolate 2.5 value."
	Wait TTSready
Return

Label SayBlack
	TTS Speak "Going Black target, time interpolate 3 value."
	Wait TTSready
Return

Label SayFastRndMove
	TTS Speak "Making random movement at high speed."
	Wait TTSready
Return

' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀█  █  █ █▀▀▀ █   █
' ║ JOG WITH KEYBOARD                        ║   █  █  █ █ ▄▄  █▄▀  █▀▀   ▀▄▀
' ╚══════════════════════════════════════════╝ █▄█  █▄▄█ █▄▄█  █ ▀▄ █▄▄▄   █
Label ExecKeys
	Variable Numeric JogSpeed = 0.1
	Select True
		Case Key("SHIFT")
			JogSpeed = JogSpeed * 0.01
		Case Key("CTRL")
			JogSpeed = JogSpeed * 0.001
	EndSelect
	'
	Select MotorToEdit
		Case 1
			If Key("Up")
				Slot(Slot_M_1) = Limit(Slot(Slot_M_1) - JogSpeed, M1min, M1max)
			EndIf
			If Key("Down")
				Slot(Slot_M_1) = Limit(Slot(Slot_M_1) + JogSpeed, M1min, M1max)
			EndIf
	EndSelect
	'
	PrintValues
	'EnableMotors
	'YellowOn
	UpdateButtons
Return

' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀▀   █▄ ▄█ █▀▀█ ▀▀█▀▀
' ║  MOTOR SELECTION FOR JOG                 ║   █  █  █ █ ▄▄   █ ▀ █ █  █   █
' ╚══════════════════════════════════════════╝ █▄█  █▄▄█ █▄▄█   █   █ █▄▄█   █
Variable Numeric MotorToEdit
Label defaultcolors
	Button BtnCoord_M1 Color LightBlue
Return

Label BtnCoord_M1
	MotorToEdit = 1
	defaultcolors
	Button BtnCoord_M1 Color Blue
Return

Label BtnCoord_M2
	MotorToEdit = 2
	defaultcolors
	Button BtnCoord_M2 Color Blue
Return

Label BtnCoord_M3
	MotorToEdit = 3
	defaultcolors
	Button BtnCoord_M3 Color Blue
Return

Label BtnCoord_M4
	MotorToEdit = 4
	defaultcolors
	Button BtnCoord_M4 Color Blue
Return

' ====================================================================
'  PRINT COORDINATES AND UPDATE COORDINATE BUTTONS
' ====================================================================
Label PrintValues
	s1 = "MoveTo " + Format(Slot(Slot_M_1), "0.00")
	Print CRLF + s1
Return

Label UpdateButtons
	Button BtnCoord_M1 Text "M1=" + Format(Slot(Slot_M_1) - Slot(Slot_M_1 + 1), "0.00") + "mm"
	Button BtnCoord_M2 Text "M2=" + Format(Slot(Slot_M_2) - Slot(Slot_M_2 + 1), "0.00") + "°"
	Button BtnCoord_M3 Text "M3=" + Format(Slot(Slot_M_3) - Slot(Slot_M_3 + 1), "0.00") + "°"
	Button BtnCoord_M4 Text "M4=" + Format(Slot(Slot_M_4) - Slot(Slot_M_4 + 1), "0.00") + "°"
	
	'Button BtnAbsoluteCoord_M1 Text "Abs M1=" + Format(Slot(160), "00000")
	'Button BtnAbsoluteCoord_M2 Text "Abs M2=" + Format(Slot(260), "00000")
	'Button BtnAbsoluteCoord_M3 Text "Abs M3=" + Format(Slot(360), "00000")
	
	'Button TempM1 Text "TempM1=" + Format(Slot(156), "0.0") + "°"
	'Button TempM2 Text "TempM2=" + Format(Slot(256), "0.0") + "°"
	'Button TempM3 Text "TempM3=" + Format(Slot(356), "0.0") + "°"
	'Button VoltM1 Text "VoltM1=" + Format((Slot(155)/327), "0.0")
	'Button VoltM2 Text "VoltM2=" + Format((Slot(255)/327), "0.0")
	'Button VoltM3 Text "VoltM3=" + Format((Slot(355)/327), "0.0")
	'
	' --------------------------------------------------- debug absolute position
	'Variable Numeric UB1
	'UB1 = Slot(160)
	'Print UB1
	'Print Format(UB1 / 112 / 4,"0.00")   '448
Return

' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▄ ▄█   █▀▀▀ ▀▄ ▄▀ █▀▀▀ █▀▀▀
' ║ COMMANDS FROM COBOT                      ║ █    █  █ █ ▀ █ █ ▀ █   █▀▀    █   █▀   █
' ╚══════════════════════════════════════════╝ █▄▄▄ █▄▄█ █   █ █   █   █▄▄▄ ▄▀ ▀▄ █▄▄▄ █▄▄▄
Label Event_CommandsFromCobot
	' ------------------------------------------------------
	Print " Exec: " + CommandText + CRLF
	' ------------------------------------------------------ Extract first word
	Select GetSeparatedString(CommandText, 0)
		' -------------------------------------------------- ACTIONS
		Case "WaitAllMotors"
			WaitAllMotors
			' ---------------------------------------------- GRIPPER
		Case "Open"
			OpenGripper
		Case "Close"
			CloseGripper
			'	-------------------------------------------- LED colors
		Case "Red"
			RedOn
		Case "Green"
			GreenOn
		Case "Blue"
			BlueOn
		Case "Yellow"
			YellowOn
		Case "RGBOFF"
			RgbOff
			'	-------------------------------------------- Speaking
		Case "SayGlueShoe"
			SayGlueShoe
		Case "SayYellow"
			SayYellow
		Case "SayGreen"
			SayGreen
		Case "SayBlue"
			SayBlue
		Case "SayRed"
			SayRed
		Case "SayWhite"
			SayWhite
		Case "SayBlack"
			SayBlack
		Case "SayFastRndMove"
			SayFastRndMove
			'	---------------------------------------------- LED COLORS
		Case "RedOn"
			RedOn
		Case "GreenON"
			GreenOn
		Case "MagentaOn"
			MagentaOn
		Case "GreenON"
			GreenOn
		Case "BlueOn"
			BlueOn
		Case "YellowOn"
			YellowOn
		Case "WhiteOn"
			WhiteOn
		Case "RGBOFF"
			RgbOff
			' ------------------------------------------------ Commands with parameters
		Case "Pause"
			Wait Seconds GetSeparatedString(CommandText, 1)
		Case "Say"
			TTS Speak Mid(CommandText, 5)
			Wait TTSready
			' ------------------------------------------------ Unrecognized command
		CaseElse
			Controls OpenTextBox
			Print CRLF + " Unrecognized command: " + CommandText + CRLF
			Beep
			Stop								'
	EndSelect
	ClearCommand
Return

Label ClearCommand
	SlotText(Slot_CommandsFromCobot) = ""
Return

' ====================================================================
'  COBOT FILE MANAGEMENT
' ====================================================================
Label InitSequencePaths
	Variable String EditorFolder
	Variable String EditorApp
	Variable String SequencePathAndName
	Variable String SequenceName
	'
	EditorFolder = ".\Apps\Theremino_Editor\"
	'
	EditorApp = EditorFolder + "Theremino_Editor.exe"
	'
	SequencePathAndName = EditorFolder + "Sequences\" + SequenceName
Return

' ====================================================================
'  COMMANDS TO Cobot
' ====================================================================
' ------------------------------------------
'  SEND COMMAND (default timeout = 0.5 Sec)
' ------------------------------------------
Label SendCommand
	Variable String SC1
	Variable Numeric SC2 = 0.5 				'<-- timeout
	Variable Numeric SC3
	SlotText Slot_CommandsToCobot = SC1
	For SC3 = 0.1 To SC2 Step 0.1
		If SlotText(Slot_CommandsToCobot) = ""
			Exit
		EndIf
		Wait Seconds 0.1
	Next
Return

Label ExecCobot
	Variable Numeric EC1
	For EC1 = 1 To Infinity
		SendCommand(DisableRepeat)
		SendCommand(SelectLine 1)
		SendCommand(StartExecution)
		WaitCobotReady
	Next
Return

Label StopCobot
	SendCommand(StopExecution)
Return

Label WaitCobotReady
	Variable Numeric WCR1
	For WCR1 = 1 To Infinity
		UpdateButtons
		Wait Seconds 0.05
		If SlotText(Slot_ResponsesFromCobot) = "Ready"
			Exit
		EndIf
	Next
Return

Label SelectSequence
	Variable String SCF1
	SCF1 = SelectFile("Apps\Theremino_Cobot\Sequences")
	If SCF1 <> ""
		SequenceName = SCF1
	EndIf
	SendCommand(LoadSequence + SequenceName)
	ShowSequenceName
Return

Label ShowSequenceName
	Button SelectSequence Text SequenceName
Return

'--------------------------------------------------------------
'Index  Name                          Culture  Gender   Age
'--------------------------------------------------------------
'1      Microsoft David Desktop       en-US    Male     Adult
'2      Microsoft Zira Desktop        en-US    Female   Adult
'3      Microsoft Elsa Desktop        it-IT    Female   Adult
'4      Microsoft Huihui Desktop      zh-CN    Female   Adult
'--------------------------------------------------------------


' ╔════════════════════════════════════════════╗  █▀▀▀ █▀▀█ █▀█    █▀▀▀ █▀▀█ █▄ ▄█
' ║ COMMANDS to COBOT                          ║  █    █  █ █▀▀█   █    █  █ █ ▀ █
' ╚════════════════════════════════════════════╝  █▄▄▄ █▄▄█ █▄▄█   █▄▄▄ █▄▄█ █   █


