Changeset 230 for hvcontrol/src/HV.cc


Ignore:
Timestamp:
06/24/10 14:16:17 (14 years ago)
Author:
ogrimm
Message:
Command reception logged by drsdaq and hvcontrol
File:
1 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/src/HV.cc

    r229 r230  
    2727  strcpy(BoardName, Name.c_str());
    2828 
    29   stringstream Buf;
    30   Buf << setw(2) << BoardNumber;
    31   string Result =Buf.str();
    32 
    3329  // Create DIM services
    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));
    36 
     30  stringstream ID;
     31  ID << setfill('0') << setw(2) << BoardNumber;
     32
     33  NameService = new DimService ((SERVER_NAME"/NAME/ID"+ID.str()).c_str(), BoardName);
     34  BiasVolt = new DimService ((char *) (SERVER_NAME"/VOLT/ID"+ID.str()).c_str(), (char *) "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double));
     35
     36  // Initialise board variables
    3737  for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = false;
    3838  ResetButton = false;
     
    4343  ClearVoltageArrays();
    4444
     45  // Open device
    4546  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));
     47    if(errno != 2) m->PrintMessage("Error: Could not open device %d/%s (%s)\n", DeviceNumber, Name.c_str(), strerror(errno));
    4748    return;
    4849  }
     
    5051  // Get current serial port settings
    5152  if (tcgetattr(fDescriptor, &tio) == -1) {
    52     m->PrintMessage(All, "Error: tcgetattr() failed (%d/%s)\n", errno, strerror(errno));
     53    m->PrintMessage("Error: tcgetattr() failed (%d/%s)\n", errno, strerror(errno));
    5354    return;   
    5455  }
    5556
    5657  // Set baudrate and raw mode
    57   if (cfsetspeed(&tio, BAUDRATE) == -1) m->PrintMessage(All, "Error: Could not set baud rate (%s)\n", strerror(errno));
     58  if (cfsetspeed(&tio, BAUDRATE) == -1) m->PrintMessage("Error: Could not set baud rate (%s)\n", strerror(errno));
    5859  cfmakeraw(&tio);
    59   if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) m->PrintMessage(All, "Error: tcsetattr() failed (%s)\n", strerror(errno));
     60  if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) m->PrintMessage("Error: tcsetattr() failed (%s)\n", strerror(errno));
    6061
    6162  //  Synchronize HV board (if fails, closes device and sets fDescriptor to -2)
     
    100101  // === Write data ===
    101102  if ((ret=write(fDescriptor, wbuf, Bytes)) < Bytes) {
    102     if (ret == -1) m->PrintMessage(All, "Could not write data to HV board (%s)\n", strerror(errno));
    103     else m->PrintMessage(All, "Could write only %d of %d bytes to HV board\n", ret, Bytes);
     103    if (ret == -1) m->Message(m->ERROR, "Could not write data to HV board (%s)", strerror(errno));
     104    else m->Message(m->ERROR, "Could write only %d of %d bytes to HV board", ret, Bytes);
    104105    ErrorCount++;
    105106    return 0;
     
    110111  struct timeval WaitTime = {(long) fTimeOut, (long) ((fTimeOut-(long) fTimeOut)*1e6)};
    111112  if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) {
    112     m->PrintMessage(All, "Error with select() (%s)\n", strerror(errno));
     113    m->Message(m->ERROR, "Error with select() (%s)", strerror(errno));
    113114    return 0;
    114115  }
     
    118119  // Read error?   
    119120  if ((ret = read(fDescriptor, &rbuf, 1)) == -1) {
    120     m->PrintMessage(All, "Read error (%s)\n", strerror(errno));
     121    m->Message(m->ERROR, "Read error (%s)", strerror(errno));
    121122    ErrorCount++;
    122123    return 0;
Note: See TracChangeset for help on using the changeset viewer.