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.