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

📄 printer.h

📁 该模块包括作业调度的三个系统进程。P1、P2、P3进程功能的实现。 P1负责对用户作业预输入处理
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*****************************************************************************

文件名称:  PRINTER.H
模块名称:  用户界面输出模块(图形界面输出模块之一)
模块作用:
编写者一:  蔡晓跃(AP0106338)
编写者二:
编写日期:
完成日期:
程序行数:   610

*****************************************************************************
*****************************************************************************/

/***************************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_INITIALZE
功    能:  将用户的显示界面初始化为图形模式(640X480)像素
入口参数:  无
出口参数:  无
调用关系:  被INIT_INTERFACE调用
编    者:  蔡晓跃(AP0106338)
编写日期:
****************************************************************************************/

G_INITIALIZE()
{
    int GraphDriver,GraphMode=0,ErrorCode;
    if(DISPLAY_MODE == TEXT)
        return(0);
/*    DISPLAY_COLOR(); */
    /* 显示操作系统标题界面 */
    if(DISPLAY_PICTURE_OK==FALSE)
    {
        if(G_DISPLAY_BMP_PICTURE_256(800,600,"COLOR.OP",0)==FALSE)
            exit(0);
    }
    else if(DISPLAY_PICTURE_OK==-4)
    /* -4 表示安装用户显示设备失败 */
        G_TITLE();
    /* 如果要显示动画,则显示进度条 */
    if(DISPLAY_FLASH == TRUE)
        G_DISPLAY_LOAD_SYSTEM_LINE(0);
    else
        getch();
    cleardevice();
    /* 标题显示后,再调用作业运行的演示界面 */
    G_INIT_FACE();
}


/****************************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_INIT_FACE
功    能:  显示作业运行的演示界面
入口参数:  无
出口参数:  无
调用关系:  被G_INITIALIZE调用
编    者:  蔡晓跃(AP0106338)
编写日期:
****************************************************************************************/
G_INIT_FACE()
{
    int i,j,x,y;
    if(DISPLAY_MODE == TEXT)
        return(0);
    setcolor(line_color);
    setfillstyle(2,yellow_color);
    settextstyle(0,0,1);
    /* 画主机箱 */
    DISPLAY_PICTURE_OK=G_PRINT_MECHINE();
    if(DISPLAY_PICTURE_OK==FALSE)
    {
        y_top = y_temp_top;
        M_DRAW_MAIN_MACHINE_BOX();
    }
    else
    {
        M_DRAW_MACHINE_LIGHTS(0,red_color,3);
        M_DRAW_MACHINE_LIGHTS(1,green_color,3);
        M_DRAW_MACHINE_LIGHTS(1,black_color,3);
        setcolor(line_color);
    }
    /* 显示“多进程操作系统演示界面”字样 */
    x = (640-35*10-100)/2+x_left;
    y = 15+y_top;
    for(i=0;i<11;i++)
        DRAWMAT(demo_title+i*128,32,x+i*35,y,white_color);
    /* 显示系统引导的过程 */
    G_DISPLAY_CHECK_LOAD_SYSTEM();


    /* 显示"内存使用情况"*/
    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);
    /* 画内存 */
    rectangle(sysbuf_left,sysbuf_top,sysbuf_left+sysbuf_width,sysbuf_top+sysbuf_height);
    rectangle(userbuf_left,userbuf_top,userbuf_left+userbuf_width,userbuf_top+userbuf_height);
    /* 画打印机 */
    rectangle(print_left,print_top,print_left+print_width,print_top+print_height);
    M_G_DRAW_PRINTER();
    /* 画键盘 */
    rectangle(keyboard_left,keyboard_top,keyboard_left+keyboard_width,keyboard_top+keyboard_height);
    M_G_DRAW_KEYBOARD();
    /* 画输入井 */
    rectangle(in_left,in_top,in_left+in_width,in_top+in_height);
    /* 画输出井 */
    rectangle(out_left,out_top,out_left+out_width,out_top+out_height);
    /* 画系统进程 */
    rectangle(system_left,system_top,system_left+system_width,system_top+system_height);
    /* 画用户就绪队列 */
    rectangle(ready_left,ready_top,ready_left+ready_width,ready_top+ready_height);
    /* 画CPU */
    rectangle(cpu_left,cpu_top,cpu_left+cpu_width,cpu_top+cpu_height);
    for(i=0;i<3;i++)
        DRAWMAT(cpu+i*32,16,cpu_left+i*16,cpu_top+1,yellow_color);

    /* 画显示CPU以及中断参数的表格 */
    rectangle(cpui_left,cpui_top-4,cpui_left+cpui_width,cpui_top+cpui_height); 
    setfillstyle(1,blue_color);
    for(i=1;i<7;i++)
    {
        rectangle(cpui_left,cpui_top+i*cpui_height,cpui_left+cpui_width*2/3,cpui_top+(i+1)*cpui_height); 
        rectangle(cpui_left+cpui_width*2/3,cpui_top+i*cpui_height,cpui_left+cpui_width,cpui_top+(i+1)*cpui_height); 
        bar(cpui_left+56,cpui_top+i*cpui_height+1,cpui_left+cpui_width*2/3-1,cpui_top+(i+1)*cpui_height-1); 
        bar(cpui_left+cpui_width*2/3+36,cpui_top+i*cpui_height+1,cpui_left+cpui_width-1,cpui_top+(i+1)*cpui_height-1); 
    }
    setfillstyle(2,yellow_color);
    /* 用中文的字体显示“CPU”字样 */
    for(i=0;i<3;i++)
        DRAWMAT(cpu+i*32,16,cpui_left+20+i*16,cpui_top-1,yellow_color);
    /* 显示中文“中断参数”字样 */
    for(i=0;i<5;i++)
        DRAWMAT(cpu_info_discript+i*32,16,cpui_left+20+(i+3)*16,cpui_top-1,yellow_color);
    /* 显示系统时间,相对时间 PC,R ,C 以及中断参数等 */
    i=1;
    setcolor(yellow_color);
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4," PI:");
    outtextxy(cpui_left+4,cpui_top+i++*cpui_height+4,"RTIME:");
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4," SI:");
    outtextxy(cpui_left+4,cpui_top+i++*cpui_height+4,"TIME :");
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4," TI:");
    outtextxy(cpui_left+4,cpui_top+i++*cpui_height+4," PC  :");
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4,"IOI:");
    outtextxy(cpui_left+4,cpui_top+i++*cpui_height+4," R   :");
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4," PT:");
    outtextxy(cpui_left+4,cpui_top+i++*cpui_height+4," C   :");
    outtextxy(cpui_left+cpui_width*2/3+4,cpui_top+i*cpui_height+4,"POL:");
    setcolor(line_color);
    /* 显示中文“当前指令”字样 */
    for(i=0;i<4;i++)
        DRAWMAT(CUR_INSTRUCTION+i*24,12,cpui_left+5+i*12,cpui_top+6*cpui_height+2,yellow_color);
    /* 画显示错误的表格 */
    rectangle(error_left,error_top-4,error_left+error_width,error_top+error_height); 
    rectangle(error_left,error_top+1*error_height,error_left+error_width,error_top+7*error_height); 
    /* 显示提示信息标题 */
    for(i=0;i<4;i++)
        DRAWMAT(MENTION+i*32,16,error_left+(error_width-64)/2+i*16,error_top-1,yellow_color);
    for(i=0;i<6;i++)
        DRAWMAT(op_mention+i*24,12,error_left+4+i*12+12,error_top+error_height*6,white_color);
    for(i=0;i<6;i++)
        DRAWMAT(_reset_+i*24,12,error_left+4+i*12+9*12,error_top+error_height*6,white_color);
    /* 显示P-单步 */
    for(i=0;i<4;i++)
        DRAWMAT(_P_step_by_step+i*24,12,error_left+4+i*12+12,error_top+error_height*5,white_color);
    /* 显示D-切换 */
    for(i=0;i<4;i++)
        DRAWMAT(_All_PC_R_C+i*24,12,error_left+4+i*12+12+12*8,error_top+error_height*5,white_color);
}

/****************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_DRAW_LINE_BY_INCREASE
功    能:  每次以增量单位画一线条
入口参数:  (G_POINT s,G_POINT e) s起始坐标,e目的坐标
出口参数:  无
调用关系:
编    者:  蔡晓跃(AP0106338)
编写日期:
****************************************************************************/
G_DRAW_LINE_BY_INCREASE(G_POINT s,G_POINT e,int c)
{
    int x,y,increase,oldc;
    if(DISPLAY_MODE == TEXT)
        return(0);
    x = s.x;
    y = s.y;
    oldc = getcolor();
    setcolor(c);
    moveto(s.x,s.y);
    /* 如果从起始坐标大于结束坐标,则增量为负数*/
    if(s.x > e.x || s.y > e.y)
        increase = -1;
    else
        /* 如果从起始坐标小于结束坐标,则增量为正数*/
        increase = 1;

    /* 起始坐标与目的坐标的Y坐标值相等,则表示画一水平线 */
    if(s.y == e.y)
    {
        /* 画水平线 */
        while(abs(e.x - x) > UNIT_LINE_LEN)
        {
            x += (UNIT_LINE_LEN * increase);
            lineto(x,y);
            delay(DELAY_TIME*2);
        }
        x = e.x;
        lineto(x,y);
    }
    else
    {
        /* 画垂直线 */
        while(abs(e.y - y) > UNIT_LINE_LEN)
        {
            y += (UNIT_LINE_LEN * increase);
            lineto(x,y);
            delay(DELAY_TIME*2);
        }
        y = e.y;
        lineto(x,y);
    }
    setcolor(oldc);
}


/****************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_MOVE_RECTANGLE_BASE_MIDDLE_POINT
功    能:  该函数负责移动一个长方形的图形区从源坐标到目的坐标
入口参数:  (G_POINT left_top,G_POINT right_bottom,G_POINT s,G_POINT e,void *buf)
            left_top 被移动的长方形左上角坐标
            right_bottom 被移动的长方形右下角坐标
            s 被移动的长方形源坐标
            e 被移动的长方形目的坐标
出口参数:  无
调用关系:
编    者:  蔡晓跃(AP0106338)
编写日期:
****************************************************************************/
G_MOVE_RECTANGLE_BASE_MIDDLE_POINT(G_POINT left_top,G_POINT right_bottom,G_POINT s,G_POINT e,void *buf)
{
    int width,height,x,y,increase;
    if(DISPLAY_MODE == TEXT)
        return(0);
    /* 计算长方形的宽度和调度 */
    width = abs(left_top.x - right_bottom.x);
    height = abs(left_top.y - right_bottom.y);
    x = s.x - width/2;
    y = s.y - height/2;
    if(s.x > e.x || s.y > e.y)
        /* 从大坐标移动到小坐标 */
        increase = -1;
    else
        /* 从小坐标移动到大坐标 */
        increase = 1;
    /* 以异或的方式显示先前被保存的图像 */
    putimage(x,y,buf,XOR_PUT);
    /* 延时处理 */
    delay(DELAY_TIME*2);
    if(s.y == e.y)
    {
        /* 水平移动方式 */
        while(abs(e.x- width/2 - x) > UNIT_LINE_LEN)
        {
            /* 以异或的方式显示先前被保存的图像,作用:先擦除旧图像 */
            putimage(x,y,buf,XOR_PUT);
            /* 水平方式移动 ,改变X坐标的值 */
            x += (UNIT_LINE_LEN * increase);
            /* 以异或的方式显示先前被保存的图像,作用:在新的坐标位置显示图像 */
            putimage(x,y,buf,XOR_PUT);
            delay(DELAY_TIME*2);
        }
    }
    else
    {
        /* 垂直移动方式 */
        while(abs(e.y- height/2 - y) > UNIT_LINE_LEN)
        {
            /* 以异或的方式显示先前被保存的图像,作用:先擦除旧图像 */
            putimage(x,y,buf,XOR_PUT);
            /* 垂直方式移动 ,改变Y坐标的值 */
            y += (UNIT_LINE_LEN * increase);
            /* 以异或的方式显示先前被保存的图像,作用:在新的坐标位置显示图像 */
            putimage(x,y,buf,XOR_PUT);
            delay(DELAY_TIME*2);
        }
    }
    /* 最后擦除图像 */
    putimage(x,y,buf,XOR_PUT);
}


/****************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_DISPLAY_INFORMATION
功    能:  负责调用G_ERROR_INFORMATION和G_FLASH_INFORMATION来显示信息
入口参数:  (PCB *job,char *p,int size,int len,int color)
出口参数:  无
调用关系:  
编    者:  蔡晓跃(AP0106338)
编写日期:
****************************************************************************/
G_DISPLAY_INFORMATION(PCB *job,char *p,int size,int len,int color)
{
    if(DISPLAY_MODE == TEXT)
        return(0);
    /* 如果job不为空,则表示当前运行的进程出错,显示出错的行号,作业名,代码等*/
    if(job != NULL)
        G_ERROR_INFORMATION(job,TRUE);
    /* 显示出错的中文信息*/
    G_FLASH_INFORMATION(p,size,len,color);
    /* 发出鸣叫 */
    putchar(7);
    /* 等待按键 */
    getch();
    /* 最后清除出错的信息 */
    G_FLASH_INFORMATION(p,size,len,0);
    
    if(job != NULL)
        G_ERROR_INFORMATION(job,FALSE);
}

/****************************************************************************
所属模块:  界面输出(图形方式)
函 数 名:  G_ERROR_INFORMATION
功    能:  显示出错的信息
入口参数:  (PCB *job,int dis)作业的进程,dis表示是否要显示,为FALSE时不显示
出口参数:  无
调用关系:  
编    者:  蔡晓跃(AP0106338)

⌨️ 快捷键说明

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