«   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 05:54
관리 메뉴

언제나 휴일

[C# 실습,통신 제어] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션 본문

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

[C# 실습,통신 제어] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션

언제나 휴일 언제나휴일 2020. 10. 13. 15:19

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

 

이번에는 이전 게시글에 통신을 통해 제어할 수 있는 기능을 추가할 거예요.

 

1. 통신 제어 부분(DPM_SocketLib)은 클래스 라이브러리(.NET Framework)로 제작합니다.

    DMP_SocketLib에서는 앞에서 작성한 증착설비 라이브러리(DPMachineLib)를 참조합니다.

MsgType.cs

namespace DPM_SocketLib
{
    /// <summary>
    /// 메시지 종류
    /// </summary>
    public enum MsgType
    {
        /// <summary>
        /// 설비 추가
        /// </summary>
        MSG_ADD_MAC=1,
        /// <summary>
        /// 페이지 추가
        /// </summary>
        MSG_ADD_PAG,
        /// <summary>
        /// 설비 가동
        /// </summary>
        MSG_STA_MAC,
        /// <summary>
        /// 설비 멈춤
        /// </summary>
        MSG_STP_MAC,
        /// <summary>
        /// Burn In Test
        /// </summary>
        MSG_BUR_TST
    }
}

RecvMsgEventArgs.cs

using System;

namespace DPM_SocketLib
{
    /// <summary>
    /// 메시지 수신 이벤트 핸들러 형식(대리자)
    /// </summary>
    /// <param name="sender">이벤트 게시자</param>
    /// <param name="e">이벤트 인자</param>
    public delegate void RecvMsgEventHandler(object sender, RecvMsgEventArgs e);
    /// <summary>
    /// 메시지 수신 이벤트 인자 클래스
    /// </summary>
    public class RecvMsgEventArgs:EventArgs
    {
        /// <summary>
        /// 수신한 메시지 종류 - 가져오기
        /// </summary>
        public MsgType MT { get; private set; }
        /// <summary>
        /// 수신한 데이터의 첫 번째 데이터 - 가져오기
        /// </summary>
        public int Param1 { get; private set; }
        /// <summary>
        /// 수신한 데이터의 두 번째 데이터 - 가져오기
        /// </summary>
        public int Param2 { get; private set; }
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="msg">수신한 메시지(버퍼)</param>
        public RecvMsgEventArgs(byte[] msg)
        {
            MT = (MsgType)BitConverter.ToInt32(msg, 0);
            Param1 = BitConverter.ToInt32(msg, 4);
            Param2 = BitConverter.ToInt32(msg, 8);
        }
    }
}

DMPServer.cs

using System.Net;
using System.Net.Sockets;

namespace DPM_SocketLib
{
    /// <summary>
    /// 증착 설비 서버(증착 설비에서 원격 제어 기능을 제공)
    /// </summary>
    public class DPMServer
    {
        /// <summary>
        /// 메시지 수신 이벤트
        /// </summary>
        public event RecvMsgEventHandler OnRecv;
        /// <summary>
        /// 연결할 서버의 IP 주소 - 가져오기
        /// </summary>
        public string IP { get; private set; }
        /// <summary>
        /// 연결할 서버의 포트 - 가져오기
        /// </summary>
        public int Port { get; private set; }

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="ip"> 자신의 IP 주소</param>
        /// <param name="port">자신의 포트</param>
        public DPMServer(string ip, int port)
        {
            IP = ip;
            Port = port;
        }

        /// <summary>
        /// 서버 가동 - 비동기
        /// </summary>
        public void StartAsync()
        {
            StartDele dele = Start;
            dele.BeginInvoke(null, null);
        }
        delegate void StartDele();
        /// <summary>
        /// 서버 가동 - 동기
        /// </summary>
        public void Start()
        {
            //소켓 생성
            Socket sock = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream,
                ProtocolType.Tcp);
            //네트워크 인터페이스와 결합
            IPAddress addr = IPAddress.Parse(IP);
            IPEndPoint iep = new IPEndPoint(addr, Port);
            sock.Bind(iep);
            //백로그 큐 크기 결정
            sock.Listen(5);
            //AcceptLoop
            AcceptLoopAsync(sock);

        }
        void AcceptLoopAsync(Socket sock)
        {
            AcceptDele dele = AcceptLoop;
            dele.BeginInvoke(sock, null, null);
        }
        delegate void AcceptDele(Socket sock);
        void AcceptLoop(Socket sock)
        {
            while(true)
            {
                Socket dosock = sock.Accept();
                DoIt(dosock);
            }
        }
        private void DoIt(Socket dosock)
        {
            byte[] buffer = new byte[12];
            dosock.Receive(buffer);
            dosock.Close();
            if(OnRecv!=null)
            {
                OnRecv(this, new RecvMsgEventArgs(buffer));
            }
        }
    }
}

DPMClient.cs

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

namespace DPM_SocketLib
{
    /// <summary>
    /// 증착 공정 클라이언트(제어기)
    /// </summary>
    public class DMPClient
    {
        /// <summary>
        /// 연결할 서버의 IP 주소 - 가져오기
        /// </summary>
        public string IP { get; private set; }
        /// <summary>
        /// 연결할 서버의 포트 - 가져오기
        /// </summary>
        public int Port { get; private set; }

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="ip">연결할 서버의 IP 주소</param>
        /// <param name="port">연결할 서버의 포트</param>
        public DMPClient(string ip, int port)
        {
            IP = ip;
            Port = port;
        }
        /// <summary>
        /// 설비 추가 메시지 전송
        /// </summary>
        /// <param name="dt">추가할 설비의 증착방법</param>
        public void SendAddMachine(DeposType dt)
        {
            Socket sock = Connect();
            byte[] msg = MakeMessage(MsgType.MSG_ADD_MAC, (int)dt, 0);
            sock.Send(msg);
            sock.Close();
        }
        /// <summary>
        /// 페이지 추가 메시지 전송
        /// </summary>
        /// <param name="mno">설비 번호</param>
        /// <param name="pcnt">페이지 개수</param>
        public void SendAddPage(int mno,int pcnt)
        {
            Socket sock = Connect();
            byte[] msg = MakeMessage(MsgType.MSG_ADD_PAG, mno,pcnt);
            sock.Send(msg);
            sock.Close();
        }
        /// <summary>
        /// 설비 가동 메시지 전송
        /// </summary>
        /// <param name="mno">설비 번호</param>
        public void SendStartMachine(int mno)
        {
            Socket sock = Connect();
            byte[] msg = MakeMessage(MsgType.MSG_STA_MAC, mno, 0);
            sock.Send(msg);
            sock.Close();
        }
        /// <summary>
        /// 설비 멈춤 메시지 전송
        /// </summary>
        /// <param name="mno">설비 번호</param>
        public void SendStopMachine(int mno)
        {
            Socket sock = Connect();
            byte[] msg = MakeMessage(MsgType.MSG_STP_MAC, mno, 0);
            sock.Send(msg);
            sock.Close();
        }
        /// <summary>
        /// Burn In Test 메시지 전송
        /// </summary>
        /// <param name="mno">설비 번호</param>
        public void SendBurnInTest(int mno)
        {
            Socket sock = Connect();
            byte[] msg = MakeMessage(MsgType.MSG_BUR_TST, mno, 0);
            sock.Send(msg);
            sock.Close();
        }        
        private byte[] MakeMessage(MsgType mt, int v1, int v2)
        {
            byte[] msg = new byte[12];
            MemoryStream ms = new MemoryStream(msg);
            BinaryWriter bw = new BinaryWriter(ms);
            bw.Write((int)mt);
            bw.Write(v1);
            bw.Write(v2);
            bw.Close();
            ms.Close();
            return msg;
        }

        private Socket Connect()
        {
            //소켓 생성
            Socket sock = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream,
                ProtocolType.Tcp);
            //서버와 연결
            IPAddress servaddr = IPAddress.Parse(IP);
            IPEndPoint iep = new IPEndPoint(servaddr, Port);
            sock.Connect(iep);
            return sock;
        }
    }
}

2. 이전 게시글에서 제작한 공장 UI 구현한 프로젝트를 추가 구현합시다.

   먼저 DPM_SocketLib를 참조합니다.

 MainForm.cs 코드에 서버 코드를 사용하는 부분을 추가합니다.

MainForm.cs

using DPM_SocketLib;
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";
            DPMServer dpmserver = new DPMServer("192.168.0.80", 19000);
            dpmserver.OnRecv += Dpmserver_OnRecv;
            dpmserver.StartAsync();
        }

        private void Dpmserver_OnRecv(object sender, RecvMsgEventArgs e)
        {
            switch(e.MT)
            {
                case MsgType.MSG_ADD_MAC: AddMachineProc(e.Param1); break;
                case MsgType.MSG_ADD_PAG: AddPageProc(e.Param1, e.Param2); break;
                case MsgType.MSG_STA_MAC: StartProc(e.Param1); break;
                case MsgType.MSG_STP_MAC:StopProc(e.Param1); break;
                case MsgType.MSG_BUR_TST: BurnInProc(e.Param1); break;
            }
        }

        private void BurnInProc(int mno)
        {
            DepositionMachine dpmachine = dms[mno - 1];
            dpmachine.BurnInTest();
        }

        private void StopProc(int mno)
        {
            cb_no.SelectedItem = mno;
            btn_stop_Click(null, null);
        }

        private void StartProc(int mno)
        {
            cb_no.SelectedItem = mno;
            btn_start_Click(null, null);
        }

        private void AddPageProc(int mno, int pcnt)
        {
            cb_no.SelectedItem = mno;
            nud_source.Value = pcnt;
            btn_addpage_Click(null, null);
        }

        private void AddMachineProc(int param1)
        {
            DeposType dt = (DeposType)param1;
            switch(dt)
            {
                case DeposType.PVD: rb_pvd.Checked = true; break;
                case DeposType.CVD: rb_cvd.Checked = true; break;
                case DeposType.ALD: rb_ald.Checked = true; break;
            }
            btn_add_Click(null, null);
        }
    }
}

3. 제어기(클라이언트)는 Windows Forms(.NET Framework) 앱으로 제작합니다.

   DMP_SocketLib와 증착설비 라이브러리(DPMachineLib)를 참조합니다.

   

제어기 Form1 자식 컨트롤 배치

Form1.Designer.cs

namespace 증착설비제어기
{
    partial class Form1
    {
        /// <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.btn_stop = new System.Windows.Forms.Button();
            this.btn_start = new System.Windows.Forms.Button();
            this.btn_addpage = new System.Windows.Forms.Button();
            this.btn_add = new System.Windows.Forms.Button();
            this.nud_source = new System.Windows.Forms.NumericUpDown();
            this.label2 = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.rb_ald = new System.Windows.Forms.RadioButton();
            this.rb_cvd = new System.Windows.Forms.RadioButton();
            this.rb_pvd = new System.Windows.Forms.RadioButton();
            this.label1 = new System.Windows.Forms.Label();
            this.nud_mno = new System.Windows.Forms.NumericUpDown();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.tbox_ip = new System.Windows.Forms.TextBox();
            this.tbox_port = new System.Windows.Forms.TextBox();
            this.btn_set = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.nud_source)).BeginInit();
            this.groupBox1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nud_mno)).BeginInit();
            this.SuspendLayout();
            // 
            // btn_stop
            // 
            this.btn_stop.Enabled = false;
            this.btn_stop.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.btn_stop.Location = new System.Drawing.Point(202, 350);
            this.btn_stop.Name = "btn_stop";
            this.btn_stop.Size = new System.Drawing.Size(160, 35);
            this.btn_stop.TabIndex = 17;
            this.btn_stop.Text = "설비 멈춤";
            this.btn_stop.UseVisualStyleBackColor = true;
            this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);
            // 
            // btn_start
            // 
            this.btn_start.Enabled = false;
            this.btn_start.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.btn_start.Location = new System.Drawing.Point(36, 350);
            this.btn_start.Name = "btn_start";
            this.btn_start.Size = new System.Drawing.Size(160, 35);
            this.btn_start.TabIndex = 16;
            this.btn_start.Text = "설비 가동";
            this.btn_start.UseVisualStyleBackColor = true;
            this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
            // 
            // btn_addpage
            // 
            this.btn_addpage.Enabled = false;
            this.btn_addpage.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.btn_addpage.Location = new System.Drawing.Point(389, 309);
            this.btn_addpage.Name = "btn_addpage";
            this.btn_addpage.Size = new System.Drawing.Size(143, 30);
            this.btn_addpage.TabIndex = 15;
            this.btn_addpage.Text = "페이지 추가";
            this.btn_addpage.UseVisualStyleBackColor = true;
            this.btn_addpage.Click += new System.EventHandler(this.btn_addpage_Click);
            // 
            // btn_add
            // 
            this.btn_add.Enabled = false;
            this.btn_add.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.btn_add.Location = new System.Drawing.Point(24, 208);
            this.btn_add.Name = "btn_add";
            this.btn_add.Size = new System.Drawing.Size(137, 38);
            this.btn_add.TabIndex = 13;
            this.btn_add.Text = "설비 추가";
            this.btn_add.UseVisualStyleBackColor = true;
            this.btn_add.Click += new System.EventHandler(this.btn_add_Click);
            // 
            // nud_source
            // 
            this.nud_source.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.nud_source.Location = new System.Drawing.Point(118, 309);
            this.nud_source.Name = "nud_source";
            this.nud_source.Size = new System.Drawing.Size(235, 32);
            this.nud_source.TabIndex = 14;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.label2.Location = new System.Drawing.Point(32, 311);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(80, 21);
            this.label2.TabIndex = 12;
            this.label2.Text = "페이지:";
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.rb_ald);
            this.groupBox1.Controls.Add(this.rb_cvd);
            this.groupBox1.Controls.Add(this.rb_pvd);
            this.groupBox1.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.groupBox1.Location = new System.Drawing.Point(24, 109);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(528, 93);
            this.groupBox1.TabIndex = 18;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "증착 방법";
            // 
            // 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;
            // 
            // 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_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;
            // 
            // 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(53, 267);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(59, 21);
            this.label1.TabIndex = 20;
            this.label1.Text = "설비:";
            // 
            // nud_mno
            // 
            this.nud_mno.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.nud_mno.Location = new System.Drawing.Point(118, 267);
            this.nud_mno.Name = "nud_mno";
            this.nud_mno.Size = new System.Drawing.Size(235, 32);
            this.nud_mno.TabIndex = 21;
            this.nud_mno.ValueChanged += new System.EventHandler(this.nud_mno_ValueChanged);
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.label3.Location = new System.Drawing.Point(38, 22);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(74, 21);
            this.label3.TabIndex = 23;
            this.label3.Text = "서버IP:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.label4.Location = new System.Drawing.Point(53, 63);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(59, 21);
            this.label4.TabIndex = 22;
            this.label4.Text = "포트:";
            // 
            // tbox_ip
            // 
            this.tbox_ip.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.tbox_ip.Location = new System.Drawing.Point(119, 21);
            this.tbox_ip.Name = "tbox_ip";
            this.tbox_ip.Size = new System.Drawing.Size(300, 32);
            this.tbox_ip.TabIndex = 24;
            // 
            // tbox_port
            // 
            this.tbox_port.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.tbox_port.Location = new System.Drawing.Point(119, 59);
            this.tbox_port.Name = "tbox_port";
            this.tbox_port.Size = new System.Drawing.Size(300, 32);
            this.tbox_port.TabIndex = 25;
            // 
            // btn_set
            // 
            this.btn_set.Font = new System.Drawing.Font("굴림", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.btn_set.Location = new System.Drawing.Point(440, 59);
            this.btn_set.Name = "btn_set";
            this.btn_set.Size = new System.Drawing.Size(92, 31);
            this.btn_set.TabIndex = 26;
            this.btn_set.Text = "설정";
            this.btn_set.UseVisualStyleBackColor = true;
            this.btn_set.Click += new System.EventHandler(this.btn_set_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(559, 401);
            this.Controls.Add(this.btn_set);
            this.Controls.Add(this.tbox_port);
            this.Controls.Add(this.tbox_ip);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.nud_mno);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.btn_stop);
            this.Controls.Add(this.btn_start);
            this.Controls.Add(this.btn_addpage);
            this.Controls.Add(this.btn_add);
            this.Controls.Add(this.nud_source);
            this.Controls.Add(this.label2);
            this.Name = "Form1";
            this.Text = "증착 설비 제어기";
            ((System.ComponentModel.ISupportInitialize)(this.nud_source)).EndInit();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nud_mno)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btn_stop;
        private System.Windows.Forms.Button btn_start;
        private System.Windows.Forms.Button btn_addpage;
        private System.Windows.Forms.Button btn_add;
        private System.Windows.Forms.NumericUpDown nud_source;
        private System.Windows.Forms.Label label2;
        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.NumericUpDown nud_mno;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox tbox_ip;
        private System.Windows.Forms.TextBox tbox_port;
        private System.Windows.Forms.Button btn_set;
    }
}

Form1.cs 코드를 작성합니다.

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

namespace 증착설비제어기
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_add_Click(object sender, EventArgs e)
        {
            DeposType dt = DeposType.DT_NONE;
            if (rb_pvd.Checked) 
            {
                dt = DeposType.PVD;
            }
            if(rb_cvd.Checked)
            {
                dt = DeposType.CVD;
            }
            if(rb_ald.Checked)
            {
                dt = DeposType.ALD;
            }
            dmpclient.SendAddMachine(dt);
        }

        DMPClient dmpclient;
        private void btn_set_Click(object sender, EventArgs e)
        {
            int port = int.Parse(tbox_port.Text);
            dmpclient = new DMPClient(tbox_ip.Text, port);
            btn_add.Enabled = true;
        }

        private void nud_mno_ValueChanged(object sender, EventArgs e)
        {
            bool is_nzero = (nud_mno.Value != 0)&&(btn_add.Enabled);

            btn_addpage.Enabled = is_nzero;
            btn_start.Enabled = is_nzero;
            btn_stop.Enabled = is_nzero;
        }

        private void btn_addpage_Click(object sender, EventArgs e)
        {
            int mno = (int)nud_mno.Value;
            int pcnt = (int)nud_source.Value;
            dmpclient.SendAddPage(mno, pcnt);
        }

        private void btn_start_Click(object sender, EventArgs e)
        {
            int mno = (int)nud_mno.Value;
            dmpclient.SendStartMachine(mno);
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
            int mno = (int)nud_mno.Value;
            dmpclient.SendStopMachine(mno);
        }
    }
}
0 Comments
댓글쓰기 폼