def process_command( input ): global CLI_ACTIVE, BANNER_ON, mode stripped = input.rstrip() tokens = input.rstrip().split() if len(tokens) < 1: return cmd = tokens[0] args = tokens[1:] print 'processing command: ' + ' '.join(tokens) LEFT(1000) #--- banner if cmd=='banner': if len(args) == 0: print 'command banner requires you to specify "on" or "off". (see help for details)' elif args[0] == 'on' : BANNER_ON = True elif args[0] == 'off': BANNER_ON = False else: print 'command banner requires you to specify "on" or "off". (see help for details)' #--- exit, quit elif cmd=='exit' or cmd=='quit': CLI_ACTIVE = False jana.Quit() #--- help elif cmd=='help': print_help() #--- history elif cmd=='history': idx = 0 for h in history: print '%3d %s\r' % (idx, h) idx += 1 print '%3d %s\r' % (idx, ' '.join(tokens) ) # include this history command which will be added below #--- nthreads elif cmd=='nthreads': if len(args) == 0: print 'Number of JThreads: %d' % jana.GetNJThreads() elif len(args)==1: print 'Number of JThreads now at: %d' % jana.SetNJThreads( int(args[0]) ) else: print 'njthreads takes either 0 or 1 argument (see help for details)' #--- parameter elif cmd=='parameter': if len(args) == 0: print 'command parameter requires arguments. (see help for details)' elif args[0] == 'get': if len(args)==2: print '%s: %s' % (args[1], jana.GetParameterValue(args[1])) else: print 'command parameter get requires exactly 1 argument! (see help for details)' elif args[0] == 'set': if len(args)==3: jana.SetParameter(args[1], args[2]) else: print 'command parameter set requires exactly 2 arguments! (see help for details)' elif args[0] == 'list': if len(args)==1: jana.PrintParameters(True) else: print 'command parameter list requires no arguments! (see help for details)' #--- resume elif cmd=='resume': jana.Resume() print 'event processing resumed' #--- status elif cmd=='status': jana.PrintStatus() print '' #--- stop elif cmd=='stop': jana.Stop(True) print 'event processing stopped after %d events (use "resume" to start again)' % jana.GetNeventsProcessed() #--- unknown command else: print 'Unknown command: ' + cmd return history.append( ' '.join(tokens) ) # add to history
# Copyright 2020, Jefferson Science Associates, LLC. # Subject to the terms in the LICENSE file found in the top-level directory. # # This example JANA python script import time import jana print('Hello from jana.py!!!') # Turn off JANA's standard ticker so we can print our own updates jana.SetTicker(False) # Wait for 4 seconds before allowing processing to start for i in range(1, 5): time.sleep(1) print(" waiting ... %d" % (4 - i)) # Start event processing jana.Start() # Wait for 5 seconds while processing events for i in range(1, 6): time.sleep(1) print(" running ... %d (Nevents: %d)" % (i, jana.GetNeventsProcessed())) # Tell program to quit gracefully jana.Quit()