Changeset 100 for hvcontrol/src/HV.cc
- Timestamp:
- 08/12/09 12:15:02 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/HV.cc
r98 r100 22 22 m = PIO; 23 23 24 fTestMode = m->config->TestMode;25 fTestModeWrap = 0;26 27 24 SetTimeOut(m->config->fTimeOut); 28 25 BoardNumber = DeviceNumber; … … 34 31 LastWrapCount = -1; 35 32 36 if (fTestMode) {37 fDescriptor = 99;38 return;39 }40 41 33 ClearVoltageArrays(); 42 34 … … 78 70 // Destructor (Resetting board) 79 71 HVBoard::~HVBoard() { 80 if(fDescriptor >= 0 && !fTestMode) {72 if(fDescriptor >= 0) { 81 73 Reset(); 82 74 close(fDescriptor); … … 87 79 // Communicate: Write and read from HV Board until fTimeOut has been reached 88 80 // 89 // Returns: 0 readerror, 1 success, -1 fTimeOut exceeded81 // Returns: 0 error, 1 success, -1 fTimeOut exceeded 90 82 int HVBoard::Communicate(unsigned char* wbuf, int Bytes) { 91 83 … … 96 88 // === Write data === 97 89 if (write(fDescriptor, wbuf, Bytes) < Bytes) { 98 m->PrintMessage("Error: could not write (all) data to HV board\n");90 m->PrintMessage("Error: Could not write (all) data to HV board\n"); 99 91 return 0; 100 92 } … … 128 120 } 129 121 LastWrapCount = rbuf & 0X07; 130 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] =(rbuf & (0X08 << i));122 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = (rbuf & (0X08 << i)); 131 123 ResetButton = (bool) (rbuf & 0X80); 132 124 … … 140 132 int HVBoard::Reset() { 141 133 142 if (fTestMode) return 1;143 144 134 unsigned char wbuf[] = {REG_RESET,0,0}; 145 135 int ret; … … 153 143 int HVBoard::GetStatus() { 154 144 155 if (fTestMode) return 1;156 157 145 unsigned char wbuf[] = {REG_STATUS,0,0}; 158 146 … … 164 152 int HVBoard::SetHV(int chain, unsigned int channel, int hv) { 165 153 166 if (fTestMode){ 167 m->PrintMessage("Test mode: Nothing to be done. \n"); 168 return 1; 169 } 154 unsigned char wbuf[] = {0,0,0}; 155 int ret; 170 156 171 unsigned char wbuf[] = {0,0,0}; 172 173 if (hv > 0x3FFF) { 174 m->PrintMessage(" Error: HV beyond upper 0x3FFF\n"); 157 if (hv<0 || hv > 0x3FFF) { 158 m->PrintMessage("Error: Voltage out of range 0-0x3FFF\n"); 175 159 return 0; 176 160 } 177 if (hv<0) hv = 0;178 161 179 162 switch (chain) { … … 183 166 case 3: wbuf[0] = REG_HV3; break; 184 167 185 default : m->PrintMessage(" Error: chain %d does not exist\n",chain); return 0;168 default : m->PrintMessage(" Error: Chain %d does not exist\n",chain); return 0; 186 169 } 187 170 … … 192 175 wbuf[2] |= (unsigned char)(hv & 0X000000FF); // Add [D7-D0] 193 176 194 return Communicate(wbuf, 3); 177 if ((ret = Communicate(wbuf, 3)) == 1) HV[chain][channel] = hv; 178 return ret; 195 179 } 196 180
Note:
See TracChangeset
for help on using the changeset viewer.