//************************************************************************** //Skeleton of trread.dll(read path data) //************************************************************************** // #include #include //external define __declspec(dllexport) void TRREADSUFFIX(char*); __declspec(dllexport) void TRREADKIND(int*,char*); __declspec(dllexport) void TRREADOPEN(char*); __declspec(dllexport) void TRREADPATH(int*,int*,double*,double*,double*,int*, double*,double*,int*,int*); __declspec(dllexport) void TRREADCLOSE(); //Global FILE *fp; char rddata[80]; int rtype; double pss[3]; void TRREADSUFFIX(char *suffix) //[- O] suffix text { strcpy(suffix,".H"); } void TRREADKIND(int *lang, //[I -] =0 standard =1 other langage char *item) //[- O] ITEM NAME { strcpy(item,"HEIDENHAIN L-CODE DATA(*.H)"); } void TRREADOPEN(char *clfilename) //[I -] file name { fp=fopen(clfilename,"r"); fgets(rddata,sizeof(rddata),fp); if( !strnicmp(&rddata[1],"BEGIN",5) ) { rtype=0; } else { rtype=1; } } void TRREADPATH(int *nblock,//[- O] BLOCK NO int *kind, //[- O] 0:G00 1:G01 2:G02 3:G03 // *T-CODE 1000+(TOOL-NO) double *ps, //[- O] Start Point XYZ double *pe, //[- O] End Point XYZ double *pc, //[- O] Center of ARC XYZ int *ipl, //[- O] Plane 17:G17,18:G18,19:G19 double *feed, //[- O] Feedrate double *dataux,//[- O] Additional DATA int *pcl, //[- O] Color Number of TRREADPATHCOLOR(0`9) int *irc) //[- O] Return Code 1(TRUE) // 0(FALSE) { char *tmp,*tmp0; *irc= TRUE; if( fgets(rddata,sizeof(rddata),fp) == NULL ) { *irc=FALSE; return; } // read block if( rtype ) { tmp=strpbrk(&rddata[0]," ")+1; } else { tmp=&rddata[0]; } if( !strnicmp(tmp,"L",1) ) { tmp++; memcpy(ps,pss,24); memcpy(pe,pss,24); if( (tmp0=strpbrk(tmp,"X")) != NULL ) { tmp=tmp0+1; pe[0]=atof(tmp); } if( (tmp0=strpbrk(tmp,"Y")) != NULL ) { tmp=tmp0+1; pe[1]=atof(tmp); } if( (tmp0=strpbrk(tmp,"Z")) != NULL ) { tmp=tmp0+1; pe[2]=atof(tmp); } if( (tmp0=strpbrk(tmp,"F")) != NULL ) *feed=atof(tmp0+1); if( *feed >= 20000 ) { *kind=0; } else { *kind=1; } memcpy(pss,pe,24); } else if( !strnicmp(tmp,"F",1) ) { tmp++; *feed=atof(tmp); } else if( !strnicmp(tmp,"TOOL CALL",9) ) { // ATC NOT AVAILABLE // tmp+=10; // *kind=1000; // *kind+=atoi(tmp); } else if( !strnicmp(tmp,"END PGM",7) ) { *irc= FALSE; } else { } *nblock++; *pcl=0; } void TRREADCLOSE() { fclose(fp); }