Changeset 269
- Timestamp:
- 07/29/10 07:32:58 (14 years ago)
- Files:
-
- 5 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DAQReadout.cc
r254 r269 47 47 {"update", &DAQReadout::cmd_update, false, "<sec>", "Minimum delay between updates to DIM event service"}, 48 48 {"exit", &DAQReadout::cmd_exit, false, "", "Exit program"}, 49 {"fmode", &DAQReadout::cmd_fmode, false, "[off|active|targ]", "Set or get feedback mode"},50 {"faverage", &DAQReadout::cmd_faverage, false, "[n]", "Set ot get number of averages for feedback"},51 {"fgain", &DAQReadout::cmd_fgain, false, "[gain]", "Set ot get feedback gain"},52 {"ftarget", &DAQReadout::cmd_ftarget, false, "[brd chip chan]", "Set or get target value (also 'all' supported)"},53 {"fresponse", &DAQReadout::cmd_fresponse, false, "[voltage]", "Start response measurement with given voltage difference"},54 {"fconfig", &DAQReadout::cmd_fconfig, false, "", "Print feedback configuration"},55 49 {"help", &DAQReadout::cmd_help, false, "", "Print help"}}; 56 50 … … 96 90 fDefaultFrequency = atof(GetConfig("DefaultFrequency").c_str()); 97 91 92 fLedTrigBoard = atoi(GetConfig("TrigBoard").c_str()); 93 fLedTrigChannel = atoi(GetConfig("TrigChannel").c_str()); 94 fLedTrigChip = atoi(GetConfig("TrigChip").c_str()); 95 fLedTrigSample = atoi(GetConfig("TrigSample").c_str()); 96 fLedTrigThreshold = atoi(GetConfig("TrigThreshold").c_str()); 97 fLedSignalSample = atoi(GetConfig("SignalSample").c_str()); 98 fLedBaselineSample = atoi(GetConfig("BaselineSample").c_str()); 99 fIntHalfWidth = atoi(GetConfig("IntHalfWidth").c_str()); 100 98 101 if (fFirstSample < 0 || fFirstSample > kNumberOfBins || fSamples > kNumberOfBins) { 99 102 PrintMessage("Warning: Sample range in configuration beyond limits, setting to full range\n"); … … 140 143 EventService = new DimService (SERVER_NAME"/EventData", (char *) "C", DIMEventData, 0); 141 144 142 // Create instance of HV feedback (must be called after board detection)143 HVFB = new HVFeedback(this);144 145 145 // Install DIM command (after all initialized) 146 146 Command = new DimCommand((char *) SERVER_NAME"/Command", (char *) "C", this); … … 157 157 delete EventService; delete[] DIMEventData; 158 158 delete RHeader; delete EHeader; 159 delete HVFB; delete[] ACalibTemp;159 delete[] ACalibTemp; 160 160 delete[] ACalib; delete[] TCalib; 161 161 delete[] DRSFreq; delete[] BStruct; … … 220 220 // Print DAQ configuration 221 221 void DAQReadout::cmd_config() { 222 PrintConfig(); 222 223 PrintMessage("RawDataPath: %s\n" 224 "DefaultFrequency: %.2f\tFirstSample: %d\tSamples: %u\n" 225 "MinDiskSpaceMB: %u\tMaxFileSizeMB: %d\n" 226 "CalibDataPath: %s\n\n" 227 "LedTrigBoard: %d\t\tLedTrigChip: %d\t\tLedTrigChannel: %d\n" 228 "LedTrigSample: %d\tLedTrigThreshold: %.2f\n" 229 "LedSignalSample: %d\tLedBaselineSample: %d\tIntHalfWidth:%u\n", 230 fRawDataPath,fDefaultFrequency,fFirstSample,fSamples,fMinDiskSpaceMB, 231 fMaxFileSizeMB,fCalibDataPath, 232 fLedTrigBoard, fLedTrigChip, fLedTrigChannel, fLedTrigSample, 233 fLedTrigThreshold, fLedSignalSample, fLedBaselineSample, fIntHalfWidth); 223 234 } 224 235 … … 755 766 } 756 767 757 // Set/get mode of feedback758 void DAQReadout::cmd_fmode() {759 760 if(Match(Param[1],"off")) HVFB->SetFBMode(FB_Off);761 else if(Match(Param[1],"active")) HVFB->SetFBMode(FB_Active);762 else if(Match(Param[1],"targets")) HVFB->SetFBMode(FB_Targets);763 else HVFB->GetFBMode();764 }765 766 // Set/get current number of events767 void DAQReadout::cmd_faverage() {768 769 if(NParam==1) PrintMessage("Current number of feedback events: %u (acting when %u events are reached)\n",770 HVFB->GetCurrentCount(), HVFB->GetNumAverages());771 else if(atoi(Param[1])>=0) HVFB->SetNumAverages(atoi(Param[1]));772 else PrintUsage();773 }774 775 // Set/get feedback gain776 void DAQReadout::cmd_fgain() {777 778 if(NParam==2) HVFB->SetGain(atof(Param[1]));779 PrintMessage("Feedback gain is %.2f\n", HVFB->GetGain());780 }781 782 // Set/get target value783 void DAQReadout::cmd_ftarget() {784 785 if(NParam==1) HVFB->GetTargets();786 else if(NParam!=5) PrintUsage();787 else for (int i=FirstBoard; i<=LastBoard; i++)788 for (int j=0; j<GetBoard(i)->GetNumberOfChips(); j++)789 for (int k=0; k<GetBoard(i)->GetNumberOfChannels(); k++)790 if ((atoi(Param[1])==i || Match(Param[1],"all")) &&791 (atoi(Param[2])==j || Match(Param[2],"all")) &&792 (atoi(Param[3])==k || Match(Param[3],"all")))793 HVFB->SetTarget(i,j,k,atof(Param[4]));794 }795 796 // Start response measurement797 void DAQReadout::cmd_fresponse() {798 799 if(NParam==1) HVFB->GetResponse();800 else if(atof(Param[1])) HVFB->MeasureResponse(atof(Param[1]));801 else PrintUsage();802 }803 804 // Print feedback configuration805 void DAQReadout::cmd_fconfig() {806 807 HVFB->PrintConfig();808 }809 768 810 769 // ---------------------------------------------- … … 1156 1115 } 1157 1116 1158 // Print configuration to target1159 void DAQReadout::PrintConfig() {1160 PrintMessage("RawDataPath: %s\n"1161 "DefaultFrequency: %.2f\tFirstSample: %d\tSamples: %u\n"1162 "MinDiskSpaceMB: %u\tMaxFileSizeMB: %d\n"1163 "CalibDataPath: %s\n",1164 fRawDataPath,fDefaultFrequency,fFirstSample,fSamples,fMinDiskSpaceMB,1165 fMaxFileSizeMB,fCalibDataPath);1166 }1167 1168 1117 // Print usage text for command 1169 1118 void DAQReadout::PrintUsage() { … … 1249 1198 int DIMSize; 1250 1199 1200 // Initialize run 1251 1201 NumEvents = 0; 1252 1202 FileNumber = 0; 1253 HVFB->ClearAverages(); 1203 DimClient::sendCommandNB("Feedback/Command", "clear"); 1204 1254 1205 gettimeofday(&StartTime, NULL); 1255 1206 PrintMessage("\rStarting run #%d (%s) with %u event(s)\n", RunNumber, daq_runtype_str[daq_runtype], NumEventsRequested); … … 1303 1254 } 1304 1255 1305 // Call feedback to process event 1306 HVFB->ProcessEvent(); 1256 // Check for LED trigger 1257 if (WaveForm[fLedTrigBoard][fLedTrigChip][fLedTrigChannel][fLedTrigSample] > fLedTrigThreshold) { 1258 std::stringstream Cmd; 1259 float Integral; 1260 1261 // Calculate feedback signal 1262 for (int i=FirstBoard; i<=LastBoard; i++) { 1263 for (unsigned int j=0; j<RHeader->NChips; j++) { 1264 for (unsigned int k=0; k<RHeader->NChannels; k++) { 1265 Integral = 0.0; 1266 for (int q=-fIntHalfWidth; q<=(int) fIntHalfWidth; q++) { 1267 Integral += (WaveForm[i][j][k][fLedSignalSample+q] - WaveForm[i][j][k][fLedBaselineSample+q])*GetBoard(i)->GetPrecision(); 1268 } 1269 Integral /= 2*fIntHalfWidth+1; 1270 Cmd << Integral << " "; 1271 } 1272 } 1273 } 1274 1275 // Send data to feedback 1276 DimClient::sendCommandNB("Feedback/Command", (char *) ("data "+Cmd.str()).c_str()); 1277 } 1307 1278 1308 1279 // Call routine to update DIM service (update rate is limited) -
drsdaq/DAQReadout.h
r254 r269 9 9 #include <ctype.h> 10 10 #include <time.h> 11 #include <math.h> 11 12 #include <errno.h> 12 13 #include <unistd.h> … … 19 20 #include "RawDataCTX.h" 20 21 #include "DRS.h" 21 #include "HVFeedback.h"22 22 23 23 #define MAX_PATH 256 // also used for filename length … … 38 38 DimService *ConsoleOut; 39 39 char *ConsoleText; 40 int Rawfile; 40 41 41 42 void PrintUsage(); 42 43 void commandHandler(); 43 44 int Rawfile;45 class HVFeedback* HVFB;46 44 47 45 // Configuration data … … 53 51 unsigned int fSamples; 54 52 double fDefaultFrequency; 53 54 int fLedTrigBoard; 55 int fLedTrigChip; 56 int fLedTrigChannel; 57 int fLedTrigSample; 58 float fLedTrigThreshold; 59 int fLedSignalSample; 60 int fLedBaselineSample; 61 unsigned int fIntHalfWidth; 55 62 56 63 state_enum daq_state; … … 103 110 void cmd_disk(); void cmd_uptime(); 104 111 105 void cmd_fmode(); void cmd_faverage();106 void cmd_ftarget(); void cmd_fgain();107 void cmd_fresponse(); void cmd_fconfig();108 109 112 void Execute(char*); 110 113 void StartDRS(); … … 121 124 bool ReadCalibration(); 122 125 void ReadCalibratedDRSData(); 123 void PrintConfig();124 126 void PrintMessage(const char*, ...); 125 127 bool OpenRawFile(); -
drsdaq/History.txt
r254 r269 68 68 18/5/2010 Rate of event service adjustable with command 'update'. 69 69 21/5/2010 Fix so that 'exit' command also works as DimCommand. 70 20/7/2010 Replaced mutex with Lock()/Unlock() from Evidence class, introduced DIM feedback state service, 71 streamlined PrintMessage(). 70 20/7/2010 Replaced mutex with Lock()/Unlock() from Evidence class, introduced DIM 71 feedback state service, streamlined PrintMessage(). 72 27/7/2010 Removed feedback from drsdaq. Feedback is now a separate DIM server and 73 invoked through a DIM command. Last revision with feedback integrated into 74 drsdaq is 264. 75 -
drsdaq/Makefile
r182 r269 10 10 CC = g++ # Compiler to use 11 11 12 SOURCES = HVFeedback.ccDAQReadout.cc RawDataCTX.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc12 SOURCES = DAQReadout.cc RawDataCTX.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc 13 13 OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 14 14 INCDIRS = -I. -IDRS -I../pixelmap -I../Evidence -I$(DIMDIR)/dim -
drsdaq/drsdaq.cpp
r254 r269 19 19 20 20 #include "DAQReadout.h" 21 #include "HVFeedback.h"22 21 23 22 // Function prototypes
Note:
See TracChangeset
for help on using the changeset viewer.