发布于 2003-09-02 23:16:39
0楼
下面是个简单的例子
1.在TagLoging 中建立一个空的Trend window template,名字为Trend1,在里边加入一个趋势名为Curve1,不作任何设置,保存退出。
2.建立一个画面,用于显示趋势Trend1->Curve1,设为主显示画面
3.建立两个globle action
第一个(info/trig设为time-500ms):
#include "apdefap.h"
int gscAction( void )
{
static int direction=0;
unsigned int nXPos = GetTagWord("XPos");
if(direction == 0)
{
if(nXPos<439) SetTagWord("XPos",nXPos+1);
else {SetTagWord("XPos",438);direction = 1;}
}
else
{
if(nXPos>0) SetTagWord("XPos",nXPos-1);
else {SetTagWord("XPos",1);direction = 0;}
}
return 1;
}
第二个(info/triger设为Tag-"XPos"):
#include "apdefap.h"
int gscAction( void )
{
DWORD dwCounter = 440;
static double doTestX[440]={0};
static double doTestY[440]={0};
int i;
int nXPos;
time_t t;
for(i=0;i<440;i++) doTestX[i]=i;
srand((unsigned) time(&t));
nXPos = (int)GetTagWord("XPos");
doTestY[nXPos] = 70+(rand()%20);
TLGConnect(NULL,NULL);
TLGSetTemplateData( "Trend1",
"Curve1",
dwCounter,
doTestX,
dwCounter,
doTestY,
TLG_SETDATA_RESET,
TLG_SETDATA_RESETTLG_SETDATA_TIME_RANGE_XTLG_SETDATA_TIME_RANGE_Y,
TRUE,
NULL
);
TLGDisconnect(NULL);
return 1;
}
如果要控制Y轴范围,只需要在首尾增加两个点分别代表Y轴范围的最高点和最低点就行了(同时趋势显示设为Autorange),基本上不影响显示效果。具体代码XD们自己实现吧。这种方法有一定的缺点,但就我目前使用足够了,各位XD有更好的方法,还请多多指教啊