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

📄 sys.dpr

📁 Delphi编的板卡内部程序。分享给大家
💻 DPR
字号:
program Sys;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  PCI8613 in 'PCI8613.pas';

Function getch() : Integer; Stdcall; External'MSVCRT.DLL' name'_getch';
  Function kbhit() : Integer; Stdcall; External'MSVCRT.DLL' name'_kbhit';
  Function WaitForSingleObject(hHandle: LongInt; dwMilliseconds: LongWord) : LongWord; Stdcall; External'kernel32.dll' name'WaitForSingleObject';

// 获得用户选择的输入量程
Function SelectInputRange() : Integer;
var
  InputRange : LongInt;
begin
  Repeat
  Writeln('1. -5V   ~ +5V');
  Writeln('2. -2.5V ~ +2.5V');
  Writeln('Please Select Input Range[1-2]:');
  Readln(InputRange);
  until(inputRange>=1) and (InputRange<=2);   // 判断用户选择的量程是否合法,不合法,则重新选择

  SelectInputRange := InputRange;

end;

Var
  hDevice       : LongInt;                    // 设备对象句柄
  DeviceLgcID   : Integer = 0;                // 物理设备ID号(由板上JP1决定)
  nADChannel    : Integer = 0;
  bDISts        : Array [0..15] of Byte;
  bDOSts        : Array [0..15] of Byte;
  Key           : Integer;
  Label ExitRead0;
  Label ExitRead1;
  Label nextstep;
  Label Repeat1;


begin
  { TODO -oUser -cConsole Main : Insert code here }

	hDevice := PCI8613_CreateDevice(DeviceLgcID);
	if hDevice =-1 then
  begin
    Writeln('PCI8613_CreateDevice Error...');
		getch();
		Exit;                                      // 如果创建设备对象失败,则返回
  end;

	bDOSts[0] := 0;
	bDOSts[1] := 1;
	bDOSts[2] := 0;
	bDOSts[3] := 1;
	bDOSts[4] := 0;
	bDOSts[5] := 1;
	bDOSts[6] := 0;
	bDOSts[7] := 1;

  bDOSts[8] := 0;
	bDOSts[9] := 1;
	bDOSts[10] := 0;
	bDOSts[11] := 1;
	bDOSts[12] := 0;
	bDOSts[13] := 1;
	bDOSts[14] := 0;
	bDOSts[15] := 1;

Repeat1:
	Writeln('Press any key to set DO');
  writeln;

	if( PCI8613_SetDeviceDO(hDevice, @bDOSts) = false ) then // 开关量输出
  begin
    Writeln('PCI8613_SetDeviceDO Error ...');
		getch();
		goto ExitRead0;                         // 如果创建设备对象失败,则返回
  end;

	if (bDOSts[0]=1) then
  begin
    Writeln('DO0 = On');
  end
  else Writeln('DO0 = Off');

	if (bDOSts[1] =1) then
  begin
    Writeln('DO1 = On');
  end
  else Writeln('DO1 = Off');

	if (bDOSts[2] = 1) then
  begin
    Writeln('DO2 = On');
  end
  else Writeln('DO2 = Off');

	if (bDOSts[3] = 1) then
  begin
    Writeln('DO3 = On');
  end
  else Writeln('DO3 = Off');

	if (bDOSts[4] = 1) then
  begin
    Writeln('DO4 = On');
  end
  else Writeln('DO4 = Off');
	if (bDOSts[5] = 1) then
  begin
    Writeln('DO5 = On');
  end
  else Writeln('DO5 = Off');
	if (bDOSts[6] = 1) then
  begin
    Writeln('DO6 = On');
  end
  else Writeln('DO6 = Off');
	if (bDOSts[7] = 1) then
  begin
    Writeln('DO7 = On');
  end
  else Writeln('DO7 = Off');

  	if (bDOSts[8]=1) then
  begin
    Writeln('DO8 = On');
  end
  else Writeln('DO8 = Off');

	if (bDOSts[9] =1) then
  begin
    Writeln('DO9 = On');
  end
  else Writeln('DO9 = Off');

	if (bDOSts[10] = 1) then
  begin
    Writeln('DO10 = On');
  end
  else Writeln('DO10 = Off');

	if (bDOSts[11] = 1) then
  begin
    Writeln('DO11 = On');
  end
  else Writeln('DO11 = Off');

	if (bDOSts[12] = 1) then
  begin
    Writeln('DO12 = On');
  end
  else Writeln('DO12 = Off');
	if (bDOSts[13] = 1) then
  begin
    Writeln('DO13 = On');
  end
  else Writeln('DO13 = Off');
	if (bDOSts[14] = 1) then
  begin
    Writeln('DO14 = On');
  end
  else Writeln('DO14 = Off');
	if (bDOSts[15] = 1) then
  begin
    Writeln('DO15 = On');
  end
  else Writeln('DO15 = Off');

	Writeln('');
	Writeln('Press any key to get DI');

	if( PCI8613_GetDeviceDI(hDevice, @bDISts) = false) then // 开关量输入
  begin
		Writeln('PCI8613_GetDeviceDI Error...');
		getch();
		goto ExitRead0;                         // 如果创建设备对象失败,则返回
	end;
	
	if (bDISts[0] = 1) then
  begin
    Writeln('DI0 = On');
  end
  else Writeln('DI0 = Off');
	if (bDISts[1] = 1) then
  begin
    Writeln('DI1 = On');
  end
  else Writeln('DI1 = Off');
	if (bDISts[2] = 1) then
  begin
    Writeln('DI2 = On');
  end
  else Writeln('DI2 = Off');
	if (bDISts[3] = 1) then
  begin
    Writeln('DI3 = On');
  end
  else Writeln('DI3 = Off');
	if (bDISts[4] = 1) then
  begin
    Writeln('DI4 = On');
  end
  else Writeln('DI4 = Off');
	if (bDISts[5] = 1) then
  begin
    Writeln('DI5 = On');
  end
  else Writeln('DI5 = Off');
	if (bDISts[6] = 1) then
  begin
    Writeln('DI6 = On');
  end
  else Writeln('DI6 = Off');
	if (bDISts[7] = 1) then
  begin
    Writeln('DI7 = On');
  end
  else Writeln('DI7 = Off');


  if (bDISts[8] = 1) then
  begin
    Writeln('DI8 = On');
  end
  else Writeln('DI8 = Off');
	if (bDISts[9] = 1) then
  begin
    Writeln('DI9 = On');
  end
  else Writeln('DI9 = Off');
	if (bDISts[10] = 1) then
  begin
    Writeln('DI10 = On');
  end
  else Writeln('DI10 = Off');
	if (bDISts[11] = 1) then
  begin
    Writeln('DI11 = On');
  end
  else Writeln('DI11 = Off');
	if (bDISts[12] = 1) then
  begin
    Writeln('DI12 = On');
  end
  else Writeln('DI12 = Off');
	if (bDISts[13] = 1) then
  begin
    Writeln('DI13 = On');
  end
  else Writeln('DI13 = Off');
	if (bDISts[14] = 1) then
  begin
    Writeln('DI14 = On');
  end
  else Writeln('DI14 = Off');
	if (bDISts[15] = 1) then
  begin
    Writeln('DI15 = On');
  end
  else Writeln('DI15 = Off');

	Writeln('');
	Writeln('Press ESC to quit');
	Key := getch();
	if(Key <> 27) then
    goto Repeat1;

ExitRead0:
	PCI8613_ReleaseDevice(hDevice);

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -