DLL 源码:
procedure TestPlugin1(DataLen: Integer; pfOUT: ArraySingle; pfINa: ArraySingle;
pfINb: ArraySingle; pfINc: ArraySingle); cdecl;
var
i, n: Integer;
prev, refprev, boxv: double;
up, dn: boolean;
begin
up := false;
dn := false;
prev := pfINa[0];
i := 0;
repeat
boxv := pfINc;
refprev := prev;
if (not dn) and (pfINb > prev) then
begin
up := true;
n := trunc((pfINb - prev) / boxv);
prev := prev + boxv * n;
end;
if dn and (pfINb > prev) then
begin
n := trunc((pfINb - prev) / boxv);
if n > 1 then
begin
up := true;
dn := false;
prev := prev + boxv * n;
end
else
prev := prev;
end;
if (not up) and (pfINb < prev) then
begin
dn := true;
n := trunc((prev - pfINb) / boxv);
prev := prev - boxv * n;
end;
if up and (pfINb < prev) then
begin
n := trunc((prev - pfINb) / boxv);
if n > 1 then
begin
dn := true;
up := false;
prev := prev - boxv * n;
end
else
prev := prev;
end;
if prev < refprev then
pfOUT := prev + pfINc
else if prev > refprev then
pfOUT := prev - pfINc
else
pfOUT := pfOUT[i - 1];
i := i + 1;
until i = DataLen;
end;