⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac1080.cpp

📁 数据采集vc程序
💻 CPP
字号:
// ac1080.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 "..\include\ac1080.h"		//AC1080专用API----在程序头部加入

	HINSTANCE hDLL;     //DLL句柄
	HANDLE NTportio=NULL;  //NT IO驱动 句柄--->暂定为全局变量,自定义时,可以自己传递参数


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 "..\include\ac1080_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(	AC1080_Run==NULL||
						AC1080_SetChannel==NULL||
						AC1080_ADSampleAverage==NULL||
						AC1080_GetADData==NULL ||
						AC1080_InputIOData==NULL||
						AC1080_OutputIOData==NULL
						)
					{
						printf("\nAC1080函数不存在!");
					}else
					{
						printf("\nAC1080函数存在。");
						
						for(;;){
				printf("data=%d\n",	AC1080_ADSampleAverage(NTportio, 0x210,0,1));
					Sleep(10);
							if(kbhit() && getch()==27)break;
						}
						//此处仅是示例,与测试接头相连时测试才正常
						for(int i=0;i<256;i++){
							AC1080_OutputIOData(NTportio, 0x210, 0, i);
							AC1080_OutputIOData(NTportio, 0x210, 1, i);
						if(AC1080_InputIOData(NTportio, 0x210, 0)!=i ||
							AC1080_InputIOData(NTportio, 0x210, 1)!=i)
						{
							printf("IO Error!\n");
							break;
						}else{
							printf(".");
						}
						
						}
				
					}

			//关闭驱动程序
			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 + -