⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.bak

📁 This is a CNCPro source file. It is include the G-Code interpreter source.
💻 BAK
📖 第 1 页 / 共 5 页
字号:
                  if(ftell(ifp)==place_holder) {message("Beginning Of Program"); continue;}
                  fgetpos(ifp,&fpos3); i=0;
                  while(ftell(ifp)!=place_holder)
                    {fgetpos(ifp,&fpos1);
                     if(i<=6) i++;
                     if(i==7) {fsetpos(ifp,&fpos3); fgets(fstring, 200, ifp); fgetpos(ifp,&fpos3); fsetpos(ifp,&fpos1);}
                     while((ch2=fgetc(ifp))!='\n' && ch2!=EOF && ftell(ifp)!=place_holder);
                     if(ch2==EOF) break;
                    }
                  gettext(43,4,78,16,buffer2); puttext(43,5,78,17,buffer2); puttext(43,4,78,4,buffer3);
                  if(i==7) {fstring[36]=0; gotoxy(43,4); textcolor(WHITE); textbackground(BLACK); cprintf("%s",fstring);}
                  fsetpos(ifp,&fpos1);
                  for(i=0;i<8;i++) fgets(fstring, 200, ifp);
                  fgetpos(ifp,&fpos2); fsetpos(ifp,&fpos1);
                  message("Skipped Back");
                  goloop=OFF;
                 }
               if(ch=='r' || ch=='R')
                 {do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30);
                  window(43,3,78,18); textcolor(WHITE); textbackground(BLACK); clrscr();
                  rewind(ifp); fgetpos(ifp,&fpos1);
                  get_var(0,0,CLEAR);
                  for(i=0;i<8;i++)
                    {if(fgets(fstring, 200, ifp)!=NULL)
                       {fstring[36]=0; textcolor(WHITE); textbackground(BLACK); gotoxy(1,8+i); cprintf("%s",fstring);}
                    }
                  fgetpos(ifp,&fpos2); fsetpos(ifp, &fpos1);
                  window(1,1,80,25);
                  message("Program Start");
                  goloop=OFF;
                 }
              }
            puttext(22,19,59,24,buffer);
            break;
         case 18+1000: //alt e
         case 'e':
         case 'E':
            gettext(22,19,59,24,buffer);
            box(22,19,59,24, RED,BLACK,WHITE,WHITE);
            if(strcmp(ctrl.file,"NONE")==0)
              {gotoxy(4,3); cprintf("        No Program Loaded");
               gotoxy(4,4); cprintf("            <Any Key>");
              }
            else
              {gotoxy(4,3);
               if(kp==1018) cprintf("      Line By Line Execute?");
               else         cprintf("          Run Program?");
               gotoxy(4,4); cprintf("<Enter> To Accept  <Esc> To Abort");
               textcolor(YELLOW+BLINK);
               gotoxy(1,1); cprintf("<<WARNING!!! MOVEMENT ABOUT TO BEGIN>>");
              }
            window(1,1,80,25);
            while(1)
              {ch=getch();
               if(strcmp(ctrl.file,"NONE")==0) break;
               else if(ch==27 || ch==13 || ch==32) break;
              }
            puttext(22,19,59,24,buffer);
            if(ch==27 || strcmp(ctrl.file,"NONE")==0) break;

            BEGIN_EXEC:
            msg=COMPLETE;
            gettext(41,2,80,2,buffer);
            gotoxy(48,2); cprintf("<<WARNING!!! STAY CLEAR>>");
            gettext(2,6,22,12,buffer4);
            move_menu(3);
            if(ctrl.M00!=ON) {ctrl.M00=OFF; GMTtext(&software, &ctrl, &gcode);}
            message("Program In Progress.");
            if(kp==1018) do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 1, 0); //line by line execute
            else do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 2, 0);  //normal execute
            while(1)
              {ch=fgetc(ifp);
               if(ch=='(') while((ch=fgetc(ifp))!='\n' && ch!=EOF);
               if(ch==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
               if(ch>=97 && ch<=122) ch=ch-32;
               if(ch=='V' && version!=LITE)
                 {if(NULL==fscanf(ifp, "%lf", &num)) continue;
                  while((ch=fgetc(ifp))==' ' && ch!=EOF);
                  if(ch==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
                  if(ch=='=')
                    {if(NULL==fscanf(ifp, "%lf", &num2)) continue;
                     get_var(num,num2,STORE);
                    }
                 }
               if(ch=='L' && version!=LITE)
                 {if(goloop==ON || NULL==fscanf(ifp, "%lf", &loopmax)) {continue;}
                  goloop=ON;
                  loopnum=0;
                 }

               if(ch=='X' || ch=='Y' || ch=='Z' || ch==software.a_label || ch=='I' || ch=='J' || ch=='K' ||
                  ch=='R' || ch=='Q' || ch=='F' || ch=='G' || ch=='M' || ch=='P' || ch=='\n')
                 {if(ch=='\n')
                    {num=NULL;
                     if(goloop==ON) {loopnum++; if(loopnum>=abs(loopmax)) goloop=OFF; else fsetpos(ifp,&fpos1);}
                    }
                  else
                    {fgetpos(ifp,&fpostemp);
                     if(NULL==fscanf(ifp, "%lf", &num))
                       {fsetpos(ifp,&fpostemp);
                        while((ch2=fgetc(ifp))==' ' && ch2!=EOF);
                        if(ch2==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
                        if((ch2=='V' || ch2=='v') && version!=LITE)
                          {if(NULL==fscanf(ifp, "%lf", &num2)) continue;
                           num=get_var(num2,0,GET);
                          }
                        else continue;
                       }
                    }
                  //check for go to subroutine command
                  if(ch=='G' && num==22 && version!=LITE)
                    {while((ch2=fgetc(ifp))==' ' && ch2!=EOF);
                     if(ch2==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
                     if(ch2=='P' || ch2=='p')
                       {if(NULL==fscanf(ifp, "%lf", &num2)) continue;
                        if(num2<0) continue;
                        for(i=0;i<100;i++) if(sub[i].id==num2) {gosub=ON; subpos=sub[i].pos;}
                       }
                     else continue;
                    }
                  //check for file chain command
                  else if(ch=='G' && num==95)
                    {while((ch2=fgetc(ifp))==' ' && ch2!=EOF);
                     if(ch2=='#' && fscanf(ifp,"%s",tstring)!=NULL && (ifp2=fopen(tstring,"r"))!=NULL)
                       {fclose(ifp);
                        ifp=ifp2;
                        while((ch=fgetc(ifp))!=EOF)
                          {if(ch=='(')
                             {while((ch=fgetc(ifp))!=EOF && ch!='\n');
                              if(ch==EOF) break;
                             }
                           if(ch=='M' || ch=='m')
                             {if(NULL==fscanf(ifp, "%lf", &num)) continue;
                              if(num==30) break;
                             }
                          }
                        //clear old subs from memory and get new subs id's and file positions
                        for(i=0;i<100;i++) sub[i].id=-1;
                        while(ch!=EOF && (ch=fgetc(ifp))!=EOF)
                          {if(ch=='(')
                             {while((ch=fgetc(ifp))!=EOF && ch!='\n');
                              if(ch==EOF) break;
                             }
                           if(ch=='$')
                             {if(NULL==fscanf(ifp, "%lf", &num)) continue;
                              if(num>=0) for(i=0;i<100;i++) if(sub[i].id==-1) {sub[i].id=num; fgetpos(ifp,&sub[i].pos); break;}
                             }
                          }
                          msg=do_gcode(&hardware, &software, &gcode, &ctrl, &world, 'M', 99);
                       }
                    }
                  else msg=do_gcode(&hardware, &software, &gcode, &ctrl, &world, ch, num);
                  //go to subroutine now if needed
                  if(ch=='\n' && gosub==ON)
                    {gosub=OFF;
                     fgetpos(ifp,&mainpos);
                     fsetpos(ifp,&subpos);




                     //do subroutine now
                     while(1)
                       {ch=fgetc(ifp);
                        if(ch=='(') while((ch=fgetc(ifp))!='\n' && ch!=EOF);
                        if(ch==EOF) break;
                        if(ch>=97 && ch<=122) ch=ch-32;
                        if(ch=='V')
                          {if(NULL==fscanf(ifp, "%lf", &num)) continue;
                           while((ch=fgetc(ifp))==' ' && ch!=EOF);
                           if(ch==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
                           if(ch=='=')
                             {if(NULL==fscanf(ifp, "%lf", &num2)) continue;
                              get_var(num,num2,STORE);
                             }
                          }
                        if(ch=='X' || ch=='Y' || ch=='Z' || ch==software.a_label || ch=='I' || ch=='J' || ch=='K' ||
                           ch=='R' || ch=='Q' || ch=='F' || ch=='G' || ch=='M' || ch=='P' || ch=='\n')
                          {if(ch=='\n') num=NULL;
                           else
                             {fgetpos(ifp,&fpostemp);
                              if(NULL==fscanf(ifp, "%lf", &num))
                                {fsetpos(ifp,&fpostemp);
                                 while((ch2=fgetc(ifp))==' ' && ch2!=EOF);
                                 if(ch2==EOF) {msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 30); break;}
                                 if(ch2=='V' || ch2=='v')
                                   {if(NULL==fscanf(ifp, "%lf", &num2)) continue;
                                    num=get_var(num2,0,GET);
                                   }
                                 else continue;
                                }
                             }
                           if(ch=='M' && num==2) break;
                           msg=do_gcode(&hardware, &software, &gcode, &ctrl, &world, ch, num);
                          }
                        if(msg==M30 || msg==M99 || msg==M0 || msg==QUIT || msg==E_STOP || (msg>=X_PLIMIT && msg<=A_NLIMIT)) break;
                       }
                     //end subroutine




                     fsetpos(ifp,&mainpos);
                     ch='\n';
                    }
                 }
               if(ch=='\n' && goloop==OFF)
                 {gettext(43,5,78,17,buffer2); puttext(43,4,78,16,buffer2); puttext(43,17,78,17,buffer3);
                  fgetpos(ifp,&fpos1); fsetpos(ifp,&fpos2);
                  if(fgets(fstring, 200, ifp)!=NULL)
                    {fstring[36]=0; gotoxy(43,17); textcolor(WHITE); textbackground(BLACK); cprintf("%s",fstring);}
                  fgetpos(ifp,&fpos2); fsetpos(ifp,&fpos1);

                  if(kp==1018 && msg!=M30 && msg!=M0 && msg!=QUIT && msg!=E_STOP && (msg<X_PLIMIT || msg>A_NLIMIT))
                    {update_display(&software, 0, 0, 0, 0, 0, 0, 0, 3);
                     update_display(&software, 0, 0, 0, 0, 0, 0, 0, 5);
                     if(ctrl.pty==REL)
                        for(i=0;i<4;i++)
                          {if(i==3) i++;
                           update_display(&software, 0, 0, 0, 0, 0, 0, 0, i);
                          }
                     puttext(2,6,22,12,buffer4);
                     gettext(22,19,59,24,buffer5);
                     box(22,19,59,24, RED,BLACK,WHITE,WHITE);
                     gotoxy(4,3); cprintf("           Continue?");
                     gotoxy(4,4); cprintf("<Enter> To Accept  <Esc> To Abort");
                     window(1,1,80,25);
                     while(1)
                       {ch=getch();
                        if(ch==27 || ch==13 || ch==32) break;
                       }
                     puttext(22,19,59,24,buffer5);
                     move_menu(3);
                     if(ch==27) msg=do_gcode(&hardware, &software, &gcode, &ctrl, &pt, 'M', 0);
                    }
                 }
               if(msg==M30 || msg==M99 || msg==M0 || msg==QUIT || msg==E_STOP ||(msg>=X_PLIMIT && msg<=A_NLIMIT)) break;
              }
            if(msg==M30 || msg==M99)
              {window(43,3,78,18); textcolor(WHITE); textbackground(BLACK); clrscr();
               rewind(ifp); fgetpos(ifp,&fpos1);
               get_var(0,0,CLEAR);
               for(i=0;i<8;i++)
                 {if(fgets(fstring, 200, ifp)!=NULL)
                    {fstring[36]=0; textcolor(WHITE); textbackground(BLACK); gotoxy(1,8+i); cprintf("%s",fstring);}
                 }
               fgetpos(ifp,&fpos2); fsetpos(ifp, &fpos1);
               window(1,1,80,25);
               message("Program Start");
              }
            if(msg==M0) {ctrl.M00=ON; message("Program Paused...<E>/<Alt-E> To Cont.");}
            else goloop=OFF;
            puttext(2,6,22,12,buffer4);
            puttext(41,2,80,2,buffer);
            if(msg==M99) goto BEGIN_EXEC;
            break;
         case 'a':
         case 'A':
            gettext(22,18,59,25,buffer);
            box(22,18,59,25, RED,BLACK,WHITE,WHITE);
            gotoxy(12,1); cprintf("<Esc> To Exit");
            gotoxy(4,3); cprintf("<1> +90 About %c",software.x_label);
            gotoxy(21,3); cprintf("<2> -90 About %c",software.x_label);
            gotoxy(4,4); cprintf("<3> +90 About %c",software.y_label);
            gotoxy(21,4); cprintf("<4> -90 About %c", software.y_label);
            gotoxy(4,5); cprintf("<5> +90 About %c",software.z_label);
            gotoxy(21,5); cprintf("<6> -90 About %c", software.z_label);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -