📄 9111int.c
字号:
hLTRedPen= CreatePen(PS_SOLID,1,RGB(128,128,0));
hLTGreenPen= CreatePen(PS_SOLID,1,RGB(0,128,0));
hWhitePen= CreatePen(PS_SOLID,1,RGB(255,255,255));
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
// Analog Input Box
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
Rectangle(hDC, output_pos[15].x-10, io_pos[15].y-24, output_pos[0].x+26, io_pos[0].y+195);
SetTextColor(hDC,RGB(255,255,0));
SetBkColor(hDC, RGB(0, 0, 255));
TextOut(hDC, io_pos[15].x, io_pos[15].y-35, "Interrupt Input(A/D) ", 22);
SelectObject(hDC, hBlackBrush);
Rectangle(hDC, output_pos[15].x+35, io_pos[15].y-2, output_pos[4].x+41, io_pos[0].y+172);
SelectObject(hDC,hYellowBrush );
Rectangle(hDC,output_pos[4].x+68, io_pos[0].y-5+18,output_pos[4].x+80, io_pos[0].y+10+18);
SelectObject(hDC, hGreenBrush);
Rectangle(hDC,output_pos[4].x+68, io_pos[0].y+13+18,output_pos[4].x+80, io_pos[0].y+28+18);
SelectObject(hDC, hBlueBrush);
Rectangle(hDC,output_pos[4].x+68, io_pos[0].y+31+18,output_pos[4].x+80, io_pos[0].y+46+18);
SelectObject(hDC, hRedBrush);
Rectangle(hDC,output_pos[4].x+68, io_pos[0].y+49+18,output_pos[4].x+80, io_pos[0].y+64+18);
SelectObject(hDC, hLTBlueBrush);
Rectangle(hDC,output_pos[4].x+108, io_pos[0].y-5+18,output_pos[4].x+120, io_pos[0].y+10+18);
SelectObject(hDC, hLTRedBrush);
Rectangle(hDC,output_pos[4].x+108, io_pos[0].y+13+18,output_pos[4].x+120, io_pos[0].y+28+18);
SelectObject(hDC, hLTGreenBrush);
Rectangle(hDC,output_pos[4].x+108, io_pos[0].y+31+18,output_pos[4].x+120, io_pos[0].y+46+18);
SelectObject(hDC, hWhiteBrush);
Rectangle(hDC,output_pos[4].x+108, io_pos[0].y+49+18,output_pos[4].x+120, io_pos[0].y+64+18);
SetBkMode(hDC,TRANSPARENT);
TextOut(hDC,output_pos[13].x-60, input_pos[10].y,"Samping Rate",12);
TextOut(hDC,output_pos[13].x+30, input_pos[15].y+20,"KHZ",3);
TextOut(hDC,output_pos[13].x+80, input_pos[10].y,"Channel",7);
TextOut(hDC,input_pos[2].x-10, io_pos[15].y+118,"Range: +-5V",11);
TextOut(hDC,input_pos[15].x, io_pos[15].y-19,"Volts",5);
TextOut(hDC,input_pos[15].x, io_pos[15].y-5,"5.00",4);
TextOut(hDC,input_pos[15].x, io_pos[15].y+36,"2.50",4);
TextOut(hDC,input_pos[15].x, io_pos[15].y+77,"0.00",4);
TextOut(hDC,input_pos[15].x-3, io_pos[15].y+118,"-2.50",5);
TextOut(hDC,input_pos[15].x-3, io_pos[15].y+159,"-5.00",5);
TextOut(hDC,input_pos[10].x+10, io_pos[10].y-19,"Signals",7);
TextOut(hDC,output_pos[4].x+58, io_pos[0].y-5+18,"0",1);
TextOut(hDC,output_pos[4].x+58, io_pos[0].y+13+18,"1",1);
TextOut(hDC,output_pos[4].x+58, io_pos[0].y+31+18,"2",1);
TextOut(hDC,output_pos[4].x+58, io_pos[0].y+49+18,"3",1);
TextOut(hDC,output_pos[4].x+98, io_pos[0].y-5+18,"4",1);
TextOut(hDC,output_pos[4].x+98, io_pos[0].y+13+18,"5",1);
TextOut(hDC,output_pos[4].x+98, io_pos[0].y+31+18,"6",1);
TextOut(hDC,output_pos[4].x+98, io_pos[0].y+49+18,"7",1);
//TextOut(hDC,output_pos[13].x-63, input_pos[10].y-35,"Card",4);
//TextOut(hDC,output_pos[13].x-63, input_pos[10].y-22,"Type",4);
EndPaint(hWnd, &ps);
break;
// Sample Rate Spin Control
case WM_VSCROLL:
switch(LOWORD(wParam)){
case SB_LINEUP :
sample_rate+=1000;
if (sample_rate > 100000 ) sample_rate=100000;
break;
case SB_LINEDOWN:
sample_rate-=1000;
if (sample_rate < 1000 ) sample_rate=1000;
break;
}
wsprintf(n,"%d",sample_rate/1000);
SetWindowText(hEdit,n);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDM_EXIT:
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
case IDC_SHOW :
DialogBox(hInst,
"IntBox",
hWnd,
ShowINT);
break;
case IDC_CHAN:
if (HIWORD(wParam) == CBN_CLOSEUP) {
if ((i=(int)SendMessage(GetDlgItem(hWnd,IDC_CHAN),CB_GETCURSEL, 0, 0L))>=0 ) {
channel=i;
}
}
break;
case IDC_START://采集 启动
EnableWindow (hData, FALSE);//hdata是“data value”按钮
if (hMem != NULL)
{
GlobalUnfix(hMem);
GlobalUnlock(hMem);
GlobalFree(hMem);
}
// allocate a memory for user DMA buffer
mem_size=data_size*2;
hMem = GlobalAlloc(GMEM_ZEROINIT,mem_size);
ai_buf = GlobalLock(hMem);
if (ai_buf == NULL )
{
MessageBox(hWnd,"INT",
"No Memory", MB_OK);
}
GlobalFix(hMem);
err=AI_9111_Config(card,TRIG_INT_PACER, 0, 1024);
if (err!=0) {
wsprintf(s, "AI_9111_Config error=%d", err);
MessageBox(hWnd, s, "Error", MB_OK);
}
err=AI_AsyncDblBufferMode(card, 0);
if (err!=0) {
wsprintf(s, "AI_DblBufferMode error=%d", err);
MessageBox(hWnd, s, "Error", MB_OK);
}
err=AI_ContScanChannels (card, channel, range, ai_buf, data_size, (F64)sample_rate, SYNCH_OP);
if (err!=0) {
wsprintf(s, "AI_ContReadChannel error=%d", err);
MessageBox(hWnd, s, "Error", MB_OK);
}
EnableWindow (hData, TRUE);
for (i=0;i<8;i++) oldinput[i]=-1;
hDC = GetDC(hWnd);
SelectObject(hDC, hBlackBrush);
Rectangle(hDC,output_pos[15].x+35,io_pos[0].y-3,output_pos[15].x+370,io_pos[0].y+175);
for (i=0;i<data_size;i++) {
adinput = ai_buf[i];
if (Card_Type==PCI_9111DG) cur_channel=adinput & 0x0f;
else
cur_channel= i%(channel+1);
switch(cur_channel) {
case 0:
SelectObject(hDC, hYellowPen);
break;
case 1:
SelectObject(hDC, hLTGreenPen);
break;
case 2:
SelectObject(hDC, hBluePen);
break;
case 3:
SelectObject(hDC, hRedPen);
break;
case 4:
SelectObject(hDC, hLTBluePen);
break;
case 5:
SelectObject(hDC, hLTRedPen);
break;
case 6:
SelectObject(hDC, hGreenPen);
break;
case 7:
SelectObject(hDC, hWhitePen);
break;
}
adinput = adinput >> 4;
adinput=io_pos[0].y+86-(87* (I16) adinput)/2048;
if (oldinput[cur_channel]!=-1)
MoveToEx(hDC,(i*334)/data_size+output_pos[15].x+35,oldinput[cur_channel],NULL);
else
MoveToEx(hDC,(i*334)/data_size+output_pos[15].x+35,adinput,NULL);
LineTo(hDC,(i*334)/data_size+output_pos[15].x+36,adinput);
oldinput[cur_channel]=adinput;
} // for
ReleaseDC(hWnd, hDC);
break;
default:
return(DefWindowProc(hWnd, message, wParam, lParam));
}
break;
case WM_DESTROY:
if (card >= 0) Release_Card (card);
DeleteObject(hRedBrush);
DeleteObject(hGreenBrush);
DeleteObject(hLTGreenBrush);
DeleteObject(hYellowBrush);
DeleteObject(hBlueBrush) ;
DeleteObject(hBlackBrush);
DeleteObject(hRedPen);
DeleteObject(hYellowPen);
DeleteObject(hBluePen);
DeleteObject(hGreenPen);
DeleteObject(hLTBluePen);
DeleteObject(hLTRedPen);
DeleteObject(hLTGreenPen);
DeleteObject(hWhitePen);
GlobalUnfix(hMem);
GlobalUnlock(hMem);
GlobalFree(hMem);
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, message, wParam, lParam));
}
return(NULL);
}
BOOL PASCAL ShowINT(hDlg, message, wParam, lParam)
HWND hDlg;
UINT message;
WPARAM wParam;
LPARAM lParam;
{
int nTabs[2] = {32, 92};
long i;
I16 ch_no;
char cBuf[64];
char string[10]=" ";
char data_str[3]=" ";
I16 *pp;
switch (message)
{
case WM_INITDIALOG:
hListBox = CreateWindow("LISTBOX", "Memory Count Data CH#",\
WS_CHILD | WS_VISIBLE | LBS_HASSTRINGS\
| LBS_STANDARD | LBS_USETABSTOPS |WS_CAPTION,\
50, 40, 240, 180, hDlg, 100, hInst, NULL);
SendMessage(hListBox, LB_RESETCONTENT, 0, 0L);
SendMessage(hListBox, LB_SETTABSTOPS, 2, (DWORD)\
(LPINT) nTabs);
pp=(I16 *) ai_buf;
for(i=0; i<data_size; i++) {
if (Card_Type==PCI_9111DG) {
ch_no = ai_buf[i] & 0x0f;
wsprintf(cBuf, "%5d\t %5d %2d", i, pp[i] >>4 , ch_no);
} else {
ch_no= i%(channel+1);
wsprintf(cBuf, "%5d\t %6d %2d", i, pp[i], ch_no);
}
SendMessage(hListBox, LB_INSERTSTRING, -1, (DWORD)(LPSTR)cBuf);
}
itoa(data_size, string, 10);
SetDlgItemText(hDlg, DMA_SPACE, string);
ShowWindow(hListBox, SW_SHOW);
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam) == ID_STOP)
{
DestroyWindow(hListBox);
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
} //switch
return (FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -