Ejemplo n.º 1
0
STDMETHODIMP CLabInput::GetSingleValues(VARIANT* values)
{

    AUTO_LOCK; // Should not be needed inserted on a whim
    if (!_isConfig)
        DAQ_CHECK(Configure(FORSINGLEVALUE));
    // 3 SCANS IS THE MIN with scan_op
    SAFEARRAY *ps = SafeArrayCreateVector(VT_I2, 0, _nChannels*2);
    if (ps==NULL) return E_SAFEARRAY_ERR;

    // set the data type and values
    V_ARRAY(values)=ps;
    V_VT(values)=VT_ARRAY | VT_I2;
    TSafeArrayAccess <short > binarray(values);

    if (_nChannels<=2)
    {
        for (int i=0; i<_nChannels; i++)
        {
            DAQ_CHECK(AI_Read(_id, _chanList[i], _gainList[i], &binarray[i]));
        }
    }
    else
    {
        // setup the channels to read and scan them
        DAQ_TRACE(Set_DAQ_Device_Info(_id, ND_DATA_XFER_MODE_AI, ND_INTERRUPTS));
        short *dummy=(short*)_alloca(_nChannels*sizeof(short));
        DAQ_CHECK(Lab_ISCAN_Op(_id,static_cast<i16>(_nChannels),_gainList[0],&binarray[0],
                               _nChannels, 1.0/_chanSkew,0,dummy));
    }


    return S_OK;
}
Ejemplo n.º 2
0
void main(void)
{
    /*
     * Local Variable Declarations: 
     */

    i16 iStatus = 0;
    i16 iRetVal = 0;
    i16 iDevice = 1;
    i16 iOnDevChan = 0;
    i16 iOnDevGain = 1;
    i16 iReading = 0;
    i16 iChassisID = 1;
    i16 iModuleSlot = 1;
    i16 iModuleChan = 0;
    f64 dSCXIgain = 1.0;
    f64 dTermBlockGain = 1.0;
    f64 dSCXIvoltage = 0.0;
    i16 iIgnoreWarning = 0;

    iStatus = SCXI_Load_Config(iChassisID);

    iRetVal = NIDAQErrorHandler(iStatus, "SCXI_Load_Config",
     iIgnoreWarning);

    /* Specify SCXI module and channel to sample. */

    iStatus = SCXI_Single_Chan_Setup(iChassisID, iModuleSlot,
     iModuleChan, iDevice);

    iRetVal = NIDAQErrorHandler(iStatus, "SCXI_Single_Chan_Setup",
     iIgnoreWarning);

    /* You can call SCXI_Set_Gain before AI_Read to change the gain on
     the SCXI module or SCXI channel, depending on what the module allows.
      Otherwise, SCXIgain is assumed to be 1.0. */

    /* Some modules require that you call SCXI_Get_Status after
     changing gain but before taking a reading to make sure the gain has
     switched.  The delay call below should then be replaced with
     SCXI_Get_Status. */

    iRetVal = NIDAQDelay(1.0);

    /* If you are using an SCXI-1140 module, call
     SCXI_Track_Hold_Control to put the module in 'Hold' mode at this
     point. */

    iStatus = AI_Read(iDevice, iOnDevChan, iOnDevGain, &iReading);

    iRetVal = NIDAQErrorHandler(iStatus, "AI_Read", iIgnoreWarning);
    

    /* If you are using an SCXI-1140 module, call
     SCXI_Track_Hold_Control to put the module in 'Track' mode at this
     point. */

    /* If you call SCXI_Set_Gain before AI_Read, make sure to change
     the 'dSCXIgain' in SCXI_Scale. */

    iStatus = SCXI_Scale(iChassisID, iModuleSlot, iModuleChan,
     dSCXIgain, dTermBlockGain, iDevice, iOnDevChan, iOnDevGain, 1,
     &iReading, &dSCXIvoltage);

    iRetVal = NIDAQErrorHandler(iStatus, "SCXI_Scale",
     iIgnoreWarning);

    printf(" The SCXI voltage is %lf volts.\n", dSCXIvoltage);


}