# ============================================================================= # # Determine super-module and layer # # ============================================================================= LAYER=$(subst L,,$(notdir $(shell pwd))) SM_ROMAN=$(shell pwd | perl -ne 'if ( /.*SM-([IVX]*)/ ) { print "$$1\n"};') SM_FULL=$(shell pwd | perl -ne 'if ( /.*SM-([IVX]*_?\d*)/ ) { print "$$1\n"};') I_TO_DECIMAL = 1 II_TO_DECIMAL = 2 III_TO_DECIMAL = 3 IV_TO_DECIMAL = 4 V_TO_DECIMAL = 5 VI_TO_DECIMAL = 6 VII_TO_DECIMAL = 7 VIII_TO_DECIMAL = 8 IX_TO_DECIMAL = 9 X_TO_DECIMAL = 10 XI_TO_DECIMAL = 11 XII_TO_DECIMAL = 12 XIII_TO_DECIMAL = 13 XIV_TO_DECIMAL = 14 XV_TO_DECIMAL = 15 XVI_TO_DECIMAL = 16 XVII_TO_DECIMAL = 17 XVIII_TO_DECIMAL = 18 SM=$($(SM_ROMAN)_TO_DECIMAL) # ============================================================================= # # Variables # # ============================================================================= CETEST_TARGET?=sm0 OLDPICS = pics/s0.JPG pics/s1.JPG pics/s3.JPG pics/s4.JPG \ pics/s2a.JPG pics/s2b.JPG \ pics/s0dcs.JPG pics/s1dcs.JPG pics/s2dcs.JPG \ pics/s3dcs.JPG pics/s4dcs.JPG PICS = $(patsubst %,pics/%.jpg, s0 s1 s2a s2b s3 s4 s0dcs s1dcs s2dcs s3dcs s4dcs) TEXINPUTS=/home/trd/smint/report/tex/: export TEXINPUTS # ============================================================================= # # Default target: help text # # ============================================================================= help: @echo " usage: make " @echo @echo " possible commands:" @echo " wing: update wingDB from gateDB and restart dhcpd" @echo " flash: flash DCS boards with current firmware" @echo " fnoise: fast noise readout and display" @echo " cetests: run control engine tests" @echo " jtag: run JTAG test for current layer" @echo " check: check that all tests were done (INCOMPLETE)" @echo " report: create the report for this layer" @echo " pics: create pics.pdf for this layer" check: $(PICS) \ jtag.log \ opticalpower.txt \ cooling.txt @echo "Everything's fine!" %.pdf: %.eps epstopdf --outfile=$@ $< # ============================================================================= # JTAG Test # ============================================================================= .PHONY: jtag jtag: jtag/$(shell date '+%Y%m%d-%H%M%S').log jtag/%.log: mkdir -p $(dir $@) ~/helge_development/jtagtest/testjtag.sh l$(LAYER)s0 recursive | tee $@ $NEWLINE=$(shell echo; echo) njtag: echo "qqq$(NEWLINE)qqq\n" screen -d -m -S jtag screen -S jtag -X stuff echo "screen 1" screen -S jtag -X split screen -S jtag -X focus down screen -S jtag -X screen screen -S jtag -X stuff "ls $(NEWLINE)\n" # screen -S jtag -X split # screen -S jtag -X focus down # screen -S jtag -X screen # screen -S jtag -X stuff "ls $(NEWLINE)" # generate report jtag.tex: $(wildcard jtag/*.log) report-jtag.pl # ============================================================================= # Temperature Test # ============================================================================= temptest: echo `seq 0 $(LAYER)` # ============================================================================= # Tests from the Control Engine # ============================================================================= .PHONY: nitest nitest: mkdir -p cetests nginject sm0@err 600 nginject $(CETEST_TARGET) 404 \ | tee cetests/$(shell date '+%Y%m%d-%H%M%S').xml .PHONY: cetests cetests: cetests/$(shell date '+%Y%m%d-%H%M%S').xml xsltproc /usr/share/pvss_mockup/cetests.xsl $< cetests/%.xml: mkdir -p $(dir $@) nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 400 | tee $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 401 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 402 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 403 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 404 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 405 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 406 | tee -a $@ nginject $(CETEST_TARGET)@err 600 nginject $(CETEST_TARGET)@stdby 407 | tee -a $@ nginject $(CETEST_TARGET)@err 600 # #remove multiple nginject tags needed for error cetests cat $@ |grep -v nginject > $@.tmp echo "" > $@ cat $@.tmp >> $@ echo "" >> $@ # ============================================================================= # gate2wing and friends # ============================================================================= .PHONY: wing wing: gate2wing sm13=0 sudo wing_dhcpd sudo /etc/init.d/dhcpd restart # ============================================================================= # Create plot from underpressure cooling test # ============================================================================= cooling-test/%.eps: mkdir -p cooling-test ARGS=$$(echo $* | \ sed -r 's/([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})/\"\1-\2-\3 \4:\5\"/g' | \ sed -r 's/\-\-/,/' ) ; \ root -b -q -l "cooling_test.C($$ARGS,\"$@\")" # ============================================================================= # Gas leak test # ============================================================================= # GASPLOT=$(shell perl -n -e 'print "$$1\n" if /includegraphics.*\{(gas\/.*)\}/' ~/SM-XII_2/L4/report.tex) # .PHONY: gas # gas: $(GASPLOT) # xpdf $(GASPLOT) # gas/%.eps gas/%.png: # mkdir -p gas # root -q -l 'gasplot.C+(1,"$*")' gasreport.eps gasreport.tex: gasreport.C root -b -q -l $< # ============================================================================= # Firmware flashing for one layer # ============================================================================= .PHONY: flash flash: make -C /home/trd/current_firmware FLV=trd_ipkg \ $$(wing_showrocs | \ awk '$$3==0 && $$5==$(LAYER) {print "login_l"$$5"s"$$4}') make -C /home/trd/current_firmware -j 5 FLV=trd_ipkg \ $$(wing_showrocs | \ awk '$$3==0 && $$5==$(LAYER) {print "flash_l"$$5"s"$$4}') # ============================================================================= # # Fast noise readout of current layer # # Resets the TTC event counter, sends 1 kHz triggers for 1 sec and reads the # accumulated statistics from the MCMs in the current layer # # ============================================================================= .PHONY: fnoise oldfnoise: nginject sm0@error 600 nginject sm0@standby 200 nginject sm0@cfg 399 nginject sm0@init 1010 # nginject sm0@init 300 rm -f fastnoise/s?.txt # dimcmd ttcvi/command reset # dimcmd ttcvi/command 1 dimcmd mstrg/command reset dimcmd mstrg/command fnoise sleep 20 # dimcmd ttcvi/command 7 dimcmd mstrg/command off make -j 5 getnoise fnoise: fastnoise/$(shell date +%Y%m%d-%H%M).png .PRECIOUS: fastnoise/%.xml fastnoise/%.xml: mkdir -p fastnoise nginject sm0@error 600 nginject sm0@standby 200 nginject sm0@cfg 399 nginject sm0@init 300 dimcmd mstrg/command reset dimcmd mstrg/command fnoise sleep 20 dimcmd mstrg/command off nginject sm0@cfg 61 > $@ fastnoise/%.txt: fastnoise/%.xml xsltproc ~/dietel/pvss_mockup/xsl/adcstat.xsl $< > $@ fastnoise/%.png: fastnoise/%.txt root rmslayerplot.C\(0,$(LAYER),\"$<\",\"$@\"\) getnoise: fastnoise/s0.txt \ fastnoise/s1.txt \ fastnoise/s3.txt \ fastnoise/s4.txt # fastnoise/s2.txt \ root rmslayerplot.C\(\"fastnoise/`date +%Y%m%d-%H%M`.png\"\) fastnoise/s0.txt: mkdir -p $(dir $@) ssh l$(LAYER)s0 adcrms -c 1 > $@ fastnoise/s1.txt: mkdir -p $(dir $@) ssh l$(LAYER)s1 adcrms -c 1 > $@ fastnoise/s2.txt: mkdir -p $(dir $@) ssh l$(LAYER)s2 adcrms -c 0 > $@ fastnoise/s3.txt: mkdir -p $(dir $@) ssh l$(LAYER)s3 adcrms -c 1 > $@ fastnoise/s4.txt: mkdir -p $(dir $@) ssh l$(LAYER)s4 adcrms -c 1 > $@ fastnoise.tex: $(wildcard fastnoise/*.png) report-fastnoise.pl .PHONY: newfnoise newfnoise: nginject sm0@error 600 nginject sm0@standby 200 nginject sm0@cfg 399 nginject sm0@init 300 rm -f fastnoise/s?.txt dimcmd mstrg/command fnoise sleep 1 dimcmd mstrg/command off nginject sm0 61 > newfnoise.txt # ============================================================================= # # Creating Report # # ============================================================================= LATEX = pdflatex --interaction scrollmode REPORTS = stresstest.tex jtag.tex opticalpower.tex .PHONY: report report: report.pdf xpdf $< report.pdf: report.tex \ cetests.tex \ fastnoise.tex \ jtag.tex \ gasreport.tex \ gasreport.pdf \ stresstest.tex \ opticalpower.tex \ opticalpower.pdf \ $(shell perl -ne \ 'print "$$1\n" if (/^\s*\\includegraphics.*\{(.*)\}/)'\ report.tex) $(LATEX) report.tex || true while grep 'Rerun to get cross-references right' report.log; do \ $(LATEX) report; \ done; stresstest.tex: $(wildcard stresstest/*/begin-*.xml) \ $(wildcard stresstest/*/end-*.xml) \ $(wildcard stresstest/*/crash-*.xml) report-stresstest.pl cetests.tex: $(wildcard cetests/*.xml) report-cetests.pl # echo "\\begin{verbatim}" > $@ # xsltproc ~/dietel/pvss_mockup/xsl/cetests.xsl cetests.xml >> $@ # echo "\\end{verbatim}" >> $@ #noise.tex: $(wildcard noise/*.pdf) #rm -f $@ #for i in $^; do \ #echo "\\vspace{-10mm}" >> $@; \ #echo "\\begin{center}" >> $@; \ #echo "\\includegraphics[angle=90,width=0.85\\textwidth]{$$i}" \ #>> $@; \#echo "\\end{center}" >> $@; \ #done # ============================================================================= # Optical Power # ============================================================================= opticalpower.tex: opticalpower.txt report-opticalpower.pl opticalpower.eps: opticalpower.txt root -b -q -l 'opticalpower.C("$@")' oripwr_att.eps oripwr_abs.eps: opticalpower.txt root -b -q -l 'oripwr.C("oripwr_att.eps","oripwr_abs.eps")' # direct export as PDF seems to be problematic #oripwr_att.pdf oripwr_abs.pdf: opticalpower.txt # root -b -q -l 'oripwr.C("oripwr_att.pdf","oripwr_abs.pdf")' ifeq ($(LAYER),final) opticalpower.txt: $(wildcard ../L[012345]/opticalpower.txt) cat $^ > $@ endif # ============================================================================= # # Picture readout from camera # # ============================================================================= .PHONY: pics pics: pics.pdf xpdf pics.pdf pics/AUTPRINT.MRK: mkdir -p pics cd pics \; \ sudo /usr/bin/gphoto2 --auto-detect -P || \ echo failed to retrieve images, make sure camera is connected and in PTP mode && false pics/.renamed: pics/AUTPRINT.MRK rename JPG jpg pics/* gqview pics touch $@ pics/INDEX: pics/.renamed report-pics.pl > $@ pics.tex: $(wildcard pics/*.jpg) pics/.renamed @echo "Creating $@" report-pics.pl > $@ pics.pdf: pics.tex pdftex $< # ============================================================================= # # upload report and pictures to web and gateDB # # ============================================================================= WEBDIR=/var/www/html/reports web: $(WEBDIR)/SM-$(SM_FULL)-L$(LAYER)-report.pdf \ $(WEBDIR)/SM-$(SM_FULL)-L$(LAYER)-pics.pdf $(WEBDIR)/SM-$(SM_FULL)-L$(LAYER)-%: % cp $< $@ upload: report.pdf pics.pdf upload-report.pl $(SM) $(LAYER) report.pdf pics.pdf # ============================================================================= # # Debugging stuff: show variables... # # ============================================================================= vars: @echo "SM: $(SM_ROMAN) ($(SM))" @echo "Layer: $(LAYER)" @echo "SM_FULL: $(SM_FULL)" @echo "Pics: $(PICS)" clean: rm -f $(REPORTS) rm -f report.pdf