📄 last.c
字号:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h> /* for usleep( long ) */
#include <string.h>
#include <fcntl.h>
#include "vga.h"
#include <vgagl.h>
#include <signal.h>
#include "hzk.h"
#define BACKGRND 20
#define EDIT_COLOR 6
#define B2_BASE_Y 4+30+4
#define B3_BASE_Y B2_BASE_Y+18*3+1
#define B3_FIELD_WIDTH 25
#define B3_GAP_X 7
#define B4_BASE_Y 480-3-40-22
#define B5_BASE_Y B4_BASE_Y+22+1
#define B5_FIELD_WIDTH 90
#define B5_FIELD_GAP 5
#define GRAPH_BASE_X 20
#define GRAPH_BASE_Y 200
FILE *fp_xhqgraph;
char savebox1[(283-269+1)*(97-47+1)*8];
char savebox2[(424-376+1)*(78-66+1)*8];
typedef struct {
int x;
int y;
int w;
int h;
int box_width;
int box_color;
} BOX;
typedef struct {
int x;
int y;
int w;
int h;
unsigned char *caption;
int bg_color;
int ft_color;
int ft_width;
int ft_height;
} LABEL;
void box( BOX b )
{
int acolor;
acolor = vga_getpixel( b.x+b.w/2, b.y+b.h/2 );
gl_fillbox( b.x, b.y, b.w, b.h, b.box_color );
gl_fillbox( b.x+b.box_width, b.y+b.box_width, b.w-2*b.box_width, b.h-2*b.box_width, acolor );
}
void clabel( LABEL l )
{
int v_shift;
v_shift = (l.h - 12 ) / 2;
gl_fillbox( l.x, l.y, l.w, l.h, l.bg_color );
puthz12(l.x, l.y+v_shift, 1, l.ft_color, l.caption, l.ft_width/12.0, l.ft_height/12.0);
}
void elabel( LABEL l )
{
int v_shift;
v_shift = (l.h - 12 ) / 2;
gl_fillbox( l.x, l.y, l.w, l.h, l.bg_color );
gl_setfont(8, 12, gl_font8x12);
gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
//gl_setwritemode(FONT_COMPRESSED + WRITEMODE_MASKED);
gl_setfontcolors(l.bg_color, l.ft_color);
gl_printf(l.x+1, l.y+v_shift, "%s", l.caption);
}
//-------------------------------
int myalarm( int no )
{
static int i1=269, i2=376;
gl_fillbox( GRAPH_BASE_X+i1, 47+GRAPH_BASE_Y, 283-269+1, 97-47+1, BACKGRND);
i1--;
gl_putbox( GRAPH_BASE_X+i1, 47+GRAPH_BASE_Y, 283-269+1, 97-47+1, savebox1);
if (i1<200)
{
gl_fillbox( GRAPH_BASE_X+i1, 47+GRAPH_BASE_Y, 283-269+1, 97-47+1, BACKGRND);
i1 = 269;
}
gl_fillbox( GRAPH_BASE_X+i2, 66+GRAPH_BASE_Y, 424-376+1, 78-66+1, BACKGRND);
i2--;
gl_putbox( GRAPH_BASE_X+i2, 66+GRAPH_BASE_Y, 424-376+1, 78-66+1, savebox2);
if (i2<320)
{
gl_fillbox( GRAPH_BASE_X+i2, 66+GRAPH_BASE_Y, 424-376+1, 78-66+1, BACKGRND);
i2 = 376;
}
}
int openxhqgraph(void)
{
fp_xhqgraph=fopen("graph.txt","r");
if( fp_xhqgraph == NULL )
{
printf("Error on open Chinese Font File");
return -1;
}
return 0;
}
int closexhqgraph(void)
{
fclose(fp_xhqgraph);
return 0;
}
int xhqcolor(char *cl_str)
{
if ( !strcmp(cl_str, "background") )
return BACKGRND;
else if ( !strcmp(cl_str, "black") )
return 0;
else if ( !strcmp(cl_str, "blue") )
return 1;
else if ( !strcmp(cl_str, "green") )
return 2;
else if ( !strcmp(cl_str, "cyan") )
return 3;
else if ( !strcmp(cl_str, "red") )
return 4;
else if ( !strcmp(cl_str, "pink") )
return 5;
else if ( !strcmp(cl_str, "orange") )
return 6;
else if ( !strcmp(cl_str, "white") )
return 7;
else if ( !strcmp(cl_str, "gray") )
return 8;
else if ( !strcmp(cl_str, "light_blue") )
return 9;
else if ( !strcmp(cl_str, "light_green") )
return 10;
else if ( !strcmp(cl_str, "light_cyan") )
return 11;
else if ( !strcmp(cl_str, "light_red") )
return 12;
else if ( !strcmp(cl_str, "light_pink") )
return 13;
else if ( !strcmp(cl_str, "yellow") )
return 14;
else if ( !strcmp(cl_str, "light_white") )
return 15;
else if ( !strcmp(cl_str, "black") )
return 16;
else
return 0;
return 7;
}
xhqbox(int x0, int y0, int x1, int y1, int bd_flag, int cl )
{
int i;
switch ( bd_flag )
{
case 0:
gl_fillbox( x0, y0, (x1-x0+1), (y1-y0+1), cl );
break;
case 1:
gl_fillbox( x0, y0, (x1-x0+1), (y1-y0+1), 7 );
gl_fillbox( x0+1, y0+1, (x1-x0-1), (y1-y0-1), cl );
break;
case 2:
vga_setcolor(cl);
vga_drawline(x0, y0, x1, y1);
break;
case 3:
vga_setcolor(cl);
for ( i=y0; i<=y1; i++ )
vga_drawline(x0, i, x0+(x1-x0+1)*(i-y0+1)/(y1-y0+1), i);
break;
case 4:
vga_setcolor(cl);
for ( i=y0; i<=y1; i++ )
vga_drawline(x0+(x1-x0+1)*(i-y0+1)/(y1-y0+1), i, x1, i);
break;
break;
case 5:
vga_setcolor(cl);
for ( i=y1; i<=y0; i++ )
vga_drawline(x0, i, x0+(x1-x0+1)*(y0-i+1)/(y0-y1+1), i);
break;
case 6:
for ( i=y1; i<=y0; i++ )
vga_drawline(x0+(x1-x0+1)*(y0-i+1)/(y0-y1+1), i, x1, i);
break;
default:
return 1;
}
return 0;
}
int xhqgraph()
{
int x0,y0,x1,y1, bd;
float rx, ry;
char cl[20];
if ( openxhqgraph()==-1 )
exit(1);
fscanf( fp_xhqgraph, "%d%d%d%d%d%s",
(int *)&x0,
(int *)&y0,
(int *)&x1,
(int *)&y1,
(int *)&bd, cl );
rx = 600.0/x1;
ry = 200.0/y1;
while ( !feof(fp_xhqgraph) )
{
fscanf( fp_xhqgraph, "%d%d%d%d%d%s",
(int *)&x0,
(int *)&y0,
(int *)&x1,
(int *)&y1,
(int *)&bd, cl );
xhqbox(x0*rx+GRAPH_BASE_X, y0*ry+GRAPH_BASE_Y, x1*rx+GRAPH_BASE_X, y1*ry+GRAPH_BASE_Y, bd, xhqcolor(cl) );
}
gl_getbox( 269+GRAPH_BASE_X, 47+GRAPH_BASE_Y, 283-269+1, 97-47+1, savebox1);
gl_getbox( 376+GRAPH_BASE_X, 66+GRAPH_BASE_Y, 424-376+1, 78-66+1, savebox2);
closexhqgraph();
}
//----------------------------
int main(void)
{
int mode;
int i, high;
BOX b0_0={ 0, 0, 640, 480, 1, 8 };
BOX b0_1={ 1, 1, 638, 478, 1, 7 };
BOX b0_2={ 2, 2, 636, 476, 1, 8 };
BOX b1_0={ 4, 4, 632, 26, 1, 7 };
BOX b1_1={ 6, 6, 209, 22, 1, 7 };
BOX b1_2={ 216, 6, 209, 22, 1, 7 };
BOX b1_3={ 426, 6, 208, 22, 1, 7 };
//--------------------------------------------
BOX b4_0={ 4, B4_BASE_Y, 632, 22, 1, 7 };
BOX b4_1={ 4, B4_BASE_Y, 60, 22, 1, 7 };
BOX b4_2={ 4+60+1, B4_BASE_Y, 330, 22, 1, 7 };
BOX b4_3={ 4+60+1+330+1, B4_BASE_Y, 60, 22, 1, 7 };
BOX b4_4={ 4+60+1+330+1+60+1, B4_BASE_Y, 179, 22, 1, 7 };
LABEL lab4_1={6, B4_BASE_Y+4, 30, 16, "操作信息", BACKGRND, 7, 12, 12};
LABEL lab4_3={4+60+1+330+1+2, B4_BASE_Y+4, 30, 16, "设定范围", BACKGRND, 7, 12, 12};
LABEL lab4_4={4+60+1+330+1+60+1+5, B4_BASE_Y+4, 170, 14, "请按 ENTER 键更改功能", 3, 11, 12, 12};
//---------------------------------------------
BOX b5_0={ 4, B5_BASE_Y, 632, 38, 1, 7 };
BOX b5_1={ 4, B5_BASE_Y, 60, 38, 1, 7 };
LABEL lab5_1_1={8, B5_BASE_Y+3, 50, 16, "动 态", BACKGRND, 7, 12, 12};
LABEL lab5_1_2={8, B5_BASE_Y+3+16, 50, 16, "监 视", BACKGRND, 7, 12, 12};
LABEL lab5_2_1={4+60+3, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " 关 开 模", 14, 0, 12, 12};
LABEL lab5_2_2={4+60+3, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
LABEL lab5_2_3={4+60+3+B5_FIELD_WIDTH+B5_FIELD_GAP, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " 射 出", 14, 0, 12, 12};
LABEL lab5_2_4={4+60+3+B5_FIELD_WIDTH+B5_FIELD_GAP, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
LABEL lab5_2_5={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*2, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " 功能时间", 14, 0, 12, 12};
LABEL lab5_2_6={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*2, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " 产量记忆", 14, 0, 12, 12};
LABEL lab5_2_7={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*3, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " 生 产", 14, 0, 12, 12};
LABEL lab5_2_8={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*3, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " 管 理", 14, 0, 12, 12};
LABEL lab5_2_9={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*4, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
LABEL lab5_2_10={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*4, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
LABEL lab5_2_11={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*5, B5_BASE_Y+3, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
LABEL lab5_2_12={4+60+3+(B5_FIELD_WIDTH+B5_FIELD_GAP)*5, B5_BASE_Y+3+16, B5_FIELD_WIDTH, 16, " ", 14, 0, 12, 12};
/*
int x;
int y;
int w;
int h;
unsigned char *caption;
int bg_color;
int ft_color;
int ft_width;
int ft_height;
*/
//-----box 1-----------------------
LABEL lab1_1={22, 10, 180, 14, "000 TEST MOULD DATA", 44, 0, 12, 12};
LABEL lab1_2_1={230, 10, 80, 14, "动作", BACKGRND, 7, 12, 12};
LABEL lab1_2_2={280, 10, 120, 14, "快速关模", 6, 44, 12, 12};
LABEL lab1_3_1={454, 10, 60, 14, " 371.2", 6, 44, 12, 12};
LABEL lab1_3_2={524, 10, 80, 14, "周期/1小时", BACKGRND, 7, 12, 12};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -