'╔═══════════════════════════════════════════════════════════╗
'║     Name: COBOT_Blue_Col_7.txt           Date: 30 Jan 2022║
'║   Author: Livio & Leo                                     ║
'║    Scope: Test all the functionality of the small COBOT   ║
'║                                                           ║
'╠═══════════════════════════════════════════════════════════╣
'║Hardware: Standard FeeTech STS3215                         ║
'╟───────────────────────────────────────────────────────────╢
'║    Note: General test of all functions                    ║
'║          Adding button color recognition                  ║
'╚═══════════════════════════════════════════════════════════╝

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

RestoreVars

Option Speed 9
'Option GlobalKeys Enabled
Load images\COBOT_Blue.jpg
TTS SelectVoice 2'Language
TTS SetVolume 100
TTS SetSpeed -2

' ╔════════════════════════════════════════════╗
' ║ SLOT TEXT for COMMANDS and RESPONSES       ║
' ╚════════════════════════════════════════════╝
Variable Numeric SlotCobotCommands = 1
Variable Numeric SlotCobotResponses = 2
Variable Numeric SlotQRcode = 3

' ╔════════════════════════════════════════════╗
' ║ SLOT ASSIGNEMENT                           ║
' ╚════════════════════════════════════════════╝
Slot_LedR =  7
Slot_LedG =  8
Slot_LedB =  9
Slot_Pump =  6

' ╔════════════════════════════════════════════╗
' ║ BUTTONS                                    ║
' ╚════════════════════════════════════════════╝
Button 1 Text CobotGotoHome

Button 2 Text CobotGotoCenter

Button 3 Text CobotShowPoint

Button 4 Text CobotReadQRcode

Button 5 Text EditSequence
Button EditSequence Text "Edit sequence"
Button EditSequence Color PaleGreen

Button 6 Text RunSequence
Button RunSequence Text "RUN SEQUENCE"
Button RunSequence Color Aqua

Button 7 Text SelectSequence
Button SelectSequence Text "Select Sequence"
Button SelectSequence Color PowderBlue

Button 8 Text ManagePump
Button ManagePump Text "Start Pump"
Button ManagePump Color LemonChiffon

Button  9 Text SayQRCode
Button SayQRCode Color Yellow
Button 10 Text SayColor
Button SayColor Color Yellow

Button 14 Text "MotorTemp"

Button MotorTemp Color Salmon

Button 15 Text CloseAll
Button CloseAll Text "CLOSE ALL"
Button CloseAll Color Red

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

'Button 17 Text RedOn
'Button RedOn Color Red
'
'Button 18 Text GreenOn
'Button GreenOn Color Green
'
'Button 19 Text YellowOn
'Button YellowOn Color Yellow
'
'Button 20 Text BlueOn
'Button BlueOn Color MediumBlue
'
'Button 21 Text WhiteOn
'Button GreenOn Color Green
'
'Button 22 Text RgbOff
'Button RgbOff Color Black


Stop


ShowSequenceName
DisableAllButtons

' ╔════════════════════════════════════════════╗
' ║ LOAD APPS                                  ║
' ╚════════════════════════════════════════════╝
Load Theremino_HAL.exe
Load Theremino_RS485.exe
'Load Theremino_MicroVideo.exe
Load Theremino_SlotViewer_M1_M2.exe
Load Theremino_SlotViewer_M3_M4.exe
Load Theremino_SlotViewer_M5.exe
'Load Theremino_SignalScope_M1.exe
'Load Theremino_SignalScope_M3.exe
'Load Theremino_SignalScope_M5.exe
'Load Theremino_VideoColors.exe
Load Theremino_QRdecoder.exe
Load Theremino_Cobot.exe

'Load CloseApps Theremino_QRdecoder.exe

Load Hide
CobotDisableRepeat
WaitMotorsReady
CobotGotoCenter
CobotShowPoint
WaitCobotReady
Controls ClearTextBox

YellowOn
Print TTSvoices
EnableAllButtons
Gosub Loop
Stop

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

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


' ╔════════════════════════════════════════════╗
' ║ SAY QRCODE                                 ║
' ╚════════════════════════════════════════════╝
Label SayQRCode
	'Load CloseApps Theremino_VideoColors.exe
	Load Theremino_QRdecoder.exe
	'Load CloseApps Theremino_QRdecoder.exe
	
	WaitCobotReady
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_move_to_QRcode.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_move_to_QRcode.seq" + CRLF
	'
	For v1 = 1 To Infinity
		Wait  SlotText(SlotQRcode) <> ""
		s2 = SlotText(SlotQRcode)
		s2 = Replace(s2, CRLF, "")
		s2 = Trim(s2)
		Select s2
			Case "English male"
				Language = 1
				TTS SelectVoice 1
				SayNowTheLanguageIsEnglishMale
			Case "English female"
				Language = 2
				TTS SelectVoice 2
				SayNowTheVoiceIsEnglishFemale
			Case "Italian female"
				Language = 3
				TTS SelectVoice 3
				SayNowTheLanguageIsItalianFemale
			Case "Chinese female"
				Language = 4
				TTS SelectVoice 4
				SayNowTheLanguageIsChineseFemale
			Case "Coin"
				CobotLoadSeqCoin
			Case "Ball"
				CobotLoadSeqBall
			Case "Start pump"
				StartPump
			Case "Stop pump"
				StopPump
			Case "Home"
				CobotGotoHome
			Case "Show"
				CobotShowPoint
			Case "Red"
				RedOn
			Case "Green"
				GreenOn
			Case "Blue"
				BlueOn
			Case "END"
				CobotGotoHome
				SayEndOfRobotActions
				Exit
			CaseElse
				Print "Invalid QRcode " + s2 + CRLF
				SayUnknowQRcode
			'Stop
		EndSelect
		Print "QRcode=" + s2 + CRLF
		WaitCobotReady
		Wait SlotText(SlotQRcode) <> s2
	Next
Return

' ╔════════════════════════════════════════════╗
' ║ SAY COLOR                                  ║
' ╚════════════════════════════════════════════╝
Label SayColor
	
Return

' ╔════════════════════════════════════════════╗
' ║ ENABLE / DISABLE PUMP                      ║
' ╚════════════════════════════════════════════╝
Variable Numeric Slot_Pump = 6
Label ManagePump
	If Slot(Slot_Pump) = 0
		Gosub StartPump
	Else
		Gosub StopPump
	EndIf
Return

Label StartPump
	Slot(Slot_Pump) = 1000
	Button ManagePump Text "Stop Pump"
Return

Label StopPump
	Slot(Slot_Pump) = 0
	Button ManagePump Text "Start Pump"
Return

' ╔════════════════════════════════════════════╗
' ║ CLOSING EVENTS                             ║
' ╚════════════════════════════════════════════╝
Label CloseAll
	CobotStopExecution
	StopPump
	RedOn
	SaveVars
	CobotGotoHome
	Load CloseApps
Return

Label EventStop
	CobotStopExecution
	SaveVars
	Stoppump
	RedOn
	EnableAllButtons
	Window Sizable
	Slot(Slot_SignalScope) = 0
End

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

Label RestoreVars
	Load Vars
	SequenceName = S1
	Language = s3
Return

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

' ╔════════════════════════════════════════════╗
' ║ COBOT COMMANDS                             ║
' ╚════════════════════════════════════════════╝
Variable String CobotCommand
Label SendCommandToCobot
	SlotText SlotCobotCommands = ""
	Wait Seconds 0.05
	SlotText SlotCobotCommands = CobotCommand
	Wait Seconds 0.05
	WaitCobotReady
Return

Variable String CobotResponse
Label GetResponseFromCobot
	CobotResponse = SlotText(SlotCobotResponses)
	'Print CobotResponse + CRLF
Return

Label WaitCobotReady
	'Wait SlotText(SlotCobotResponses) = "Ready"
Return

Label CobotStartExecution
	CobotCommand = "StartExecution"
	SendCommandToCobot
Return

Label CobotStopExecution
	CobotCommand = "StopExecution"
	SendCommandToCobot
Return

Label CobotDisableRepeat
	CobotCommand = "DisableRepeat"
	SendCommandToCobot
Return
'
Label CobotGotoHome
	CobotCommand = "GotoHome"
	SendCommandToCobot
Return

Label CobotGotoCenter
	CobotCommand = "GotoCenter"
	SendCommandToCobot
Return

Label ReadQRCode
	WaitCobotReady
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_move_to_QRcode.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_move_to_QRcode.seq" + CRLF
	'
	Wait SlotText(SlotQRcode) <> ""
	s2 = SlotText(SlotQRcode)
	s2 = Replace(s2, CRLF, "")
	s2 = Trim(s2)
	Select s2
		Case "Coin"
			CobotLoadSeqCoin
		Case "Ball"
			CobotLoadSeqBall
		Case "Start pump"
			StartPump
		Case "Stop pump"
			StopPump
		Case "Home"
			CobotGotoHome
		Case "Show"
			CobotShowPoint
		Case "Red"
			RedOn
		Case "Green"
			GreenOn
		Case "Blue"
			BlueOn
		Case "END"
			CobotGotoHome
			SayEndOfRobotActions
			ExitFromSequenceLoop = 1
		Case "English male"
			Language = 1
			TTS SelectVoice 1
			SayNowTheLanguageIsEnglishMale
		Case "English female"
			Language = 2
			TTS SelectVoice 2
			SayNowTheVoiceIsEnglishFemale
		Case "Italian female"
			Language = 3
			TTS SelectVoice 3
			SayNowTheLanguageIsItalianFemale
		Case "Chinese female"
			Language = 4
			TTS SelectVoice 4
			SayNowTheLanguageIsChineseFemale
		CaseElse
			Print "Invalid QRcode " + s2 + CRLF
			Stop
	EndSelect
	Print "QRcode=" + s2 + CRLF
	WaitCobotReady
Return

Label CobotShowPoint
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_ShowPoint.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_ShowPoint.seq" + CRLF
Return

Label CobotReadQRcode
	SayReadQRcodeFunction
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_move_to_QRcode.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_ShowPoint.seq" + CRLF
Return

Label CobotLoadSeqCoin
	SayStartCoinRoutine
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_with_coin.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_with_coin.seq" + CRLF
Return

Label CobotLoadSeqBall
	SayStartBallRoutine
	CobotCommand = "StopExecution"
	SendCommandToCobot
	CobotCommand = "LoadSequence Run_with_ball.seq"
	SendCommandToCobot
	CobotCommand = "StartExecution"
	SendCommandToCobot
	Print "Run_with_ball.seq" + CRLF
Return

' ╔════════════════════════════════════════════╗ ██▀██
' ║  SPOKEN MESSAGES                           ║ ██ ██
' ╚════════════════════════════════════════════╝ ██▄██
Variable Numeric Language
Label SayPowerSwIsOn
	Select Language
		Case 1			'David English male
			TTS Speak "Power switch is on?"
		Case 2			'Zira English female
			TTS Speak "Power switch is on?"
		Case 3  		'Elsa Italian Female
			TTS Speak "Hai acceso l'alimentazione?"
		Case 4			'Huihui Chinese female
			TTS Speak "电源开关是否打开？"
	EndSelect
	Wait TTSready
Return

Label StartaSequenceOfRobotAction
	Select Language
		Case 1			'David English male
			TTS Speak "Start robot action sequence."
		Case 2			'Zira English female
			TTS Speak "Start robot action sequence."
		Case 3			'Elsa Italian Female
			TTS Speak "Avviata la sequenza di azioni del robot."
		Case 4			'Huihui Chinese female
			TTS Speak "启动机器人动作序列。"
	EndSelect
	Wait TTSready
Return

Label SayStartBallRoutine
	Select Language
		Case 1			'David English male
			TTS Speak "Start sequence of pick and place of ping pong ball"
		Case 2			'Zira English female
			TTS Speak "Start sequence of pick and place of ping pong ball"
		Case 3			'Elsa Italian Female
			TTS Speak "Avvia la sequenza di prelievo e posizionamento della pallina da ping pong."
		Case 4			'Huihui Chinese female
			TTS Speak "开始乒乓球的取放顺序。"
	EndSelect
	'Wait TTSready
Return

Label SayStartCoinRoutine
	Select Language
		Case 1			'David English male
			TTS Speak "Coin sequence management has been launched."
		Case 2			'Zira English female
			TTS Speak "Coin sequence management has been launched."
		Case 3			'Elsa Italian Female
			TTS Speak "Avviata la gestione della sequenza della moneta."
		Case 4			'Huihui Chinese female
			TTS Speak "硬币顺序管理开始。"
	EndSelect
	'Wait TTSready
Return

Label SayReadQRcodeFunction
	Select Language
		Case 1			'David English male
			TTS Speak "Interpretation of the QR code and start of the sequence of actions of the robot."
		Case 2			'Zira English female
			TTS Speak "Interpretation of the QR code and start of the sequence of actions of the robot."
		Case 3			'Elsa Italian Female
			TTS Speak "Interpretazione del codice QR e avvio della sequenza di azioni del robot."
		Case 4			'Huihui Chinese female
			TTS Speak "解读二维码并开始机器人的一系列动作。"
	EndSelect
	Wait TTSready
Return

Label SayEndOfRobotActions
	Select Language
		Case 1			'David English male
			TTS Speak "The action of the robot is finished and it goes to the rest position."
		Case 2			'Zira English female
			TTS Speak "The action of the robot is finished and it goes to the rest position."
		Case 3			'Elsa Italian Female
			TTS Speak "L'azione del robot è terminata e si porta in posizione di riposo."
		Case 4			'Huihui Chinese female
			TTS Speak "机器人动作完成，进入静止位置。"
	EndSelect
	Wait TTSready
Return

Label SayNowTheLanguageIsEnglishMale
	TTS Speak "Now the language is English."
	Wait TTSready
Return

Label SayNowTheVoiceIsEnglishFemale
	TTS Speak "Now the voice is female."
	Wait TTSready
Return

Label SayNowTheLanguageIsItalianFemale
	TTS Speak "Ora parla Italiano."
	Wait TTSready
Return

Label SayNowTheLanguageIsChineseFemale
	TTS Speak "现在语言是中文"
	Wait TTSready
Return

Label SayUnknowQRcode
	Language = 1
	TTS Speak "Unknow QRcode."
Return

' ╔════════════════════════════════════════════╗
' ║ VARIABLES                                  ║
' ╚════════════════════════════════════════════╝
Variable Numeric Slot_LedR
Variable Numeric Slot_LedG
Variable Numeric Slot_LedB
Variable Numeric NumCycle
Variable Numeric StartTime
Variable String  Result
Variable Numeric Slot_SignalScope
Variable Numeric Slot_Emergency

' ╔════════════════════════════════════════════╗
' ║ EMERGENCY                                  ║
' ╚════════════════════════════════════════════╝
Label Emergency
'	DisableAllButtons
'	Button 15 Enabled
'	Button 15 Color Flashing7 Yellow Red
'	For v1 = 1 To 9e99
'		RedOn
'		Wait Seconds 0.4
'		RgbOff
'		Wait Seconds 0.4
'		Load sound\Alarm10b.wav
'	Next
	Stop
	Emergency
	
' ╔════════════════════════════════════════════╗
' ║ LED COLORS                                 ║
' ╚════════════════════════════════════════════╝
Label RedOn
	Language = 1
	TTS Speak "Now the status light is red."
	Slot Slot_LedR = 1000
	Slot Slot_LedG = 0
	Slot Slot_LedB = 0
Return

jj

Label MagentaOn
	Slot Slot_LedR = 1000
	Slot Slot_LedG = 0
	Slot Slot_LedB = 1000
Return

Label YellowOn
	Language = 1
	TTS Speak "Now the status light is yellow."
	Slot Slot_LedR = 900
	Slot Slot_LedG = 400
	Slot Slot_LedB = 0
Return

Label GreenOn
	Language = 1
	TTS Speak "Now the status light is green."
	Slot Slot_LedR = 0
	Slot Slot_LedG = 1000
	Slot Slot_LedB = 0
Return

Label BlueOn
	Language = 1
	TTS Speak "Now the status light is blue."
	Slot Slot_LedR = 0
	Slot Slot_LedG = 0
	Slot Slot_LedB = 1000
Return

Label WhiteOn
	Language = 1
	TTS Speak "Now the status light is white."
	Slot Slot_LedR = 1000
	Slot Slot_LedG = 1000
	Slot Slot_LedB = 1000
Return

Label RgbOff
	Slot Slot_LedR = 0
	Slot Slot_LedG = 0
	Slot Slot_LedB = 0
Return

Label CheckMotorTemperature
	If Debug = 0
		Variable Numeric OldTemperature
		TestMotorsTemperature
		If MotorsTemperature <> OldTemperature
			OldTemperature = MotorsTemperature
			Button MotorTemp Text "MotorTemp: " + Format(MotorsTemperature, "0")
			If MotorsTemperature > 55
				For v1 = 1 To Infinity
					TestMotorsTemperature
					If MotorsTemperature <= 55
						Exit
					EndIf
					Load Sound\Alarm14.wav
					Wait Not MediaPlaying
				Next
			EndIf
		EndIf
		If MotorsTemperature = 0
			Controls OpenTextBox
			For v1 = 1 To 5
				Print " RS485 not ready" + CRLF
				Load Sound\Alarm14.wav
				Wait Not MediaPlaying
			Next
		EndIf
	EndIf
Return

Variable Numeric MotorsTemperature
Label TestMotorsTemperature
	MotorsTemperature = Slot(106)
	MotorsTemperature = Max(MotorsTemperature, Slot(206))
	MotorsTemperature = Max(MotorsTemperature, Slot(306))
	MotorsTemperature = Max(MotorsTemperature, Slot(406))
	MotorsTemperature = Max(MotorsTemperature, Slot(506))
Return

Label WaitMotorsReady
	SayPowerSwIsOn
	for	v2 = 1 to Infinity
		If Slot(106) = 0
			Print "Motor not ready "
		Else
			Exit for
		EndIf
		Wait Seconds 0.2
	Next
Return

' ╔════════════════════════════════════════════╗ █▀█
' ║ SEQUENCES                                  ║ █ █
' ╚════════════════════════════════════════════╝ █▄█
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

Label EditSequence
	InitSequencePaths
	If FileExists(SequencePathAndName)
		Load EditorApp + " " + SequencePathAndName
	EndIf
Return

Label SelectSequence
	InitSequencePaths
	s1 = SelectFile(EditorFolder + "Sequences\")
	If s1 <> ""
		SequenceName = s1
		ShowSequenceName
		EditSequence
	EndIf
Return

Label ShowSequenceName
	Button SelectSequence Text "Sequence" + CRLF + SequenceName
Return



' ╔════════════════════════════════════════════╗
' ║ RUN SEQUENCES                              ║
' ╚════════════════════════════════════════════╝
Label RunSequence
	GreenOn
	StartaSequenceOfRobotAction
	SlotText CobotResponse = "Ready"
	DisableAllButtons
	Button EditSequence Enabled
	Button CloseAll Enabled
	'Button Emergency Enabled
	Button MotorTemp Enabled
	Variable Numeric ExitFromSequenceLoop
	'
	'Slot(Slot_SignalScope) = 1000
	Controls OpenTextBox
	StartTime = ElapsedTime
	InitSequencePaths
	'
	ExitFromSequenceLoop = 0
	SequenceToExecute = SequencePathAndName
	For NumCycle = NumCycle To Infinity
		Slot(Slot_SignalScope) = 1000
		Result = ""
		ExecSequence
		WaitCobotReady
		Slot(Slot_SignalScope) = 0
		Wait Seconds 0.5
		If ExitFromSequenceLoop > 0
			Exit
		EndIf
	Next
	Slot(Slot_SignalScope) = 0
	EnableAllButtons
Return

' █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
' █  SEQUENCE LOADING AND EXECUTION             █
' █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
Variable String SequenceToExecute
Variable String Sequence
Variable String SequenceCmd
Variable Numeric SequenceIndex
Variable Numeric SequenceLength


Label ExecSequence
	Load Sequence SequenceToExecute
	If Len(Sequence) = 0
		Controls OpenTextBox
		Print CRLF + " Sequence file not found: " + SequenceToExecute  + CRLF
		Beep
		Stop
	EndIf
	'
	Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute)  + CRLF
	Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 50) + CRLF
	' ----------------------------------------------------------
	Variable Numeric ExecSequenceStartTime
	ExecSequenceStartTime = ElapsedTime
	' ----------------------------------------------------------
	SequenceLength = GetSeparatedStringCount(Sequence, CRLF)
	For SequenceIndex = 0 To SequenceLength - 1
		' ------------------------------------------------------
		SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF)
		SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES
		' ------------------------------------------------------ Do not print lines containing ''
		If GetSeparatedStringCount(SequenceCmd, "''") < 2
			Print " Exec: " + SequenceCmd + CRLF
		EndIf
		' ------------------------------------------------------ Trim and remove comments
		SequenceCmd = Trim(RemoveComments(SequenceCmd))
		' ------------------------------------------------------
		If SequenceCmd <> ""
			Select GetSeparatedString(SequenceCmd, 0)
            	' ---------------------------------------------- End sequence
				Case "Restart"
					SequenceIndex = SequenceLength-1
				' ---------------------------------------------- STOP
				Case "Stop"
					ExitFromSequenceLoop = 1
					Exit
				' ---------------------------------------------- COBOT ACTIONS
				Case "ShowPoint"
					CobotShowPoint
				Case "ReadQRCode"
					ReadQRCode
				' ---------------------------------------------- LED COLORS
				Case "RedON"
					RedOn
				Case "MagentaON"
					MagentaOn
				Case "YellowON"
					YellowOn
				Case "GreenON"
					GreenOn
				Case "BlueOn"
					BlueOn
				Case "WhiteOn"
					WhiteOn
				Case "RgbOFF"
					RgbOff
				' ---------------------------------------------- With parameters
				Case "Pause"
					Wait Seconds GetSeparatedString(SequenceCmd, 1)
				Case "SignalScope"
					Slot(Slot_SignalScope) = GetSeparatedString(SequenceCmd, 1)
				CaseElse
					Controls OpenTextBox
					Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF
					Beep
					Stop
			EndSelect
		EndIf
	Next
	Print Chars("-", 50) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute)
	Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF
Return

' ----------------------------------------------
'  COMMANDS
' ----------------------------------------------
' "LoadSequence SeqName.seq" (without spaces)
' "StartExecution"
' "StopExecution"
' "EnableRepeat"
' "DisableRepeat"
' "GotoHome"
' "GotoCenter
' "SelectLine nnn"
' "ExecuteSelectedLine"
' "EnableCollaborative
' "DisableCollaborative
' "AddNewPosition
' "SetHomePosition
' "SetCenterPosition
' "SetHoldingTorque nnn"
' "SetSafeTorqueLimit nnn"
' "SetTorque nnn"
' "SetAcceleration nnn"
' "SetSpeed nnn"

' ----------------------------------------------
'  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"

'--------------------------------------------------------------
'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
'--------------------------------------------------------------
''


'WATCH ttsvoices
