Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Modify Demo Tests for Your Adaptor

This topic describes how to copy demo adaptor tests and modify them for use with your own adaptor. The steps below assume you have an adaptor called MyAdaptor, as created in the example of Create Your Adaptor from the Demo Adaptor.

  1. Copy matlabroot\toolbox\daq\daqsdk\tests to C:\adaptors\daqsdk\tests

  2. In a file browser, navigate to the SDK tests package folder C:\adaptors\daqsdk\tests\+daq\+sdk.

  3. Rename the folder +tests to +mytests.

    The next steps require you to edit and save your test files. You can use the MATLAB® editor, or any editor of your choice. Because the tests are MATLAB files, using the MATLAB editor is recommended for debugging purposes.

  4. Navigate to C:\adaptors\daqsdk\tests\+daq\+sdk\+mytests, and open the file hardwareconfiguration.m. In MATLAB you can navigate to its folder and open the editor:

    cd ('C:\adaptors\daqsdk\tests\+daq\+sdk\+mytests')
    edit hardwareconfiguration

    Change the vendor and device parameters in this manner, using your own names.

    Original TextUpdated Text
    % HardwareInfo
      VendorName = 'mw';
      VendorFullName = 'MathWorks';
    
      DeviceID1 = 'MWDev0';
      DeviceID2 = 'MWDev1';
      DeviceID3 = 'MWDev2';
    
    % HardwareInfo
      VendorName = 'my';
      VendorFullName = 'MyAdaptor';
    
      DeviceID1 = 'MyDev0';
      DeviceID2 = 'MyDev1';
      DeviceID3 = 'MyDev2';
    
  5. Save and close the file.

    The updated vendor information now allows your tests to run on your adaptor.

  6. Modify all files in C:\adaptors\daqsdk\tests\+daq\+sdk\+mytests\+workflow\ so that all lines use mytests instead of tests. For example,

    classdef tbackground < daq.sdk.mytests.workflow.BaseDAQSessionWorkflowTester
  7. Restart MATLAB. Use the following commands to add your adaptor and tests to the command path.

    addpath 'C:\adaptors\daqsdk\bin\win64'
    addpath 'C:\adaptors\daqsdk'
    addpath 'C:\adaptors\daqsdk\tests'

    Run the test for single scan inputs.

    t = daq.sdk.mytests.workflow.tinputsinglescan;
    results = run(t);
    table(results)
    Running daq.sdk.mytests.workflow.tinputsinglescan
    ..
    Done daq.sdk.mytests.workflow.tinputsinglescan
    __________
    
    
    ans =
    
      2×6 table
    
                                        Name                                     Passed    Failed    Incomplete    Duration      Details   
        _____________________________________________________________________    ______    ______    __________    ________    ____________
    
        'daq.sdk.mytests.workflow.tinputsinglescan/verifyInputSingleScan'        true      false     false          1.692      [1×1 struct]
        'daq.sdk.mytests.workflow.tinputsinglescan/verifyInputSingleScanLoop'    true      false     false         1.2947      [1×1 struct]
    
  8. For streaming tests, there are three files to modify in the folder C:\adaptors\daqsdk\tests\+daq\+sdk\+mytests\+development\+streaming.

    Modify tstreambasic.m using your own vendor and device information, as follows:

    Original TextUpdated Text
    properties(TestParameter)
            VendorName = {'mw'}; % Add vendor adaptor name here.
            DeviceID = {'MWDev1'}; % Add device IDs you wish to test here.
        end
    properties(TestParameter)
            VendorName = {'my'}; % Add vendor adaptor name here.
            DeviceID = {'MyDev1'}; % Add device IDs you wish to test here.
        end

    Modify both tstreamread.m and tstreamwrite.m using your own adaptor information, as follows:

    Original TextUpdated Text
    properties (ClassSetupParameter)
        adaptorName = {'DemoAdaptor'}
    end
    properties (ClassSetupParameter)
        adaptorName = {'MyAdaptor'}
    end
    adaptorPath = fullfile(matlabroot, ...
    'toolbox','daq','daqsdk','bin',computer('arch'));
    
    adaptorPath = 'c:\adaptors\daqsdk\bin\win64';
    
  9. You can now run any of the streaming tests on your adaptor. For example, restart MATLAB and enter the following code:

    addpath 'C:\adaptors\daqsdk\bin\win64'
    addpath 'C:\adaptors\daqsdk'
    addpath 'C:\adaptors\daqsdk\tests'
    t = daq.sdk.mytests.development.streaming.tstreamread;
    results = run(t);
    table(results)
    Running daq.sdk.mytests.development.streaming.tstreamread
    ........
    Done daq.sdk.mytests.development.streaming.tstreamread
    __________
    
    
    ans =
    
      8×6 table
    
                                                                                  Name                                                                              Passed    Failed    Incomplete    Duration      Details   
        ________________________________________________________________________________________________________________________________________________________    ______    ______    __________    ________    ____________
    
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIFiniteRead(scanRate=value1,numOfBlocks=value1,numChannels=value1)'        true      false     false         10.698      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIFiniteRead(scanRate=value1,numOfBlocks=value1,numChannels=value2)'        true      false     false         11.543      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIFiniteRead(scanRate=value2,numOfBlocks=value1,numChannels=value1)'        true      false     false         10.124      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIFiniteRead(scanRate=value2,numOfBlocks=value1,numChannels=value2)'        true      false     false         11.087      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIContinuousRead(scanRate=value1,numOfBlocks=value1,numChannels=value1)'    true      false     false         10.159      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIContinuousRead(scanRate=value1,numOfBlocks=value1,numChannels=value2)'    true      false     false         10.568      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIContinuousRead(scanRate=value2,numOfBlocks=value1,numChannels=value1)'    true      false     false         10.079      [1×1 struct]
        'daq.sdk.mytests.development.streaming.tstreamread[adaptorName=MyAdaptor]/VerifyAIContinuousRead(scanRate=value2,numOfBlocks=value1,numChannels=value2)'    true      false     false         11.137      [1×1 struct]
    

Further Suggestions

Run Test Suites

You can run the full suite of tests for your adaptor by specifying the package folder to use all the tests contained in it.

results = runtests('daq.sdk.mytests','IncludeSubpackages',true,'Verbosity','Concise');
table(results)

Modify Functionality Tests

  • As you write your adaptor, you must modify the test files to correspond to the functionality implemented for your device. In deciding the sequence in which you implement and test functionality, consider Session Workflows with the Demo Adaptor.

  • In addition to adaptor name, you must modify where applicable the vendor name, device driver name, device names, vendor ID, etc.

See Also

Functions

Related Topics

Was this topic helpful?