
' ------------------------------------- MENU commands
Button 1 Label Title0
Button Title0 Label "Menu commands"
Button Title0 Color Green2
Button 2 Label LoadSpectrumFile1
Button 3 Label LoadSpectrumFile2
Button 4 Label LoadSpectrumFile3
Button 5 Label LoadCalibrationFile1
Button 6 Label LoadCalibrationFile2
Button 7 Label LoadCalibrationFile3
Button 8 Label LoadIrradianceFile1
Button 9 Label LoadIrradianceFile2
Button 10 Label LoadIrradianceFile3
Button 11 Label SensorTypeRandom

' ------------------------------------- Toolbar commands
Button 17 Label Title1
Button Title1 Label "Toolbar commands"
Button Title1 Color Green2
Button 18 Label SaveSpectrumImage
Button 19 Label SaveTotalImage
Button 20 Label WriteDataON
Button 21 Label WriteDataOFF
Button 22 Label WriteDataTimeRandom
Button 23 Label WriteDataRepeatON
Button 24 Label WriteDataRepeatOFF
Button 25 Label OptionsON
Button 26 Label OptionsOFF
' ------------------------------------- Serial Port
Button 33 Label Title2
Button Title2 Label "Serial Port"
Button Title2 Color Green2
Button 34 Label PortRandom
Button 35 Label BaudsRandom
Button 36 Label ComConnect
Button 37 Label ComDisconnect
Button 38 Label AutoExpON
Button AutoExpON Text "AutoExp" + CRLF + "ON"
Button 39 Label AutoExpOFF
Button AutoExpOFF Text "AutoExp" + CRLF + "OFF"
Button 40 Label ExposureRandom
Button ExposureRandom Text "Exposure" + CRLF + "Random"

' ------------------------------------- SENSOR
Button 42 Label Title4
Button Title4 Label "Sensor"
Button Title4 Color Green2
Button 43 Label SamplesRandom
Button SamplesRandom Text "Samples" + CRLF + "Random"
Button 44 Label AdcSpeedRandom
Button AdcSpeedRandom Text "AdcSpeed" + CRLF + "Random"
Button 45 Label ModeRandom
Button 46 Label AdcScaleRandom
'
' ------------------------------------- WEBCAM
Button 49 Label Title3
Button Title3 Label "WebCam"
Button Title3 Color Green2
Button 50 Label WebCamRandom
Button 51 Label WebCamConnect
Button 52 Label WebCamDisconnect
Button 53 Label VideoInControlsON
Button 54 Label VideoInControlsOFF
'
' ------------------------------------- FILES
Button 59 Label Title5
Button Title5 Label "Files"
Button Title5 Color Green2
Button 60 Label FileNameRandom
Button FileNameRandom Text "FileName" + CRLF + "Random"
Button 61 Label ImageTypeRandom
Button ImageTypeRandom Text "ImageType" + CRLF + "Random"
Button 62 Label FilePathRandom
Button FilePathRandom Text "FilePath" + CRLF + "Random"
'
' ------------------------------------- FILTERS
Button 65 Label Title6
Button Title6 Label "Filters"
Button Title6 Color Green2
Button 66 Label AverageON
Button 67 Label AverageOFF
Button 68 Label AverageRandom
Button AverageRandom Text "Average" + CRLF + "Random"
Button 69 Label SpatialFilterRandom
Button SpatialFilterRandom Text "Spatial filter" + CRLF + "Random"
Button 70 Label ReferenceON
Button 71 Label ReferenceOFF
Button 72 Label BackgroundON
Button 73 Label BackgroundOFF
Button 74 Label RisingSpeed
Button RisingSpeed Text "RisingSpeed" + CRLF + "Random"
Button 75 Label FallingSpeed
Button FallingSpeed Text "FallingSpeed" + CRLF + "Random"
Button 76 Label ResetSpectrumData

' ------------------------------------- SENSOR SAMPLES
Button 81 Label Title7
Button Title7 Label "Sensor samples"
Button Title7 Color Green2
Button 82 Label AdcMaxRandom
Button 83 Label AdcMinRandom
Button 84 Label AdcMinAuto_ON
Button 85 Label AdcMinAuto_OFF
Button 86 Label StartX_Random
Button 87 Label EndX_Random
Button 88 Label SizeY_Random
Button 89 Label StartY_Random
Button 90 Label FlipH_ON
Button 91 Label FlipH_OFF
Button 92 Label FlipV_ON
Button 93 Label FlipV_OFF

' ------------------------------------- STATUS BAR
Button 97 Label Title8
Button Title8 Label "Status bar"
Button Title8 Color Green2
Button 98 Label LogScaleRandom
Button LogScaleRandom Text "Log Scale" + CRLF + "Random"
Button 99 Label DipsON
Button 100 Label DipsOFF
Button 101 Label PeaksON
Button 102 Label PeaksOFF
Button 103 Label ColorsON
Button 104 Label ColorsOFF
Button 105 Label TrimScaleON
Button 106 Label TrimScaleOFF

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

' ------------------------------------- Menu commands
Label LoadSpectrumFile
	SendCommand("LoadSpectrumFile Test1_001.csv")
Return
Label LoadSpectrumFile2
	SendCommand("LoadSpectrumFile Test1_002.csv")
Return
Label LoadSpectrumFile3
	SendCommand("LoadSpectrumFile Test1_003.csv")
Return

Label LoadCalibrationFile1
	SendCommand("LoadCalibrationFile Calib1.txt")
Return
Label LoadCalibrationFile2
	SendCommand("LoadCalibrationFile Calib2.txt")
Return
Label LoadCalibrationFile3
	SendCommand("LoadCalibrationFile Calib3.txt")
Return

Label LoadIrradianceFile1
	SendCommand("LoadIrradianceFile Coeffs_FLAT.txt")
Return
Label LoadIrradianceFile2
	SendCommand("LoadIrradianceFile Random_100_to_2000_nm.txt")
Return
Label LoadIrradianceFile3
	SendCommand("LoadIrradianceFile Sinusoidal_100_to_2000_nm.txt")
Return

Label SensorTypeRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("SensorType WebCam")
		Case 1
			SendCommand("SensorType TCD1304")
		Case 2
			SendCommand("SensorType TCD1254")
	EndSelect
Return

' ------------------------------------- Toolbar commands
Label SaveSpectrumImage
	SendCommand("SaveSpectrumImage")
Return
Label SaveTotalImage
	SendCommand("SaveTotalImage")
Return
Label WriteDataON
	SendCommand("WriteDataON")
Return
Label WriteDataOFF
	SendCommand("WriteDataOFF")
Return
Label WriteDataTimeRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("WriteDataTime 0 sec")
		Case 1
			SendCommand("WriteDataTime 3.0 sec")
		Case 2
			SendCommand("WriteDataTime 10 sec")
	EndSelect
Return
Label WriteDataRepeatON
	SendCommand("WriteDataRepeatON")
Return
Label WriteDataRepeatOFF
	SendCommand("WriteDataRepeatOFF")
Return
Label OptionsON
	SendCommand("OptionsON")
Return
Label OptionsOFF
	SendCommand("OptionsOFF")
Return

  ' ----------------------------------- SERIAL PORT
Label PortRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("ComPort COM1")
		Case 1
			SendCommand("ComPort COM4")
		Case 2
			SendCommand("ComPort COM11")
	EndSelect
Return
Label BaudsRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("Bauds 115200")
		Case 1
			SendCommand("Bauds 250000")
		Case 2
			SendCommand("Bauds 1000000")
	EndSelect
Return

Label ComConnect
	SendCommand("ComConnect")
Return
Label ComDisconnect
	SendCommand("ComDisconnect")
Return

Label AutoExpON
	SendCommand("AutoExpON")
Return
Label AutoExpOFF
	SendCommand("AutoExpOFF")
Return
Label ExposureRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("Exposure 10 us")
		Case 1
			SendCommand("Exposure 20 ms")
		Case 2
			SendCommand("Exposure 100 ms")
	EndSelect
Return

 ' ------------------------------------ SENSOR
Variable Numeric Random
Label SamplesRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("Samples 500")
		Case 1
			SendCommand("Samples 1000")
		Case 2
			SendCommand("Samples 3600")
	EndSelect
Return

Label AdcSpeedRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("AdcSpeed 1")
		Case 1
			SendCommand("AdcSpeed 2")
		Case 2
			SendCommand("AdcSpeed 3")
	EndSelect
Return

Label ModeRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("Mode Normal")
		Case 1
			SendCommand("Mode Debug1C")
		Case 2
			SendCommand("Mode Debug3C")
	EndSelect
Return

Label AdcScaleRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("AdcScale 8 bit")
		Case 1
			SendCommand("AdcScale 10 bit")
		Case 2
			SendCommand("AdcScale 16 bit")
	EndSelect
Return

 ' ------------------------------------ WEBCAM
Label WebCamRandom
	SendCommand("WebCamIndex " + Int(Rnd * 2))
Return
Label WebCamConnect
	SendCommand("WebCamConnect")
Return
Label WebCamDisconnect
	SendCommand("WebCamDisconnect")
Return
Label VideoInControlsON
	SendCommand("VideoInControlsON")
Return
Label VideoInControlsOFF
	SendCommand("VideoInControlsOFF")
Return

' ------------------------------------- FILES
Label FileNameRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("FileName Test1")
		Case 1
			SendCommand("FileName File  1")
		Case 2
			SendCommand("FileName File___3")
	EndSelect
Return
Label ImageTypeRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("ImageType   Jpg")
		Case 1
			SendCommand("ImageType  Png")
		Case 2
			SendCommand("ImageType  	 Bmp")
	EndSelect
Return
Label FilePathRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("FilePath C:\Users\Win10\Documents")
		Case 1
			SendCommand("FilePath C:\Users\Win10\Downloads")
		Case 2
			SendCommand("FilePath C:\Users\Win10\Desktop")
	EndSelect
Return
'
' ------------------------------------- FILTERS
Label AverageON
	SendCommand("AverageON")
Return
Label AverageOFF
	SendCommand("AverageOFF")
Return
Label AverageRandom
	Random = Mod((Random + 1), 3)
	Select Random
		Case 0
			SendCommand("Average 1")
		Case 1
			SendCommand("Average 10")
		Case 2
			SendCommand("Average 100")
	EndSelect
Return
Label SpatialFilterRandom
	SendCommand("SpatialFilter " + Int(Rnd * 10))
Return
Label ReferenceON
	SendCommand("Reference_ON")
Return
Label ReferenceOFF
	SendCommand("Reference_OFF")
Return
Label BackgroundON
	SendCommand("Background_ON")
Return
Label BackgroundOFF
	SendCommand("Background_OFF")
Return
Label RisingSpeedRandom
	SendCommand("RisingSpeed " + Int(Rnd * 100))
Return
Label FallingSpeedRandom
	SendCommand("FallingSpeed " + Int(Rnd * 100))
Return
Label ResetSpectrumData
	SendCommand("ResetSpectrumData")
Return

' ------------------------------------- Sensor samples
Label AdcMaxRandom
	SendCommand("AdcMax " + Int(600 + Rnd * 200))
Return
Label AdcMinRandom
	SendCommand("AdcMin " + Int(200 + Rnd * 200))
Return
Label AdcMinAuto_ON
	SendCommand("AdcMinAuto_ON")
Return
Label AdcMinAuto_OFF
	SendCommand("AdcMinAuto_OFF")
Return

Label StartX_Random
	SendCommand("StartX " + Int(Rnd * 300))
Return
Label EndX_Random
	SendCommand("EndX " +  Int(1000 - Rnd * 400))
Return
Label SizeY_Random
	SendCommand("SizeY " + Int(Rnd * 50 + 1) )
Return
Label StartY_Random
	SendCommand("StartY " +  Int(Rnd * 50))
Return

Label FlipH_ON
	SendCommand("FlipH_ON")
Return
Label FlipH_OFF
	SendCommand("FlipH_OFF")
Return

Label FlipV_ON
	SendCommand("FlipV_ON")
Return
Label FlipV_OFF
	SendCommand("FlipV_OFF")
Return

' ------------------------------------- STATUS BAR
Label LogScaleRandom
	SendCommand("LogScale " + Int(Rnd * 20 - 10))
Return

Label DipsON
	SendCommand("Dips_ON")
Return
Label DipsOFF
	SendCommand("Dips_OFF")
Return

Label PeaksON
	SendCommand("Peaks_ON")
Return
Label PeaksOFF
	SendCommand("Peaks_OFF")
Return

Label ColorsON
	SendCommand("Colors_ON")
Return
Label ColorsOFF
	SendCommand("Colors_OFF")
Return

Label TrimScaleON
	SendCommand("TrimScale_ON")
Return
Label TrimScaleOFF
	SendCommand("TrimScale_OFF")
Return


'BOOKMARKS 

'EDITEDLINES -1 1 171 10 174 10 178 4 181 6 184 6 188 7 191 9 194 9 168 10 

'WATCH SewTo_Speed
'EXEC Button 5 Text Button5
