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

📄 show1111.c

📁 以前做的泰国瓦楞纸板生产线监控系统
💻 C
📖 第 1 页 / 共 2 页
字号:
               mask=mask>>1;
              }
         }
        }
       x+=16*n;
     }
 fclose(fpHZ);
 }
void showcondt(void)
 {int i;  
  
  if(istat!=ostat)    
   {drwfillbox(SET,BLACK,670,100,780,170);
    drwfillcircle(SET,BLACK,630,140,20);
   }
  if(istat==4)
   {strcpy(buf2,"停车");    /*stop*/
    i=RED;
   }
  else if(istat==2)
   {strcpy(buf4,"减速");    /*sub*/
    i=GREEN;
   }
  else if(istat==1)
   {strcpy(buf4,"加速");    /*add*/ 
    i=BLUE;
   }
  else if(istat==0)
   {strcpy(buf4,"正常");    /*in gear*/ 
    i=CYAN;
   }
         
  ostat=istat;
 
 drwfillcircle(XOR,i,630,140,20);
 drwhzstr(buf4,678,116,3,3,38,SET);
 }

void showtime(void)
{ int m1,n1;

  _strtime(newtimebuf);
  if(strncmp(oldtimebuf,newtimebuf,8)!=0)
    { int k;

      strcpy(oldtimebuf,newtimebuf);
      drwfillbox(SET,WHITE,650,5,778,21);
      oldtimebuf[8]='\0';
      drwstr(oldtimebuf,650,5,1,2,RED,XOR);
      
      showcondt();
      dispmem(p1);
      shang();
      xia();
      takedata();
      m1=lmtspeedcal(cutlength1);
      n1=lmtspeedcal(cutlength2);

      if(m1==0)
         k=n1;
      else if(n1==0)
         k=m1;
      else
         k=min(m1,n1);
      
      sprintf(buf2,"%3d",k);
      drwfillbox(SET,lBLUE,452,115,573,188);
      drwstr(buf2,488,136,2,2,WHITE,SET);                                                                                        
      
    }
}                       

int bcccheck(char *str)
{int i,j,bcc;

 i=strlen(str);
 bcc=str[0];
 for(j=1;j<i-1;j++)
   bcc=bcc ^ str[j];
 if(bcc<' ') bcc=bcc+' ';
 if(bcc==str[i-1])
   return TRUE;
 else
   return FALSE;
}

void waitbox(char *msg,int ikey,int hzok)
{int ilen,kk;
 int x,y,xn,yn;
 time_t tst,ted;
 
 ilen=strlen(msg);
 if(ilen<25) ilen=25;

 x=400-ilen*4-7;
 y=300-26;
 xn=400+ilen*4+7;
 yn=300+26;

 strcpy(buf1,"waittmp.pcx");
 pcxmake(x,y,xn,yn,buf1);

 drwfillbox(SET,GRAY,x,y,xn,yn);
 drwfillbox(SET,YELLOW,x+2,y+2,xn-2,yn-2);
 if(hzok==1)
  drwhzstr(msg,x+7,y+7,1,1,RED,XOR);
 else
  drwstr(msg,x+7,y+7,1,1,RED,XOR);

 if(ikey==0)
  {strcpy(buf1,"OK");

   drwfillbox(SET,BLUE,400-21,300+3,400+21,300+19);
   drwbox(XOR,RED,400-21,300+3,400+21,300+19);
   drwstr(buf1,400-16,300+3,1,2,GREEN,XOR);
  }
 else if(ikey==1)
  {strcpy(buf1,"YES");

   drwfillbox(SET,BLUE,400-21-10-58,300+3,400-21-10,300+19);
   drwbox(XOR,RED,400-21-10-58,300+3,400-21-10,300+19);
   drwstr(buf1,400-21-10-53,300+3,1,2,GREEN,XOR);

   strcpy(buf1,"NO");

   drwfillbox(SET,BLUE,400+21+10,300+3,400+21+68,300+19);
   drwbox(XOR,RED,400+21+10,300+3,400+21+68,300+19);
   drwstr(buf1,400+21+10+13,300+3,1,2,GREEN,XOR);

  }
  
 time(&tst);
 ikey=TRUE;
 kk=0;
 while(ikey)
  {time(&ted);
   kk++;
   if(kk>2000) break;
   if(kbhit()) break;
   if(fabs(difftime(ted,tst))>0.0)
      ikey=FALSE;
  }
 pcxput(SET,x,y,buf1);
}

int ErrorCheck(int Code)
{/* trap PCL error codes */
 if(Code<0)
     {printf("ERROR %d:",Code);
      SioError(Code);
      SioDone(Port);
      exit(1);
     }
 return(0);
} /* end ErrorCheck */


void dispmem(unsigned char far * addresst)
{
unsigned  char far *p;
int i,j,k;

p=addresst+2;
for(j=0;j<=9;j++)
  { for(k=0;k<70;k++)
    {
    if((*p==0x0)||(*p==0xCD)||(*p==0xBC)) *p=32;
    order[j][k]=*p;
    p++;
    }
  }                     
if(chok==TRUE)
 {
  for(i=0;i<=9;i++)
  {if(okk==TRUE)  disporder(i,order[i],BLUE,WHITE);
   else
    {if(i==0) disporder(i,order[i],RED,WHITE);
     else disporder(i,order[i],BLUE,WHITE);
    }
  }
 }
else
 for(i=0;i<=9;i++)
  {if (i==0) 
    disporder(i,order[i],RED,WHITE);
   else if(i==9)
    {
      drwfillbox(SET,PINK,9,467,72,487);
      strcpy(buf3,"备纸");
      drwhzstr(buf3,26,469,1,1,WHITE,SET);

    drwfillbox(SET,CYAN,639,467,791,487);
     disporder(i,order[i],CYAN,lPINK);      
     drwfillbox(SET,CYAN,639,467,678,487);
     drwfillbox(SET,BLACK,791,467,797,487);

     drwfillbox(SET,PINK,477,467,636,487);
     strcpy(buf1,"生产总长");
     drwhzstr(buf1,520,469,1,1,WHITE,SET);

     drwfillbox(SET,CYAN,750,467,791,487);}
   else
     disporder(i,order[i],BLUE,WHITE);
  }

 /*  drwline(SET,BLACK,476,224,476,466);*/
}            

void shang(void)
{
unsigned char far *p;
int i;

p=address+2+700;

for(i=0;i<4;i++)
{
 if(*p==0x0) *p=32;
 buf2[i]=*p;
 p++;
}
buf2[4]='\0';

cutlength2=atoi(buf2);
/*
p++; */
for(i=0;i<10;i++)
 {
   if(*p==0x0) *p=32;
   buf2[i]=*p;
   p++;
 }
 buf2[10]='\0';
 cutnumber2=atoi(buf2);   

for(i=0;i<10;i++)
 { 
 if(*p==0x0) *p=32;
 buf2[i]=*p;
 p++;
 }
 buf2[10]='\0';
 leftlength2=atol(buf2);

if(ocutlength2!=cutlength2)
  {sprintf(buf3,"%4d",cutlength2);
   drwfillbox(SET,lBLUE,83,115,204,151);
   drwstr(buf3,112,125,1,2,WHITE,SET);
   ocutlength2=cutlength2;   
  }
if(ocutnumber2!=cutnumber2)
  {sprintf(buf3,"%6d",cutnumber2);
   drwfillbox(SET,lBLUE,206,115,327,151);  
   drwstr(buf3,218,125,1,2,WHITE,SET);  
   ocutnumber2=cutnumber2;
  }
if(oleftlength2!=leftlength2)
  {sprintf(buf3,"%7d",leftlength2);
   drwfillbox(SET,lBLUE,329,115,450,151);
   drwstr(buf3,340,125,1,2,WHITE,SET);  
   oleftlength2=leftlength2;
  }
}            

void xia(void)
{
unsigned  char far *p;
int i;

p=address1+2+700;

for(i=0;i<4;i++)
{
 if(*p==0x0) *p=32;
 buf2[i]=*p;
 p++;
}
buf2[4]='\0';
cutlength1=atoi(buf2);

/*
p++;*/
for(i=0;i<10;i++)
 {
   if(*p==0x0) *p=32;
   buf2[i]=*p;
   p++;
 }
 buf2[10]='\0';
cutnumber1=atoi(buf2);   


for(i=0;i<10;i++)
 { 
 if(*p==0x0) *p=32;
 buf2[i]=*p;
 p++;
 }
 buf2[10]='\0';
 leftlength1=atol(buf2);

if(ocutlength1!=cutlength1)
  {sprintf(buf3,"%4d",cutlength1);
   drwfillbox(SET,lBLUE,83,153,204,188);
   drwstr(buf3,112,163,1,2,WHITE,SET);
   ocutlength1=cutlength1;
  }
if(ocutnumber1!=cutnumber1)
  {sprintf(buf3,"%6d",cutnumber1);
   drwfillbox(SET,lBLUE,206,153,327,188);  
   drwstr(buf3,218,163,1,2,WHITE,SET);  
   ocutnumber1=cutnumber1;
  }
if(oleftlength1!=leftlength1)
  {sprintf(buf3,"%7d",leftlength1);
   drwfillbox(SET,lBLUE,329,153,450,188);
   drwstr(buf3,340,163,1,2,WHITE,SET);  
   oleftlength1=leftlength1;
  }
}            

int msgbox(char *msg,int ikey,int hzok)
{int ilen;
 int x,y,xn,yn;

 ilen=strlen(msg);
 if(ilen<25) ilen=25;

 x=400-ilen*4-7;
 y=300-26;
 xn=400+ilen*4+7;
 yn=300+26;

 strcpy(buf2,"msgtmp.pcx");
 pcxmake(x,y,xn,yn,buf2);

 drwfillbox(SET,GRAY,x,y,xn,yn);
 drwfillbox(SET,YELLOW,x+2,y+2,xn-2,yn-2);
 if(hzok==1)
  drwhzstr(msg,x+7,y+7,1,1,RED,XOR);
 else
  drwstr(msg,x+7,y+7,1,1,RED,XOR);

 if(ikey==0)
  {strcpy(buf1,"OK");

   drwfillbox(SET,BLUE,400-21,300+3,400+21,300+19);
   drwbox(XOR,RED,400-21,300+3,400+21,300+19);
   drwstr(buf1,400-16,300+3,1,2,GREEN,XOR);
  }
 else if(ikey==1)
  {strcpy(buf1,"YES");

   drwfillbox(SET,BLUE,400-21-10-58,300+3,400-21-10,300+19);
   drwbox(XOR,RED,400-21-10-58,300+3,400-21-10,300+19);
   drwstr(buf1,400-21-10-53,300+3,1,2,GREEN,XOR);

   strcpy(buf1,"NO");

   drwfillbox(SET,BLUE,400+21+10,300+3,400+21+68,300+19);
   drwbox(XOR,RED,400+21+10,300+3,400+21+68,300+19);
   drwstr(buf1,400+21+10+13,300+3,1,2,GREEN,XOR);

  }
  
 ikey=getkey();
 pcxput(SET,x,y,buf2);
 return ikey;
}

 
void dispspeed(int speed,int icl,int x)
{       
   sprintf(buf2,"%6d",speed);
   
   drwfillbox(SET,icl,x+1,523,x+152-1,557);
   drwstr(buf2,x+50,532,1,2,BLACK,SET);
}
void dispjizhi(int jizhi,int icl,int x)
{
    sprintf(buf2,"%6d",jizhi);
    drwfillbox(SET,icl,x+1,559,x+152-1,593);
    drwstr(buf2,x+50,568,1,2,BLACK,SET);
    
}
void dispstore(char *s)
{
  char strr[10];
  drwfillbox(SET,BLACK,20,320,40,430);
  drwhzstr(s,26,324,2,1,CYAN,SET);
  if(chok==FALSE)
   strcpy(strr,"层");
  else
   strcpy(strr,"页");

  drwfillbox(SET,lGREEN,740,520,756,536);
  drwhzstr(strr,740,520,1,1,RED,SET);
  drwhzstr(strr,26,392,2,1,CYAN,SET);
}
void lmtspeedinit(void)
{
 int j;
 char *pp;
 double dtmp;
 FILE *fp;

   iCOM=1;
   dCIR=935.0;
   dANG=75.0;
   dSYN=90.0;
   dMAX=15.0;
   dRAT=5.88;
   dACC=150.0;
   dDAT=10L;
   iSEL=1;
   iADD=0;
   iSPD=100;
   iCOL=4;
   iADS=1;
   iPOS=5;


 if((fp=fopen("cutoff.ini","rb"))==NULL)
   {
   printf("File CUTOFF.INI no found.Use default data.");
   }
 else
   {
    while(!feof(fp))
     {if(fgets(buf1,80,fp)!=NULL)
       {
        if((pp=strstr(buf1,"COM"))!=NULL)
          { j=atoi(pp+5);
           if((j>=0)&&(j<=32)) iCOM=j;
            else iCOM=1;
          }
        else if((pp=strstr(buf1,"CIR"))!=NULL)
          { j=atoi(pp+5);
           if(dtmp>750.0) dCIR=dtmp;
            else dCIR=935.0;
          }
        else if((pp=strstr(buf1,"ANG"))!=NULL)
          {j=atoi(pp+5); 
           if((dtmp>0.0)&&(dtmp<100.0)) dANG=dtmp;
            else dANG=75.0;
          }
        else if((pp=strstr(buf1,"SYN"))!=NULL)
          { dtmp=atof(pp+5);
           if((dtmp>0.0)&&(dtmp<=90.0)) dSYN=dtmp;
            else dSYN=75.0;
          }
        else if((pp=strstr(buf1,"MAX"))!=NULL)
          { dtmp=atof(pp+5);
            if((dtmp>0.0)&&(dtmp<100.0)) dMAX=dtmp;
            else dMAX=15.0;
          }
        else if((pp=strstr(buf1,"RAT"))!=NULL)
          { dtmp=atof(pp+5); 
            if((dtmp>0.0)&&(dtmp<20.0)) dRAT=dtmp;
            else dRAT=5.88; 
          }
        else if((pp=strstr(buf1,"ACC"))!=NULL)
          {dtmp=atof(pp+5); 
           if((dtmp>0.0)&&(dtmp<1000.0)) dACC=dtmp;
            else dACC=150.0;
          }
        else if((pp=strstr(buf1,"DAT"))!=NULL)
          { dtmp=atof(pp+5);
            dDAT=(long int)dtmp;
          }
        else if((pp=strstr(buf1,"COL"))!=NULL)
          { j=atoi(pp+5); 
            iCOL=j;
          }
        else if((pp=strstr(buf1,"ADD"))!=NULL)
          { j=atoi(pp+5);
            iADD=j;
          }
        else if((pp=strstr(buf1,"ADS"))!=NULL)
          { j=atoi(pp+5);
            iADS=j;
          }
        else if((pp=strstr(buf1,"SPD"))!=NULL)
           {j=atoi(pp+5); 
            iSPD=j; 
           } 
        else if((pp=strstr(buf1,"SEL"))!=NULL)
           {j=atoi(pp+5); 
            iSEL=j;
           }
        else if((pp=strstr(buf1,"POS"))!=NULL) 
           {j=atoi(pp+5);
            iPOS=j;
           }
       }
      }
       fclose(fp);
  }

    icol1=14;
    icol2=14;
    icol3=14;
    icol4=14;

if(iCOL==1) 
  {icol1=10;icoll=10;yy=77;}
else if(iCOL==2) 
  {icol2=10;icoll=10;yy=381;}
else if(iCOL==3) 
  {icol3=10;icoll=10;yy=229;}
else if(iCOL==4) 
  {icol4=10;icoll=10;yy=533;}
if(iADS==0)
  {address=(unsigned char far *)0xe0000400;
   address1=(unsigned char far *)0xe0000000;}
else
  {address=(unsigned char far *)0xd0000400;
   address1=(unsigned char far *)0xd0000000;}
}
void takedata(void)
{int i,j;
 int m,k;
 long n;
 long nn,onn;
 
 onn=0;
 nn=0;
 m=0;
 n=0L;

 for(i=0;i<=9;i++)
  {
   
   for(j=0;j<4;j++)
     {slidata[i][j]=order[i][56+j];
      lendata[i][j]=order[i][60+j];
     }
   for(j=0;j<6;j++)
      numdata[i][j]=order[i][64+j];

   slidata[i][4]='\0';
   lendata[i][4]='\0';
   numdata[i][6]='\0';
   k=atoi(slidata[i]);
   if(k==0) k=1;   
   m=atoi(lendata[i]);
   n=atol(numdata[i]);
   nn=(long)((((double)m)*((double)n))/((double)k)/1000L+0.5);
   if(onn!=nn)
   {onn=nn;
    sprintf(buf2,"%10ld",onn);

    }
  }          
 
}

⌨️ 快捷键说明

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