Beispiel #1
0
int init_caen()
{
  if (handle == -1)
  {
    // Init the system
    CAENHV_SYSTEM_TYPE_t system = DT55XX;
    int linktype = LINKTYPE_USB;
    char* arg_string = "0_0_0";
    char* username = "";
    char* password = "";

    // Connect to HV supply
    CAENHVRESULT ret = CAENHV_InitSystem( system, linktype, arg_string,
                                 username, password, &handle );
    return ret;
  }
}
void PRadHVChannel::Initialize()
{
    for(size_t i = 0; i < crateList.size(); ++i)
    {
        int err;
        char arg[32];
        strcpy(arg, crateList[i].ip.c_str());
        err = CAENHV_InitSystem(crateList[i].sysType,
                                crateList[i].linkType,
                                arg,
                                crateList[i].username.c_str(),
                                crateList[i].password.c_str(),
                                &crateList[i].handle);
        if(err == CAENHV_OK) {
            cout << "Connected to high voltage system "
                 << crateList[i].name << "@" << crateList[i].ip
                 << endl;
        }
        else {
            cerr << "Cannot connect to "
                 << crateList[i].name << "@" << crateList[i].ip
                 << endl;
            showError("HV Initialize", err);
        }

        unsigned short NbofSlot;
        unsigned short *NbofChList;
        char *modelList, *descList;
        unsigned short *serNumList;
        unsigned char *fmwMinList, *fmwMaxList;

        // looks like this function only return the first model name rather than a list
        err = CAENHV_GetCrateMap(crateList[i].handle, &NbofSlot, &NbofChList, &modelList, &descList, &serNumList, &fmwMinList, &fmwMaxList);

        char *m = modelList, *d = descList;
        if(err == CAENHV_OK) {
            for(int slot = 0; slot < NbofSlot; ++slot, m += strlen(m) + 1, d += strlen(d) + 1) {
                if(NbofChList[slot]) {
                    // HVBoardInfo newBoard({slot, NbofChList[slot], serNumList[slot], fmwMinList[slot], fmwMaxList[slot]});
                    HVBoardInfo newBoard;
                    newBoard.model = m;
                    newBoard.desc = d;
                    newBoard.slot = slot;
                    newBoard.nChan = NbofChList[slot];
                    newBoard.serNum = serNumList[slot];
                    newBoard.fmwLSB = fmwMinList[slot];
                    newBoard.fmwMSB = fmwMaxList[slot];
                    crateList[i].boardList.push_back(newBoard);
                }
            }
        }
        free(NbofChList);
        free(modelList);
        free(descList);
        free(serNumList);
        free(fmwMinList);
        free(fmwMaxList);
    }

    alive = true;
}