Changeset 229 for hvcontrol/src/HV.cc
- Timestamp:
- 06/24/10 07:51:15 (14 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.