我刚刚发现了Delphi的实时绑定.并创建了我的第一个组件来处理变频器的控制字.它自己的组件似乎可以很好地在表单设计器中测试它.但是,编译和运行应用程序的东西不起作用.像这样的livbindings的屏幕截图:

这是组件的代码
unit cBits2Byte;
interface
uses
System.SysUtils, System.Classes;
type
TBits2Byte = class(TComponent)
private
{ Private declarations }
fBit00, fBit01, fBit02, fBit03, fBit04, fBit05, fBit06, fBit07: Boolean;
function bitstate(sfr, bit: Byte): Boolean;
function ReadByte: Byte;
procedure WriteByte(aByte: Byte);
published
{ Published declarations }
property char: byte read ReadByte write WriteByte;
property Bit00: Boolean read fBit00 write fBit00;
property Bit01: Boolean read fBit01 write fBit01;
property Bit02: Boolean read fBit02 write fBit02;
property Bit03: Boolean read fBit03 write fBit03;
property Bit04: Boolean …Run Code Online (Sandbox Code Playgroud) procedure TForm1.UDPUDPRead(AThread: TIdUDPListenerThread;
AData: array of Byte; ABinding: TIdSocketHandle);
var
buffer : TBytes;
begin
SetLength(buffer, Length(AData));
buffer := @AData[0];
end;
Run Code Online (Sandbox Code Playgroud)
此代码导致访问冲突。
什么是要转换的正确方法字节数组以TB的在Delphi XE3?
在Arduino库中找到了这个天才地图功能.和Delphi写的一样:
procedure TForm1.Button1Click(Sender: TObject);
function map(x, in_min, in_max, out_min, out_max: Integer): extended;
begin
result := (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
end;
var
y, in_min, in_max, out_min, out_max: Integer;
i: integer;
m: extended;
begin
in_min := 0;
in_max := 6406963;
out_min := 0;
out_max := 474;
y := 0;
for i := in_min to in_max do begin
m := map(i, in_min, in_max, out_min, out_max);
if round(m) <> y then begin
y …Run Code Online (Sandbox Code Playgroud) delphi ×3
bit-shift ×1
casting ×1
delphi-xe3 ×1
delphi-xe7 ×1
livebindings ×1
mapping ×1
python ×1
range ×1
udp ×1