void* DLLEXPORT PowerMeter_Init( int hParentInstrumentHandle , ViRsrc szRsrcAddress , int *pInstrumentHandle , int *InstrumentConnectStatus , int *InstrumentChannelsQuantity ) { errEV ret = {0}; errEV *pRet = NULL; //ERRORINFO errorInfo = {0}; int hPMObject = 0; tsHandleItem *pHandle = NULL; void *pTempHandle = NULL; char *pDevName = NULL; int bGetLock = 0; *InstrumentChannelsQuantity = 0; *InstrumentConnectStatus = 0; if ( hParentInstrumentHandle == 0 ) { STD_ERR ( USB_PM_LOAD_DRIVER (NULL, 1, LOCALE_NEUTRAL, 0, &pTempHandle )); CHK_CMT( CmtNewTSV (sizeof(tsHandleItem) , &hPMObject)); CHK_CMT( CmtGetTSVPtr ( hPMObject , &pHandle )); bGetLock=1; pHandle->DriverHandle = pTempHandle; //STD_ERR ( Delay_LastComplete(0)); STD_ERR ( USB_PM_Init_PM ( pHandle->DriverHandle , NULL)); STD_ERR ( Delay_LastComplete(0)); CHK_CMT( CmtReleaseTSVPtr ( hPMObject )); bGetLock=0; } else hPMObject = hParentInstrumentHandle; CHK_CMT( CmtGetTSVPtr ( hPMObject , &pHandle )); bGetLock=1; STD_ERR ( USB_PM_GetSensorModelName ( pHandle->DriverHandle , NULL, &pDevName)); STD_ERR ( Delay_LastComplete(0)); CHK_CMT( CmtReleaseTSVPtr ( hPMObject )); bGetLock=0; if (strcmp (pDevName , SUPPORTED_DEVICE_NAME) == 0) { if ( pInstrumentHandle ) *pInstrumentHandle = hPMObject; if ( InstrumentChannelsQuantity ) *InstrumentChannelsQuantity = 1; if ( InstrumentConnectStatus ) *InstrumentConnectStatus = 1; } else if (hPMObject) PowerMeter_Close( &hPMObject ); Error: if ( hPMObject && bGetLock ) CmtReleaseTSVPtr ( hPMObject ); if (pDevName) CA_FreeMemory(pDevName); CALLOC_COPY(pRet,1,sizeof(errEV),&ret,sizeof(errEV)); return ((void*)pRet); }
int CVICALLBACK Select_ClassPath (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { size_t numelements; char **selPaths= NULL; VBOOL okPress; SAFEARRAY *absPaths= NULL; SAFEARRAY *selectedPaths= NULL; int stringlenght = 0, i; int error = 0; ERRORINFO errorInfo; ErrMsg errMsg = ""; char * myarray = NULL; CAObjHandle engine= 0; switch (event) { case EVENT_COMMIT: tsErrChk(TS_SeqContextGetEngine (seqContext, &errorInfo,&engine)); tsErrChk(TS_EngineDisplayFileDialog (engine, &errorInfo, "Select Paths", "OK", "C:", &selectedPaths, &absPaths, TS_OpenFile_SelectDirectoriesOnly|TS_OpenFile_UseAbsolutePath, "", TS_WinFileDlg_ALLOWMULTISELECT|4096, "", CA_DEFAULT_VAL, NULL, NULL, &okPress)); if(selectedPaths != NULL) { CA_SafeArrayTo1DArray (&selectedPaths, CAVT_CSTRING, &selPaths, &numelements); if (okPress) { for(i = 0; i < numelements; i++) stringlenght += strlen(selPaths[i]); myarray = (char*) malloc((stringlenght+numelements+1)*sizeof(char)); strcpy(myarray, ""); for(i = 0; i < numelements; i++) { strcat(myarray,selPaths[i]); strcat(myarray,";"); } SetCtrlVal(panelHandle, PANEL_JAVA_CLASSPATH,myarray); } } break; } Error: if(selectedPaths) CA_SafeArrayDestroy(selectedPaths); if(absPaths) CA_SafeArrayDestroy(absPaths); if(selPaths) CA_FreeMemory(selPaths); if (engine) CA_DiscardObjHandle (engine); if(myarray) free(myarray); if (error < 0) { TS_SetStepError(seqContext, error, errMsg); } return error; }