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

[C# 실습,예광탄] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션

언제나휴일 2020. 10. 8. 12:02
반응형

[C# 실습, 시나리오] 반도체 증착공정 및 Burn in 테스트 설비 시뮬레이션

반도체 증착공정 및 BurnIn테스트 부분을 클래스 라이브러리로 작성하기 위한 예광탄입니다.

DeposType: 증착 방법

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public enum DeposType
    {
        DT_NONE, PVD, CVD, ALD
    }
}

Paper.cs: 100개의 셀로 구성하고 있는 페이퍼

using System;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public class Paper
    {
        bool[] cells = new bool[100];
        public bool this[int ccnt]//ccnt는 1~100 유효
        {
            get
            {
                if ((ccnt <= 0) || (ccnt > 100)) { return false; }
                return cells[ccnt-1];
            }
        }
        public int Now
        {
            get
            {
                return now;
            }
        }
        public bool IsEnd
        {
            get
            {
                return now == 100;
            }
        }
        int now;
        static Random rand = new Random();
        public void Deposition(int minq, int maxq)
        {
            if (IsEnd) { return; }
            int choice_q = rand.Next(maxq - minq + 1) + minq;
            int rv = rand.Next(100);
            cells[now] = (rv < choice_q);
            now++;
        }

        public int BurnInTest()
        {
            int cnt = 0;
            foreach(bool quality in cells)
            {
                if(quality)
                {
                    cnt++;
                }
            }
            return cnt;
        }
    }
}

EndCellDPEventArgs.cs : 셀 하나의 증착 작업 완료 이벤트 인자 및 대리자

using System;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public delegate void EndCellDPEventHandler(object sender, EndCellDPEventArgs e);
    public class EndCellDPEventArgs:EventArgs
    {
        public DepositionMachine DPMachine { get; private set; }
        public int PNum{  get;  private set;  }//페이퍼번호
        public int CNum { get; private set; }//셀 번호
        public bool Quality { get; private set; }//품질
        public EndCellDPEventArgs(int pnum,int cnum, DepositionMachine dm,bool quality)
        {
            PNum = pnum;
            CNum = cnum;
            DPMachine = dm;
            Quality = quality;
        }
    }
}

EndPaperDPEventArgs.cs: 페이퍼(100개의 Cell) 작업 완료 이벤트 인자 및 대리자

using System;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public delegate void EndPaperDPEventHandler(object sender, EndPaperDPEventArgs e);
    public class EndPaperDPEventArgs:EventArgs
    {
        public Paper Paper { get; private set; }
        public int PNum { get; private set; }
        public DepositionMachine DM { get; private set; }
        public EndPaperDPEventArgs(Paper paper, int pnum,DepositionMachine dm)
        {
            Paper = paper;
            PNum = pnum;
            DM = dm;
        }
    }
}

EndJobEventArgs.cs : 증착 작업 종료 이벤트 인자 및 대리자

using System;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public delegate void EndJobEventHandler(object sender, EndJobEventArgs e);
    public class EndJobEventArgs:EventArgs
    {
        public DepositionMachine DM { get; private set; }
        public int JCnt { get; private set; }
        public EndJobEventArgs(DepositionMachine dm,int jcnt)
        {
            DM = dm;
            JCnt = jcnt;
        }
    }
}

AddSourceEventArgs.cs: 페이지 추가 이벤트 인자 및 대리자

using System;

namespace DPMachileLib
{
    public delegate void AddSourceEventHandler(object sender, AddSourceEventArgs e);
    public class AddSourceEventArgs:EventArgs
    {
        public int TotalCount { get; private set; }
        public int AddCount { get; private set; }
        public AddSourceEventArgs(int addcnt, int totalcount)
        {
            AddCount = addcnt;
            TotalCount = totalcount;
        }

    }
}

 

DepositionMachine.cs:증착 공정 설비(BurnIn테스트 기능을 통해 결과 확인 기능 제공)

using DPMachileLib;
using System;
using System.Collections.Generic;
using System.Threading;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    public class DepositionMachine
    {
        public event EndCellDPEventHandler OnDPCell;
        public event EndPaperDPEventHandler OnDPPaper;
        public event EndJobEventHandler OnEndJob;
        public event AddSourceEventHandler OnAddSource;
        public event EventHandler OnStart;
        public DeposType DT { get; set; }
        public int PCnt { get; private set; }
        public List<Paper> plist = new List<Paper>();

        public DepositionMachine(DeposType dt)
        {
            DT = dt;
            SetSpeed();
            SetQuality();
        }

        private void SetQuality()
        {
            switch (DT)
            {
                case DeposType.PVD: Min_Quality = 88; Max_Quality = 98; break;
                case DeposType.CVD: Min_Quality = 90; Max_Quality = 100; break;
                case DeposType.ALD: Min_Quality = 95; Max_Quality = 100; break;
            }
        }
        private void SetSpeed()
        {
            switch(DT)
            {
                case DeposType.PVD: Speed = 100; break;
                case DeposType.CVD: Speed = 98; break;
                case DeposType.ALD: Speed = 60; break;
            }
        }

        public int Speed
        {
            get; private set;
        }
        public int Min_Quality
        {
            get; private set;
        }
        public int Max_Quality
        {
            get; private set;
        }
        public void AddPaper(int pcnt)
        {
            PCnt += pcnt;
            if(OnAddSource != null)
            {
                OnAddSource(this, new AddSourceEventArgs(pcnt, PCnt));
            }
        }

        public List<int> BurnInTest()
        {
            List<int> list = new List<int>();
            foreach(Paper paper in plist)
            {
                list.Add(paper.BurnInTest());
            }
            return list;
        }
        public bool IsStart
        {
            get;
            private set;
        }

        Timer timer;
        public void Start()
        {
            if(IsStart == true) { return; }
            IsStart = true;
            timer = new Timer(Doing, null, 0, 3000 / Speed);
            if(OnStart != null)
            {
                OnStart(this, new EventArgs());
            }
        }
        int jcnt;
        Paper paper;
        void Doing(object obj)
        {
            if(PCnt==jcnt)
            {
                Stop();
                return;
            }
            if(paper == null)
            {
                paper = new Paper();
            }
            if(paper.IsEnd)
            {
                plist.Add(paper);
                if(OnDPPaper != null)
                {
                    OnDPPaper(this, new EndPaperDPEventArgs(paper, jcnt + 1, this));
                }
                paper = null;
                jcnt++;
                Doing(null);
            }
            else
            {
                paper.Deposition(Min_Quality, Max_Quality);
                if (OnDPCell != null)
                {                    
                    OnDPCell(this, new EndCellDPEventArgs(jcnt, paper.Now, this,paper[paper.Now]));
                }                
            }            
        }
        public void Stop()
        {
            IsStart = false;
            if(OnEndJob!=null)
            {
                OnEndJob(this, new EndJobEventArgs(this, jcnt));
            }
            timer.Dispose();
        }
    }
}

Program.cs: 세 종류의 설비로 증착 공정 테스트 및 Burn In 테스트 결과 확인

using System;
using System.Collections.Generic;

namespace 증착_공정_및_Burn_in_테스트_설비_콘솔_예광탄
{
    class Program
    {
        static void Main(string[] args)
        {
            DepositionMachine[] dms = new DepositionMachine[3] ;
            for (int i = 0; i < 3; i++)
            {
                dms[i] = new DepositionMachine((DeposType)(i + 1));
                dms[i].OnDPCell += Dm_OnDPCell;
                dms[i].OnDPPaper += Program_OnDPPaper;
                dms[i].OnEndJob += Program_OnEndJob;
            }
            foreach(DepositionMachine dm in dms)
            {
                Console.WriteLine("{0} 타입 테스트", dm.DT);  
                dm.AddPaper(10);
                dm.Start();                
            }
            Console.WriteLine("키를 누르면 증착 시뮬레이션 종료");
            Console.ReadKey();
            foreach (DepositionMachine dm in dms)
            {
                dm.Stop();
            }            
            Console.WriteLine("===Burn In Test====");
            foreach (DepositionMachine dm in dms)
            {
                List<int> tlist = dm.BurnInTest();
                Console.WriteLine("{0}타입 결과 목록***", dm.DT);
                for(int i=0;i< tlist.Count;i++)
                {
                    Console.WriteLine("{0}번째:{1}퍼센트", i + 1, tlist[i]);
                }
            }            
        }

        private static void Program_OnEndJob(object sender, EndJobEventArgs e)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("{0}설비 {1}개 작업 완료", e.DM.DT, e.JCnt);            
        }

        private static void Program_OnDPPaper(object sender, EndPaperDPEventArgs e)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("{0}설비 {1}번 페이퍼 증착", e.DM.DT, e.PNum);
        }

        private static void Dm_OnDPCell(object sender, EndCellDPEventArgs e)
        {
            Console.WriteLine("{0}설비 {1}번 페이퍼 {2}셀 증착 품질:{3}", e.DPMachine.DT, e.PNum, e.CNum, e.Quality);
        }
    }
}
반응형