📄 control.bak
字号:
gotoxy(27,7); cprintf("X");
gotoxy(27,9); cprintf("Y");
gotoxy(27,11); cprintf("Z");
gotoxy(27,13); cprintf("%c",(*software).a_label);
GMTtext(software,ctrl,gcode);
}
void GMTtext(struct soft_setup *software, struct control *ctrl, struct gcode_setup *gcode)
{
window(1,1,80,25);
textcolor(WHITE); textbackground(BLACK);
if(version==LITE) {gotoxy(44,20); cprintf("(N/A)");}
else if((*ctrl).cvv==ON) {gotoxy(44,20); cprintf("(ON) ");}
else {gotoxy(44,20); cprintf("(OFF)");}
if((*ctrl).M03==ON) {gotoxy(33,21); cprintf("(ON) ");}
else {gotoxy(33,21); cprintf("(OFF)");}
if((*ctrl).M07==ON) {gotoxy(33,22); cprintf("(ON) ");}
else {gotoxy(33,22); cprintf("(OFF)");}
if((*ctrl).M08==ON) {gotoxy(33,23); cprintf("(ON) ");}
else {gotoxy(33,23); cprintf("(OFF)");}
if((*ctrl).M10==ON) {gotoxy(33,24); cprintf("(ON) ");}
else {gotoxy(33,24); cprintf("(OFF)");}
if((*ctrl).cs==0) {gotoxy(77,20); cprintf("(M)");}
if((*ctrl).cs==1) {gotoxy(77,20); cprintf("(2)");}
if((*ctrl).cs==2) {gotoxy(77,20); cprintf("(3)");}
if((*ctrl).cs==3) {gotoxy(77,20); cprintf("(4)");}
if((*ctrl).cs==4) {gotoxy(77,20); cprintf("(5)");}
if((*ctrl).cs==5) {gotoxy(77,20); cprintf("(6)");}
if((*ctrl).cs==6) {gotoxy(77,20); cprintf("(7)");}
gotoxy(64,21); cprintf("(%2d)",(*gcode).tnum);
if((*ctrl).pty==ABS) {gotoxy(64,22); cprintf("(Abs)");}
else {gotoxy(64,22); cprintf("(Rel)");}
if((*software).units==MM) {gotoxy(65,23); cprintf("(MM)");}
else {gotoxy(65,23); cprintf("(IN)");}
if((*software).a_status==ON)
{if((*software).a_follow==INDEPENDANT) {gotoxy(60,24); cprintf("%c(Independent)",(*software).a_label);}
if((*software).a_follow==FOLLOW_X) {gotoxy(60,24); cprintf("%c(Follow X) ",(*software).a_label);}
if((*software).a_follow==FOLLOW_Y) {gotoxy(60,24); cprintf("%c(Follow Y) ",(*software).a_label);}
if((*software).a_follow==FOLLOW_Z) {gotoxy(60,24); cprintf("%c(Follow Z) ",(*software).a_label);}
}
else {gotoxy(60,24); cprintf("%c(N/A) ",(*software).a_label);}
}
int limit_msg(struct hard_setup *hardware, struct soft_setup *software, struct pos *pt, int msg)
{
int xp=1, xn=1, yp=1, yn=1, zp=1, zn=1, ap=1, an=1, ch, temp_a_follow=(*software).a_follow;
static BYTE buffer[1000];
char letter;
gettext(22,19,59,24,buffer);
box(22,19,59,24, RED,BLACK,WHITE,WHITE);
gotoxy(8,3); cprintf("All Processes Aborted");
gotoxy(5,4); cprintf("Use Jog Keys To Clear Limits");
if(msg==X_PLIMIT) {xp=0; letter='X';} if(msg==X_NLIMIT) {xn=0; letter='X';} if(msg==Y_PLIMIT) {yp=0; letter='Y';} if(msg==Y_NLIMIT) {yn=0; letter='Y';}
if(msg==Z_PLIMIT) {zp=0; letter='Z';} if(msg==Z_NLIMIT) {zn=0; letter='Z';} if(msg==A_PLIMIT) {ap=0; letter=(*software).a_label;} if(msg==A_NLIMIT) {an=0; letter=(*software).a_label;}
textcolor(YELLOW+BLINK); gotoxy(8,1); cprintf("<<%c Axis Limit Override>>",letter);
(*software).a_follow=INDEPENDANT;
while(xp==0 || xn==0 || yn==0 || yp==0 || zn==0 || zp==0 || an==0 || ap==0)
{ch=getch(); if(ch==0) ch=getch()+1000;
if(ch==1014) break;
switch(ch)
{case 72+1000: //up
case 77+1000: //right
if((ch==72+1000 && (*software).invert_arrows==OFF) || (ch==77+1000 && (*software).invert_arrows==ON))
{if((msg=jog(hardware, software, pt, SLOW, NULL, Y_AXIS*yp, POS))==UNLIMIT) yn=1;}
else if((msg=jog(hardware, software, pt, SLOW, NULL, X_AXIS*xp, POS))==UNLIMIT) xn=1;
break;
case 80+1000: //down
case 75+1000: //left
if((ch==80+1000 && (*software).invert_arrows==OFF) || (ch==75+1000 && (*software).invert_arrows==ON))
{if((msg=jog(hardware, software, pt, SLOW, NULL, Y_AXIS*yn, NEG))==UNLIMIT) yp=1;}
else if((msg=jog(hardware, software, pt, SLOW, NULL, X_AXIS*xn, NEG))==UNLIMIT) xp=1;
break;
case 73+1000: //page up
if((msg=jog(hardware, software, pt, SLOW, NULL, Z_AXIS*zp, POS))==UNLIMIT) zn=1;
break;
case 81+1000: //page down
if((msg=jog(hardware, software, pt, SLOW, NULL, Z_AXIS*zn, NEG))==UNLIMIT) zp=1;
break;
case '+':
case '=':
if((msg=jog(hardware, software, pt, SLOW, NULL, A_AXIS*ap, POS))==UNLIMIT) an=1;
break;
case '-':
if((msg=jog(hardware, software, pt, SLOW, NULL, A_AXIS*an, NEG))==UNLIMIT) ap=1;
break;
}
if(msg==E_STOP || msg==QUIT) break;
if(msg==X_PLIMIT) xp=0; if(msg==X_NLIMIT) xn=0; if(msg==Y_PLIMIT) yp=0; if(msg==Y_NLIMIT) yn=0;
if(msg==Z_PLIMIT) zp=0; if(msg==Z_NLIMIT) zn=0; if(msg==A_PLIMIT) ap=0; if(msg==A_NLIMIT) an=0;
msg=COMPLETE;
}
(*software).a_follow=temp_a_follow;
puttext(22,19,59,24,buffer);
return msg;
}
void estop_msg(void)
{
static BYTE buffer[1000];
gettext(22,19,59,24,buffer);
box(22,19,59,24, RED,BLACK,WHITE,WHITE);
gotoxy(10,3); cprintf("All Processes Aborted");
gotoxy(16,4); cprintf("<Any Key>");
textcolor(YELLOW+BLINK); gotoxy(11,1); cprintf("<<Emergeny Stop>>");
getch();
puttext(22,19,59,24,buffer);
}
void message(char msg[40])
{
textcolor(WHITE);
textbackground(BLACK);
window(1,1,80,25);
gotoxy(2,3); cprintf(" ");
gotoxy(2,3); cprintf("%s",msg);
}
void move_menu(int id)
{
int i;
window(2,6,22,12);
textbackground(GREEN); textcolor(WHITE); clrscr();
window(1,1,80,25);
gotoxy(2, 6); putch(218);
for(i=3; i<22; i++) putch(196);
putch(191);
for(i=7; i<12; i++)
{gotoxy(2, i); putch(179);
gotoxy(22, i); putch(179);
}
gotoxy(2, 12); putch(192);
for (i=3; i<22; i++) putch(196);
putch(217);
gotoxy(3,7); cprintf(" Move Control");
gotoxy(3,8); cprintf("<Esc>/<Sp>...Break");
if(id==2 || id==3) {gotoxy(3,9); cprintf("<F>.....+Feed Rate");
gotoxy(3,10); cprintf("<S>.....-Feed Rate");}
if(id==3) {gotoxy(3,11); cprintf("<P>..........Pause");}
}
int check_key(char user[], char license[])
{
int i, first, last, match=0, match2=0, match3=0, against=0, against2=0, against3=0, package, temp, oldlic=TRUE;
static char SSN[]="306881320", key[10];
FILE *ifp;
//check for old license
if((ifp=fopen("cncpro.lic","r"))!=NULL || (ifp=fopen("license.dat","r"))!=NULL)
{if((first=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
first=first-'D';
if((last=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
last=last-'Y';
for(i=0;i<9;i++)
{if(i<first)
{if((user[i]=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
user[i]=user[i]-SSN[i];
}
if(i==first && last>0) user[i]=' ';
if(i>first && i<first+last+1)
{if((user[i]=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
user[i]=user[i]-SSN[i];
}
if((license[i]=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
license[i]=license[i]-SSN[i];
if((key[i]=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
if(i<first+last) key[i]=key[i]-user[i];
else key[i]=key[i]-SSN[i];
}
for(i=9;i<first+last+1;i++)
{if(i!=first)
{if((user[i]=fgetc(ifp))==EOF) {oldlic=FALSE; goto DONE;}
user[i]=user[i]-SSN[i%9];
}
else user[i]=' ';
}
if(strcmp(SSN,key)!=0) {oldlic=FALSE; goto DONE;}
}
else return DEMO;
DONE:
fclose(ifp);
if(oldlic==TRUE) //replace old license with new one
{if((ifp=fopen("cncpro.lic","w"))!=NULL)
{for(i=0;i<9;i++) match2=match=match+license[i];
for(i=0;i<strlen(user);i++) match3=match=match+user[i];
match2=match2%26+65;
match3=match3%26+65;
match=match+'A'+match2+match3;
match=match%26+65;
fputc('A',ifp);
for(i=0;i<9;i++)
{if(i+1==5) fputc('-',ifp);
fputc(license[i]-48+65+SSN[i]-48+5,ifp);
}
fputc('-',ifp);
fputc(match,ifp);
fputc(match2,ifp);
fputc(match3,ifp);
for(i=0;i<strlen(user);i++)
{if((i+3)%5==0) fputc('-',ifp);
if(user[i]==' ') fputc('1',ifp);
else if(user[i]>=97) fputc((user[i]-97+SSN[i%9]-48+8)%26+65,ifp);
else fputc((user[i]-65+SSN[i%9]-48+8)%26+97,ifp);
}
}
else return DEMO;
fclose(ifp);
}
//check for valid license
if((ifp=fopen("cncpro.lic","r"))!=NULL)
{if((package=fgetc(ifp))==EOF) {fclose(ifp); return DEMO;}
for(i=0;i<9;i++)
{if((temp=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if(temp=='-' && (temp=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
license[i]=temp+48-65-SSN[i]+48-5;
}
if((match=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if(match=='-' && (match=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if((match2=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if(match2=='-' && (match2=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if((match3=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
if(match3=='-' && (match3=fgetc(ifp))==EOF){fclose(ifp); return DEMO;}
i=0;
while((temp=fgetc(ifp))!=EOF && temp!='\n')
{if(temp=='-' && (temp=fgetc(ifp))==EOF) continue;
if(temp=='1') user[i]=' ';
else if(temp>=97) {user[i]=temp-(SSN[i%9]-48)-8; if(user[i]<97) user[i]=user[i]+26; user[i]=user[i]-32;}
else {user[i]=temp-(SSN[i%9]-48)-8; if(user[i]<65) user[i]=user[i]+26; user[i]=user[i]+32;}
i++;
}
user[i]=0;
for(i=0;i<9;i++) against2=against=against+license[i];
for(i=0;i<strlen(user);i++) against3=against=against+user[i];
against=against+package+match2+match3;
against=against%26+65;
against2=against2%26+65;
against3=against3%26+65;
if(match!=against){fclose(ifp); return DEMO;}
if(match2!=against2){fclose(ifp); return DEMO;}
if(match3!=against3){fclose(ifp); return DEMO;}
}
else return DEMO;
fclose(ifp);
user[25]=0;
if(package=='A') return FULL;
else return LITE;
}
double get_var(double num, double num2, int action)
{
static double V[101];
int i;
if(num>100 || num<0) return 0;
if(action==CLEAR) for(i=0;i<101;i++) V[i]=0;
if(action==STORE) V[num]=num2;
if(action==GET) return V[num];
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -