我正在使用 lazarus 和 nodave 组件,我想读取数字输入的状态,例如 I45.6 我通过以太网连接,据我所知,我有一个连接,CPU 位于插槽 3 和通信卡中是插槽 5。
为此,我正在尝试使用该GetBit
功能。
begin
IF
nodave1.GetBit(45,6)
then
showmessage('got it')
else
showmessage('not got it')
end;
但无论我做什么,我都无法得到回应。我不确定它是组件属性还是其他东西。
这里是完整的代码,组件设置 Area=daveinputs 和 protocol = protoISOTCP
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Spin,
StdCtrls, NoDaveComponent;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
NoDave1: TNoDave;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure NoDave1Connect(Sender: TObject);
procedure NoDave1Disconnect(Sender: TObject);
procedure NoDave1Read(Sender: TObject);
procedure SpinEdit1Change(Sender: TObject);
procedure SpinEdit2Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
nodave1.CPURack:=spinedit1.Value;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
nodave1.Active:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
nodave1.Disconnect;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if
nodave1.GetBit(46,5,nil,0,0)
then
showmessage('got it')
else
showmessage('dont got it')
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
nodave1.IPAddress:=edit1.text;
end;
procedure TForm1.NoDave1Connect(Sender: TObject);
begin
form1.Caption:='connected'
end;
procedure TForm1.NoDave1Disconnect(Sender: TObject);
begin
form1.caption:='disconnected';
end;
procedure TForm1.NoDave1Read(Sender: TObject);
begin
end;
procedure TForm1.SpinEdit2Change(Sender: TObject);
begin
nodave1.CPUSlot:=spinedit2.Value;
end;
end.