Ejemplo n.º 1
0
// id is the BoardNumber
void EnumSubsystems(short id, bool *ai, bool *ao, bool *dio)
{
    // The following information, for now, is only used to determine
    // what subsytems the HW supports.
    int ADchans;        // Number of A/D chans.
    int DAchans;        // Number of D/A chans.
    int DIOdevs;        // Number of Digital IO devices on board.

    // Determine the capability of each board, AIn, AOut, DIO
    cbGetConfig(BOARDINFO, id, 0, BINUMADCHANS, &ADchans);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (BOARDINFO,id = %d,0,BINUMADCHANS, &ADchans); result: ADchans=%d\n",id,ADchans);
    if (ADchans) *ai=true;

    cbGetConfig(BOARDINFO, id, 0, BINUMDACHANS, &DAchans);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (BOARDINFO,id = %d,0,BINUMDACHANS, &DAchans); result: DAchans=%d\n",id,DAchans);
    if (DAchans) *ao=true;
    
    cbGetConfig(BOARDINFO, id, 0, BIDINUMDEVS, &DIOdevs);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (BOARDINFO,id = %d,0,BIDINUMDEVS, &DIOdevs); result: DIOdevs=%d\n",id,DIOdevs);
    if (DIOdevs) *dio=true;
}
Ejemplo n.º 2
0
int CbDevice::LoadDeviceInfo(const TCHAR* prefix)
{  
    
    // we expect the ini file to be in the same directory as the application,
    // namely, this DLL. It's the only way to find the file if it's not
    // in the windows subdirectory

    _ASSERTE(_iniSection.length()>0);
    TCHAR keyname[64];
    strcpy(keyname,prefix);
    int clockMHz=0;
    CBI_CHECK(cbGetConfig(BOARDINFO, _BoardNum, 0, BICLOCK, &clockMHz));
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (BOARDINFO,_BoardNum = %d,0,BICLOCK, &clockMHz); result: DIOdevs=%d\n",_BoardNum,clockMHz);
    _ClockBaseFrequency=clockMHz*1e6;
    _FifoSize=GetFromIni(mkName(keyname,_T("FIFO")),0);
    _maxSampleRate = GetFromIni(mkName(keyname,_T("MaxSR")),0);
    _maxContinuousSampleRate = GetFromIni(mkName(keyname,_T("MaxContSR")),0);
    _minSampleRate = GetFromIni(mkName(keyname,_T("MinSR")),0);
    _Resolution= GetFromIni(mkName(keyname,_T("Resolution")),12);
    return S_OK;
}
Ejemplo n.º 3
0
void GetInstalledBoardInfo(short *ids, short *len)
{
    short   cnt=0;
    int     MaxBoards=0;      // Maximum number of boards UL will support.   
    char    BoardName[BOARDNAMELEN];
    _ASSERT(ids);

    cbGetConfig(GLOBALINFO,0,0,GINUMBOARDS,&MaxBoards);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (GLOBALINFO,0,0,GINUMBOARDS, &MaxBoards); result: MaxBoards=%d\n",MaxBoards);

    for (int i=0; i<MaxBoards; i++)
    {
        // Just use this call to determine if board num is valid. 
        if (!cbGetBoardName(i,BoardName))
        {
            ATLTRACE2(MCC_UL_CALL,3,"cbGetBoardName (i = %d,BoardName); result: BoardName=%s\n",i,BoardName);
            ids[cnt++]=i;
        }
    }
    *len=cnt;    
}
Ejemplo n.º 4
0
HRESULT CbRoot::SetBaseHwInfo()
{
    CComPtr<IProp> prop;        

    char tmpString[512];
    
    // we expect the ini file to be in the same directory as the application,
    // namely, this DLL. It's the only way to find the file if it's not
    // in the windows subdirectory

    if (GetModuleFileName(_Module.GetModuleInstance(), tmpString, 512)==0)
        return E_FAIL;
    // replace .dll with .ini
    strrchr(tmpString, '.' )[1]='\0';
    strcat(tmpString,"ini"); 
    _iniFileName=tmpString;


    cbGetBoardName(_BoardNum,tmpString);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetBoardName(_BoardNum = %i, tmpString); result tmpString = %s\n",_BoardNum,tmpString);
    _boardName=tmpString;
    _iniSection=_boardName;  

    CBI_CHECK(cbGetConfig(BOARDINFO, _BoardNum, 0, BIBOARDTYPE, &_BoardType));
    ATLTRACE2(MCC_UL_CALL,3,"cbGetConfig (BOARDINFO,_BoardNum = %d,0,BIBOARDTYPE, &_BoardType); result: _BoardType=%d\n",_BoardNum,_BoardType);
    long id=GetFromIni(_T("ID"),0L);
    if (id==0)
    {
        _engine->WarningMessage(CComBSTR("Board not found in mwmcc.ini file.  Board is not supported but may work.")); 
    }
    // Check to see if this is a DEMO-BOARD (code 45)
    else if (_BoardType == 45)
    {
        // Geck 224706:  When people create a DEMO-BOARD device, they probably didn't mean to.
        // Give them a warning to indicate that they might want to recosider this.
        _engine->WarningMessage(CComBSTR("The ID value selected is associated with Measurement Computing's virtual DEMO-BOARD. This virtual software device provides simulated data for demo purposes. Use a different ID if this was not your intent."));
    }
    else if (id!=_BoardType)
    {
        _engine->WarningMessage(CComBSTR("BoardType from Ini file does not match that returned from universal libray."));
        _RPT2(_CRT_WARN,"BoardType from ini file is %d board type from unilib is %d\n",id,_BoardType);
    }
    

    // device Id
    wchar_t Str[80];
    swprintf(Str, L"%d", _BoardNum);
    DEBUG_HRESULT(_DaqHwInfo->put_MemberValue(CComBSTR(L"id"), CComVariant(Str)));		
    DEBUG_HRESULT(_DaqHwInfo->put_MemberValue(CComBSTR(L"adaptorname"), CComVariant(L"mcc")));

    DEBUG_HRESULT(_DaqHwInfo->put_MemberValue(CComBSTR(L"vendordriverdescription"),
	CComVariant(L"Measurement Computing Universal Library")));
    
    
    // Get the UL Revision numbers
    float DllRevNum, DriverRevNum;
    
	cbGetRevision (&DllRevNum, &DriverRevNum);
    ATLTRACE2(MCC_UL_CALL,3,"cbGetRevision (&DllRevNum,&DriverRevNum); result: DllRevNum=%d,DriverRevNum=%d\n",DllRevNum,DriverRevNum);

	// Make a call to get the decimal (.xxx) value of the minor revision number.
	// Add this to the major revision number (y.xxx)
	DllRevNum += GetDriverMinorRevision();

	CComVariant var = DllRevNum;
	var.ChangeType(VT_BSTR);

    DEBUG_HRESULT( _DaqHwInfo->put_MemberValue(CComBSTR(L"vendordriverversion"), var));

    DEBUG_HRESULT(_DaqHwInfo->put_MemberValue(CComBSTR(L"devicename"),variant_t(_boardName)));
    
    return S_OK;
}
Ejemplo n.º 5
0
MccUSBDAQDevice::MccUSBDAQDevice(ORBManager*    orb_manager, 
							std::string    DeviceName, 
							std::string    Address, 
							unsigned short ModuleNumber,
							int boardNum_, int numADChans_) : 
STI_Device(orb_manager, DeviceName, Address, ModuleNumber), boardNum(boardNum_), numADChans(numADChans_)
{
	//constants for the usb daq physical device
    UDStat = 0;

//    DataValue = 0;
	Options = DEFAULTOPTION;
    // cbw software revision number
    RevLevel = (float)CURRENTREVNUM;

	if (driverMutex != 0)
	{
		driverMutex->lock();
		// Declare UL Revision Level 
		UDStat = cbDeclareRevision(&RevLevel);

		/* Initiate error handling
		   Parameters:
			   PRINTALL :all warnings and errors encountered will be printed
			   DONTSTOP :program will continue even if error occurs.
						 Note that STOPALL and STOPFATAL are only effective in 
						 Windows applications, not Console applications. 
	   */
		cbErrHandling (DONTPRINT, DONTSTOP); //must come before evaluating ranges

		//Set whether single-ended or differential.
		int errorCode = cbSetConfig(BOARDINFO, boardNum, 0, BINUMADCHANS, numADChans);
		//Check setting
		errorCode = cbGetConfig (BOARDINFO, boardNum, 0, BINUMADCHANS, &numADChans);

		//numADChans == 0 occurs when the usb daq is not connected. 
		if (numADChans == 0) {
			initialized = false;
			return;
		}

		//Get the number of DA outs
		cbGetConfig (BOARDINFO, boardNum, 0, BINUMDACHANS, &numDAChans);

		driverMutex->unlock();
	}

	if (numDAChans == 0) {
		initialized = false;
		return;
	}

	getChannelInfo();

	if (!availableADInRanges.empty())
		ADInRange = availableADInRanges.begin()->first;
	else
		ADInRange = BIP10VOLTS; //set it to something to avoid complaints. Will be ignored
	if (!availableDAOutRanges.empty())
		DAOutRange = availableDAOutRanges.begin()->first;
	else
		DAOutRange = UNI5VOLTS; //set it to something to avoid complaints. Will be ignored

}
Ejemplo n.º 6
0
void MainWindow::on_startButton_clicked()
{

    /* Variable Declarations */
    int BoardNum = 0;
    int ULStat = 0;
    int LowChan = 0;
    int HighChan = 2;
    int Gain = BIP10VOLTS;
    short Status = RUNNING;
    long CurCount;
    long CurIndex;
    long Rate = 100;
    Count = (HighChan+1)*1000;
    channels = HighChan-LowChan+1;
    unsigned Options;
    float revision = (float)CURRENTREVNUM;
    BOOL HighResAD = FALSE;
    int ADRes;
    SamplingThread  samplingThread;
    samplingThread.setInterval( 0.1 );

   /* Declare Revision level of the Universal Library */
    ULStat = cbDeclareRevision(&revision);

    /* Initiate error handling
        Parameters:
            PRINTALL :all warnings and errors encountered will be printed
            DONTSTOP :program will continue even if error occurs.
                     Note that STOPALL and STOPFATAL are only effective in
                     Windows applications, not Console applications.
   */
    cbErrHandling (PRINTALL, DONTSTOP);

    /* Get the resolution of A/D */
    cbGetConfig(BOARDINFO, BoardNum, 0, BIADRES, &ADRes);

    /* check If the resolution of A/D is higher than 16 bit.
       If it is, then the A/D is high resolution. */
    if(ADRes > 16)
        HighResAD = TRUE;

    /*  set aside memory to hold data */
    if(HighResAD)
    {
        MemHandle = cbWinBufAlloc32(Count);
        ADData32 = (DWORD*) MemHandle;
    }
    else
    {
        MemHandle = cbWinBufAlloc(Count);
        ADData = (WORD*) MemHandle;
    }

    /* Make sure it is a valid pointer */
    if (!MemHandle)
        exit(1); /* out of memory */
    /* set up the display screen */
    /* Demonstration of cbAInScan() */
    /* Data are being collected in the BACKGROUND, CONTINUOUSLY */

    /* Collect the values with cbAInScan() in BACKGROUND mode, CONTINUOUSLY
        Parameters:
             BoardNum    :the number used by CB.CFG to describe this board
             LowChan     :low channel of the scan
             HighChan    :high channel of the scan
             Count       :the total number of A/D samples to collect
             Rate        :sample rate in samples per second
             Gain        :the gain for the board
             ADData[]    :the array for the collected data values
             Options     :data collection options */
    Options = CONVERTDATA + BACKGROUND + CONTINUOUS;
    ULStat = cbAInScan (BoardNum, LowChan, HighChan, Count, &Rate, Gain, MemHandle, Options);

    samplingThread.start();
    d_plot->start();

    /* Your program could be doing something useful here while data are collected */

    /* During the BACKGROUND operation, check the status */
    //float EngUnits;
    //QwtSystemClock checktimer;
    //checktimer.start();
    //StoredLocation=0;
    //float v;
    while (Status==RUNNING)
    {
        qApp->processEvents();
//        // Check the status of the current background operation
//        /*Parameters:
//            BoardNum  :the number used by CB.CFG to describe this board
//            Status    :current status of the operation (IDLE or RUNNING)
//            CurCount  :current number of samples collected
//            CurIndex  :index to the last data value transferred
//            FunctionType: A/D operation (AIFUNCTIOM)*/
//        ULStat = cbGetStatus (BoardNum, &Status, &CurCount, &CurIndex,AIFUNCTION);

//        if (CurIndex==StoredLocation+1)
//        {
//            double elapsed=checktimer.elapsed();
//            elapsed=elapsed/1000;
//            int ENG = cbToEngUnits(BoardNum,BIP5VOLTS,ADData[CurIndex],&v);
//            double v_double=(double)v;
//            const QPointF s(elapsed, 1.0);
//            SignalData::instance().append( s );
//            StoredLocation=CurIndex;
//            //printf("IIndex:%d\n",CurIndex);
//            checktimer.restart();
//        }
//            //printf("OIndex:%d",CurIndex);
////        // check the current status of the background operation */

        if ((Status == RUNNING) && CurCount > 0)
        {

//          int ENG = cbToEngUnits(BoardNum,BIP5VOLTS,ADData[CurIndex],&EngUnits);
//          double v_double=static_cast<double>(EngUnits);
//            printf ("  Value: %d  ",v_double);
//            emit dataValueChanged(*EngUnits);

        }
    }




    /* Data collection terminated */

    /* The BACKGROUND operation must be explicitly stopped
        Parameters:
             BoardNum    :the number used by CB.CFG to describe this board
             FunctionType: A/D operation (AIFUNCTIOM)*/

}