Changeset 269 for drsdaq


Ignore:
Timestamp:
07/29/10 07:32:58 (14 years ago)
Author:
ogrimm
Message:
First commit of separated Feedback program
Location:
drsdaq
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • drsdaq/DAQReadout.cc

    r254 r269  
    4747   {"update", &DAQReadout::cmd_update, false, "<sec>", "Minimum delay between updates to DIM event service"},             
    4848   {"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"},
    5549   {"help", &DAQReadout::cmd_help, false, "", "Print help"}};
    5650
     
    9690  fDefaultFrequency = atof(GetConfig("DefaultFrequency").c_str());
    9791
     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
    98101  if (fFirstSample < 0 || fFirstSample > kNumberOfBins || fSamples > kNumberOfBins) {
    99102    PrintMessage("Warning: Sample range in configuration beyond limits, setting to full range\n");
     
    140143  EventService = new DimService (SERVER_NAME"/EventData", (char *) "C", DIMEventData, 0);
    141144                                                   
    142   // Create instance of HV feedback (must be called after board detection)
    143   HVFB    = new HVFeedback(this); 
    144 
    145145  // Install DIM command (after all initialized)
    146146  Command = new DimCommand((char *) SERVER_NAME"/Command", (char *) "C", this);
     
    157157  delete EventService;  delete[] DIMEventData;
    158158  delete RHeader;               delete EHeader;
    159   delete HVFB;                  delete[] ACalibTemp;
     159  delete[] ACalibTemp;
    160160  delete[] ACalib;              delete[] TCalib;
    161161  delete[] DRSFreq;     delete[] BStruct;
     
    220220// Print DAQ configuration
    221221void 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);
    223234}
    224235
     
    755766}
    756767
    757 // Set/get mode of feedback
    758 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 events
    767 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 gain
    776 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 value
    783 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 measurement
    797 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 configuration
    805 void DAQReadout::cmd_fconfig() {
    806 
    807   HVFB->PrintConfig();
    808 }
    809768
    810769// ----------------------------------------------
     
    11561115}
    11571116
    1158 // Print configuration to target
    1159 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 
    11681117// Print usage text for command
    11691118void DAQReadout::PrintUsage() {
     
    12491198  int DIMSize;
    12501199
     1200  // Initialize run
    12511201  NumEvents = 0;
    12521202  FileNumber = 0;
    1253   HVFB->ClearAverages();   
     1203  DimClient::sendCommandNB("Feedback/Command", "clear");
     1204   
    12541205  gettimeofday(&StartTime, NULL);
    12551206  PrintMessage("\rStarting run #%d (%s) with %u event(s)\n", RunNumber, daq_runtype_str[daq_runtype], NumEventsRequested);
     
    13031254      }
    13041255
    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          }
    13071278
    13081279      // Call routine to update DIM service (update rate is limited)
  • drsdaq/DAQReadout.h

    r254 r269  
    99#include <ctype.h>
    1010#include <time.h>
     11#include <math.h>
    1112#include <errno.h>
    1213#include <unistd.h>
     
    1920#include "RawDataCTX.h"
    2021#include "DRS.h"
    21 #include "HVFeedback.h"
    2222
    2323#define MAX_PATH 256            // also used for filename length
     
    3838        DimService *ConsoleOut;
    3939        char *ConsoleText;
     40    int Rawfile;
    4041
    4142    void PrintUsage();
    4243        void commandHandler();
    43 
    44     int Rawfile;
    45     class HVFeedback* HVFB;
    4644
    4745    // Configuration data
     
    5351    unsigned int fSamples;
    5452    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;
    5562
    5663    state_enum   daq_state;
     
    103110    void cmd_disk();       void cmd_uptime();
    104111     
    105     void cmd_fmode();      void cmd_faverage();
    106     void cmd_ftarget();    void cmd_fgain();
    107     void cmd_fresponse();  void cmd_fconfig();
    108 
    109112    void Execute(char*); 
    110113    void StartDRS();
     
    121124    bool ReadCalibration();
    122125    void ReadCalibratedDRSData();
    123     void PrintConfig();
    124126    void PrintMessage(const char*, ...);
    125127    bool OpenRawFile();
  • drsdaq/History.txt

    r254 r269  
    686818/5/2010       Rate of event service adjustable with command 'update'.
    696921/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().
     7020/7/2010       Replaced mutex with Lock()/Unlock() from Evidence class, introduced DIM
     71                        feedback state service, streamlined PrintMessage().
     7227/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  
    1010CC      = g++           # Compiler to use
    1111
    12 SOURCES = HVFeedback.cc DAQReadout.cc RawDataCTX.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc
     12SOURCES = DAQReadout.cc RawDataCTX.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc
    1313OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
    1414INCDIRS   = -I. -IDRS -I../pixelmap -I../Evidence -I$(DIMDIR)/dim
  • drsdaq/drsdaq.cpp

    r254 r269  
    1919
    2020#include "DAQReadout.h"
    21 #include "HVFeedback.h"
    2221
    2322// Function prototypes
Note: See TracChangeset for help on using the changeset viewer.