The following demo script demostrates the Spectra-Python interface as it exists now.
#!/usr/bin/env python # # file name: test_py2s.py # # invoked by # # SPECTRA> run test_py2s.py [param1 [param2 [...]]] # import Spectra import sys # # put cursor to the upper left corner # print "\033[1;1f" # # print param1, param2, ... # print " args ", sys.argv # # delete the internal storage, create a SCAN and display ot # Spectra.gra_command( "delete *.*"); Spectra.gra_command( "create test 0 10 100"); Spectra.gra_command( "display") # # return some values from Spectra: int, double and text # status, value = Spectra.gra_decode_int( "2*3") print " 2*3, status %d, result %d " % (status, value) status, value = Spectra.gra_decode_double( "random()") print " random(), status %d, result %g " % (status, value) status, value = Spectra.gra_decode_text( "date()") print " date(), status %d, %s, len %d " % ( status, value, len( value)) # # running Spectras in online mode? If so, return a motor position # flagOnline = Spectra.gra_decode_int( "flag(online)") if( flagOnline == 1): print " mot1 at ", Spectra.gra_decode_double( "gmup(Mot1)") # # pass a result to Spectra by setting the symbol RETURN_VALUE # result = 1.2345 cmd = "return_value = %g" % result Spectra.gra_command( cmd)