?? mosmain.java
字號:
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.LinkedList;
import javax.swing.*;
import javax.swing.border.*;
public class MosMain extends JFrame implements ActionListener {
private int[] pro_table = null;
Toolkit tool = null;
Dimension dim = null;
Container con = null;
JPanel collect_panel = null;
JPanel input_panel = null;
JPanel btn_panel = null;
JPanel in_panel = null;
JPanel in_btn_panel = null;
JPanel tot_in_btn_panel =null;
JPanel tot_inpu_panel = null;
JPanel show_stat_panel = null;
JPanel mm_disk_panel = null;
JPanel barname_panel = null;
JPanel barvalue_panel = null;
JPanel queue_panel = null;
JPanel cpu_state_panel = null;
JPanel cpu_panel = null;
Box prt_box = null;
Box sys_box = null;
Box mm_box = null;
Box disk_box = null;
Box show_prtsys_box = null;
Box show_mmdisk_box = null;
Box v1_systat_box = null;
Box v2_systat_box = null;
Box v3_systat_box = null;
Box v4_systat_box = null;
Box h_systat_box = null;
Box sys_stat_box = null;
Box v1_cputat_box = null;
Box v2_cputat_box = null;
Box v3_cputat_box = null;
Box v4_cputat_box = null;
Box h_cputat_box = null;
Box cpu_stat_box = null;
Box cpu_box = null;
Box chan_box = null;
Box var_chan_box = null;
Box chan_prt_box = null;
Box tot_chan_box = null;
JButton input_btn = null;
JButton kb_btn = null;
JButton prt_btn = null;
JButton stop_btn = null;
JButton next_btn = null;
JButton contin_btn = null;
JTextField input_field = null;
JLabel input_label = null;
JTextArea prt_area = null;
JTextArea mm_area = null;
JTextArea disk_area = null;
JLabel mm_label = null;
JLabel mm_var_label = null;
JLabel disk_label = null;
JLabel disk_var_label = null;
JLabel jcb_ready_label = null;
JLabel jcb_start_label = null;
JLabel jcb_finish_label = null;
JLabel pcb_ready_label = null;
JLabel var_jcb_ready_label = null;
JLabel var_jcb_start_label = null;
JLabel var_jcb_finish_label = null;
JLabel var_pcb_ready_label = null;
JLabel cpu_label = null;
JLabel var_cpu_label = null;
JLabel cpu_stat_label = null;
JLabel sys_label = null;
JLabel prt_label = null;
JLabel pi_label = null;
JLabel si_label = null;
JLabel ioi_label = null;
JLabel ti_label = null;
JLabel rtime_label = null;
JLabel time_label = null;
JLabel var_pi_label = null;
JLabel var_si_label = null;
JLabel var_ioi_label = null;
JLabel var_ti_label = null;
JLabel var_rtime_label = null;
JLabel var_time_label = null;
JLabel ptr_label = null;
JLabel pc_label = null;
JLabel c_label = null;
JLabel r_label = null;
JLabel comm_label = null;
JLabel next_label = null;
JLabel var_ptr_label = null;
JLabel var_pc_label = null;
JLabel var_c_label = null;
JLabel var_r_label = null;
JLabel var_comm_label = null;
JLabel var_next_label = null;
JLabel chan1_label = null;
JLabel chan2_label = null;
JLabel chan3_label = null;
JLabel var_chan1_label = null;
JLabel var_chan2_label = null;
JLabel var_chan3_label = null;
JLabel jobnum_label = null;
JLabel job_num_label = null;
JLabel[] jl_progress = null;
JProgressBar[] jpb_progress = null;
int test = 10;
MosVar var = new MosVar();
MosMM mm = new MosMM(var);
MosDisk disk = new MosDisk(var);
MosCPU cpu = new MosCPU(var);
MosROM rom = new MosROM(cpu,mm,var);
MosProcess proc = null;
MosChannel1 chan1 = new MosChannel1(mm,var);
MosChannel2 chan2 = new MosChannel2(mm,var);
MosChannel3 chan3 = new MosChannel3(mm,disk,var);
LinkedList que_jcb_ready = new LinkedList();
LinkedList que_jcb_start = new LinkedList();
LinkedList que_jcb_finish = new LinkedList();
LinkedList que_pcb_ready = new LinkedList();
LinkedList que_pcb_wait = new LinkedList();
MosP1 p1 = new MosP1(mm,disk,chan1,chan3,que_jcb_ready,var);;
MosP2 p2 = new MosP2(mm,disk,chan3,que_jcb_ready,que_jcb_start,que_pcb_ready,var,cpu,p1);
MosP3 p3 = new MosP3(mm,disk,chan2,chan3,que_jcb_finish,var);
byte[] mm_data = new byte[4];
byte[] disk_data = new byte[40];
String s = "";
Border edge1 = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border edge2 = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
Font f3 = new Font("",Font.PLAIN,16);
Font f2 = new Font("",Font.PLAIN,18);
Font f_job = new Font("",Font.PLAIN,12);
JScrollPane mm_scr_pane = null;
JScrollPane disk_scr_pane = null;
JScrollPane prt_scr_pane = null;
MosPrt mosp = null;
KBInBuffer kbinb = null;
PrtOutBuffer prtoutb = null;
/**
* @param args
*/
public MosMain() {
con = getContentPane();
tool = Toolkit.getDefaultToolkit();
dim = tool.getScreenSize();
// input label;
this.input_label = new JLabel();
Font f = new Font("",Font.BOLD,18);
this.input_label.setFont(f);
this.input_label.setForeground(Color.BLUE);
this.input_label.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.input_label.setHorizontalAlignment(JLabel.CENTER);
this.input_label.setText("作業名:");
// input field;
this.input_field = new JTextField("",40);
var.input_field = this.input_field;
f = new Font("",Font.PLAIN,20);
this.input_field.setFont(f);
this.input_field.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.in_panel = new JPanel();
this.in_panel.setLayout(new BorderLayout());
this.in_panel.setBackground(new Color(240,248,255));
this.in_panel.setBorder(BorderFactory.createTitledBorder(edge1,
"作業輸入區",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.in_panel.add(this.input_label,BorderLayout.WEST);
this.in_panel.add(this.input_field,BorderLayout.CENTER);
// input button;
this.input_btn = new JButton("確定");
this.input_btn.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.input_btn.addActionListener(this);
var.input_btn = this.input_btn;
this.stop_btn = new JButton("暫停");
this.stop_btn.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.stop_btn.addActionListener(this);
this.next_btn = new JButton("單步");
this.next_btn.setEnabled(false);
this.next_btn.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.next_btn.addActionListener(this);
this.contin_btn = new JButton("繼續");
this.contin_btn.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.contin_btn.addActionListener(this);
this.contin_btn.setEnabled(false);
this.tot_in_btn_panel = new JPanel();
this.tot_in_btn_panel.setLayout(new GridLayout(1,3));
this.tot_in_btn_panel.setBackground(new Color(240,248,255));
this.tot_in_btn_panel.setBorder(BorderFactory.createTitledBorder(edge1,
"用戶接口",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.tot_in_btn_panel.add(this.input_btn);
this.tot_in_btn_panel.add(this.stop_btn);
this.tot_in_btn_panel.add(this.next_btn);
this.tot_in_btn_panel.add(this.contin_btn);
this.in_btn_panel = new JPanel();
this.in_btn_panel.setLayout(new BorderLayout());
this.in_btn_panel.setBackground(new Color(240,248,255));
this.in_btn_panel.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.in_btn_panel.add(this.in_panel,BorderLayout.CENTER);
this.in_btn_panel.add(this.tot_in_btn_panel,BorderLayout.EAST);
this.kb_btn = new JButton("輸入緩存區");
this.kb_btn.addActionListener(this);
this.prt_btn = new JButton("輸出緩存區");
this.prt_btn.addActionListener(this);
this.btn_panel = new JPanel();
this.btn_panel.setLayout(new FlowLayout());
this.btn_panel.setBackground(new Color(255,228,212));
this.btn_panel.setBorder(BorderFactory.createTitledBorder(edge1,
"作業緩存區",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.btn_panel.add(this.kb_btn);
this.btn_panel.add(this.prt_btn);
this.tot_inpu_panel = new JPanel();
this.tot_inpu_panel.setLayout(new BorderLayout());
this.tot_inpu_panel.setBackground(new Color(0,255,212));
this.tot_inpu_panel.setBorder(BorderFactory.createTitledBorder(edge1,
"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
this.tot_inpu_panel.add(this.in_btn_panel, BorderLayout.CENTER);
this.tot_inpu_panel.add(this.btn_panel, BorderLayout.EAST);
f = new Font("",Font.PLAIN,18);
this.ptr_label = new JLabel(" PTR :");
this.ptr_label.setFont(f);
this.ptr_label.setForeground(Color.BLUE);
this.pc_label = new JLabel(" PC :");
this.pc_label.setFont(f);
this.pc_label.setForeground(Color.BLUE);
this.r_label = new JLabel(" R :");
this.r_label.setFont(f);
this.r_label.setForeground(Color.BLUE);
this.c_label = new JLabel(" C :");
this.c_label.setFont(f);
this.c_label.setForeground(Color.BLUE);
this.comm_label = new JLabel("COMM:");
this.comm_label.setFont(f);
this.comm_label.setForeground(Color.BLUE);
this.next_label = new JLabel("NEXT:");
this.next_label.setFont(f);
this.next_label.setForeground(Color.BLUE);
this.var_ptr_label = new JLabel("0");
var.var_ptr_label = this.var_ptr_label;
this.var_ptr_label.setFont(f2);
this.var_ptr_label.setForeground(Color.RED);
this.var_pc_label = new JLabel("0");
var.var_pc_label = this.var_pc_label;
this.var_pc_label.setFont(f2);
this.var_pc_label.setForeground(Color.RED);
this.var_r_label = new JLabel("0");
var.var_r_label = this.var_r_label;
this.var_r_label.setFont(f2);
this.var_r_label.setForeground(Color.RED);
this.var_c_label = new JLabel("F");
var.var_c_label = this.var_c_label;
this.var_c_label.setFont(f2);
this.var_c_label.setForeground(Color.RED);
this.var_comm_label = new JLabel("0");
var.var_comm_label = this.var_comm_label;
this.var_comm_label.setFont(f2);
this.var_comm_label.setForeground(Color.RED);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -