📄 graph.h
字号:
tcolor = yellow_color;
}
else if(s == Block)
{
/* 如果进程状态是阻塞的,则表黑色底色和白色前景来显示*/
st = &_block_[0];
tcolor = white_color;
}
else if(s == Destory)
{
/* 如果进程状态是销毁的,则表黑色底色和灰色前景来显示*/
st = &_destory_[0];
tcolor = systemp_death_color;
}
setcolor(tcolor);
setfillstyle(1,bcolor);
bar(system_left+1,system_top+index*system_height/4+1,system_left+system_width-1,system_top+(index+1)*(system_height/4)-1);
if(len == 0)
{
/* 如果len的长度为0 ,则表示要显示的不是汉字 ,而是P1P2P3之类的*/
outtextxy(system_left+(system_width/2-16)/2,system_top+index*system_height/4+(system_height/4 - 8)/2,n);
}
else
{
/* 如果len不为0,则表示是显示汉字,而len为汉字的个数 */
for(i=0;i<2;i++)
DRAWMAT(n+i*24,12,system_left+(system_width/2-24)/2+i*12,system_top+index*system_height/4+(system_height/4 - 12)/2,tcolor);
}
/* 用汉字显示进程的状态 */
for(i=0;i<2;i++)
DRAWMAT(st+i*24,12,system_left+system_width/2+(system_width/2-24)/2+i*12,system_top+index*system_height/4+(system_height/4 - 12)/2,tcolor);
}
/****************************************************************************
模块名称: 辅助模块
函 数 名: M_G_DISPLAY_OR_CLEAN_LINE_BETWEEN_CPU_AND_SYSTEM_PROCESS
功 能: 显示或清除CPU与系统进程之间的线条
入口参数: int color 要显示或清除的颜色值
出口参数: 无
调用关系: 被进程管理函数调用
编 者: 蔡晓跃(AP0106338)
编写日期: 2003-10-17
*****************************************************************************/
M_G_DISPLAY_OR_CLEAN_LINE_BETWEEN_CPU_AND_SYSTEM_PROCESS(int color)
{
G_POINT s,m1,m2,e;
if(RUNNING_QUEUE->p_next->p_id == SYSTEM_INPUT_PROCESS)
{
s.x = system_left-1;
s.y = system_top+0*system_height/4+system_height/4/2;
}
else if(RUNNING_QUEUE->p_next->p_id == SYSTEM_JOB_SCHEDUL)
{
s.x = system_left-1;
s.y = system_top+1*system_height/4+system_height/4/2;
}
else if(RUNNING_QUEUE->p_next->p_id == SYSTEM_OUTPUT_PROCESS)
{
s.x = system_left-1;
s.y = system_top+2*system_height/4+system_height/4/2;
}
else if(RUNNING_QUEUE->p_next->p_id == SYSTEM_SUPERWAIT)
{
s.x = system_left-1;
s.y = system_top+3*system_height/4+system_height/4/2;
}
m1.x = (cpu_left+cpu_width+system_left)/2;
m1.y = s.y;
m2.x = m1.x;
m2.y = cpu_top+(cpu_height-ready_height)+ready_height/2;
e.x = cpu_left+cpu_width+1;
e.y = m2.y;
M_G_DRAW_A_LINE_WITH_COLOR(s,m1,color);
M_G_DRAW_A_LINE_WITH_COLOR(m1,m2,color);
M_G_DRAW_A_LINE_WITH_COLOR(m2,e,color);
if(color == line_color)
M_G_DISPLAY_OR_CLEAN_JOB_IN_CPU(blue_color);
else
M_G_DISPLAY_OR_CLEAN_JOB_IN_CPU(black_color);
}
/****************************************************************************
模块名称: 辅助模块
函 数 名: M_G_DRAW_A_LINE_WITH_COLOR
功 能: 用某一指定的颜色值快速画直线
入口参数: G_POINT s 要画线条的开始坐标
G_POINT e 要画线条的结束坐标
int color 要显示或清除的颜色值
出口参数: 无
调用关系:
编 者: 蔡晓跃(AP0106338)
编写日期: 2003-10-17
*****************************************************************************/
M_G_DRAW_A_LINE_WITH_COLOR(G_POINT s,G_POINT e,int color)
{
setcolor(color);
line(s.x,s.y,e.x,e.y);
}
/****************************************************************************
模块名称: 辅助模块
函 数 名: M_G_DISPLAY_MACHINE_HAS_SHUTDOWN
功 能: 显示机器已关闭,现在可以安全关机字样
入口参数: 无
出口参数: 无
调用关系: 被主模块调用
编 者: 蔡晓跃(AP0106338)
编写日期: 2003-10-17
*****************************************************************************/
M_G_DISPLAY_MACHINE_HAS_SHUTDOWN()
{
int i,x1,y1,x2,y2,maxx,maxy;
float p;
G_POINT s,e;
maxx = getmaxx();
maxy = getmaxy();
s.x = (getmaxx()-10*32)/2;
s.y = (getmaxy()-3*32)/2;
e.x = (getmaxx()-10*32)/2+10*32;
e.y = (getmaxy()-3*32)/2+3*32;
p = (float)(e.x-s.x)/(float)(e.y - s.y);
y1 = maxy/2;
y2 = y1;
if(DISPLAY_PICTURE_OK==TRUE)
{
setfillstyle(1,black_color);
bar(cpui_left,cpui_top-5,cpui_left+cpui_width,cpui_top+cpui_height*6+15);
if(G_DISPLAY_MECHINE_CAN_CLOSE()==TRUE)
return(TRUE);
}
setfillstyle(1,shutdown_color);
/* 采用动态方式,要显示的矩形区域越来越大 */
while(y2<e.y)
{
y2++;
y1--;
x1 = maxx/2 - (y2-y1)*p/2;
x2 = maxx/2 + (y2-y1)*p/2;
bar(x1,y1,x2,y2);
delay(DELAY_TIME*2);
}
/* 最后显示"现在可以安全关机"字样 */
for(i=0;i<8;i++)
DRAWMAT(_shutdown_+i*128,32,(getmaxx()-10*32)/2+32+i*32,(getmaxy()-3*32)/2+32,blue_color);
}
/****************************************************************************
模块名称: 辅助模块
函 数 名: M_CHARGE_MEMORY_TABLE_STATUS
功 能: 显示内存页表的使用情况
入口参数: int index 内存页表的数组下标
char status 该内存页表的状态(空闲或占用)
出口参数: 无
调用关系:
编 者: 蔡晓跃(AP0106338)
编写日期: 2003-10-17
*****************************************************************************/
M_CHARGE_MEMORY_TABLE_STATUS(int index,char status)
{
MEMORY_TABLE[index] = status;
if(DISPLAY_MEMORY_STATUS == FALSE)
return(FALSE);
G_DRAW_MEMORY_STATUS(index,status);
}
G_DRAW_MEMORY_STATUS(int index,char status)
{
int i,c;
char *p,buf[10];
setcolor(line_color);
setlinestyle(0,0,1);
setfillstyle(1,0);
/* 画对应内存页表的方格 */
bar(memorypage_left+1,memorypage_top+index*memorypage_height+1,memorypage_left+memorypage_width-1,memorypage_top+(index+1)*memorypage_height-1);
rectangle(memorypage_left,memorypage_top+index*memorypage_height,memorypage_left+memorypage_width,memorypage_top+(index+1)*memorypage_height);
if(status == 'F')
{
/* 如果状态是空闲,则指针p指向"空闲"的首地址*/
p = &_free_[0];
/* 显示的颜色值*/
c = 7;
}
else
{
/* 如果状态是占用,则指针p指向"占用"的首地址*/
p = &_taken_[0];
/* 显示的颜色值*/
c = green_color;
}
setcolor(c);
itoa(index,buf,10);
/* 显示内存页表的序号*/
outtextxy(memorypage_left+20,memorypage_top+index*memorypage_height+3,buf);
/* 显示其状态 */
for(i=0;i<2;i++)
DRAWMAT(p+i*24,12,memorypage_left+memorypage_width-24-10+i*12,memorypage_top+index*memorypage_height+2,c);
setlinestyle(0,0,3);
}
G_DISPLAY_LOAD_SYSTEM_LINE(int index)
{
int mx,my,x,y,xx;
mx=getmaxx();
my=getmaxy();
y=my-30;
setlinestyle(0,0,1);
setcolor(yellow_color);
if(index==1)
{
for(xx=0;xx<5;xx++)
{
for(x=xx;x<mx;x+=5)
{
line(x-5,y-5,x,y);
line(x,y,x-5,y+5);
delay(DELAY_TIME*3);
}
}
}
else
{
for(x=0;x<mx+5*5*2;x+=5)
{
line(x-5,y-5,x,y);
line(x,y,x-5,y+5);
}
for(xx=0;xx<mx*2;xx+=5)
{
setcolor(blue_color);
x=xx%(mx+5*5);
line(x-5,y-5,x,y);
line(x,y,x-5,y+5);
setcolor(yellow_color);
line(x-5-5*5,y-5,x-5*5,y);
line(x-5*5,y,x-5-5*5,y+5);
x=(xx-(mx/2+1))%(mx+5*5);
setcolor(line_color);
line(x-5,y-5,x,y);
line(x,y,x-5,y+5);
setcolor(yellow_color);
line(x-5-5*5,y-5,x-5*5,y);
line(x-5*5,y,x-5-5*5,y+5);
delay(DELAY_TIME*8);
}
}
}
G_DISPLAY_ONE_PC_R_C(PCB *p,int color,int i)
{
char buf1[10],buf2[10],buf3[10];
if(DISPLAY_MEMORY_STATUS == TRUE)
return(FALSE);
i++;
/* 用line_color显示当前正在运行的PC_R_C 值*/
setfillstyle(1,black_color);
bar(memorypage_left,memorypage_top+i*16+10,memorypage_left+memorypage_width,memorypage_top+i*16+8+10);
setcolor(color);
if(i == 1)
{
itoa(PC,buf1,10);
itoa(R,buf2,10);
buf3[0] = C;
}
else
{
itoa(p->p_pc,buf1,10);
itoa(p->p_r,buf2,10);
buf3[0] = p->p_c;
}
buf3[1] = '\0';
outtextxy(memorypage_left+1,memorypage_top+i*16+10,buf1);
outtextxy(memorypage_left+1+32,memorypage_top+i*16+10,buf2);
outtextxy(memorypage_left+5+32+48,memorypage_top+i*16+10,buf3);
}
G_DISPLAY_ALL_PC_R_C()
{
char buf[10];
int i;
PCB *p;
if(DISPLAY_MEMORY_STATUS == TRUE)
return(FALSE);
setfillstyle(1,black_color);
bar(memorypage_left,memorypage_top,memorypage_left+memorypage_width,memorypage_top+memorypage_height*30);
G_DISPLAY_ONE_PC_R_C(RUNNING_QUEUE->p_next,RUNNING_QUEUE->p_next->p_color,0);
p = READY_QUEUE->p_next;
for(i=0;i<READY_QUEUE->p_tick;i++)
{
G_DISPLAY_ONE_PC_R_C(p,p->p_color,i+1);
p = p->p_next;
}
}
G_CHANGE_DISPLAY_STYLE_BETWEEN_MEMORY_AND_PC_R_C()
{
int i;
if(DISPLAY_MEMORY_STATUS == TRUE)
{
setfillstyle(1,black_color);
bar(memorypage_left,memorypage_top-16,memorypage_left+memorypage_width,memorypage_top+memorypage_height*30);
/* 显示"内存使用情况"*/
for(i=0;i<6;i++)
DRAWMAT(_memorypage_status_+i*24,12,memorypage_left+(memorypage_width-72)/2+i*12,memorypage_top-16,yellow_color);
for(i=0;i<30;i++)
G_DRAW_MEMORY_STATUS(i,MEMORY_TABLE[i]);
}
else
{
setfillstyle(1,black_color);
bar(memorypage_left,memorypage_top-16,memorypage_left+memorypage_width,memorypage_top);
setcolor(yellow_color);
outtextxy(memorypage_left+(memorypage_width-12*8)/2,memorypage_top-12,"PC R C ");
G_DISPLAY_ALL_PC_R_C();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -