Data Structures | Enumerations | Functions | Variables

utilities/UtilityApp.cxx File Reference

(r4864/r4198)

#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <memory>
#include <readline/readline.h>
#include <readline/history.h>
#include "boost/format.hpp"
#include "roc/defines_roc.h"
#include "base/defines_gpio.h"
#include "nxyter/defines_nxyter.h"
#include "roc/defines_udp.h"
#include "roc/defines_optic.h"
#include "base/Board.h"
#include "sp605/Board.h"
#include "roc/Board.h"
#include "base/Gpio.h"
#include "roc/I2cDevice.h"
#include "roc/UdpBoard.h"
#include "nxyter/RocNx.h"
#include "nxyter/FebBase.h"
#include "nxyter/Feb1nxGenB.h"
#include "nxyter/Feb1nxGenC.h"
#include "nxyter/Feb1nxGenD.h"
#include "nxyter/Feb2nxGas.h"
#include "nxyter/Feb4nxBT.h"
#include "nxyter/NxI2c.h"
#include "nxyter/NxContext.h"
#include "nxyter/FebUtil.h"
#include "nxyter/QuickDaq.h"
#include "nxyter/DistFunc.h"
#include "nxyter/DistFuncArray.h"
#include "nxyter/NxDataSummary.h"
#include "feet/RocFeet.h"
Include dependency graph for UtilityApp.cxx:

Go to the source code of this file.

Data Structures

struct  cmditem_t

Enumerations

enum  ArgNeedConstants { kNeedBoard = (1<<0), kNeedRocBoard = (1<<1), kNeedFeb = (1<<2), kNeedDaq = (1<<3) }

Functions

int cmd_autoped ()
int cmd_autosettrh ()
int cmd_autotrim ()
int cmd_autovbiass ()
int cmd_board ()
int cmd_discover ()
int cmd_dlm ()
int cmd_feb ()
int cmd_firepulser ()
int cmd_getadcdirect ()
int cmd_geti2c ()
int cmd_puti2c ()
int cmd_getnx ()
int cmd_getroc ()
int cmd_help ()
int cmd_ident ()
int cmd_idsigch ()
int cmd_initfeb ()
int cmd_printadc ()
int cmd_printdata ()
int cmd_printdatadbg ()
int cmd_printfeb ()
int cmd_printgpio ()
int cmd_printid ()
int cmd_printmon ()
int cmd_printnx ()
int cmd_printroc ()
int cmd_printrocmap ()
int cmd_printstatus ()
int cmd_putroc ()
int cmd_quit ()
int cmd_resetnxi2cbus ()
int cmd_resetnxi2creg ()
int cmd_resetrocnxts ()
int cmd_restartbrd ()
int cmd_saverocconf ()
int cmd_scanadclat ()
int cmd_scanmonadc ()
int cmd_scanvbiasf ()
int cmd_scanvbiass ()
int cmd_setadc ()
int cmd_setadcclock ()
int cmd_setadcdef ()
int cmd_setadcpatt ()
int cmd_setaux ()
int cmd_setdebug ()
int cmd_setfebdef ()
int cmd_seti2c ()
int cmd_setlhwater ()
int cmd_setnx ()
int cmd_setnxaddr ()
int cmd_setnxdef ()
int cmd_setnxmask ()
int cmd_setnxmode ()
int cmd_setnxoff ()
int cmd_setnxpower ()
int cmd_setnxtrim ()
int cmd_setbrddef ()
int cmd_setrocdef ()
int cmd_setsyncm ()
int cmd_setsyncs ()
int cmd_settrace ()
int cmd_testadccntl ()
int cmd_testadcdata ()
int cmd_testfebcntl ()
int cmd_testnxcntl ()
int cmd_testnxdata ()
int cmd_testnxregs ()
int cmd_testrocaux ()
int cmd_testrocsync ()
void add_cmdlist (cmditem_t *lst)
void reset_cmdlist ()
int check_feb (bool needfeb=true)
 Check whether FEB connection is required and available.
int check_daq (bool needdaq)
 Check whether ROC connection in DAQ mode required and available.
int args_check (int needs)
 Final check on argument processing phase.
void trim_whitespace (std::string &str)
 Remove leading/trailing white space (blank, tab) from a string.
bool cmd_full_short (const char *cmd, std::string &cmdfull, std::string &cmdshort)
std::string get_timestamp (const char *fields="dtm")
int print_opererr (const char *text, int rc)
void print_loop_stats (const char *text, int ecnt)
void print_daq_stats (const char *text, uint64_t cnt, int ecnt)
int get_arg (std::string &arg, const char *aname, bool &defaulting)
 Get a string argument, returns also defaulting status.
int get_arg (std::string &arg, const char *aname=0)
 Get a string argument.
int get_arg (int32_t &arg, const char *aname=0, int32_t min=(1<< 31), int32_t max=~(1<< 31))
 Get a int32_t type argument.
int get_arg (double &arg, const char *aname=0)
 Get a double type argument.
int get_arg (bool &arg, const char *aname=0)
 Get a bool type argument.
int get_nxind (int32_t &nx, const char *aname=0)
 Get a nXYTER index type argument.
int get_nxrange (int32_t &nxbeg, int32_t &nxend, const char *aname=0)
 Get a 'range of nXYTER index' type argument.
bool get_opt (const std::string &opt)
 Get an command option of the form "-x".
bool check_nxoffline (int nxind, int nxbeg, int nxend)
 Check for nx 'offline' flag in case a nxind range is used.
void print_40f_41f (float val)
void print_dfa_ent_med_w50 (int vb, int ncha, nxyter::DistFunc &df_ent, nxyter::DistFunc &df_med, nxyter::DistFunc &df_w50, bool mode_ent, bool phead)
void get_vbiass_data (int nxind, int vb, float &med, int npuls, bool opt_v, bool phead)
int autoped_issue_system_message (uint32_t type)
int autoped_setnxmode (bool testtrig)
void acquire_data (int nxind, std::vector< std::vector< float > > &data, float time)
void acquire_data (int nxind, std::vector< int > &nhits, float time)
void autotrim_print_rates (const std::vector< int > &npulses, double time)
void autotrim_print_trim (const nxyter::NxContext &cntx_trim)
void autotrim_print_trim_dbg (const nxyter::NxContext &cntx_trim, const std::vector< int > &trim_min, const std::vector< int > &trim_max)
float get_npuls_avg (const std::vector< int > &npuls, int nchactive)
float get_mean (std::vector< float > const &vect)
int process_command (const std::string &line, int level)
void hdl_int (int sig, siginfo_t *info, void *cnxt)
int main (int argc, char *argv[])

Variables

base::BoardgBaseBoard = 0
roc::BoardgRocBoard = 0
sp605::BoardgSP605Board = 0
base::GpiogGpio = 0
nxyter::RocNxgRocNx = 0
nxyter::FebBasegFeb = 0
nxyter::QuickDaqgQdaq = 0
nxyter::FebUtilgUtil = 0
std::string gBoardName
int gIntCount = 0
std::vector< std::string > argspos
std::vector< std::string > argsopt
std::vector< cmditem_t * > cmdlist
cmditem_t cmdlist_base []
cmditem_t cmdlist_board []
cmditem_t cmdlist_sp605 []
cmditem_t cmdlist_nxyter []
cmditem_t cmdlist_gpio []
cmditem_t cmdlist_roc []
static const char * history_file = "./.rocutil_history"
static const int history_max = 250

Enumeration Type Documentation

Enumerator:
kNeedBoard 
kNeedRocBoard 
kNeedFeb 
kNeedDaq 

Definition at line 83 of file UtilityApp.cxx.


Function Documentation

void acquire_data ( int  nxind,
std::vector< std::vector< float > > &  data,
float  time 
)
void acquire_data ( int  nxind,
std::vector< int > &  nhits,
float  time 
)
void add_cmdlist ( cmditem_t lst  ) 

Definition at line 786 of file UtilityApp.cxx.

References cmditem_t::name.

Referenced by cmd_board(), and reset_cmdlist().

int args_check ( int  needs  ) 

Final check on argument processing phase.

Checks whether all given positional and optional arguments where used and whether the command pre-conditions are fulfilled.

Parameters:
needs mask of command requirements, the or of

  • kNeedBoard
  • kNeedRocBoard
  • kNeedFeb
  • kNeedDaq
Returns:
non-zero on failure (leftover arguments or not fulfilled requirements).

Definition at line 849 of file UtilityApp.cxx.

References argsopt, argspos, check_daq(), check_feb(), kNeedBoard, kNeedDaq, kNeedFeb, and kNeedRocBoard.

Referenced by cmd_autoped(), cmd_autotrim(), cmd_autovbiass(), cmd_board(), cmd_discover(), cmd_feb(), cmd_firepulser(), cmd_getadcdirect(), cmd_geti2c(), cmd_getnx(), cmd_getroc(), cmd_idsigch(), cmd_printadc(), cmd_printdata(), cmd_printdatadbg(), cmd_printfeb(), cmd_printgpio(), cmd_printid(), cmd_printmon(), cmd_printnx(), cmd_printroc(), cmd_printrocmap(), cmd_printstatus(), cmd_puti2c(), cmd_putroc(), cmd_resetnxi2cbus(), cmd_resetnxi2creg(), cmd_restartbrd(), cmd_saverocconf(), cmd_scanadclat(), cmd_scanmonadc(), cmd_scanvbiasf(), cmd_scanvbiass(), cmd_setadc(), cmd_setadcclock(), cmd_setadcdef(), cmd_setadcpatt(), cmd_setaux(), cmd_setbrddef(), cmd_setdebug(), cmd_setfebdef(), cmd_seti2c(), cmd_setnx(), cmd_setnxaddr(), cmd_setnxdef(), cmd_setnxmask(), cmd_setnxmode(), cmd_setnxoff(), cmd_setnxpower(), cmd_setnxtrim(), cmd_setrocdef(), cmd_setsyncm(), cmd_setsyncs(), cmd_settrace(), cmd_testadccntl(), cmd_testadcdata(), cmd_testfebcntl(), cmd_testnxcntl(), cmd_testnxdata(), cmd_testnxregs(), cmd_testrocaux(), and cmd_testrocsync().

int autoped_issue_system_message ( uint32_t  type  ) 

Definition at line 3757 of file UtilityApp.cxx.

References base::Board::operPPP(), print_opererr(), ROC_ADDSYSMSG, and ROC_NX_FIFO_RESET.

Referenced by cmd_autoped().

int autoped_setnxmode ( bool  testtrig  ) 
void autotrim_print_rates ( const std::vector< int > &  npulses,
double  time 
)

Definition at line 4217 of file UtilityApp.cxx.

Referenced by cmd_autotrim().

void autotrim_print_trim ( const nxyter::NxContext cntx_trim  ) 

Definition at line 4230 of file UtilityApp.cxx.

References nxyter::NxContext::getThresholdTrim().

Referenced by cmd_autotrim().

void autotrim_print_trim_dbg ( const nxyter::NxContext cntx_trim,
const std::vector< int > &  trim_min,
const std::vector< int > &  trim_max 
)

Definition at line 4244 of file UtilityApp.cxx.

References nxyter::NxContext::getThresholdTrim().

int check_daq ( bool  needdaq  ) 

Check whether ROC connection in DAQ mode required and available.

Parameters:
needdaq if true a ROC connection in DAQ mode is required
Returns:
non-zero on failure (DAQ mode required but not available).

Definition at line 825 of file UtilityApp.cxx.

Referenced by args_check().

int check_feb ( bool  needfeb = true  ) 

Check whether FEB connection is required and available.

Parameters:
needfeb if true a FEB connection is required
Returns:
non-zero on failure (FEB connection required but not available).

Definition at line 809 of file UtilityApp.cxx.

Referenced by args_check(), get_nxind(), and get_nxrange().

bool check_nxoffline ( int  nxind,
int  nxbeg,
int  nxend 
)
int cmd_autoped (  ) 
int cmd_autosettrh (  ) 
int cmd_autotrim (  ) 
int cmd_autovbiass (  ) 
int cmd_board (  ) 
int cmd_discover (  ) 

Definition at line 1522 of file UtilityApp.cxx.

References args_check(), get_opt(), kNeedRocBoard, and nxyter::FebUtil::probe().

int cmd_dlm (  ) 

Definition at line 1532 of file UtilityApp.cxx.

References get_arg(), and roc::Board::invokeDLM().

int cmd_feb (  ) 
int cmd_firepulser (  ) 
bool cmd_full_short ( const char *  cmd,
std::string &  cmdfull,
std::string &  cmdshort 
)

Definition at line 907 of file UtilityApp.cxx.

Referenced by cmd_help(), and process_command().

int cmd_getadcdirect (  ) 
int cmd_geti2c (  ) 
int cmd_getnx (  ) 
int cmd_getroc (  ) 
int cmd_help (  ) 

Definition at line 1202 of file UtilityApp.cxx.

References cmd_full_short(), get_arg(), and get_opt().

int cmd_ident (  ) 

Definition at line 1494 of file UtilityApp.cxx.

References gBoardName, and get_timestamp().

int cmd_idsigch (  ) 
int cmd_initfeb (  ) 

Definition at line 1507 of file UtilityApp.cxx.

References nxyter::FebBase::initRoc().

int cmd_printadc (  ) 
int cmd_printdata (  ) 
int cmd_printdatadbg (  ) 
int cmd_printfeb (  ) 
int cmd_printgpio (  ) 
int cmd_printid (  ) 
int cmd_printmon (  ) 
int cmd_printnx (  ) 
int cmd_printroc (  ) 
int cmd_printrocmap (  ) 
int cmd_printstatus (  ) 
int cmd_puti2c (  ) 
int cmd_putroc (  ) 
int cmd_quit (  ) 

Definition at line 1359 of file UtilityApp.cxx.

int cmd_resetnxi2cbus (  ) 

Definition at line 2484 of file UtilityApp.cxx.

References args_check(), kNeedFeb, and nxyter::FebBase::resetNxI2cBus().

int cmd_resetnxi2creg (  ) 

Definition at line 2493 of file UtilityApp.cxx.

References args_check(), kNeedFeb, and nxyter::FebBase::resetNxI2cRegister().

int cmd_resetrocnxts (  ) 

Definition at line 4084 of file UtilityApp.cxx.

References print_opererr(), and nxyter::RocNx::resetRocNxTs().

int cmd_restartbrd (  ) 

Definition at line 3992 of file UtilityApp.cxx.

References args_check(), kNeedBoard, and base::Board::restartBoard().

int cmd_saverocconf (  ) 

Definition at line 3976 of file UtilityApp.cxx.

References args_check(), kNeedRocBoard, and roc::UdpBoard::saveConfig().

int cmd_scanadclat (  ) 
int cmd_scanmonadc (  ) 
int cmd_scanvbiasf (  ) 
int cmd_scanvbiass (  ) 
int cmd_setadc (  ) 
int cmd_setadcclock (  ) 
int cmd_setadcdef (  ) 
int cmd_setadcpatt (  ) 
int cmd_setaux (  ) 
int cmd_setbrddef (  ) 
int cmd_setdebug (  ) 

Definition at line 1470 of file UtilityApp.cxx.

References args_check(), get_arg(), kNeedRocBoard, and base::Board::setVerbosity().

int cmd_setfebdef (  ) 
int cmd_seti2c (  ) 
int cmd_setlhwater (  ) 

Definition at line 1952 of file UtilityApp.cxx.

References get_arg(), and roc::UdpBoard::setRocLowHighWater().

int cmd_setnx (  ) 
int cmd_setnxaddr (  ) 
int cmd_setnxdef (  ) 
int cmd_setnxmask (  ) 
int cmd_setnxmode (  ) 
int cmd_setnxoff (  ) 
int cmd_setnxpower (  ) 
int cmd_setnxtrim (  ) 
int cmd_setrocdef (  ) 
int cmd_setsyncm (  ) 
int cmd_setsyncs (  ) 
int cmd_settrace (  ) 

Definition at line 1482 of file UtilityApp.cxx.

References args_check(), get_arg(), kNeedBoard, and base::Board::setOperTrace().

int cmd_testadccntl (  ) 
int cmd_testadcdata (  ) 
int cmd_testfebcntl (  ) 
int cmd_testnxcntl (  ) 
int cmd_testnxdata (  ) 
int cmd_testnxregs (  ) 
int cmd_testrocaux (  ) 
int cmd_testrocsync (  ) 
int get_arg ( std::string &  arg,
const char *  aname = 0 
)

Get a string argument.

Definition at line 1028 of file UtilityApp.cxx.

References get_arg().

int get_arg ( std::string &  arg,
const char *  aname,
bool &  defaulting 
)
int get_arg ( bool &  arg,
const char *  aname = 0 
)

Get a bool type argument.

Definition at line 1112 of file UtilityApp.cxx.

References get_arg().

int get_arg ( int32_t &  arg,
const char *  aname = 0,
int32_t  min = (1<<31),
int32_t  max = ~(1<<31) 
)

Get a int32_t type argument.

Definition at line 1037 of file UtilityApp.cxx.

References get_arg(), and trim_whitespace().

int get_arg ( double &  arg,
const char *  aname = 0 
)

Get a double type argument.

Definition at line 1081 of file UtilityApp.cxx.

References get_arg(), and trim_whitespace().

float get_mean ( std::vector< float > const &  vect  ) 

Definition at line 4597 of file UtilityApp.cxx.

Referenced by cmd_idsigch().

float get_npuls_avg ( const std::vector< int > &  npuls,
int  nchactive 
)

Definition at line 4258 of file UtilityApp.cxx.

Referenced by cmd_autotrim().

int get_nxind ( int32_t &  nx,
const char *  aname = 0 
)

Get a nXYTER index type argument.

Definition at line 1123 of file UtilityApp.cxx.

References check_feb(), get_arg(), and nxyter::FebBase::numNx().

Referenced by cmd_scanadclat(), cmd_setnxaddr(), and cmd_setnxoff().

int get_nxrange ( int32_t &  nxbeg,
int32_t &  nxend,
const char *  aname = 0 
)
bool get_opt ( const std::string &  opt  ) 
std::string get_timestamp ( const char *  fields = "dtm"  ) 
void get_vbiass_data ( int  nxind,
int  vb,
float &  med,
int  npuls,
bool  opt_v,
bool  phead 
)
void hdl_int ( int  sig,
siginfo_t *  info,
void *  cnxt 
)
int main ( int  argc,
char *  argv[] 
)
void print_40f_41f ( float  val  ) 

Definition at line 2712 of file UtilityApp.cxx.

Referenced by print_dfa_ent_med_w50().

void print_daq_stats ( const char *  text,
uint64_t  cnt,
int  ecnt 
)
void print_dfa_ent_med_w50 ( int  vb,
int  ncha,
nxyter::DistFunc df_ent,
nxyter::DistFunc df_med,
nxyter::DistFunc df_w50,
bool  mode_ent,
bool  phead 
)
void print_loop_stats ( const char *  text,
int  ecnt 
)
int print_opererr ( const char *  text,
int  rc 
)
int process_command ( const std::string &  line,
int  level 
)

Definition at line 4674 of file UtilityApp.cxx.

References argsopt, argspos, cmd_full_short(), gIntCount, and trim_whitespace().

Referenced by main().

void reset_cmdlist (  ) 

Definition at line 793 of file UtilityApp.cxx.

References add_cmdlist().

Referenced by cmd_board(), and main().

void trim_whitespace ( std::string &  str  ) 

Remove leading/trailing white space (blank, tab) from a string.

Will remove all leading and trailing white space characters from str.

Parameters:
str string to be trimmed of white space

Definition at line 894 of file UtilityApp.cxx.

Referenced by get_arg(), get_nxrange(), main(), and process_command().


Variable Documentation

std::vector<std::string> argsopt

Definition at line 81 of file UtilityApp.cxx.

Referenced by args_check(), get_arg(), get_opt(), and process_command().

std::vector<std::string> argspos

Definition at line 80 of file UtilityApp.cxx.

Referenced by args_check(), get_arg(), and process_command().

std::vector<cmditem_t*> cmdlist

Definition at line 175 of file UtilityApp.cxx.

Definition at line 178 of file UtilityApp.cxx.

Generic list for any kind of board

Definition at line 212 of file UtilityApp.cxx.

Definition at line 430 of file UtilityApp.cxx.

Command list for nXYTER-frontentds

Definition at line 307 of file UtilityApp.cxx.

Definition at line 470 of file UtilityApp.cxx.

Initial value:
 {
   { name:    "set605def",
     func: cmd_setrocdef,
     shelp:" : set SP605 registers to default values",
     lhelp:"    Note: use after board boot"
   },
   { name: 0,
     func: 0,
     shelp:0,
     lhelp:0
   }
}

Command list for SP605 board

Definition at line 293 of file UtilityApp.cxx.

Definition at line 67 of file UtilityApp.cxx.

std::string gBoardName

Definition at line 76 of file UtilityApp.cxx.

Referenced by cmd_board(), and cmd_ident().

Definition at line 72 of file UtilityApp.cxx.

Definition at line 70 of file UtilityApp.cxx.

int gIntCount = 0

Definition at line 78 of file UtilityApp.cxx.

Referenced by hdl_int(), and process_command().

Definition at line 73 of file UtilityApp.cxx.

Definition at line 68 of file UtilityApp.cxx.

Definition at line 71 of file UtilityApp.cxx.

Definition at line 69 of file UtilityApp.cxx.

Definition at line 74 of file UtilityApp.cxx.

const char* history_file = "./.rocutil_history" [static]

Definition at line 4842 of file UtilityApp.cxx.

const int history_max = 250 [static]

Definition at line 4843 of file UtilityApp.cxx.