📄 ac_dacard.cpp
字号:
// ac_dacard.cpp : Defines the entry point for the console application.
//
#include "Stdafx.h"
#include "stdio.h"
#include <conio.h>
#include "windows.h" // 应加入的头文件
#include "winioctl.h" // 应加入的头文件
#include <conio.h>
#include <stdlib.h>
#include <winbase.h>
#include "..\include\io_nt.h" //通用IO---在程序头部加入
#include "ac_dacard.h" //AC4165专用API----在程序头部加入
HINSTANCE hDLL; //DLL句柄
HANDLE NTportio=NULL; //NT IO驱动 句柄--->暂定为全局变量,自定义时,可以自己传递参数
const int BaseACDA=0x310;
int k;
int main(int argc, char* argv[])
{
char *dll_name="aciont.dll";//动态连接库名
hDLL=LoadLibrary(dll_name); //调入DLL ,动态调用
if(hDLL!=NULL){
if((int)hDLL<31){
printf("%s未找到!", dll_name);
}else{
printf("%s已调入。", dll_name);
#include "..\include\io_nt_func.h" //通用IO---在程序头部加入
#include "ac_dacard_func.h"
//-----------------------------------------------------------------
if(AC_OpenDriver==NULL){
printf("\nAC_OpenDriver函数不存在!");
}else{
printf("\nAC_OpenDriver函数存在。");
NTportio=AC_OpenDriver(); //获取IO驱动句柄
if(NTportio==NULL)
{
printf("Drivers is not exist!!!\n");//未成功加载驱动
getch();
FreeLibrary(hDLL);//清DLL句柄
exit(0);//退出
}
if(AC_Version==NULL){
printf("\nAC_Version函数不存在!");
}else{
printf("\nAC_Version函数存在。");
char Version[100];
AC_Version(NTportio, Version);
printf("%s\n",Version);
}
if( AC1343_SetDAData==NULL||AC1344_SetDAData==NULL||
AC1331_SetDAData==NULL||AC1331_EnableDAOut==NULL||
AC1356_SetDAData==NULL||AC1356_EnableDAOut==NULL||
AC1357_SetDAData==NULL||AC1357_EnableDAOut==NULL||
AC1360_SetDAData==NULL||AC1360_EnableDAOut==NULL
)
{
printf("\nAC_DA函数不存在!");
}else
{
printf("\nAC_DA函数存在。\n");
int hh;
//-----1343/44-DA test------------------
for(hh=8;hh<16;hh++){
AC1344_SetDAData(NTportio, BaseACDA, hh, 0x0);
getch();
AC1344_SetDAData(NTportio, BaseACDA, hh, 0x80);
getch();
AC1344_SetDAData(NTportio, BaseACDA, hh, 0xff);
getch();
}
//-------1331-------
for(hh=0;hh<4;hh++){
AC1331_SetDAData(NTportio, BaseACDA, hh, 0);
AC1331_EnableDAOut(NTportio, BaseACDA);
getch();
AC1331_SetDAData(NTportio, BaseACDA, hh, 0x800);
AC1331_EnableDAOut(NTportio, BaseACDA);
getch();
AC1331_SetDAData(NTportio, BaseACDA, hh, 0xfff);
AC1331_EnableDAOut(NTportio, BaseACDA);
getch();
}
//-------1356-------
for(hh=0;hh<8;hh++){
AC1356_SetDAData(NTportio, BaseACDA, hh, 0);
AC1356_EnableDAOut(NTportio, BaseACDA);
getch();
AC1356_SetDAData(NTportio, BaseACDA, hh, 0x800);
AC1356_EnableDAOut(NTportio, BaseACDA);
getch();
AC1356_SetDAData(NTportio, BaseACDA, hh, 0xfff);
AC1356_EnableDAOut(NTportio, BaseACDA);
getch();
}
//-------1357-------
for(hh=0;hh<8;hh++){
AC1357_SetDAData(NTportio, BaseACDA, hh, 0);
AC1357_EnableDAOut(NTportio, BaseACDA);
getch();
AC1357_SetDAData(NTportio, BaseACDA, hh, 0x800);
AC1357_EnableDAOut(NTportio, BaseACDA);
getch();
AC1357_SetDAData(NTportio, BaseACDA, hh, 0xfff);
AC1357_EnableDAOut(NTportio, BaseACDA);
getch();
}
//-------1360-------
for(hh=0;hh<8;hh++){
AC1360_SetDAData(NTportio, BaseACDA, hh, 0);
AC1360_EnableDAOut(NTportio, BaseACDA);
getch();
AC1360_SetDAData(NTportio, BaseACDA, hh, 0x800);
AC1360_EnableDAOut(NTportio, BaseACDA);
getch();
AC1360_SetDAData(NTportio, BaseACDA, hh, 0xfff);
AC1360_EnableDAOut(NTportio, BaseACDA);
getch();
}
}
//关闭驱动程序
if(AC_CloseDriver==NULL){
printf("AC_CloseDriver函数不存在!");
}else{
printf("\nAC_CloseDriver函数存在。");
AC_CloseDriver(NTportio);
}
}
FreeLibrary(hDLL);//清DLL
}
}
getch();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -