
' ------------------------------------- Serial port
Button 1 Label Title0
Button Title0 Label "Serial port"
Button Title0 Color Green2
Button 2 Label "Port random"
Button 3 Label "Speed random"
Button 4 Label "Connect"
Button 5 Label "Disconnect"
Button 6 Label "Enable AutoFind"
Button 7 Label "Disable AutoFind"
'
' ------------------------------------- Controls
Button 9 Label Title1
Button Title1 Label "Controls"
Button Title1 Color Green2
Button 10 Label Get version
Button 11 Label "TrimKHz random"
Button 12 Label "TrimDb random"
Button 13 Label "CalibDelta random"
Button 14 Label "Fout random"
Button 15 Label "OutLevel random"
'
' ------------------------------------- Sweep settings
Button 17 Label Title2
Button Title2 Label "Sweep settings"
Button Title2 Color Green2
Button 18 Label "Fmax random"
Button 19 Label "Fmin random"
Button 20 Label "Samples random"
Button 21 Label "MaxDb random"
Button 22 Label "MinDb random"
Button 23 Label "SmoothFactor random"
Button 24 Label "BandPassDB random"
'
' ------------------------------------- Sweep commands
Button 26 Label Title4
Button Title4 Label "Sweep commands"
Button Title4 Color Green2
Button 27 Label "Save sweep data"
Button 28 Label "Set calibration"
Button 29 Label "Clear calibration"
Button 30 Label "Start sweep"
Button 31 Label "Stop sweep"
'
' ------------------------------------- Tracking and OUT commands
Button 33 Label Title5
Button Title5 Label "Tracking and OUT"
Button Title5 Color Green2
Button 34 Label "Enable tracking"
Button 35 Label "Disable tracking"
Button 36 Label "Enable Output"
Button 37 Label "Disable Output"
'
' ------------------------------------- Slot FirstOut
Button 39 Label Title3
Button Title3 Label "Slot First_Out"
Button Title3 Color Green2
Button 40 Label "Slot FirstOut random"
'
' ------------------------------------- Window commands
Button 42 Label Title6
Button Title6 Label "Window commands"
Button Title6 Color Green2
Button 43 Label "Maximize"
Button 44 Label "Minimize"
Button 45 Label "Sizable"


' =============================================================
'  START AND STOP PROGRAM
' =============================================================
Variable Numeric Slot_Commands = 31
'Variable Numeric Slot_Responses = 32

Load Theremino_SlotViewer.exe
'Window MinSize
Stop

Label EventStop
	For v1 = 0 To 128
		Button v1 Text ""
	Next
	Window Sizable
End


' =============================================================
'  SEND COMMAND (default timeout = 0.5 Sec)
' =============================================================
Label SendCommand
	Variable String SC1           '<-- Parameter Command-String
	SlotText Slot_Commands = SC1
	Variable Numeric SC2
	For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout
		If SlotText(Slot_Commands) = ""
			Exit
		EndIf
		Wait Seconds 0.1
	Next
Return


' =============================================================
'  COMMANDS
' =============================================================

' ------------------------------------- Serial port
Label Port Random
	Variable String ComPorts = "COM1 COM17 COM13"
	SendCommand("ComPort " + GetSeparatedString(ComPorts, Int(Rnd * 3)))
Return
Label Speed random
	Variable String ComSpeeds = "9600 57600 115200"
	SendCommand("ComSpeed " + GetSeparatedString(ComSpeeds, Int(Rnd * 3)))
Return
Label Connect
	SendCommand("Connect")
Return
Label Disconnect
	SendCommand("Disconnect")
Return
Label Enable AutoFind
	SendCommand("EnableAutoFind")
Return
Label Disable AutoFind
	SendCommand("DisableAutoFind")
Return

' ------------------------------------- Controls
Label Get version
	SendCommand("GetVersion")
Return
Label TrimKHz random
	SendCommand("TrimKHz " + (Int(Rnd * 2000 - 1000)))
Return
Label TrimDB random
	SendCommand("TrimDb " + (Int(Rnd * 60 - 30)))
Return
Label CalibDelta random
	SendCommand("CalibDelta " + (Int(Rnd * 100 - 50)))
Return
Label Fout
	SendCommand("Fout " + Int(Rnd * 500 + 200))
Return
Label OutLevel
	SendCommand("OutLevel " + Int(Rnd * 4))
Return

' ------------------------------------- Sweep settings
Label Fmax
	SendCommand("Fmax " + Int(Rnd * 500 + 200))
Return
Label Fmin
	SendCommand("Fmin " + Int(Rnd * 200 + 200))
Return
Label Samples
	SendCommand("Samples " + Int(Rnd * 500))
Return
Label MaxDb
	SendCommand("MaxDb " + Int(Rnd * 30))
Return
Label MinDb
	SendCommand("MinDb " + -Int(Rnd * 90))
Return
Label SmoothFactor
	SendCommand("SmoothFactor " + Int(Rnd * 10))
Return
Label BandPassDB
	SendCommand("BandPassDB " + -Int(Rnd * 10))
Return


' ------------------------------------- Sweep commands
Label Save sweep data
	SendCommand("SaveSweepData")
Return
Label Set calibration
	SendCommand("SetCalibration")
Return
Label Clear calibration
	SendCommand("ClearCalibration")
Return
Label Start sweep
	SendCommand("StartSweep")
Return
Label Stop sweep
	SendCommand("StopSweep")
Return

' ------------------------------------- Tracking and Output
Label Enable tracking
	SendCommand("EnableTracking")
Return
Label Disable tracking
	SendCommand("DisableTracking")
Return
Label Enable Output
	SendCommand("EnableOutput")
Return
Label Disable Output
	SendCommand("DisableOutput")
Return

' ------------------------------------- Slot FirstOut
Label Slot First Out
	SendCommand("SlotFirstOut " + Int(Rnd * 999))
Return

' ------------------------------------- Window functions
Label Maximize
	SendCommand("Maximize")
Return
Label Minimize
	SendCommand("Minimize")
Return
Label Sizable
	SendCommand("Sizable")
Return


'BOOKMARKS 

'EDITEDLINES 218 2 -1 1 190 2 209 3 210 4 213 5 216 7 217 7 66 8 211 9 214 10 

'WATCH SewTo_Speed
'EXEC Button 5 Text Button5
