#include "../acslib/include/acslib0.h" #include "../acslib/include/acslib1.h" #include "../acslib/include/acslib2.h" #include "../acslib/include/param.h" #include #include #include #include static HANDLE ACShandle; static long stop=0; void tim(int i) { write(2,"uz koncim",9); stop=1; } time_t starttime,curtime; long pomoc; long cas_prace; char str[2]; void main(int argc,char *argv[]) { long i,komun,neuspech; double POS; struct AXIS_STATUS MM[3]; struct sigaction act,old; struct itimerval itime,itimeold; if (argc<2) {cas_prace=10;printf("cas prace=%ld",cas_prace);} else{cas_prace=(long)atoi(argv[1]);printf("cas_prace=%ld",cas_prace);} act.sa_handler=tim; //act.sa_mask=0; act.sa_restorer=NULL; act.sa_flags=SA_RESTART; do{ pomoc=sigaction(SIGALRM,&act,&old); }while(pomoc!=0); stop=0; ACShandle=DefineController(256,0,11,0,0,SB214); printf("%d",(long)ACShandle); i=0; komun=0; printf(" SB214PC Linux driver comunication speed test at timeout 11ms\n\n"); printf(" - when used time out 10ms we can not conect to the card\n\n"); printf(" - when comunication is not successfully finished in period of timeout it is reported as unsuccessfull\n\n"); printf(" - timeout in Windows NT was 200 or 300 ms and there were unsuccessfull comunications!!!\n\n"); itime.it_value.tv_sec=(long)cas_prace; sprintf(str,"%ld",itime.it_value.tv_sec); write(2,str,2); do{ pomoc=setitimer(ITIMER_REAL,&itime,NULL); }while(pomoc!=0); starttime=time(NULL); while (stop==0) {curtime=time(NULL); printf("%ld.run (at %lfs)\n %lf runs per second =%lf comunications per second\n" ,i++,difftime(curtime,starttime),(double)(i-1)/(double)difftime(curtime,starttime),(double)(2*(i-1))/(double)difftime(curtime,starttime)); printf("Average comunication time: %lfms\n",1000*(double)difftime(curtime,starttime)/(double)(2*(i-1))); printf("Count of successfull comunications:%ld or %lf%% of success\n",komun, (double)komun/(2*(double)(i-1))*100); //neuspech=2*i-komun; printf("Count of unsuccessfull comunications:%ld or %lf%% of unsuccess\n\n",neuspech, (double)neuspech/(2*(double)(i-1))*100); komun=komun+GetPosition(ACShandle,"X",&POS); printf("X=%lf\n\n",POS); komun=komun+GetAxesStatus(ACShandle,"XY",MM); neuspech=2*i-komun; printf("XMM=%ld\n",MM[0].Mode); printf("YMM=%ld\n\n",MM[1].Mode); }; curtime=time(NULL); printf("======= end ====\n"); printf("statistics:\n %lf Runs per second\n",(double)i/(double)difftime(curtime,starttime)); printf("Percentage of successfull comunication:%lf%%\n",(double)komun/(2*(double)i)*100); printf("Average comunication time:%lf ms\n\n",1000*(double)difftime(curtime,starttime)/(2*(double)i)); act.sa_handler=SIG_DFL; sigaction(SIGALRM,&act,&old); FreeController(ACShandle); }