반응형
WaferLineControlLib는 Windows Forms 컨트롤 라이브러리(.NET Framework)입니다.
1. DPanel.cs
using System.Windows.Forms;
namespace WaferLineControlLib
{
public class DPanel : Panel
{
public DPanel()
{
SetStyle(System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer |
System.Windows.Forms.ControlStyles.UserPaint |
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
}
2. WaferPanel.cs
using System.Drawing;
using WaferLineLib;
namespace WaferLineControlLib
{
public class WaferPanel:DPanel
{
public Wafer Wafer
{
get;
set;
}
public WaferPanel()
{
this.Paint += WaferPanel_Paint;
}
private void WaferPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics graphics = e.Graphics;
Brush brush = Brushes.Silver;
Rectangle rect = new Rectangle(0, 0, Width, Height);
graphics.FillEllipse(brush, rect);
int width = Width;
int height = Height;
int sx = (int)(width * 0.15);
int sy = (int)(height * 0.15);
Rectangle rect2 = new Rectangle(sx, sy, (int)(width * 0.7), (int)(height * 0.7));
graphics.DrawRectangle(Pens.Red, rect2);
int xu = rect2.Width / 10;
int yu = rect2.Height / 10;
Pen pen = new Pen(Color.DarkGray, 1);
for (int x = 1; x < 10; x++)
{
graphics.DrawLine(pen, new Point(sx + x * xu, sy), new Point(sx + x * xu, sy + rect2.Height));
}
for (int y = 1; y < 10; y++)
{
graphics.DrawLine(pen, new Point(sx, sy + y * yu), new Point(sx + rect2.Width, sy + y * yu));
}
if (Wafer == null)
{
return;
}
int dir = 0;
int step = 1, nowstep = step;
int nx = 4, ny = 5;
for (int i = 0; i < 100; i++)
{
int qual = Wafer[i];
Color color = Color.FromArgb(200 - qual * 2, 55 + qual * 2, 0);
Rectangle rt = new Rectangle(sx + nx * xu + 1, sy + ny * yu + 1, xu - 1, yu - 1);
graphics.FillRectangle(new SolidBrush(color), rt);
if (nowstep == 0)
{
dir = (dir + 1) % 4;
if (dir % 2 == 0)
{
step++;
}
nowstep = step;
}
nowstep--;
switch (dir)
{
case 0: ny--; break;
case 1: nx++; break;
case 2: ny++; break;
case 3: nx--; break;
}
}
}
}
}
3. WaferLineControl.cs
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using WaferLineLib;
namespace WaferLineControlLib
{
public partial class WaferLineControl : UserControl
{
WaferLine wl = null;
public WaferLine Line
{
get
{
return wl;
}
set
{
wl = value;
}
}
public WaferLineControl()
{
InitializeComponent();
}
public void SetStatus()
{
if(wl != null)
{
lb_wcnt.Text = wl.BWCnt.ToString();
lb_pcnt.Text = wl.PCnt.ToString();
tbar_spin.Value = wl.Spin;
tbar_drop.Value = wl.Drop;
}
else
{
lb_wcnt.Text = "해당 없음";
lb_pcnt.Text = "해당 없음";
tbar_spin.Value = tbar_spin.Minimum;
tbar_drop.Value = tbar_drop.Minimum;
}
}
private void tbar_wafer_Scroll(object sender, EventArgs e)
{
if (wl == null) { return; }
lb_wafer.Text = tbar_wafer.Value.ToString();
}
private void tbar_pr_Scroll(object sender, EventArgs e)
{
if (wl == null) { return; }
lb_pr.Text = tbar_pr.Value.ToString();
}
private void btn_wafer_Click(object sender, EventArgs e)
{
if (wl == null) { return; }
int bwcnt = tbar_wafer.Value;
if (bwcnt > (tbar_wafer.Maximum - wl.BWCnt))
{
bwcnt = tbar_wafer.Maximum - wl.BWCnt;
}
wl.InWafer(bwcnt);
tbar_wafer.Value = 0;
lb_wafer.Text = "0";
pn_wafer.Invalidate();
ts_lb.Text = string.Format("Wafer {0}개 투입, 현재:{1}개", bwcnt, wl.BWCnt);
lb_wcnt.Text = wl.BWCnt.ToString();
}
private void btn_pr_Click(object sender, EventArgs e)
{
if (wl == null) { return; }
int pcnt = tbar_pr.Value;
if (pcnt > (tbar_pr.Maximum - wl.PCnt))
{
pcnt = tbar_pr.Maximum - wl.PCnt;
}
wl.InPr(pcnt);
tbar_pr.Value = 0;
lb_pr.Text = "0";
pn_pr.Invalidate();
ts_lb.Text = string.Format("코팅액 {0}병 투입, 현재:{1}병", pcnt, wl.PCnt);
lb_pcnt.Text = wl.PCnt.ToString();
}
private void tbar_spin_Scroll(object sender, EventArgs e)
{
if (wl == null) { return; }
lb_spin.Text = tbar_spin.Value.ToString();
wl.SetSpin(tbar_spin.Value);
ChangeInterval();
}
private void ChangeInterval()
{
if (wl == null) { return; }
tm_coating.Interval = 6000000 / (wl.Spin * wl.Drop);
}
private void tbar_drop_Scroll(object sender, EventArgs e)
{
if (wl == null) { return; }
lb_drop.Text = tbar_drop.Value.ToString();
wl.SetDrop(tbar_drop.Value);
ChangeInterval();
}
private void btn_start_Click(object sender, EventArgs e)
{
if (wl == null) { return; }
if (tm_coating.Enabled)
{
tm_coating.Enabled = false;
btn_start.Text = "시작";
}
else
{
tm_coating.Enabled = true;
btn_start.Text = "멈춤";
}
}
private void cb_awafer_SelectedIndexChanged(object sender, EventArgs e)
{
if (wl == null) { return; }
pn_awafer.Wafer = wl.LastWafer;
pn_awafer.Invalidate();
}
private void tm_coating_Tick(object sender, EventArgs e)
{
if (wl == null) { return; }
if (wl.Coating() == false)
{
tm_coating.Enabled = false;
btn_start.Text = "시작";
}
Wafer wafer = wl.Now;
pn_nwafer.Wafer = wafer;
if (wafer != null)
{
int ccount = wafer.Now;
if (ccount == 1)
{
Wafer lwafer = wl.LastWafer;
if (lwafer != null)
{
cb_awafer.Items.Add(lwafer);
lb_awcnt.Text = wl.AWCnt.ToString();
ts_lb.Text = string.Format("코팅 완료:{0}", lwafer);
}
lb_wcnt.Text = wl.BWCnt.ToString();
}
}
if (wl.NPcnt == 999)
{
lb_pcnt.Text = wl.PCnt.ToString();
ts_lb.Text = string.Format("코팅액 교체: 남은 코팅액:{0}병", wl.PCnt);
}
Invalidate(true);
}
private void pn_wafer_Paint(object sender, PaintEventArgs e)
{
if (wl == null) { return; }
Graphics graphics = e.Graphics;
Pen pen = new Pen(Color.DarkGray, 1);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
int xu = pn_wafer.Width / 10;
int yu = pn_wafer.Height / 20;
int wcnt = wl.BWCnt;
for (int x = 1; x < 10; x++)
{
graphics.DrawLine(pen, new Point(x * xu, 0), new Point(x * xu, pn_wafer.Height));
}
for (int y = 1; y < 20; y++)
{
graphics.DrawLine(pen, new Point(0, y * yu), new Point(pn_wafer.Width, y * yu));
}
for (int i = 0, ri = 200; i < 200; i++, ri--)
{
Brush brush;
if (ri <= wcnt)
{
brush = new HatchBrush(HatchStyle.DiagonalCross, Color.Goldenrod);
}
else
{
brush = new SolidBrush(pn_wafer.BackColor);
}
int x = i % 10;
int y = i / 10;
graphics.FillRectangle(brush, new Rectangle(x * xu + 1, y * yu + 1, xu - 1, yu - 1));
}
}
private void pn_pr_Paint(object sender, PaintEventArgs e)
{
if (wl == null) { return; }
Graphics graphics = e.Graphics;
Pen pen = new Pen(Color.DarkGray, 1);
pen.DashStyle = DashStyle.Dot;
int yu = pn_pr.Height / 20;
for (int y = 1; y < 20; y++)
{
graphics.DrawLine(pen, new Point(0, y * yu), new Point(pn_pr.Width, y * yu));
}
int pcnt = wl.PCnt;
for (int i = 0, ri = 20; i < 20; i++, ri--)
{
Color color = pn_pr.BackColor;
if (ri <= pcnt)
{
color = Color.DarkCyan;
}
Brush brush = new SolidBrush(color);
graphics.FillRectangle(brush, new Rectangle(0, i * yu + 1, pn_pr.Width, yu - 1));
}
}
private void pn_npr_Paint(object sender, PaintEventArgs e)
{
if (wl == null) { return; }
Graphics graphics = e.Graphics;
int npcnt = wl.NPcnt;
for (int x = 0; x < 50; x++)
{
for (int y = 0; y < 20; y++)
{
if (npcnt < (1000 - y * 50 + x))
{
graphics.DrawLine(Pens.White, new Point(x, y), new Point(x + 1, y));
}
else
{
graphics.DrawLine(Pens.DarkCyan, new Point(x, y), new Point(x + 1, y));
}
}
}
}
}
}
반응형
'프로젝트 > Wafer 코팅 시뮬레이션 [반도체 장비 제어 시스템]' 카테고리의 다른 글
중앙 관제 - Windows Forms 앱 (0) | 2021.02.27 |
---|---|
WaferLine 공장 시뮬레이션 - Windows Forms (0) | 2021.02.27 |
WaferLineCommLib - 클래스 라이브러리 (0) | 2021.02.27 |
WaferLineLib 라이브러리 (0) | 2021.02.27 |