# # Abs: get_hist.awk is an awk program to get the history values of all EPICS # PVs that are in a given machine model and match the given patterns # for primary and attribute. Ie, it gets hist for all devices of a given # type, sorted by Z. # # Usage: # # aidaget modelTwiss//Design. | \ # awk -v patt= -v attr= \ # -v st= -v et= -f get_hist.awk # # Examples # 1) The following gets the archived history of the BDES of # all QUADs in the Full Machine, from 24 hours ago to the present time. # # aidaget modelTwiss//Design.FullMachine | awk -v patt=QUAD \ # -v attr=BDES -v st='1 day ago' -v et='now' -f get_hist.awk # # 2) The following gets the archived history of the BDES of # all QUADs (as defined the Full Machine), from Jan 12th 2011 # at 12:15pm to 1/2 hour later at 12:45pm, piping output to a file # for offline inspection. Takes ~ 10 minutes to run! # # aidaget modelTwiss//Design.FullMachine | awk -v patt=QUAD \ # -v attr=BDES -v st='01/12/2011 12:15' -v et='01/12/2011 12:45' \ # -f get_hist.awk > allQuadsSuspectHist.txt # # get_hist.awk is not intended to be used directly by a user. Use valz or # plotz instead. # # Ret: Prints the PV name, Z value, and archived value, of # each matched PV, one row per PV, on stdout. # # Auth: Greg White, 13-Jan-2011 # # --------------------------------------------------------------------- # Mods: # ===================================================================== $5~/BEGIN/ { dev_name = $3; z = $4; if ( match(dev_name,patt)) { pvname = dev_name ":" attr; inst=sprintf("aidagethist -s '%s' -e '%s' -n %s", st, et, pvname); while (( inst | getline res ) > 0) { numfields=split(res,throwaway," "); if ( numfields == 1 ) { print "# " res; } else { print z " " res; } } close(inst); printf("\n"); } }