def display_status(stdscr, stat, gpu_id): # Set non-blocking input stdscr.nodelay(1) run = 1 # Look like gbtstatus (why not?) curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_RED) keycol = curses.color_pair(1) valcol = curses.color_pair(2) errcol = curses.color_pair(3) # Loop while run: # Refresh status info stat.read() # Reset screen stdscr.erase() # Draw border stdscr.border() # Get dimensions (ymax, xmax) = stdscr.getmaxyx() # Display main status info onecol = False # Set True for one-column format col = 2 curline = 0 stdscr.addstr(curline, col, "Current NUPPI status: GPU %d/%d" % (gpu_id, stat["N_GPU"]), keycol) curline += 2 flip = 0 for k, v in stat.hdr.items(): if curline < ymax - 3: stdscr.addstr(curline, col, "%8s : " % k, keycol) stdscr.addstr("%s" % v, valcol) else: stdscr.addstr(ymax - 3, col, "-- Increase window size --", errcol) if flip or onecol: curline += 1 col = 2 flip = 0 else: col = 40 flip = 1 col = 2 if flip and not onecol: curline += 1 # Refresh current block info try: curblock = stat["CURBLOCK"] except KeyError: curblock = -1 try: data = Databuf(gpu_id) # Display current packet index, etc if curblock >= 0 and curline < ymax - 4: curline += 1 stdscr.addstr(curline, col, "Current data block info:", keycol) curline += 1 data.read_hdr(curblock) try: pktidx = data.hdr[curblock]["PKTIDX"] except KeyError: pktidx = "Unknown" stdscr.addstr(curline, col, "%8s : " % "PKTIDX", keycol) stdscr.addstr("%s" % pktidx, valcol) except: stdscr.addstr(curline, col, "nuppi_daq is NOT running", keycol) # Figure out if we're folding foldmode = False try: foldstat = stat["FOLDSTAT"] curfold = stat["CURFOLD"] if foldstat != "exiting": foldmode = True except KeyError: foldmode = False # Display fold info if foldmode and curline < ymax - 4: folddata = Databuf(2) curline += 2 stdscr.addstr(curline, col, "Current fold block info:", keycol) curline += 1 folddata.read_hdr(curfold) try: npkt = folddata.hdr[curfold]["NPKT"] ndrop = folddata.hdr[curfold]["NDROP"] except KeyError: npkt = "Unknown" ndrop = "Unknown" stdscr.addstr(curline, col, "%8s : " % "NPKT", keycol) stdscr.addstr("%s" % npkt, valcol) curline += 1 stdscr.addstr(curline, col, "%8s : " % "NDROP", keycol) stdscr.addstr("%s" % ndrop, valcol) # Bottom info line stdscr.addstr(ymax - 2, col, "Last update: " + time.asctime() + " - Press 'q' to quit") # Redraw screen stdscr.refresh() # Sleep a bit time.sleep(0.25) # Look for input c = stdscr.getch() while c != curses.ERR: if c == ord("q"): run = 0 c = stdscr.getch()
log = logfile("foldbuf_monitor.py") # Get all of the useful values g = Status(log) g.read() nchan = g["OBSNCHAN"] totnchan = g["TOTNCHAN"] npoln = g["NPOL"] BW = g["OBSBW"] fctr = g["OBSFREQ"] blocsize = g["BLOCSIZE"] nbin = g["NBIN"] # Access the data buffer which contain fold buffer, ie: 2 d = Databuf(2) # argument is the current fold block in the data buffer data = d.data(g["FBLOCK"]) """ print "BW = %f, totnchan = %d"%(BW, totnchan) print 'nbin = %d'%nbin print data print data.shape print data[0,0,:] print "Len", len(data[0,0,:]) """
# Get all of the useful values g = Status(log) g.read() nchan = g["OBSNCHAN"] totnchan = g["TOTNCHAN"] npoln = g["NPOL"] BW = g["OBSBW"] fctr = g["OBSFREQ"] blocsize = g["BLOCSIZE"] # Sum different amount depending on nchan #nspec_sum = 512 * 2048 / nchan # Access the data buffer d = Databuf() dt = 1/ ((BW / totnchan)* 1e6) data = d.data(0) # argument is the block in the data buffer d.dtype = n.uint8 print 'd.blocsize (allocated) = %d, blocksize used = %d'%(d.block_size, blocsize) print "BW = %f, totnchan = %d"%(BW, totnchan) print 'dt = %e'%dt print 'len(data) = %d, poln = %d\n'%(len(data), poln) #n.set_printoptions(threshold=n.nan) #print data[:1024*1024, poln, 0] #print data[:nspec,poln]