LabelMachine.print.cs
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using CodeLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public partial class LabelMachine
{
public void InitPrint()
{
RobotManage.PrintBean.PrintStatusChanged += Print_PrintStatusChanged;
RobotManage.LoadPrintSetting();
}
public Asa.PrintLabel.PrinterStatus LastPrintStatus = Asa.PrintLabel.PrinterStatus.Unknown;
void Print_PrintStatusChanged(Asa.PrintLabel.PrinterStatus sta, string msg)
{
if (sta.Equals(LastPrintStatus).Equals(false))
{
LogUtil.info("PrintLabel 收到打印机新状态:【" + sta + "】【" + msg + "】,替换原来的状态【" + LastPrintStatus + "】 ");
}
else
{
if (sta == Asa.PrintLabel.PrinterStatus.Idle)
{
Task.Run(() => {
while (true)
{
if (MoveInfo.IsStep(MoveStep.Lbl_WaitPrint))
{
MoveInfo.NextMoveStep(MoveStep.Lbl_Printted);
break;
}
Task.Delay(500).Wait();
}
});
}
LogUtil.info(" PrintLabel 收到打印机新状态:【" + sta + "】【" + msg + "】,与之前状态一样 ");
}
LastPrintStatus = sta;
}
public string LastPrintLabel = "";
void StartPrintLabel(string wareCode, string wareCount, bool ReverseLabel=false)
{
try
{
LastPrintStatus = Asa.PrintLabel.PrinterStatus.Unknown;
LogUtil.info("调用 PrintLabel 打印标签 StartPrintLabel ,[" + wareCode + "] [" + wareCount + "] 开始");
Dictionary<string, string> text = new Dictionary<string, string>();
text.Add("Code", wareCode);
text.Add("Count", wareCount);
text.Add("DateTime", System.DateTime.Now.ToString("F"));
text.Add("FactoryCode", "");
LastPrintLabel = wareCode;
RobotManage.PrintBean.Rotate180 = ReverseLabel;
RobotManage.PrintBean.Print(text);
LogUtil.info("PrintLabel 打印标签 StartPrintLabel 结束 ");
}
catch (Exception ex)
{
LogUtil.error("PrintLabel 打印标签 StartPrintLabel 错误:" + ex.ToString());
}
}
public Task DoPrint(ReelParam labelParam, bool ReverseLabel = false)
{
LogUtil.info($"调用 PrintLabel 打印标签 WareCode:{labelParam.WareCode}, QTY:{labelParam.QTY}, ReverseLabel:{ReverseLabel}");
StartPrintLabel(labelParam.WareCode, labelParam.QTY.ToString(), ReverseLabel);
return Task.Run(() =>
{ });
}
/// <summary>
/// 扫码线程
/// </summary>
Task<List<CodeInfo>> ScanTask;
Task<List<CodeInfo>> ScanCode()
{
MoveInfo.log("开始贴标扫码线程");
return Task.Run(new Func<List<CodeInfo>>(() =>
{
try
{
IOMove(IO_Label_Type.Camera_Led, IO_VALUE.HIGH);
Task.Delay(10).Wait();
List<CodeInfo> LastCodeList = CodeManager.CameraScan(new List<string> { Config.CameraName });
if (LastCodeList.Count <= 0)
{
Task.Delay(500).Wait();
LastCodeList = CodeManager.CameraScan(new List<string> { Config.CameraName });
}
IOMove(IO_Label_Type.Camera_Led, IO_VALUE.LOW);
return LastCodeList;
}
catch {
return new List<CodeInfo>();
}
}));
}
}
}