
' -------------------------------------------- BUTTONS
Button  1 Label CounterA
Button  2 Label CounterB
Button  3 Label CounterC
Button  4 Label Coincidences
Button  6 Label Generator
Button  8 Label Microsec

' ----------------------------------------------------- OPEN APPS
'Load OpenApps
' ----------------------------------------------------- INIT OPTIONS
Load Vars
GeneratorFreq = Max(v1, 1)
MicrosecTime = v2
GeneratorUpdate
MicrosecUpdate
' ----------------------------------------------------- LOOP AND STOP
Loop
Stop

Label EventStop
	v1 = GeneratorFreq
	v2 = MicrosecTime
	Save Vars
End

' ----------------------------------------------------- LOOP
Label Loop
	Button CounterA Text "A " + Slot(1)
	Button CounterB Text "B " + Slot(2)
	Button CounterC Text "C " + Slot(3)
	Button Coincidences Text "Muons " + Slot(4)
	If GeneratorFreq < 9999
		Slot 12 = 1000
		Wait Seconds 0.5 / GeneratorFreq
		Slot 12 = 0
		Wait Seconds 0.5 / GeneratorFreq
	EndIf
	Slot 10 = MicrosecTime
Goto Loop

' ------------------------------------------------------ GENERATOR
Variable Numeric GeneratorFreq = 9999

Label GeneratorChange
	Select GeneratorFreq
		Case 9999
			GeneratorFreq = 0.1
		Case 0.1
			GeneratorFreq = 1
		Case 1
			GeneratorFreq = 10
		Case 10
			GeneratorFreq = 50
		Case 50
			GeneratorFreq = 9999
	EndSelect
	GeneratorUpdate
Return

Label GeneratorUpdate
	Select GeneratorFreq
		Case 9999
			Button Generator Text  "Generator OFF"
		Case 0.1
			Button Generator Text  "Generator 0.1 Hz"
		Case 1
			Button Generator Text  "Generator 1 Hz"
		Case 10
			Button Generator Text  "Generator 10 Hz"
		Case 50
			Button Generator Text  "Generator 50 Hz"
	EndSelect
Return

' -------------------------------------------------- MICROSEC
Variable Numeric MicrosecTime = 0

Label Microsec
	Select MicrosecTime
		Case 0
			MicrosecTime = 8
		Case 8
			MicrosecTime = 10
		Case 10
			MicrosecTime = 20
		Case 20
			MicrosecTime = 50
		Case 50
			MicrosecTime = 100
		Case 100
			MicrosecTime = 200
		Case 200
			MicrosecTime = 500
		Case 500
			MicrosecTime = 1000
		Case 1000
			MicrosecTime = 0
	EndSelect
	MicrosecUpdate
Return

Label MicrosecUpdate
	Select MicrosecTime
		Case 0
			Button Microsec Text  "Microsec 0"
		Case 8
			Button Microsec Text  "Microsec 8"
		Case 10
			Button Microsec Text  "Microsec 10"
		Case 20
			Button Microsec Text  "Microsec 20"
		Case 50
			Button Microsec Text  "Microsec 50"
		Case 100
			Button Microsec Text  "Microsec 100"
		Case 200
			Button Microsec Text  "Microsec 200"
		Case 500
			Button Microsec Text  "Microsec 500"
		Case 1000
			Button Microsec Text  "Microsec 1000"
	EndSelect
Return


'BOOKMARKS 83 

