247 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			247 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AR;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Drawing;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| namespace Project
 | |
| {
 | |
|     public partial class FMain
 | |
|     {
 | |
|         public Boolean PRINTER(eWorkPort target, eSMStep cmdIndex)
 | |
|         {
 | |
|             UInt16 idx = 1;
 | |
|             var mv = PUB.Result.vModel;
 | |
|             var mc = PUB.Result.mModel;
 | |
|             var funcName = System.Reflection.MethodBase.GetCurrentMethod().Name;
 | |
|             var seqTime = PUB.sm.seq.GetTime(cmdIndex);
 | |
|             var msgType = (Class.eStatusMesage)target;
 | |
|             var item = target == eWorkPort.Left ? PUB.Result.ItemDataL : PUB.Result.ItemDataR;
 | |
|             var Printer = target == eWorkPort.Left ? PUB.PrinterL : PUB.PrinterR;
 | |
|             //var Jobtype = VAR.STR[eVarString.JOB_TYPE];
 | |
|             var CVMode = VAR.BOOL[eVarBool.Use_Conveyor];
 | |
| 
 | |
|             //option check
 | |
|             var OPT_PrinterOff = PUB.OPT_PRINTEROFF(target);
 | |
|             var OPT_CameraOff = PUB.OPT_CAMERA(target);
 | |
|             var OPT_BYPASS = PUB.OPT_BYPASS();
 | |
| 
 | |
| 
 | |
| 
 | |
|             //####################################################
 | |
|             //###	작업시작
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 PUB.log.Add($"[{target}] Print operation started");
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //### 프린트 모션 위치 확인
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 sPositionData PosY, PosZ;
 | |
|                 if (target == eWorkPort.Left)
 | |
|                 {
 | |
|                     PosY = MOT.GetLMPos(eLMLoc.READY);
 | |
|                     PosZ = MOT.GetLZPos(eLZLoc.PICKON);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     PosY = MOT.GetRMPos(eRMLoc.READY);
 | |
|                     PosZ = MOT.GetRZPos(eRZLoc.PICKON);
 | |
|                 }
 | |
| 
 | |
|                 if (MOT.CheckMotionPos(seqTime, PosY, funcName) == false) return false;
 | |
|                 if (MOT.CheckMotionPos(seqTime, PosZ, funcName) == false) return false;
 | |
| 
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             //####################################################
 | |
|             //###	인쇄데이터 확인
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (item.VisionData.RID.isEmpty())
 | |
|                 {
 | |
|                     if (target == eWorkPort.Left)
 | |
|                     {
 | |
|                         PUB.Result.SetResultMessage(eResult.OPERATION, eECode.NOPRINTLDATA, eNextStep.PAUSE);
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         PUB.Result.SetResultMessage(eResult.OPERATION, eECode.NOPRINTRDATA, eNextStep.PAUSE);
 | |
|                     }
 | |
|                     return false;
 | |
|                 }
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	인쇄데이터전송
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (OPT_PrinterOff == false)
 | |
|                 {
 | |
|                     string zpl, qrdata;
 | |
|                     zpl = Printer.makeZPL_210908(new Class.Reel
 | |
|                     {
 | |
|                         SID = item.VisionData.SID,
 | |
|                         venderLot = item.VisionData.VLOT,
 | |
|                         venderName = item.VisionData.VNAME,
 | |
|                         qty = item.VisionData.QTY.isEmpty() ? -1 : int.Parse(item.VisionData.QTY),
 | |
|                         id = item.VisionData.RID,
 | |
|                         mfg = item.VisionData.MFGDATE,
 | |
|                         PartNo = item.VisionData.PARTNO,
 | |
|                     }, AR.SETTING.Data.DrawOutbox, out qrdata);
 | |
|                     item.VisionData.ZPL = zpl;
 | |
|                     item.VisionData.PrintQRData = qrdata;
 | |
| 
 | |
|                     PUB.log.Add("PRINT", $"[{target}] Printing");//QR=" + item.VisionData.QRData);
 | |
| 
 | |
|                     if (target == eWorkPort.Left)
 | |
|                     {
 | |
|                         var prn = Printer.Print(zpl);
 | |
|                         //PUB.PrintSend(true, zpl); //PUB.PrintL.Write(zpl);
 | |
|                         if (prn == false)
 | |
|                         {
 | |
|                             PUB.Result.SetResultMessage(eResult.HARDWARE, eECode.PRINTL, eNextStep.ERROR);
 | |
|                             return false;
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             SETTING.Counter.CountPrintL += 1;
 | |
|                             item.PrintTime = DateTime.Now;
 | |
|                         }
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         var prn = Printer.Print(zpl);
 | |
|                         //PUB.PrintSend(false, zpl); //PUB.PrintR.Write(zpl);
 | |
| 
 | |
| 
 | |
|                         if (prn == false)
 | |
|                         {
 | |
|                             PUB.Result.SetResultMessage(eResult.HARDWARE, eECode.PRINTR, eNextStep.ERROR);
 | |
|                             return false;
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             SETTING.Counter.CountPrintR += 1;
 | |
|                             item.PrintTime = DateTime.Now;
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|                 else PUB.log.AddAT($"[{target}] Printer function OFF (bypass or model or setting)");
 | |
| 
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	잠시대기
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 var WaitMS = target == eWorkPort.Left ? AR.SETTING.Data.PrintLWaitMS : AR.SETTING.Data.PrintRWaitMS;
 | |
|                 if (OPT_PrinterOff == false && seqTime.TotalMilliseconds < WaitMS) return false;
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	위쪽흡기 ON
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (OPT_PrinterOff == false)
 | |
|                 {
 | |
|                     if (target == eWorkPort.Left)
 | |
|                     {
 | |
|                         DIO.SetPrintLVac(ePrintVac.inhalation);
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         DIO.SetPrintRVac(ePrintVac.inhalation);
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             //####################################################
 | |
|             //###	잠시대기
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (OPT_PrinterOff == false && seqTime.TotalMilliseconds < 100) return false;
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	아래쪽 블로우
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (OPT_PrinterOff == false && SETTING.Data.Disable_BottomAirBlow == false)
 | |
|                 {
 | |
|                     if (target == eWorkPort.Left)
 | |
|                     {
 | |
|                         DIO.SetPrintLAir(true);
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         DIO.SetPrintRAir(true);
 | |
|                     }
 | |
|                 }
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	잠시대기
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 if (OPT_PrinterOff == false && seqTime.TotalMilliseconds < 100) return false;
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //###	장비기술데이터저장
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 PUB.log.Add($"6.PRINT : EE-SAVE");
 | |
|                 SaveData_EE(item, (target == eWorkPort.Left ? "L" : "R"), "","printer");
 | |
|                 //RefreshList();  //목록업데이트
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //####################################################
 | |
|             //### spare
 | |
|             //####################################################
 | |
|             if (PUB.sm.seq.Get(cmdIndex) == idx++)
 | |
|             {
 | |
|                 PUB.sm.seq.Update(cmdIndex);
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             return true;
 | |
|         }
 | |
|     }
 | |
| } | 
