Add support for the R & D data collection module in the QT Project

Source: Internet
Author: User

1. Correctly install the analyticdb module ManagementProgramAdvantech Device ManagerAnd install the driver.

  

2. ChangeC: \ Program Files \ advantech \ adsapiPATH (default installation location)Include,LibCopy folderQtUnder the project folder.

  

3.CodeAdd the header file of the function library of the wasu data collection module:

# Include "include \ driver. H"

Add the system header file:

# Include <windef. h>

# Include <stdio. h>

 

4.ProAdd the function library file of the wasu data collection module to the file.

Headers + = include/driver. h

Libs + = lib/adsapi32.lib

 

5. Basic code:

1, Open the driver

DWORD dwerrcde = drv_deviceopen (0, & ldriverhandle );

If (dwerrcde! = Success ){

Qdebug () <"dwerrcde =" <dwerrcde;

Exit (1 );

}

2, ReadIoInput number

Pt_dioreadportword m_ptdioreadportword;

Ushort m_validmask = 0;

Ushort m_divalue = 0;

M_ptdioreadportword.port = 0;

M_ptdioreadportword.validchannelmask = (ushort far *) & m_validmask;

M_ptdioreadportword.value = (ushort far *) & m_divalue;

Lresult m_errcde = drv_dioreadportword (ldriverhandle, (lpt_dioreadportword) & m_ptdioreadportword );

If (m_errcde! = Success ){

Qdebug () <"m_errcde =" <m_errcde;

Exit (1 );

}

 

3, OutputIoNumber

Pt_diowritebit ptdiowritebit;

Ptdiowritebit. Port = 0; // output port: 0

Ptdiowritebit. Bit = 0; // output channel: 0

Ptdiowritebit. State =! (Tmp_bit & current_dataout); // output state

///*

DWORD dwerrcde = drv_diowritebit (ldriverhandle, (lpt_diowritebit) & ptdiowritebit );

If (dwerrcde! = Success ){

Qdebug () <"dwerrcde =" <dwerrcde;

Exit (1 );

}//*/

4Disable the driver

DWORD dwerrcde = drv_deviceclose (& ldriverhandle );

If (dwerrcde! = Success ){

Qdebug () <"dwerrcde =" <dwerrcde;

Exit (1 );

}

5For more instructions, see the user manual and related routines.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.