«   2020/10   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
10-22 06:54
관리 메뉴

언제나 휴일

[C# 실습,공장 UI 구현] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션 본문

언어 자료구조 알고리즘/프로그래밍 실습

[C# 실습,공장 UI 구현] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션

언제나 휴일 언제나휴일 2020. 10. 12. 11:53

앞에서 반도체 증착공정 설비를 제작하고 이를 시각화하는 설비 컨트롤 예광탄 코드를 소개했어요.

 

설비 컨트롤 예광탄의 코드를 이용하여 설비 컨트롤 라이브러리를 만드세요. 

이번 코드는 설비와 설비 커트롤 라이브러리를 참조하여 공장 UI에 관한 글입니다.

1. Form1의 이름을 MainForm으로 변경하세요.(파일이름을 바꾸세요.)

2. MainForm에 자식 컨트롤을 배치합니다.

설비를 추가할 수 있고 추가할 설비를 관리할 수 있는 컨트롤을 배치합니다.

MainForm 자식 컨트롤 배치

MainForm.Designer.cs

namespace 증착_및_BurnInTest_공장_시뮬레이션
{
    partial class MainForm
    {
        /// <summary>
        /// 필수 디자이너 변수입니다.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 사용 중인 모든 리소스를 정리합니다.
        /// </summary>
        /// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form 디자이너에서 생성한 코드

        /// <summary>
        /// 디자이너 지원에 필요한 메서드입니다. 
        /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
        /// </summary>
        private void InitializeComponent()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.rb_pvd = new System.Windows.Forms.RadioButton();
            this.rb_cvd = new System.Windows.Forms.RadioButton();
            this.rb_ald = new System.Windows.Forms.RadioButton();
            this.label1 = new System.Windows.Forms.Label();
            this.lb_no = new System.Windows.Forms.Label();
            this.btn_add = new System.Windows.Forms.Button();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.cb_no = new System.Windows.Forms.ComboBox();
            this.btn_manage = new System.Windows.Forms.Button();
            this.label2 = new System.Windows.Forms.Label();
            this.nud_source = new System.Windows.Forms.NumericUpDown();
            this.btn_addpage = new System.Windows.Forms.Button();
            this.btn_start = new System.Windows.Forms.Button();
            this.label3 = new System.Windows.Forms.Label();
            this.lb_source = new System.Windows.Forms.Label();
            this.btn_stop = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nud_source)).BeginInit();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.rb_ald);
            this.groupBox1.Controls.Add(this.rb_cvd);
            this.groupBox1.Controls.Add(this.rb_pvd);
            this.groupBox1.Location = new System.Drawing.Point(13, 28);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(570, 93);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "증착 방법";
            // 
            // rb_pvd
            // 
            this.rb_pvd.AutoSize = true;
            this.rb_pvd.Location = new System.Drawing.Point(39, 40);
            this.rb_pvd.Name = "rb_pvd";
            this.rb_pvd.Size = new System.Drawing.Size(66, 25);
            this.rb_pvd.TabIndex = 0;
            this.rb_pvd.TabStop = true;
            this.rb_pvd.Text = "PVD";
            this.rb_pvd.UseVisualStyleBackColor = true;
            // 
            // rb_cvd
            // 
            this.rb_cvd.AutoSize = true;
            this.rb_cvd.Location = new System.Drawing.Point(228, 40);
            this.rb_cvd.Name = "rb_cvd";
            this.rb_cvd.Size = new System.Drawing.Size(67, 25);
            this.rb_cvd.TabIndex = 1;
            this.rb_cvd.TabStop = true;
            this.rb_cvd.Text = "CVD";
            this.rb_cvd.UseVisualStyleBackColor = true;
            // 
            // rb_ald
            // 
            this.rb_ald.AutoSize = true;
            this.rb_ald.Location = new System.Drawing.Point(444, 40);
            this.rb_ald.Name = "rb_ald";
            this.rb_ald.Size = new System.Drawing.Size(64, 25);
            this.rb_ald.TabIndex = 2;
            this.rb_ald.TabStop = true;
            this.rb_ald.Text = "ALD";
            this.rb_ald.UseVisualStyleBackColor = true;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(13, 149);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(108, 21);
            this.label1.TabIndex = 1;
            this.label1.Text = "설비 번호:";
            // 
            // lb_no
            // 
            this.lb_no.AutoSize = true;
            this.lb_no.Location = new System.Drawing.Point(144, 149);
            this.lb_no.Name = "lb_no";
            this.lb_no.Size = new System.Drawing.Size(60, 21);
            this.lb_no.TabIndex = 2;
            this.lb_no.Text = "[No.]";
            // 
            // btn_add
            // 
            this.btn_add.Location = new System.Drawing.Point(446, 140);
            this.btn_add.Name = "btn_add";
            this.btn_add.Size = new System.Drawing.Size(137, 38);
            this.btn_add.TabIndex = 3;
            this.btn_add.Text = "설비 추가";
            this.btn_add.UseVisualStyleBackColor = true;
            this.btn_add.Click += new System.EventHandler(this.btn_add_Click);
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.btn_stop);
            this.groupBox2.Controls.Add(this.lb_source);
            this.groupBox2.Controls.Add(this.label3);
            this.groupBox2.Controls.Add(this.btn_start);
            this.groupBox2.Controls.Add(this.btn_addpage);
            this.groupBox2.Controls.Add(this.nud_source);
            this.groupBox2.Controls.Add(this.label2);
            this.groupBox2.Controls.Add(this.btn_manage);
            this.groupBox2.Controls.Add(this.cb_no);
            this.groupBox2.Location = new System.Drawing.Point(17, 205);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(566, 253);
            this.groupBox2.TabIndex = 4;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "설비 관리";
            // 
            // cb_no
            // 
            this.cb_no.FormattingEnabled = true;
            this.cb_no.Location = new System.Drawing.Point(6, 45);
            this.cb_no.Name = "cb_no";
            this.cb_no.Size = new System.Drawing.Size(371, 29);
            this.cb_no.TabIndex = 0;
            this.cb_no.SelectedIndexChanged += new System.EventHandler(this.cb_no_SelectedIndexChanged);
            // 
            // btn_manage
            // 
            this.btn_manage.Location = new System.Drawing.Point(388, 45);
            this.btn_manage.Name = "btn_manage";
            this.btn_manage.Size = new System.Drawing.Size(143, 29);
            this.btn_manage.TabIndex = 1;
            this.btn_manage.Text = "관리";
            this.btn_manage.UseVisualStyleBackColor = true;
            this.btn_manage.Click += new System.EventHandler(this.btn_manage_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(7, 96);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(129, 21);
            this.label2.TabIndex = 2;
            this.label2.Text = "페이지 추가:";
            // 
            // nud_source
            // 
            this.nud_source.Location = new System.Drawing.Point(142, 94);
            this.nud_source.Name = "nud_source";
            this.nud_source.Size = new System.Drawing.Size(235, 32);
            this.nud_source.TabIndex = 3;
            // 
            // btn_addpage
            // 
            this.btn_addpage.Location = new System.Drawing.Point(388, 96);
            this.btn_addpage.Name = "btn_addpage";
            this.btn_addpage.Size = new System.Drawing.Size(143, 30);
            this.btn_addpage.TabIndex = 4;
            this.btn_addpage.Text = "페이지 추가";
            this.btn_addpage.UseVisualStyleBackColor = true;
            this.btn_addpage.Click += new System.EventHandler(this.btn_addpage_Click);
            // 
            // btn_start
            // 
            this.btn_start.Location = new System.Drawing.Point(11, 154);
            this.btn_start.Name = "btn_start";
            this.btn_start.Size = new System.Drawing.Size(160, 35);
            this.btn_start.TabIndex = 5;
            this.btn_start.Text = "설비 가동";
            this.btn_start.UseVisualStyleBackColor = true;
            this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(6, 216);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(129, 21);
            this.label3.TabIndex = 7;
            this.label3.Text = "소스 페이지:";
            // 
            // lb_source
            // 
            this.lb_source.AutoSize = true;
            this.lb_source.Location = new System.Drawing.Point(159, 216);
            this.lb_source.Name = "lb_source";
            this.lb_source.Size = new System.Drawing.Size(60, 21);
            this.lb_source.TabIndex = 9;
            this.lb_source.Text = "[No.]";
            // 
            // btn_stop
            // 
            this.btn_stop.Location = new System.Drawing.Point(193, 154);
            this.btn_stop.Name = "btn_stop";
            this.btn_stop.Size = new System.Drawing.Size(160, 35);
            this.btn_stop.TabIndex = 11;
            this.btn_stop.Text = "설비 멈춤";
            this.btn_stop.UseVisualStyleBackColor = true;
            this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(619, 466);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.btn_add);
            this.Controls.Add(this.lb_no);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.groupBox1);
            this.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.Name = "MainForm";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.MainForm_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nud_source)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.RadioButton rb_ald;
        private System.Windows.Forms.RadioButton rb_cvd;
        private System.Windows.Forms.RadioButton rb_pvd;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label lb_no;
        private System.Windows.Forms.Button btn_add;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Label lb_source;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button btn_start;
        private System.Windows.Forms.Button btn_addpage;
        private System.Windows.Forms.NumericUpDown nud_source;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Button btn_manage;
        private System.Windows.Forms.ComboBox cb_no;
        private System.Windows.Forms.Button btn_stop;
    }
}

3. 설비 하나를 제어하고 시각화할 폼을 하나 추가합니다. 폼 이름은 MachineForm이라 명명할게요.

설비 번호를 시각화할 레이블과 설비 컨트롤을 배치합니다.

MachineForm의 자식 커트롤 배치

namespace 증착_및_BurnInTest_공장_시뮬레이션
{
    partial class MachineForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.lb_no = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.dpcon = new DPMachineControl_예광탄.DPMachineControl();
            this.SuspendLayout();
            // 
            // lb_no
            // 
            this.lb_no.AutoSize = true;
            this.lb_no.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.lb_no.Location = new System.Drawing.Point(147, 41);
            this.lb_no.Name = "lb_no";
            this.lb_no.Size = new System.Drawing.Size(60, 21);
            this.lb_no.TabIndex = 4;
            this.lb_no.Text = "[No.]";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.label1.Location = new System.Drawing.Point(31, 41);
            this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(108, 21);
            this.label1.TabIndex = 3;
            this.label1.Text = "설비 번호:";
            // 
            // dpcon
            // 
            this.dpcon.DPMachine = null;
            this.dpcon.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.dpcon.Location = new System.Drawing.Point(30, 79);
            this.dpcon.Margin = new System.Windows.Forms.Padding(5);
            this.dpcon.Name = "dpcon";
            this.dpcon.Size = new System.Drawing.Size(713, 509);
            this.dpcon.TabIndex = 5;
            // 
            // MachineForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(757, 603);
            this.Controls.Add(this.dpcon);
            this.Controls.Add(this.lb_no);
            this.Controls.Add(this.label1);
            this.Name = "MachineForm";
            this.Text = "MachineForm";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label lb_no;
        private System.Windows.Forms.Label label1;
        private DPMachineControl_예광탄.DPMachineControl dpcon;
    }
}

4. MachineForm을 생성할 때 증착 머신 개체와 머신 번호를 입력 인자로 받아 설정합시다.

MachineForm.cs

using System.Windows.Forms;
using 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄;

namespace 증착_및_BurnInTest_공장_시뮬레이션
{
    public partial class MachineForm : Form
    {
        public MachineForm(DepositionMachine dm,int no)
        {
            InitializeComponent();
            dpcon.DPMachine = dm;
            lb_no.Text = no.ToString();
        }
    }
}

5. MainForm에 모든 버튼의 클릭 이벤트 핸들러를 등록하고 설비를 선택하는 콤버 박스(cb_no)의 선택 항목 변경 이벤트 핸들러를 등록하고 구현합니다.

MainForm.cs

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄;

namespace 증착_및_BurnInTest_공장_시뮬레이션
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        List<DepositionMachine> dms = new List<DepositionMachine>();
        private void btn_add_Click(object sender, EventArgs e)
        {
            DeposType dt = DeposType.DT_NONE;
            if(rb_cvd.Checked)
            {
                dt = DeposType.CVD;
            }
            if(rb_pvd.Checked)
            {
                dt = DeposType.PVD;
            }
            if(rb_ald.Checked)
            {
                dt = DeposType.ALD;
            }
         
            dms.Add(new DepositionMachine(dt));
            int no = int.Parse(lb_no.Text);
            cb_no.Items.Add(no);
            cb_no.SelectedItem = no;
            no++;
            lb_no.Text = no.ToString();
            dms[dms.Count - 1].OnStart += MainForm_OnStart;
            dms[dms.Count - 1].OnEndJob += MainForm_OnEndJob;
            dms[dms.Count - 1].OnAddSource += Dm_OnAddSource;
        }

        private void MainForm_OnEndJob(object sender, EndJobEventArgs e)
        {
            if (dm == e.DM)
            {
                SetToggleStart(false);
            }
        }

        private void SetToggleStart(bool isstart)
        {
            btn_start.Enabled = !isstart;
            btn_stop.Enabled = isstart;
        }

        private void MainForm_OnStart(object sender, EventArgs e)
        {
            if (dm == sender)
            {
                SetToggleStart(true);
            }
        }

        Dictionary<int,MachineForm> mfdic = new Dictionary<int,MachineForm>();
        private void btn_manage_Click(object sender, EventArgs e)
        {
            if(cb_no.SelectedIndex == -1)
            {
                return;
            }
            int index = cb_no.SelectedIndex;
            if(mfdic.ContainsKey(index)==false)
            {
                int no = (int)cb_no.SelectedItem;
                mfdic[index] = new MachineForm(dms[index],no);
                mfdic[index].Show();
                mfdic[index].FormClosed += MainForm_FormClosed;
            }
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            MachineForm mf = sender as MachineForm;
            foreach(KeyValuePair<int,MachineForm> kvp in mfdic)
            {
                if(kvp.Value == mf)
                {
                    mfdic.Remove(kvp.Key);
                    return;
                }
            }
        }

        private void btn_addpage_Click(object sender, EventArgs e)
        {
            if (dm == null) { return; }
            int source = (int)nud_source.Value;
            dm.AddPaper(source);
            nud_source.Value = 0;            
        }

        private void btn_start_Click(object sender, EventArgs e)
        {
            if (dm == null) { return; }
            dm.Start();
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
            if (dm == null) { return; }
            dm.Stop();
        }


        DepositionMachine dm;
        private void cb_no_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_no.SelectedIndex == -1)
            {
                return;
            }
            dm = dms[cb_no.SelectedIndex];
            lb_source.Text = dm.PCnt.ToString();
            SetToggleStart(dm.IsStart);              
        }

        private void Dm_OnAddSource(object sender, DPMachileLib.AddSourceEventArgs e)
        {
            if (dm == sender)
            {
                lb_source.Text = dm.PCnt.ToString();
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            lb_no.Text = "1";
        }
    }
}
0 Comments
댓글쓰기 폼