Changeset 229 for hvcontrol/src
- Timestamp:
- 06/24/10 07:51:15 (15 years ago)
- Location:
- hvcontrol/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/HV.cc
r220 r229 14 14 #include "ProcessIO.h" // Must be not in HV.h to avoid problem with declaring class ProcessIO 15 15 16 using namespace std; 17 16 18 // Constructor 17 HVBoard::HVBoard(int DeviceNumber, char *DeviceName, class ProcessIO *PIO) {19 HVBoard::HVBoard(int DeviceNumber, string Name, class ProcessIO *PIO) { 18 20 19 char *Buffer;20 21 struct termios tio; 21 22 22 23 m = PIO; 23 24 24 SetTimeOut(m->fTimeOut); 25 25 BoardNumber = DeviceNumber; 26 BoardName = DeviceName; 27 26 BoardName = new char [Name.size()+1]; 27 strcpy(BoardName, Name.c_str()); 28 29 stringstream Buf; 30 Buf << setw(2) << BoardNumber; 31 string Result =Buf.str(); 32 28 33 // Create DIM services 29 if (asprintf(&Buffer, SERVER_NAME"/NAME/ID%.2d", BoardNumber) == -1) { 30 m->PrintMessage(All, "asprintf() failed for DIM service name creation\n"); 31 return; 32 } 33 Name = new DimService (Buffer, BoardName); 34 free(Buffer); 35 36 if (asprintf(&Buffer, SERVER_NAME"/VOLT/ID%.2d", BoardNumber) == -1) { 37 m->PrintMessage(All, "asprintf() failed for DIM service name creation\n"); 38 return; 39 } 40 BiasVolt = new DimService (Buffer, "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double)); 41 free(Buffer); 34 NameService = new DimService ((SERVER_NAME"/NAME/ID"+Result).c_str(), BoardName); 35 BiasVolt = new DimService ((char *) (SERVER_NAME"/VOLT/ID"+Result).c_str(), (char *) "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double)); 42 36 43 37 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = false; … … 49 43 ClearVoltageArrays(); 50 44 51 // Open device (do not warn on non-existing device) 52 if (asprintf(&Buffer, "/dev/%s",DeviceName) == -1) { 53 m->PrintMessage(All, "asprintf() failed for device name creation\n"); 54 return; 55 } 56 if ((fDescriptor = open(Buffer, O_RDWR|O_NOCTTY|O_NDELAY)) == -1) { 57 if(errno != 2) m->PrintMessage(All, "Error: Could not open device %d/%s (%s)\n", DeviceNumber,DeviceName, strerror(errno)); 58 free(Buffer); 45 if ((fDescriptor = open(("/dev/"+Name).c_str(), O_RDWR|O_NOCTTY|O_NDELAY)) == -1) { 46 if(errno != 2) m->PrintMessage(All, "Error: Could not open device %d/%s (%s)\n", DeviceNumber, Name.c_str(), strerror(errno)); 59 47 return; 60 48 } 61 free(Buffer);62 49 63 50 // Get current serial port settings … … 96 83 } 97 84 98 delete Name ;85 delete NameService; 99 86 delete BiasVolt; 87 delete[] BoardName; 100 88 } 101 89 -
hvcontrol/src/HV.h
r183 r229 8 8 #include <unistd.h> 9 9 #include <sys/ioctl.h> 10 #include <string> 10 11 11 12 #include "dis.hxx" … … 39 40 public: 40 41 41 HVBoard(int, char *, class ProcessIO *);42 HVBoard(int, std::string, class ProcessIO *); 42 43 ~HVBoard(); 43 44 … … 54 55 double HVV[NUM_CHAINS][NUM_CHANNELS]; // HV value in volts 55 56 56 DimService *Name ;57 DimService *NameService; 57 58 DimService *BiasVolt; 58 59 -
hvcontrol/src/ProcessIO.cc
r226 r229 12 12 #include "ProcessIO.h" 13 13 14 static c har* state_str[] = {"active", "stopped", "n.a."};14 static const char* state_str[] = {"active", "stopped", "n.a."}; 15 15 16 16 // Branch table for command evaluation … … 63 63 64 64 // Get configuration data 65 char *Boards = GetConfig("Boards");65 vector<string> Boards = Tokenize(GetConfig("Boards"), " \t"); 66 66 fPixMapTable = GetConfig("PixMapTable"); 67 fTimeOut = atof(GetConfig("TimeOut") );68 fStatusRefreshRate = atof(GetConfig("StatusRefreshRate") );69 DACMin = atoi(GetConfig("DACMin") );70 DACMax = atoi(GetConfig("DACMax") );71 fHVCalibOffset = atof(GetConfig("HVCalibOffset") );72 fHVCalibSlope = atof(GetConfig("HVCalibSlope") );73 fHVMaxDiff = atoi(GetConfig("HVMaxDiff") );67 fTimeOut = atof(GetConfig("TimeOut").c_str()); 68 fStatusRefreshRate = atof(GetConfig("StatusRefreshRate").c_str()); 69 DACMin = atoi(GetConfig("DACMin").c_str()); 70 DACMax = atoi(GetConfig("DACMax").c_str()); 71 fHVCalibOffset = atof(GetConfig("HVCalibOffset").c_str()); 72 fHVCalibSlope = atof(GetConfig("HVCalibSlope").c_str()); 73 fHVMaxDiff = atoi(GetConfig("HVMaxDiff").c_str()); 74 74 75 75 if (fStatusRefreshRate < MIN_RATE || fStatusRefreshRate > MAX_RATE) fStatusRefreshRate = 1; 76 76 77 77 // Open HV devices 78 fHVBoard = new HVBoard* [strlen(Boards)]; 79 char *Token = strtok(Boards, " \t"); 80 while (Token != NULL) { 81 fHVBoard[NumHVBoards] = new HVBoard(NumHVBoards, Token, this); 78 fHVBoard = new HVBoard* [Boards.size()]; 79 for (unsigned int i=0; i<Boards.size(); i++) { 80 fHVBoard[NumHVBoards] = new HVBoard(NumHVBoards, Boards[i], this); 82 81 if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { 83 PrintMessage("Synchronized and reset board %d (%s)\n", NumHVBoards,fHVBoard[NumHVBoards]->BoardName);82 PrintMessage("Synchronized and reset board %d (%s)\n", NumHVBoards, fHVBoard[NumHVBoards]->BoardName); 84 83 NumHVBoards++; 85 84 } 86 85 else { 87 PrintMessage(All, "Failed to synchronize board %d (%s)\n", NumHVBoards,fHVBoard[NumHVBoards]->BoardName);86 PrintMessage(All, "Failed to synchronize board %d (%s)\n", NumHVBoards, fHVBoard[NumHVBoards]->BoardName); 88 87 delete fHVBoard[NumHVBoards]; 89 88 } 90 Token = strtok(NULL, " \t");91 89 } 92 90 LastBoard = NumHVBoards-1; … … 199 197 200 198 PrintMessage( " Pixel map table: %s\n" 201 " %d USB devices:\n", fPixMapTable , NumHVBoards);199 " %d USB devices:\n", fPixMapTable.c_str(), NumHVBoards); 202 200 203 201 for (int i=0; i<NumHVBoards; i++) PrintMessage(" Board %d: %s\n", i, fHVBoard[i]->BoardName); -
hvcontrol/src/ProcessIO.h
r226 r229 7 7 #include <math.h> 8 8 #include <signal.h> 9 #include <string> 9 10 10 11 #define SERVER_NAME "Bias" // Name to use in DIM … … 46 47 47 48 // Configuration data 48 char *fPixMapTable;49 std::string fPixMapTable; 49 50 float fTimeOut; 50 51 float fStatusRefreshRate;
Note:
See TracChangeset
for help on using the changeset viewer.