STDMETHODIMP Session::COMGETTER(Console)(IConsole **aConsole) { CheckComArgOutPointerValid(aConsole); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); CHECK_OPEN(); HRESULT rc; if (mConsole) rc = mConsole.queryInterfaceTo(aConsole); else rc = mRemoteConsole.queryInterfaceTo(aConsole); if (FAILED(rc)) { /** @todo VBox 3.3: replace E_FAIL with rc here. */ if (mConsole) setError(E_FAIL, tr("Failed to query the console (%Rhrc)"), rc); else if (FAILED_DEAD_INTERFACE(rc)) setError(E_FAIL, tr("Peer process crashed")); else setError(E_FAIL, tr("Failed to query the remote console (%Rhrc)"), rc); } return rc; }
STDMETHODIMP Session::COMGETTER(Machine)(IMachine **aMachine) { CheckComArgOutPointerValid(aMachine); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); CHECK_OPEN(); HRESULT rc; #ifndef VBOX_COM_INPROC_API_CLIENT if (mConsole) rc = mConsole->machine().queryInterfaceTo(aMachine); else #endif rc = mRemoteMachine.queryInterfaceTo(aMachine); if (FAILED(rc)) { /** @todo VBox 3.3: replace E_FAIL with rc here. */ #ifndef VBOX_COM_INPROC_API_CLIENT if (mConsole) setError(E_FAIL, tr("Failed to query the session machine (%Rhrc)"), rc); else #endif if (FAILED_DEAD_INTERFACE(rc)) setError(E_FAIL, tr("Peer process crashed")); else setError(E_FAIL, tr("Failed to query the remote session machine (%Rhrc)"), rc); } return rc; }
/** * Retrieves information about a file. * * @param camera a #Camera * @param folder a folder * @param file the name of the file * @param info * @param context a #GPContext * @return a gphoto2 error code * **/ int gp_camera_file_get_info (Camera *camera, const char *folder, const char *file, CameraFileInfo *info, GPContext *context) { int result = GP_OK; const char *mime_type; const char *data; /* long int size; */ CameraFile *cfile; gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Getting file info for '%s' " "in '%s'...", file, folder); CHECK_NULL (camera && folder && file && info); CHECK_INIT (camera, context); memset (info, 0, sizeof (CameraFileInfo)); /* Check first if the camera driver supports the filesystem */ CHECK_OPEN (camera, context); result = gp_filesystem_get_info (camera->fs, folder, file, info, context); CHECK_CLOSE (camera, context); if (result != GP_ERROR_NOT_SUPPORTED) { CAMERA_UNUSED (camera, context); return (result); } /* * The CameraFilesystem doesn't support file info. We simply get * the preview and the file and look for ourselves... */ /* It takes too long to get the file */ info->file.fields = GP_FILE_INFO_NONE; /* Get the preview */ info->preview.fields = GP_FILE_INFO_NONE; CRS (camera, gp_file_new (&cfile), context); if (gp_camera_file_get (camera, folder, file, GP_FILE_TYPE_PREVIEW, cfile, context) == GP_OK) { unsigned long size; info->preview.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE; gp_file_get_data_and_size (cfile, &data, &size); info->preview.size = size; gp_file_get_mime_type (cfile, &mime_type); strncpy (info->preview.type, mime_type, sizeof (info->preview.type)); } gp_file_unref (cfile); /* We don't trust the camera libraries */ info->file.fields |= GP_FILE_INFO_NAME; strncpy (info->file.name, file, sizeof (info->file.name)); info->preview.fields &= ~GP_FILE_INFO_NAME; CAMERA_UNUSED (camera, context); return (GP_OK); }
/* close communication with mainframe under logical number 'id' and stop thread */ int sy527Stop(unsigned id) { char name[MAX_NAME]; int i, j, ret; /* lock global mutex to prevent other mainframes to be stoped until we are done with this one */ LOCK_GLOBAL; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Measure[id]->name); /* stop thread */ force_exit[id] = 1; ret = CAENHVDeinitSystem(name); if(ret == CAENHV_OK) { printf("\nConnection >%s< closed (num. %d)\n\n", name,ret); Measure[id]->id = -1; } else { printf("\nERROR(sy527): %s (num. %d)\n\n", CAENHVGetError(name), ret); UNLOCK_GLOBAL; return(CAENHV_SYSERR); } /* unregister mainframe */ j = -1; for(i=0; i<nmainframes; i++) { if(mainframes[i] == id) { j = i; break; } } if(j==-1) { printf("ERROR: mainframe %d was not registered\n",id); UNLOCK_GLOBAL; return(CAENHV_SYSERR); } for(i=j; i<nmainframes; i++) mainframes[i] = mainframes[i+1]; nmainframes --; UNLOCK_GLOBAL; return(CAENHV_OK); }
STDMETHODIMP Session::UnlockMachine() { LogFlowThisFunc(("mState=%d, mType=%d\n", mState, mType)); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* close() needs write lock */ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); CHECK_OPEN(); return unlockMachine(false /* aFinalRelease */, false /* aFromServer */); }
STDMETHODIMP Session::COMGETTER(Type)(SessionType_T *aType) { CheckComArgOutPointerValid(aType); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); CHECK_OPEN(); *aType = mType; return S_OK; }
int sy1527PrintMap(unsigned int id) { int i, j; CHECK_ID(id); CHECK_OPEN(id); printf("\n\nMAP for mainframe %d, nslots=%d\n\n",id,Measure[id].nslots); for(i=0; i<Measure[id].nslots; i++) { if(Measure[id].board[i].nchannels == 0) { printf("Board %2d: Not Present\n", i); } else { printf("Board %2d: %s %s Nr. Ch: %d Ser. %d Rel. %d.%d\n", i, Measure[id].board[i].modelname, Measure[id].board[i].description, Measure[id].board[i].nchannels, Measure[id].board[i].sernum, Measure[id].board[i].relmax, Measure[id].board[i].relmin); printf(" nparams = %d\n",Measure[id].board[i].nparams); for(j=0; j<Measure[id].board[i].nparams; j++) { printf(" >%s<\t\t%ld", Measure[id].board[i].parnames[j],Measure[id].board[i].partypes[j]); if(Measure[id].board[i].partypes[j]==PARAM_TYPE_NUMERIC) printf(" (PARAM_TYPE_NUMERIC)\n"); else if(Measure[id].board[i].partypes[j]==PARAM_TYPE_ONOFF) printf(" (PARAM_TYPE_ONOFF)\n"); else if(Measure[id].board[i].partypes[j]==PARAM_TYPE_CHSTATUS) printf(" (PARAM_TYPE_CHSTATUS)\n"); else if(Measure[id].board[i].partypes[j]==PARAM_TYPE_BDSTATUS) printf(" (PARAM_TYPE_BDSTATUS)\n"); else printf(" (? ? ? UNKNOWN ? ? ?)\n"); } } } printf("\n"); return(CAENHV_OK); }
int gp_camera_list_config (Camera *camera, CameraList *list, GPContext *context) { CameraWidget *rootwidget; int ret; C_PARAMS (camera); CHECK_INIT (camera, context); if (camera->functions->list_config) { CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->list_config ( camera, list, context), context); CAMERA_UNUSED (camera, context); return GP_OK; } if (!camera->functions->get_config) { gp_context_error (context, _("This camera does not provide any configuration options.")); CAMERA_UNUSED (camera, context); return GP_ERROR_NOT_SUPPORTED; } /* emulate it ... */ CHECK_OPEN (camera, context); ret = camera->functions->get_config ( camera, &rootwidget, context); if (ret != GP_OK) { CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; } _get_widget_names (rootwidget, list); gp_widget_free (rootwidget); CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; }
int sy1527GetMap(unsigned int id) { unsigned short NrOfSl, *SerNumList, *NrOfCh, ChList[MAX_CHAN]; char *ModelList, *DescriptionList; unsigned char *FmwRelMinList, *FmwRelMaxList; char name[MAX_CAEN_NAME]; int i, j, ret; unsigned long tipo; char ParName[MAX_CAEN_NAME]; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Measure[id].name); /* char *ParNameList, *plist; CAENHVGetChParamInfo(name,0,1,&ParNameList); plist=ParNameList; for(i=0;i<10;i++){ if(*plist == '\0'){printf("NULL %d\n",i);break;} //if(ParNameList[i]) printf("param=%s %d\n",plist, i); plist+=strlen(plist)+1; //else printf("param number %d is NULL\n", i); } */ /* char **ParNameList; CAENHVGetChParamInfo(name,1,0,ParNameList); // plist=ParNameList; for(i=0;i<10;i++){ // if(*plist == '\0'){printf("NULL %d\n",i);break;} if(ParNameList[i]) printf("param=%s %d\n",ParNameList[i], i); // plist+=strlen(plist)+1; //else printf("param number %d is NULL\n", i); } */ /* char *ParNameList, (*parnamelist)[100]; CAENHVGetChParamInfo(name,0,0,&ParNameList); parnamelist=( char (*)[100])ParNameList; int nj=0; for(nj=0;parnamelist[nj][0];nj++); printf("nj=%d\n",nj); // plist=ParNameList; // for(i=0;i<10;i++){ // if(*plist == '\0'){printf("NULL %d\n",i);break;} // if(ParNameList[i]) // printf("param=%s %d\n",ParNameList[i], i); // plist+=strlen(plist)+1; //else printf("param number %d is NULL\n", i); // } */ ret = CAENHVGetCrateMap(name, &NrOfSl, &NrOfCh, &ModelList, &DescriptionList, &SerNumList, &FmwRelMinList, &FmwRelMaxList ); if(ret != CAENHV_OK) { printf("ERROR(sy1527): %s (num. %d)\n\n", CAENHVGetError(name), ret); } else { char *m = ModelList, *d = DescriptionList; printf("Measure MAP:\n\n");// my: printf("NrofSl=%d\n",NrOfSl); // my: Measure[id].nslots = NrOfSl; printf("=========================> %d %d\n",id,Measure[id].nslots); //my: Demand[id].nslots = NrOfSl; for(i=0; i<NrOfSl; i++, m+=strlen(m)+1, d+=strlen(d)+1) { if(*m == '\0') { Measure[id].board[i].nchannels = 0; Demand[id].board[i].nchannels = 0; /*printf("Board %2d: Not Present\n", i);*/ } else { ///----------------- HV parameters finding piece ------------------- // printf("name================================================%s\n",name); int retv; retv=CAENHVGetChParamInfo(name,i,0,&g_parr); int nj=0; int ni=0; int index=0; while(1){ if(!((nj)%10)){ if((*(g_parr+nj))==0){ g_parr_index[index++]=ni; // printf("%s\n",g_parr+ni); break; } else{ if(nj!=0){ // printf("%s\n",g_parr+ni); g_parr_index[index++]=ni; ni=nj; } } } nj++; //printf("%c %d\n",*(parr+nj), *(parr+nj)); } int found=0; char tmp[PATH_MAX]; strcpy(tmp,getenv("HOME")); strcat(tmp,"/.hv_params"); if(!fp_params){ fp_params = fopen(tmp,"w+"); if(fp_params) fprintf(fp_params, "This file contains not found parameters: \n"); fflush(fp_params); } // printf("nj================================================%d i=%d retv=%d %d\n",nj, i, retv,sizeof(A1520param)); for(ni=0; ni < nA1520param; ni++){ found=0; for(nj=0;nj<index;nj++){ if(!strcmp(A1520param[ni],g_parr+g_parr_index[nj]))found=1; } if(!found){ if(fp_params) fprintf(fp_params, "parameter %s: NOT FOUND. CRATE=%s SLOT=%d \n",A1520param[ni], name, i); exit(1); } } // if(fp_params) // fprintf(fp_params, "all parameters are found in crate:%s the slot: %d\n",name, i); ///----------------- end of HV parameters finding piece ------------------- strncpy(Measure[id].board[i].modelname,m,MAX_CAEN_NAME-1); strncpy(Measure[id].board[i].description,d,MAX_CAEN_NAME-1); Measure[id].board[i].nchannels = NrOfCh[i]; Measure[id].board[i].sernum = SerNumList[i]; Measure[id].board[i].relmax = FmwRelMaxList[i]; Measure[id].board[i].relmin = FmwRelMinList[i]; strncpy(Demand[id].board[i].modelname,m,MAX_CAEN_NAME-1); strncpy(Demand[id].board[i].description,d,MAX_CAEN_NAME-1); Demand[id].board[i].nchannels = NrOfCh[i]; Demand[id].board[i].sernum = SerNumList[i]; Demand[id].board[i].relmax = FmwRelMaxList[i]; Demand[id].board[i].relmin = FmwRelMinList[i]; printf("Board %2d: %s %s Nr. Ch: %d Ser. %d Rel. %d.%d\n", i, m, d, NrOfCh[i], SerNumList[i], FmwRelMaxList[i], FmwRelMinList[i]); /* get params info */ for(j=0; j<Demand[id].board[i].nchannels; j++) ChList[j] = (unsigned short)j; if(!strcmp(Measure[id].board[i].modelname,"A1535") || !strcmp(Measure[id].board[i].modelname,"A1733") ) // my: was A1520 { printf("---> found board %s\n",Measure[id].board[i].modelname); Measure[id].board[i].nparams = nA1535param; Demand[id].board[i].nparams = nA1535param; for(j=0; j<Measure[id].board[i].nparams; j++) { strcpy(Measure[id].board[i].parnames[j],A1535param[j]); strcpy(Demand[id].board[i].parnames[j],A1535param[j]); strcpy(ParName,Measure[id].board[i].parnames[j]); ret=CAENHVGetChParamProp(name,i,ChList[0],ParName,"Type",&tipo); if(ret != CAENHV_OK) { printf("CAENHVGetChParamProp error: %s (num. %d) ParName=>%s<\n", CAENHVGetError(name),ret,ParName); Measure[id].board[i].nchannels = 0; Demand[id].board[i].nchannels = 0; return(CAENHV_SYSERR); } else { Measure[id].board[i].partypes[j] = tipo; Demand[id].board[i].partypes[j] = tipo; } } } else if( !strcmp(Measure[id].board[i].modelname,"A1520")) // my: was A1520 { printf("---> found board %s\n",Measure[id].board[i].modelname); Measure[id].board[i].nparams = nA1520param; Demand[id].board[i].nparams = nA1520param; for(j=0; j<Measure[id].board[i].nparams; j++) { strcpy(Measure[id].board[i].parnames[j],A1520param[j]); strcpy(Demand[id].board[i].parnames[j],A1520param[j]); strcpy(ParName,Measure[id].board[i].parnames[j]); ret=CAENHVGetChParamProp(name,i,ChList[0],ParName,"Type",&tipo); if(ret != CAENHV_OK) { printf("CAENHVGetChParamProp error: %s (num. %d) ParName=>%s<\n", CAENHVGetError(name),ret,ParName); Measure[id].board[i].nchannels = 0; Demand[id].board[i].nchannels = 0; return(CAENHV_SYSERR); } else { Measure[id].board[i].partypes[j] = tipo; Demand[id].board[i].partypes[j] = tipo; } } } else { printf("Unknown board =%s\n",Measure[id].board[i].modelname); Measure[id].board[i].nchannels = 0; Demand[id].board[i].nchannels = 0; } } } /*printf("\n");*/ free(SerNumList); free(ModelList); free(DescriptionList); free(FmwRelMinList); free(FmwRelMaxList); free(NrOfCh); // free(ParNameList); // my: } return(CAENHV_OK); }
int sy1527SetBoard(unsigned int id, unsigned int board) { int nXXXXXparam; char *XXXXparam[MAX_PARAM]; char name[MAX_CAEN_NAME]; int i, ipar, iparr, ret; unsigned short Slot, ChNum, ChList[MAX_CHAN], Ch; float fParVal;///, fparval[MAX_CHAN]; unsigned long tipo, lParVal;///, lparval[MAX_CHAN]; char ParName[MAX_CAEN_NAME]; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Demand[id].name); nXXXXXparam = Demand[id].board[board].nparams; for(i=0;i<nXXXXXparam;i++) XXXXparam[i]=Demand[id].board[board].parnames[i]; Slot = board; ChNum = Demand[id].board[board].nchannels; for(i = 0; i<ChNum; i++) ChList[i] = (unsigned short)i; /* loop over parameters */ for(iparr=0; iparr<nXXXXXparam; iparr++) { /* patch to make sure 'PwEn' always executed before 'Pw' */ if(iparr == Pw) ipar = PwEn; else if(iparr == PwEn) ipar = Pw; else ipar = iparr; strcpy(ParName,XXXXparam[ipar]); /* Param name */ tipo = Demand[id].board[board].partypes[ipar]; /* will be good to do it this way, but is does not work if(tipo == PARAM_TYPE_NUMERIC) { for(Ch=0; Ch<ChNum; Ch++) { fparval[Ch] = Demand[id].board[board].channel[Ch].fval[ipar]; fparval[Ch] = 1.0*Ch+1.0; printf("Value %s: %f\n",ParName,fparval[Ch]); } ret = CAENHVSetChParam(name, Slot, ParName, ChNum, ChList, fparval); } else { for(Ch=0; Ch<ChNum; Ch++) { lparval[Ch] = Demand[id].board[board].channel[Ch].lval[ipar]; printf("Value %s: %ld\n",ParName,lparval[Ch]); } ret = CAENHVSetChParam(name, Slot, ParName, ChNum, ChList, lparval); } if(ret != CAENHV_OK) { printf("CAENHVSetChParam: %s (num. %d)\n",CAENHVGetError(name),ret); return(CAENHV_SYSERR); } */ /* loop over all channels */ for(Ch=0; Ch<ChNum; Ch++) { if(Demand[id].board[board].channel[Ch].setflag[ipar] == 1) { if(tipo == PARAM_TYPE_NUMERIC) { fParVal = Demand[id].board[board].channel[Ch].fval[ipar]; /*printf("Set Value %s: %f\n",ParName,fParVal);*/ ret = CAENHVSetChParam(name, Slot, ParName, 1, &Ch, &fParVal); } else { lParVal = Demand[id].board[board].channel[Ch].lval[ipar]; /// printf("Set Value %s: %ld\n",ParName,lParVal); ret = CAENHVSetChParam(name, Slot, ParName, 1, &Ch, &lParVal); } if(ret != CAENHV_OK) { /* set was unsuccessful so return error */ printf("CAENHVSetChParam error: %s (num. %d)\n",CAENHVGetError(name),ret); return(CAENHV_SYSERR); } else { /* set was successful so cleanup setflag */ Demand[id].board[board].channel[Ch].setflag[ipar] = 0; } } } } return(CAENHV_OK); }
int sy1527GetBoard(unsigned int id, unsigned int board) { int b_status=0;/// b_status_res=0; /// my: smi int nXXXXXparam; char *XXXXparam[MAX_PARAM]; char name[MAX_CAEN_NAME]; int i, ipar, ret, i10; unsigned short Slot, ChNum, ChList[MAX_CHAN], Ch; float fParValList[MAX_CHAN]; unsigned long tipo, lParValList[MAX_CHAN]; char ParName[MAX_CAEN_NAME]; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Measure[id].name); for(i10=0;i10<nmainframes;i10++){ // my_n: hbeat if(mainframes[i10]==id)break; } nXXXXXparam = Measure[id].board[board].nparams; for(i=0;i<nXXXXXparam;i++) XXXXparam[i]=Measure[id].board[board].parnames[i]; Slot = board; ChNum = Measure[id].board[board].nchannels; for(i = 0; i<ChNum; i++) { Ch = i; ChList[i] = (unsigned short)Ch; } /* loop over parameters */ for(ipar=0; ipar<nXXXXXparam; ipar++) { strcpy(ParName,XXXXparam[ipar]); /* Param name */ tipo = Measure[id].board[board].partypes[ipar]; // if(!strcmp(ParName,"RUp"))printf("RUp type=%d %d\n",tipo,PARAM_TYPE_NUMERIC); if(tipo == PARAM_TYPE_NUMERIC) { ret = CAENHVGetChParam(name, Slot, ParName, ChNum, ChList, fParValList); //if(!strcmp(ParName,"RUp")){ printf("%s %d %d \n",name, Slot, ChNum); //printf("RUp f %f\n",fParValList[0]);} } else { ret = CAENHVGetChParam(name, Slot, ParName, ChNum, ChList, lParValList); //if(!strcmp(ParName,"RUp"))printf("RUp l %d\n", lParValList); } ///-------------- simulator ------- /** FILE *fps=fopen("/home/clasioc/flags","r"); int flags; //printf("pointer=%p\n",fps); fscanf(fps,"%d",&flags);//printf("%d\n",flags); //printf("%s\n",name); if(!strcmp(name,"B_HV009")) { ///printf("%d\n",flags); if(flags==1) { printf("==%d\n",flags); ret=4001;} } fclose(fps); */ ///-------------------------------- if(ret != CAENHV_OK) { printf("CAENHVGetChParam error: %s (num. %d) id=%d \n\n", CAENHVGetError(name), ret, id); mainframes_disconnect[i10]=1; /// my_n: hbeat /// mainframes[i10]=-1; } else { /// mainframes_disconnect[i10]=0; /// my_n: hbeat /*printf("PARAM VALUE\n");*/ if(tipo == PARAM_TYPE_NUMERIC) { for(i=0; i<ChNum; i++) { Measure[id].board[board].channel[i].fval[ipar] = fParValList[i]; /*printf("Slot: %2d Ch: %3d %s: %10.2f\n", Slot, ChList[i], ParName, fParValList[i]);*/ } } else { for(i=0; i<ChNum; i++) { Measure[id].board[board].channel[i].lval[ipar] = lParValList[i]; if(ipar==Status){ /// my: smi: accumulates all channels attuses into board status b_status = b_status | lParValList[i]; if(!(lParValList[i] & 0x1))b_status = b_status | BIT_OFF; /// at least one channel in the board is OFF } /*printf("Slot: %2d Ch: %3d %s: %x\n", Slot, ChList[i], ParName, lParValList[i]);*/ } } } } /// my:smi /* char smi_obj_name1[150]; /// temporal char smi_obj_name[150]; /// temporal char smi_command[150]; /// temporal if(b_status & BIT_ON)b_status_res=BIT_ON; if(b_status & (BIT_RAMPUP | BIT_RAMPDOWN ))b_status_res=BIT_RAMPUP; if(b_status & BIT_OFF)b_status_res=BIT_OFF; if(b_status & (BIT_INTTRIP | BIT_EXTTRIP | BIT_OVERCUR | BIT_OVERVOLT | BIT_UNDERVOLT )) b_status_res=BIT_INTTRIP; if(b_status_res==BIT_ON)strcpy(smi_command,"SET_ON"); else if(b_status_res==BIT_RAMPUP)strcpy(smi_command,"SET_ON"); /// temporal !!! else if(b_status_res==BIT_OFF)strcpy(smi_command,"SET_OFF"); else if(b_status_res==BIT_INTTRIP)strcpy(smi_command,"SET_ERROR"); if(b_status_res != boards_status[id][board]){ sprintf(smi_obj_name1, CRATE_LABEL, id); sprintf(smi_obj_name, "HV_TEST::%s_%d", smi_obj_name1, board); smiui_send_command(smi_obj_name, smi_command); printf("smi: smi_obj_name=%s smi_command=%s \n", smi_obj_name, smi_command); boards_status[id][board]=b_status_res; } */ return(CAENHV_OK); }
int sy527GetMap(unsigned int id) { unsigned short NrOfSl, *SerNumList, *NrOfCh, ChList[MAX_CHAN]; char *ModelList, *DescriptionList; unsigned char *FmwRelMinList, *FmwRelMaxList; char name[MAX_NAME]; int i, j, ret; unsigned long tipo; char ParName[MAX_NAME]; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Measure[id]->name); ret = CAENHVGetCrateMap(name, &NrOfSl, &NrOfCh, &ModelList, &DescriptionList, &SerNumList, &FmwRelMinList, &FmwRelMaxList ); if(ret != CAENHV_OK) { printf("ERROR(sy527): %s (num. %d)\n\n", CAENHVGetError(name), ret); } else { char *m = ModelList, *d = DescriptionList; /*printf("Measure MAP:\n\n");*/ Measure[id]->nslots = NrOfSl; printf("=========================> %d %d\n",id,Measure[id]->nslots); Demand[id]->nslots = NrOfSl; for(i=0; i<NrOfSl; i++, m+=strlen(m)+1, d+=strlen(d)+1) { if(*m == '\0') { Measure[id]->board[i].nchannels = 0; Demand[id]->board[i].nchannels = 0; printf("Board %2d: Not Present\n", i); } else { strncpy(Measure[id]->board[i].modelname,m,MAX_NAME-1); strncpy(Measure[id]->board[i].description,d,MAX_NAME-1); Measure[id]->board[i].nchannels = NrOfCh[i]; Measure[id]->board[i].sernum = SerNumList[i]; Measure[id]->board[i].relmax = FmwRelMaxList[i]; Measure[id]->board[i].relmin = FmwRelMinList[i]; strncpy(Demand[id]->board[i].modelname,m,MAX_NAME-1); strncpy(Demand[id]->board[i].description,d,MAX_NAME-1); Demand[id]->board[i].nchannels = NrOfCh[i]; Demand[id]->board[i].sernum = SerNumList[i]; Demand[id]->board[i].relmax = FmwRelMaxList[i]; Demand[id]->board[i].relmin = FmwRelMinList[i]; printf("Board %2d: %s %s Nr. Ch: %d Ser. %d Rel. %d.%d\n", i, m, d, NrOfCh[i], SerNumList[i], FmwRelMaxList[i], FmwRelMinList[i]); /* get params info */ for(j=0; j<Demand[id]->board[i].nchannels; j++) ChList[j] = (unsigned short)j; printf("The board is: >%s<\n",Measure[id]->board[i].modelname); if( !strcmp(Measure[id]->board[i].modelname,"A1520") ) { printf("The board %s is connecting\n",Measure[id]->board[i].modelname); Measure[id]->board[i].nparams = nA1520param; Demand[id]->board[i].nparams = nA1520param; for(j=0; j<Measure[id]->board[i].nparams; j++) { strcpy(Measure[id]->board[i].parnames[j],A1520param[j]); strcpy( Demand[id]->board[i].parnames[j],A1520param[j]); strcpy(ParName,Measure[id]->board[i].parnames[j]); ret=CAENHVGetChParamProp(name,i,ChList[0],ParName,"Type",&tipo); if(ret != CAENHV_OK) { printf("CAENHVGetChParamProp: %s (num. %d) ParName=>%s<\n", CAENHVGetError(name),ret,ParName); Measure[id]->board[i].nchannels = 0; Demand[id]->board[i].nchannels = 0; return(CAENHV_SYSERR); } else { Measure[id]->board[i].partypes[j] = tipo; Demand[id]->board[i].partypes[j] = tipo; } } } else if( !strcmp(Measure[id]->board[i].modelname,"A1533") || !strcmp(Measure[id]->board[i].modelname,"A1733") ) { printf("The board %s is connecting\n",Measure[id]->board[i].modelname); Measure[id]->board[i].nparams = nA1533_1733param; Demand[id]->board[i].nparams = nA1533_1733param; for(j=0; j<Measure[id]->board[i].nparams; j++) { strcpy(Measure[id]->board[i].parnames[j],A1533_1733param[j]); strcpy( Demand[id]->board[i].parnames[j],A1533_1733param[j]); strcpy(ParName,Measure[id]->board[i].parnames[j]); ret=CAENHVGetChParamProp(name,i,ChList[0],ParName,"Type",&tipo); if(ret != CAENHV_OK) { printf("CAENHVGetChParamProp: %s (num. %d) ParName=>%s<\n", CAENHVGetError(name),ret,ParName); Measure[id]->board[i].nchannels = 0; Demand[id]->board[i].nchannels = 0; return(CAENHV_SYSERR); } else { Measure[id]->board[i].partypes[j] = tipo; Demand[id]->board[i].partypes[j] = tipo; } } } else if( !strcmp(Measure[id]->board[i].modelname,"A944N") ) { printf("The board %s is connecting\n",Measure[id]->board[i].modelname); Measure[id]->board[i].nparams = nA944Nparam; Demand[id]->board[i].nparams = nA944Nparam; for(j=0; j<Measure[id]->board[i].nparams; j++) { strcpy(Measure[id]->board[i].parnames[j],A944Nparam[j]); strcpy( Demand[id]->board[i].parnames[j],A944Nparam[j]); strcpy(ParName,Measure[id]->board[i].parnames[j]); ret=CAENHVGetChParamProp(name,i,ChList[0],ParName,"Type",&tipo); if(ret != CAENHV_OK) { printf("CAENHVGetChParamProp: %s (num. %d) ParName=>%s<\n", CAENHVGetError(name),ret,ParName); Measure[id]->board[i].nchannels = 0; Demand[id]->board[i].nchannels = 0; return(CAENHV_SYSERR); } else { Measure[id]->board[i].partypes[j] = tipo; Demand[id]->board[i].partypes[j] = tipo; } } } else { printf("Unknown board >%s<\n",Measure[id]->board[i].modelname); Measure[id]->board[i].nchannels = 0; Demand[id]->board[i].nchannels = 0; } } } /*printf("\n");*/ free(SerNumList); free(ModelList); free(DescriptionList); free(FmwRelMinList); free(FmwRelMaxList); free(NrOfCh); } return(CAENHV_OK); }
int sy527GetBoard(unsigned int id, unsigned int board) { int nXXXXXparam; char *XXXXparam[MAX_PARAM]; char name[MAX_NAME]; int i, ipar, ret; unsigned short Slot, ChNum, ChList[MAX_CHAN], Ch; float fParValList[MAX_CHAN]; unsigned long tipo, lParValList[MAX_CHAN]; char ParName[MAX_NAME]; CHECK_ID(id); CHECK_OPEN(id); strcpy(name, Measure[id]->name); nXXXXXparam = Measure[id]->board[board].nparams; for(i=0;i<nXXXXXparam;i++) XXXXparam[i]=Measure[id]->board[board].parnames[i]; Slot = board; ChNum = Measure[id]->board[board].nchannels; for(i = 0; i<ChNum; i++) { Ch = i; ChList[i] = (unsigned short)Ch; } /* loop over parameters */ for(ipar=0; ipar<nXXXXXparam; ipar++) { strcpy(ParName,XXXXparam[ipar]); /* Param name */ tipo = Measure[id]->board[board].partypes[ipar]; #ifdef DEBUG printf("%s called ipar=%d\n",__FUNCTION__,ipar); #endif if(tipo == PARAM_TYPE_NUMERIC) { ret = CAENHVGetChParam(name, Slot, ParName, ChNum, ChList, fParValList); } else { ret = CAENHVGetChParam(name, Slot, ParName, ChNum, ChList, lParValList); } if(ret != CAENHV_OK) { printf("CAENHVGetChParam: %s (num. %d)\n\n", CAENHVGetError(name), ret); } else { /*printf("PARAM VALUE\n");*/ if(tipo == PARAM_TYPE_NUMERIC) { for(i=0; i<ChNum; i++) { Measure[id]->board[board].channel[i].fval[ipar] = fParValList[i]; #ifdef DEBUG printf("%s Slot: %2d Ch: %3d %s: %10.2f\n", __FUNCTION__, Slot, ChList[i], ParName, fParValList[i]); #endif } } else { for(i=0; i<ChNum; i++) { Measure[id]->board[board].channel[i].lval[ipar] = lParValList[i]; #ifdef DEBUG printf("%s Slot: %2d Ch: %3d %s: %lx\n", __FUNCTION__, Slot, ChList[i], ParName, lParValList[i]); #endif } } } } return(CAENHV_OK); }
/** * Retrieve a single configuration \c widget for the \c camera. * * @param camera a #Camera * @param name the name of a configuration widget * @param widget a #CameraWidget * @param context a #GPContext * @return gphoto2 error code * * This \c widget will then contain the current and the possible values and the type. * */ int gp_camera_get_single_config (Camera *camera, const char *name, CameraWidget **widget, GPContext *context) { CameraWidget *rootwidget, *child; CameraWidgetType type; const char *label; int ret, ro; C_PARAMS (camera); CHECK_INIT (camera, context); if (camera->functions->get_single_config) { CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->get_single_config ( camera, name, widget, context), context); CAMERA_UNUSED (camera, context); return GP_OK; } if (!camera->functions->get_config) { gp_context_error (context, _("This camera does not provide any configuration options.")); CAMERA_UNUSED (camera, context); return GP_ERROR_NOT_SUPPORTED; } /* emulate it ... */ CHECK_OPEN (camera, context); ret = camera->functions->get_config ( camera, &rootwidget, context); if (ret != GP_OK) { CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; } ret = gp_widget_get_child_by_name (rootwidget, name, &child); if (ret != GP_OK) { gp_widget_free (rootwidget); CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; } /* We need to duplicate the widget, as we will free the widgettree */ gp_widget_get_type (child, &type); gp_widget_get_label (child, &label); gp_widget_get_readonly (child, &ro); ret = gp_widget_new (type, label, widget); if (ret != GP_OK) goto out; gp_widget_set_name (*widget, name); gp_widget_set_readonly (*widget, ro); switch (type) { case GP_WIDGET_MENU: case GP_WIDGET_RADIO: { char *value; int i, nrofchoices; nrofchoices = gp_widget_count_choices (child); for (i = 0; i < nrofchoices; i++) { const char *choice; gp_widget_get_choice (child, i, &choice); gp_widget_add_choice (*widget, choice); } gp_widget_get_value (child, &value); gp_widget_set_value (*widget, value); break; } case GP_WIDGET_TEXT: { char *value; gp_widget_get_value (child, &value); gp_widget_set_value (*widget, value); break; } case GP_WIDGET_RANGE: { float value, rmin, rmax, rstep; gp_widget_get_range (child, &rmin, &rmax, &rstep); gp_widget_set_range (*widget, rmin, rmax, rstep); gp_widget_get_value (child, &value); gp_widget_set_value (*widget, &value); break; } case GP_WIDGET_TOGGLE: case GP_WIDGET_DATE: { int value; gp_widget_get_value (child, &value); gp_widget_set_value (*widget, &value); break; } case GP_WIDGET_BUTTON: case GP_WIDGET_SECTION: case GP_WIDGET_WINDOW: default: ret = GP_ERROR_BAD_PARAMETERS; break; } out: gp_widget_free (rootwidget); CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; }
/** * Set a single configuration \c widget for the \c camera. * * @param camera a #Camera * @param name the name of a configuration widget * @param widget a #CameraWidget * @param context a #GPContext * @return gphoto2 error code * * This \c widget contains the new value of the widget to set. * */ int gp_camera_set_single_config (Camera *camera, const char *name, CameraWidget *widget, GPContext *context) { CameraWidget *rootwidget, *child; CameraWidgetType type; int ret; C_PARAMS (camera); CHECK_INIT (camera, context); if (camera->functions->set_single_config) { CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->set_single_config ( camera, name, widget, context), context); CAMERA_UNUSED (camera, context); return GP_OK; } if (!camera->functions->set_config) { gp_context_error (context, _("This camera does not provide any configuration options.")); CAMERA_UNUSED (camera, context); return GP_ERROR_NOT_SUPPORTED; } /* emulate single config with the full tree */ CHECK_OPEN (camera, context); ret = camera->functions->get_config ( camera, &rootwidget, context); if (ret != GP_OK) { CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; } ret = gp_widget_get_child_by_name (rootwidget, name, &child); if (ret != GP_OK) { gp_widget_free (rootwidget); CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; } gp_widget_get_type (child, &type); ret = GP_OK; switch (type) { case GP_WIDGET_MENU: case GP_WIDGET_RADIO: case GP_WIDGET_TEXT: { char *value; gp_widget_get_value (widget, &value); gp_widget_set_value (child, value); break; } case GP_WIDGET_RANGE: { float value; gp_widget_get_value (widget, &value); gp_widget_set_value (child, &value); break; } case GP_WIDGET_TOGGLE: case GP_WIDGET_DATE: { int value; gp_widget_get_value (widget, &value); gp_widget_set_value (child, &value); break; } case GP_WIDGET_BUTTON: case GP_WIDGET_SECTION: case GP_WIDGET_WINDOW: default: ret = GP_ERROR_BAD_PARAMETERS; break; } gp_widget_set_changed (child, 1); if (ret == GP_OK) ret = camera->functions->set_config (camera, rootwidget, context); gp_widget_free (rootwidget); CHECK_CLOSE (camera, context); CAMERA_UNUSED (camera, context); return ret; }