?? 9111prtg.c
字號:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <process.h>
#include "resource.h"
#include "Dask.h"
#define IDM_EXIT 110
#define IDC_SCROLL 207
#define IDC_SPIN 301
#define IDC_START 208
#define IDC_STOP 209
#define IDC_EDIT 211
#define IDC_EDIT1 214
#define IDC_EDIT2 215
#define IDC_SHOW 213
#define IDC_CH 400
int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
long PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL PASCAL ShowDMA(HWND, UINT, WPARAM, LPARAM);
HANDLE hInst;
HWND hListBox;
HWND hEdit,hEdit1, hEdit2, hStart, hStop, hValue;
BOOL bCheck[8];
U16 precheck =0;
HBRUSH hBlackBrush;
HPEN hRedPen, hBlackPen;
HWND hMainWnd;
unsigned int sample_rate=10000;
U16 channel;
BOOLEAN fstop, HalfReady;
U32 data_size=1024, mem_size;
static HANDLE hMem=NULL;
HANDLE hThread1;
I16 *ai_buf;
I16 card=-1, card_number = 0;
U32 count, postCount = 512;
BOOLEAN clear_op;
POINT input_pos[16]= {{470, 280}, {440, 280},
{410, 280}, {380, 280},
{350, 280}, {320, 280},
{ 290, 280}, {260, 280},
{230, 280}, {200, 280},
{170, 280}, {140, 280},
{110, 280}, {80, 280},
{ 50, 280}, { 20, 280},
};
POINT output_pos[16] ={
{470, 340}, {440, 340},
{410, 340}, {380, 340},
{350, 340}, {320, 340},
{ 290, 340}, {260, 340},
{230, 340}, {200, 340},
{170, 340}, {140, 340},
{110, 340}, {80, 340},
{ 50, 340}, { 20, 340},
};
POINT io_pos[16] ={
{395, 40}, {370, 40},
{345, 40}, {320, 40},
{295, 40}, {270, 40},
{ 245, 40}, {220, 40},
{195, 40}, {170, 40},
{145, 40}, {120, 40},
{95, 40}, {70, 40},
{ 45, 40}, { 20, 40},
};
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
//void ProcessThread(void* pArg);
void AI_DBCallBack();
void AI_CallBack();
int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpCmdLine;
int nCmdShow;
{
MSG msg;
if (!hPrevInstance)
if (!InitApplication(hInstance)) return(FALSE);
if (!InitInstance(hInstance, nCmdShow)) return(FALSE);
while (GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg.wParam);
}
BOOL InitApplication(hInstance)
HANDLE hInstance;
{
WNDCLASS wc;
/* Main Window Class */
wc.style = NULL;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, "MyIcon");
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "GenericWClass";
if (!RegisterClass(&wc)) return(FALSE);
}
BOOL InitInstance(hInstance, nCmdShow)
HANDLE hInstance;
int nCmdShow;
{
HWND hWnd;
HMENU hSampleMenu;
hInst = hInstance;
hSampleMenu = LoadMenu(hInstance, "U7120Menu");
hWnd = CreateWindow("GenericWClass",
(LPCSTR)"PCI-9111 Double Buffered Interrupt W/O Pre-Trigger Mode",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
520,
400,
NULL,
hSampleMenu,
hInstance,
NULL);
if (!hWnd) return(FALSE);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return(TRUE);
}
BOOL PASCAL setup(HWND hWnd, unsigned message, WPARAM wParam, LPARAM lParam)
{
int i,k;
char n[16];
char s[50];
switch (message) {
case WM_INITDIALOG:
for (i=0;i<16;i++) {
wsprintf(n, "%d", i);
_strupr(n);
SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_ADDSTRING, NULL, (LONG)(LPSTR) n);
}
SendMessage(GetDlgItem(hWnd,IDC_COMBO1) , CB_SETCURSEL, 0, 0L);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_COMBO1:
if (HIWORD(wParam) == CBN_CLOSEUP) {
i = (int)SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETCURSEL, 0, 0L);
SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETLBTEXT, i, (LPARAM)((LPCSTR)n));
card_number = i;
}
return(TRUE);
case IDC_CHECK1:
if (precheck) {
SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 0, 0);
precheck=FALSE;
}
else {
SendMessage(GetDlgItem(hWnd,wParam), BM_SETCHECK, 1, 0);
precheck=TRUE;
}
break;
case IDOK:
if(card <0) {
if ((card=Register_Card(PCI_9111DG, card_number))< 0) {
wsprintf(s, "Register_Card Error = %d\n", card);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
}
EndDialog(hWnd, TRUE);
InvalidateRect(hWnd, NULL, FALSE);
return (TRUE);
case IDCANCEL:
EndDialog(hWnd, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
long PASCAL MainWndProc(hWnd, message, wParam, lParam)
HWND hWnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
{
HDC hDC;
PAINTSTRUCT ps;
int i;
char n[6];
static int pos=0;
I16 err;
char s[50];
switch(message) {
case WM_CREATE:
DialogBox(hInst,IDD_DIALOG2, hWnd, setup);
if(card<0) {
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
hEdit=CreateWindow("EDIT", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT,
output_pos[13].x-30, input_pos[15].y+20,40, 20, hWnd, IDC_EDIT, hInst, NULL);
hEdit1=CreateWindow("EDIT", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT,
output_pos[13].x+90, input_pos[15].y+20,60, 20, hWnd, IDC_EDIT1, hInst, NULL);
if(precheck) {
hEdit2=CreateWindow("EDIT", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT,
output_pos[13].x+90, input_pos[15].y-20,60, 20, hWnd, IDC_EDIT2, hInst, NULL);
}
wsprintf(n,"%d",sample_rate/1000);
SetWindowText(hEdit,n);
wsprintf(n,"%d",data_size);
SetWindowText(hEdit1,n);
if(precheck) {
wsprintf(n,"%d", postCount);
SetWindowText(hEdit2,n);
}
CreateWindow("SCROLLBAR", NULL,
WS_CHILD | WS_VISIBLE | SBS_VERT,
output_pos[13].x+10, input_pos[15].y+20,20, 20, hWnd, IDC_SCROLL, hInst, NULL);
hStart = CreateWindow("BUTTON","Start" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+110, input_pos[10].y+10,50, 30, hWnd, IDC_START, hInst, NULL);
hStop = CreateWindow("BUTTON","Stop" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+170, input_pos[10].y+10,50, 30, hWnd, IDC_STOP, hInst, NULL);
hValue = CreateWindow("BUTTON","Data Value" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+230, input_pos[10].y+10,80, 30, hWnd, IDC_SHOW, hInst, NULL);
EnableWindow(hStop, FALSE);
CreateWindow("BUTTON","0" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP ,
output_pos[4].x+50, io_pos[0].y-5+20,25,15, hWnd,IDC_CH, hInst, NULL);
CreateWindow("BUTTON","1" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,
output_pos[4].x+50, io_pos[0].y+13+20,25,15, hWnd,IDC_CH+1, hInst, NULL);
CreateWindow("BUTTON","2" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,
output_pos[4].x+50, io_pos[0].y+31+20,25,15, hWnd,IDC_CH+2, hInst, NULL);
CreateWindow("BUTTON","3" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,
output_pos[4].x+50, io_pos[0].y+49+20,25,15, hWnd,IDC_CH+3, hInst, NULL);
CreateWindow("BUTTON","4" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,
output_pos[4].x+100, io_pos[0].y-5+20,25,15, hWnd,IDC_CH+4, hInst, NULL);
CreateWindow("BUTTON","5" ,
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,
output_pos[4].x+100, io_pos[0].y+13+20,25,15, hWnd, IDC_CH+5, hInst, NULL);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -