Changeset 10118 for fact/Feedback


Ignore:
Timestamp:
01/25/11 09:47:27 (14 years ago)
Author:
ogrimm
Message:
Adapted various programs to new PixelMap class
Location:
fact/Feedback
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/Feedback/Feedback.cc

    r269 r10118  
    1010#include "Feedback.h"
    1111#include "PixelMap.h"
    12 
    13 #define PIXMAP_LOCATION "../config/PixelMap.txt"
    1412
    1513static const char* FBState_Description[] = {
     
    4240Feedback::Feedback(): EvidenceServer(SERVER_NAME) {
    4341
    44   PixMap = new PixelMap(PIXMAP_LOCATION, false);
     42  // Make RPC to get pixelmap
     43  DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
     44  RPC.setData((char *) "Misc PixelMap");
     45
     46  PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
    4547  TimeBarrier = 0;
    4648
     
    5254  fIDTable = Tokenize(GetConfig("IDTable"), " \t");
    5355  Multiplicity = new unsigned int [fIDTable.size()];
    54  
    55   multiset<string> A;
    56   char *Buf;
    57  
     56
     57  // Determine multiplicity of bias to pixel connection 
     58  std::vector<unsigned int> A;
    5859  for (unsigned int i=0; i<fIDTable.size(); i++) {
    59         if (asprintf(&Buf, "BiasID%d%d%d", PixMap->Pixel_to_HVboard(fIDTable[i]),
    60                 PixMap->Pixel_to_HVchain(fIDTable[i]), PixMap->Pixel_to_HVchannel(fIDTable[i])) == -1) Message(FATAL, "asprintf() failed");
    61         A.insert(Buf);
    62         free(Buf);
    63   }
    64  
    65   for (unsigned int i=0; i<fIDTable.size(); i++) {
    66         if (asprintf(&Buf, "BiasID%d%d%d", PixMap->Pixel_to_HVboard(fIDTable[i]),
    67                 PixMap->Pixel_to_HVchain(fIDTable[i]), PixMap->Pixel_to_HVchannel(fIDTable[i])) == -1) Message(FATAL, "asprintf() failed");
    68         Multiplicity[i] = A.count(Buf);
    69         free(Buf);
    70   }
    71 
     60        A = PixMap->HV_to_Pixel(PixMap->Pixel_to_HVcrate(atoi(fIDTable[i].c_str())), PixMap->Pixel_to_HVboard(atoi(fIDTable[i].c_str())), PixMap->Pixel_to_HVchannel(atoi(fIDTable[i].c_str())));
     61        Multiplicity[i] = A.size();
     62  }
     63 
    7264  // Initialise with zero content ???
    7365  Average    = new float [fIDTable.size()];
     
    227219  float Correction;
    228220
    229   // Refect data is feedback off or timestamp too early
     221  // Reject data if feedback off or timestamp too early
    230222  if (FBMode == Off || getCommand()->getTimestamp() < TimeBarrier) return;
    231223  TimeBarrier = 0;
     
    298290  // Send command (non-blocking since in handler thread)
    299291  if (!Cmd.str().empty()) {
    300         DimClient::sendCommandNB("Bias/Command", (char *) ("hv "+Cmd.str()).c_str());
     292        DimClient::sendCommandNB("Bias/Command", (char *) ("pixel "+Cmd.str()).c_str());
    301293  }
    302294
     
    385377  // Build command
    386378  for (unsigned int i=0; i<fIDTable.size(); i++) {
    387         Cmd << fIDTable[i] << " " << std::showpos << -U/2/Multiplicity[i] << " ";                                 
     379        Cmd << fIDTable[i] << " " << std::showpos << -U/2/Multiplicity[i] << " ";
    388380  }
    389381 
    390382  // Send command
    391383  if (!Cmd.str().empty()) {
    392         DimClient::sendCommand("Bias/Command", ("hv "+Cmd.str()).c_str());
     384        DimClient::sendCommand("Bias/Command", ("pixel "+Cmd.str()).c_str());
    393385  }
    394386
    395387  DiffVoltage = U;
    396388  SetFBMode(ResponseFirst);
    397   PrintMessage("HV Feedback: Decreasing voltages by %f for response measurement, acquiring data.\n",DiffVoltage/2);
     389  PrintMessage("Feedback: Decreasing voltages by %f for response measurement, acquiring data.\n",DiffVoltage/2);
    398390}
    399391
     
    439431void Feedback::commandHandler() {
    440432
    441   string Command = ToString("C", getCommand()->getData(), getCommand()->getSize());
     433  string Command = ToString((char *) "C", getCommand()->getData(), getCommand()->getSize());
    442434 
    443435  // Parse command into tokens
  • fact/Feedback/Makefile

    r269 r10118  
    1212
    1313CPPFLAGS = -DREVISION='"$(REVISION)"' -O3 -Wall
    14 LIBS = -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
     14LIBS = -L /usr/lib/termcap -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
    1515
    1616Feedback: $(OBJECTS)
Note: See TracChangeset for help on using the changeset viewer.