- UIControl 프로젝트 구조 변경 (CapCleaningControl → Sub/UIControl) - arAjinextek 라이브러리 통합 및 구조 개선 - 새로운 arAjinextek_Union 프로젝트 추가 - 솔루션 파일에 README.md 추가 - QR 모드에서 WMS RCV 태그 인식 기능 강화 - 데이터베이스 스키마 업데이트 및 관련 클래스 수정 - 프린터 및 바코드 장치 연동 로직 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
126 lines
3.9 KiB
C#
126 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Project.Device
|
|
{
|
|
public class SATOPrinter : arDev.RS232
|
|
{
|
|
public string LastPrintZPL = string.Empty;
|
|
public string qrData = string.Empty;
|
|
public string ZPLFileName { get; set; } = "zpl.txt";
|
|
public string baseZPL
|
|
{
|
|
get
|
|
{
|
|
var fi = new System.IO.FileInfo(ZPLFileName);
|
|
if (fi.Exists == false || fi.Length == 0)
|
|
{
|
|
PUB.log.AddE($"{ZPLFileName} 이 존재하지않거나 데이터가 없습니다 zpl.txt 기본으로 변경합니다");
|
|
fi = new System.IO.FileInfo("zpl.txt");
|
|
if (fi.Exists == false) PUB.log.AddE("인쇄기본파일(zpl.txt)가 존재하지 않습니다");
|
|
}
|
|
if (fi.Exists && fi.Length > 1)
|
|
return System.IO.File.ReadAllText(fi.FullName, System.Text.Encoding.Default);
|
|
else
|
|
{
|
|
PUB.log.AddAT("ZPL파일이 없어 설정의 ZPL코드를 사용합니다");
|
|
return Properties.Settings.Default.ZPL7;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public SATOPrinter()
|
|
{
|
|
//this.baseZPL = Properties.Settings.Default.ZPL7;
|
|
this.Terminal = eTerminal.CR;
|
|
this.ReceiveData += SATOPrinter_ReceiveData;
|
|
this.ReceiveData_Raw += SATOPrinter_ReceiveData_Raw;
|
|
}
|
|
|
|
private void SATOPrinter_ReceiveData_Raw(object sender, ReceiveDataEventArgs e)
|
|
{
|
|
PUB.log.Add($"SATO Recv(RAW) : " + e.StrValue);
|
|
}
|
|
|
|
private void SATOPrinter_ReceiveData(object sender, ReceiveDataEventArgs e)
|
|
{
|
|
PUB.log.Add($"SATO Recv : " + e.StrValue);
|
|
}
|
|
|
|
public Boolean TestPrint(Boolean drawbox, string manu = "", string mfgdate = "")
|
|
{
|
|
var dtstr = DateTime.Now.ToShortDateString();
|
|
var printcode = "103077807;Z577603504;105-35282-1105;15000;RC00004A219001W;20210612";
|
|
var reel = new Class.Reel(printcode);
|
|
//reel.id = "RLID" + DateTime.Now.ToString("MMHHmmssfff");
|
|
reel.sid = "103000000";
|
|
reel.partnum = "PARTNO".PadRight(20, '0'); //20자리
|
|
|
|
if (mfgdate == "") reel.mfg = dtstr;
|
|
else reel.mfg = mfgdate;
|
|
|
|
reel.lot = "LOT000000000";
|
|
if (manu == "") reel.manu = "ATK4EET1";
|
|
else reel.manu = manu;
|
|
|
|
reel.qty = 15000;
|
|
var rlt = Print(reel, true, drawbox);
|
|
var fi = new System.IO.FileInfo(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp_zpl.txt"));
|
|
System.IO.File.WriteAllText(fi.FullName, LastPrintZPL, System.Text.Encoding.Default);
|
|
return rlt;
|
|
}
|
|
|
|
|
|
public Boolean Print(Class.Reel reel, Boolean display1drid, Boolean drawOUtBox)
|
|
{
|
|
string prtData;
|
|
prtData = makeZPL_210908(reel, drawOUtBox, out qrData);
|
|
|
|
return Print(prtData);
|
|
}
|
|
|
|
public bool Print(string _zpl)
|
|
{
|
|
this.LastPrintZPL = _zpl;
|
|
if (this.IsOpen() == false) return false;
|
|
|
|
try
|
|
{
|
|
this.Write(_zpl);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public string makeZPL_210908(Class.Reel reel, Boolean drawbox, out string qrData)
|
|
{
|
|
string m_strSend = string.Empty;
|
|
qrData = string.Format("{0};{1};{2};{3};{4};{5};{6}", reel.sid, reel.lot, reel.manu, reel.qty, reel.id, reel.mfg, reel.partnum);
|
|
|
|
var reeid = reel.id;
|
|
if (reeid.Length > 20)
|
|
reeid = "..." + reeid.Substring(reeid.Length - 20);
|
|
|
|
m_strSend = this.baseZPL;
|
|
m_strSend = m_strSend.Replace("{qrData}", qrData);
|
|
m_strSend = m_strSend.Replace("{sid}", reel.sid);
|
|
m_strSend = m_strSend.Replace("{lot}", reel.lot);
|
|
m_strSend = m_strSend.Replace("{partnum}", reel.partnum);
|
|
m_strSend = m_strSend.Replace("{rid}", reeid);
|
|
m_strSend = m_strSend.Replace("{qty}", reel.qty.ToString());
|
|
m_strSend = m_strSend.Replace("{mfg}", reel.mfg);
|
|
m_strSend = m_strSend.Replace("{supply}", reel.manu);
|
|
|
|
//줄바꿈제거
|
|
m_strSend = m_strSend.Replace("\r", "").Replace("\n", "");
|
|
return m_strSend;
|
|
}
|
|
}
|
|
} |