Files
ATV_STDLabelAttach/QRValidation/CapCleaningControl/CPort.cs
atvstdla dc66158497 Add QRValidation project to repository
- Added QRValidation vision control system
- Includes CapCleaningControl UI components
- WebSocket-based barcode validation system
- Support for Crevis PLC integration
- Test projects for PLC emulator, motion, IO panel, and Modbus

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 11:38:38 +09:00

335 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace UIControl
{
public class CPort
{
public Boolean Safty1Err { get; set; }
public Boolean Safty2Err { get; set; }
public Boolean SaftyErr { get { return Safty1Err || Safty2Err; } }
public Boolean MotorRun { get; set; }
public Boolean MotorDir { get; set; }
public int arrowIndex { get; set; }
public Boolean LimitUpper { get; set; }
public Boolean LimitLower { get; set; }
public Boolean OverLoad
{
get
{
return LimitLower && DetectUp;
}
}
public byte AlignOK { get; set; }
public Boolean Ready { get; set; }
public Boolean DetectUp { get; set; } //상단에 있는 자재 감지 센서
public Boolean DetectDn { get; set; } //하단에 있는 자재 감지 센서
// public List<CItem> Items { get; set; }
/// <summary>
/// 7인치 13인치의 크기 정보를 표시한다
/// </summary>
public string title { get; set; }
public int reelNo { get; set; }
/// <summary>
/// 차수별 릴 작업 수량이 표시됨
/// </summary>
public int reelCount { get; set; }
public int errorCount { get; set; }
public System.Drawing.Color bgColor { get; set; }
private Boolean _enable = false;
public Color fgColor { get; set; }
public Color fgColorCount { get; set; }
public Rectangle rect_title { get; set; }
public RectangleF Rect { get; set; }
public Rectangle rect_count { get; set; }
public int AnimationStepPort { get; set; }
/// <summary>
/// 0:notcart , 1:ready, 2:full
/// </summary>
public ushort State { get; set; }
public Boolean Enable
{
get { return _enable; }
set
{
_enable = value;
this.bgColor = value ? Color.Lime : Color.FromArgb(43, 43, 43);
this.fgColor = value ? Color.White : Color.DimGray;
}
}
public CPort()
{
Ready = false;
Enable = false;
rect_title = Rectangle.Empty;
rect_count = Rectangle.Empty;
Rect = RectangleF.Empty;
reelNo = -1;
arrowIndex = 2;
reelCount = 0;
fgColor = Color.Black;
Clear();
AlignOK = 0;
AnimationStepPort = 9;
//Items.Clear();
}
//public void ClearItem()
//{
// Items.Clear();
//}
public void Clear()
{
Enable = true;
Safty1Err = false;
Safty2Err = false;
MotorRun = false;
MotorDir = false;
LimitUpper = false;
LimitLower = false;
reelNo = 0;
reelCount = 0;
DetectUp = false;
DetectDn = false;
}
public void Display(Graphics g, Font fCnt, Font fMsg, Boolean InputMode,Boolean InputActive)
{
if (Enable == false)
{
g.DrawLine(Pens.DimGray, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
g.DrawLine(Pens.DimGray, Rect.Right, Rect.Top, Rect.Left, Rect.Bottom);
}
//모터사용시 화살표
eDirection DirL = MotorDir == false ? eDirection.TopToBottom : eDirection.BottomToTop;
if (MotorRun) UIControl.Common.Draw_Arrow(g, Rect, DirL, arrowIndex, AnimationStepPort, Color.Gold, fMsg);
//글자표시 (크기 및 작업 수량)
var sf = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center,
};
//리밋영역표시(상/하)
var limitSizeH = (int)(Rect.Height * 0.2);
if (OverLoad == true)//과적
{
g.FillRectangle(Brushes.Red, Rect);
if (InputMode)
{
using (Font f = new Font("맑은 고딕", 20, FontStyle.Bold))
{
g.DrawString("적재초과",
f,
new SolidBrush(fgColor), Rect, sf);
}
}
else
{
g.DrawString("OVER\nLOAD", fMsg, new SolidBrush(fgColor), Rect, sf);
}
}
else
{
//입력모드에서는 별도 처리를 한다
if (InputMode)
{
if(InputActive)
{
using (Font f = new Font("맑은 고딕", 20, FontStyle.Bold))
{
var msg = "투입준비";
g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Black)), Rect);
g.DrawString(msg, f, new SolidBrush(fgColor), Rect, sf);
}
}
else
{
using (Font f = new Font("맑은 고딕", 20, FontStyle.Bold))
{
var msg = "--";
g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Black)), Rect);
g.DrawString(msg, f, new SolidBrush(fgColor), Rect, sf);
}
}
}
else
{
if (errorCount > 5)
{
g.FillRectangle(new SolidBrush(Color.FromArgb(250, Color.Gold)), Rect);
}
else
{
g.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.Black)), Rect);
}
if (errorCount > 0)
{
if (errorCount > 05)
{
g.DrawString(reelCount.ToString() + "\n(ERROR)", fCnt, new SolidBrush(Color.Red), Rect, sf);
}
else g.DrawString(reelCount.ToString() + "\nE:" + errorCount.ToString(), fCnt, new SolidBrush(Color.Red), Rect, sf);
}
else
{
g.DrawString(reelCount.ToString(), fCnt, new SolidBrush(fgColor), Rect, sf);
}
}
}
//데두리표시 ( 비활성 회색, 활성 감지 : 라임, 미감지 흰색)
Color borderL = Enable ? (LimitUpper ? Color.Red : (LimitLower ? Color.Blue : (DetectUp ? Color.Lime : Color.White))) : Color.DimGray;
if (OverLoad) borderL = Color.White;
int bordersize = (InputMode ? 10 : 7);//ortL.enable ? 7 : 1;
if (OverLoad == false)
{
var fontsize = InputMode ? 9 : 9;
using (Font fnt = new Font("Consolas", fontsize, FontStyle.Bold))
{
//상단 리밋은 상단에
if (LimitUpper)
{
var msgLU = "+ LIMIT";
var fsize = g.MeasureString(msgLU, fnt);
var msgW = fsize.Width * 1.5f;
var msgH = fsize.Height * 1.5f;
if (msgW > this.Rect.Width * 0.70f) msgW = this.Rect.Width * 0.7f;
var RectMsgL = new RectangleF(
Rect.Left + (Rect.Width - msgW) / 2.0f,
Rect.Top - msgH - bordersize / 2.0f + 1,
msgW, msgH);
g.FillRectangle(new SolidBrush(Color.FromArgb(250, Color.Red)), RectMsgL);
// g.DrawRectangle(Pens.Black, RectMsgL);
g.DrawString(msgLU, fnt, Color.White, RectMsgL);
}
//아이템 감지신호는 상단 아래쪽으로
if (Ready)
{
var msgLU = "PORT READY";
var fsize = g.MeasureString(msgLU, fnt);
var msgW = fsize.Width * 1.5f;
var msgH = fsize.Height * 1.5f;
if (msgW > this.Rect.Width * 0.70f) msgW = this.Rect.Width * 0.7f;
var RectMsgL = new RectangleF(
Rect.Left + (Rect.Width - msgW) / 2.0f,
Rect.Top + bordersize / 2.0f - 1,
msgW, msgH);
g.FillRectangle(new SolidBrush(Color.FromArgb(250, Color.Lime)), RectMsgL);
// g.DrawRectangle(Pens.Black, RectMsgL);
g.DrawString(msgLU, fnt, Color.Black, RectMsgL);
}
//하단 리밋은 하단에표시
if (LimitLower)
{
var msgLU = "- LIMIT";
var fsize = g.MeasureString(msgLU, fnt);
var msgW = fsize.Width * 1.5f;
var msgH = fsize.Height * 1.5f;
if (msgW > this.Rect.Width * 0.70f) msgW = this.Rect.Width * 0.7f;
var RectMsgL = new RectangleF(
Rect.Left + (Rect.Width - msgW) / 2.0f,
Rect.Bottom + bordersize / 2.0f - 1,
msgW, msgH);
g.FillRectangle(new SolidBrush(Color.FromArgb(250, Color.Blue)), RectMsgL);
//g.DrawString(msgLU, fnt, Brushes.White, RectMsgL, sf);
g.DrawString(msgLU, fnt, Color.White, RectMsgL);
}
//아이템 감지
if (DetectUp)
{
var msgLU = "ITEM DETECT";
var fsize = g.MeasureString(msgLU, fnt);
var msgW = fsize.Width * 1.5f;
var msgH = fsize.Height * 1.5f;
if (msgW > this.Rect.Width * 0.70f) msgW = this.Rect.Width * 0.7f;
var RectMsgL = new RectangleF(
Rect.Left + (Rect.Width - msgW) / 2.0f,
Rect.Bottom - msgH - bordersize / 2.0f + 1,
msgW, msgH);
g.FillRectangle(new SolidBrush(Color.FromArgb(250, Color.Lime)), RectMsgL);
//g.DrawRectangle(Pens.Black, RectMsgL);
g.DrawString(msgLU, fnt, Color.Black, RectMsgL);
}
//안전 오류는 중앙에
if (SaftyErr && InputMode == false)
{
var msgS = "SAFTY ERROR";
var fsize = g.MeasureString(msgS, fMsg);
var msgW = fsize.Width * 1.5f;
var msgH = fsize.Height * 1.5f;
if (msgW > this.Rect.Width * 0.80f) msgW = this.Rect.Width * 0.8f;
var RectMsgL = new RectangleF(
Rect.Left + (Rect.Width - msgW) / 2.0f,
Rect.Top + (Rect.Height - msgH) / 2.0f,
msgW, msgH);
g.FillRectangle(new SolidBrush(Color.FromArgb(240, Color.Khaki)), RectMsgL);
g.DrawRectangle(Pens.Black, RectMsgL);
g.DrawString(msgS, fMsg, Color.Maroon, RectMsgL);
}
}
}
//테두리가 리밋영역을 감추도록 그린다
g.DrawRectangle(new Pen(borderL, bordersize), Rect.Left, Rect.Top, Rect.Width, Rect.Height);
sf.Dispose();
}
}
}