C的API调用问题.谁能帮我看看delphi调用api问题,先谢谢了(100分)

  • 主题发起人 主题发起人 tgzhong
  • 开始时间 开始时间
T

tgzhong

Unregistered / Unconfirmed
GUEST, unregistred user!
API原型定义
C format
int32 piar_compvaluesfil(
int32 pt,
int32 PIPTR * count,
int32 times[],
float rvals[],
int32 istats[],
char PIPTR * expression,
int32 rev,
int32 filt );

Returns
>0
System error
0
Success
-1
Bad point number
-101
Date not on line
-103
No data for this point for the passed time
-105
Bad time and date
-121
Invalid count parameter
-8xx
Expression Parsing Error
-9xx
Network Error

Arguments

pt (passed):Point number
count (passed, returned):Number of values
times (passed, returned):Time stamps of values
rvals (returned):Values in engineering units
istats (returned):Integer or status values
expression (passed):Expression string
rev (passed):Reverse sequence flag; TRUE to go backwards from times[0], FALSE to go forwards
filt (passed):Filter status flag, TRUE to return FilterFailStatus and FALSE to skip values at times when the expression is not satisfied.

//以下为我接口定义和调用的方式////////////////////////////////////////////////////
//接口单元声明
type
int32 = Longint;
float64 = double;
TDynamicInt32Array = array of int32;
TDynamicSingleArray = array of Single;

function piar_compvaluesfil( pt:int32;var count:int32;times:TDynamicInt32Array;
rvals:TDynamicSingleArray; istats:TDynamicInt32Array;
expression:pChar;rev:int32;filt:int32):int32;stdcall;external 'piapi32.dll';

//调用
var
expstr:Pchar;
i:integer;
ret,scount,rev:int32;
times,istats:TDynamicInt32Array;
rvals:TDynamicSingleArray;
begin
setLength(times,2000);
setLength(istats,2000);
setLength(rvals,2000);

scount :=strtoint(Edit4.Text);
times[0] := DateTimetoUnix(StrToDateTime(Edit2.Text));
times[scount-1] :=DateTimetoUnix(Now);
New(expstr);
expstr :='''DCS01GEN900'''+'> 200';
Ret:=piar_compvaluesfil(13898,scount,times,rvals,istats,expstr,0,0);

if Ret = 0 then //此返回值为0正确,但我的返回值-12300。好像是expression不对,但该函数没有该错误信息
Memo2.clear;
for i:=0 to scount-1 do
begin
Memo2.Lines.Add(inttostr(i)+' || '+datetimetostr(UnixtoDatetime(times))+' || '+formatfloat('0.00',rvals));
end;
 
后退
顶部