|
|
@@ -14,6 +14,7 @@ using Seagull.BarTender.Print;
|
|
|
using DEV_HDL = System.UInt32;
|
|
|
using LABEL_TEMP_HDL = System.UInt32;
|
|
|
using System.Runtime.InteropServices;
|
|
|
+using DevExpress.XtraMap;
|
|
|
|
|
|
namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
@@ -103,6 +104,8 @@ namespace UAS_MES_NEW.Make
|
|
|
int pOutRFIDSize = 1024;
|
|
|
int deviceNum = 0;
|
|
|
string device = "";
|
|
|
+ StringBuilder pSzResult = new StringBuilder(256);
|
|
|
+ int pResultLen = 256;
|
|
|
private void Make_FuselageLabelPrint_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
asc.controllInitializeSize(this);
|
|
|
@@ -140,8 +143,7 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
catch (Exception) { }
|
|
|
|
|
|
- StringBuilder pSzResult = new StringBuilder(256);
|
|
|
- int pResultLen = 256;
|
|
|
+
|
|
|
|
|
|
//1.Initialize the Library.
|
|
|
|
|
|
@@ -178,6 +180,7 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
private void sn_code_KeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
+
|
|
|
//按下enter键
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
{
|
|
|
@@ -266,8 +269,67 @@ namespace UAS_MES_NEW.Make
|
|
|
OperateResult.AppendText("<<序列号:" + sncode.Text + "\n", Color.Black);
|
|
|
//按照打印张数打印
|
|
|
//doc = lbl.Documents.Open(PrintLabel.Text);
|
|
|
+ string tmpPath = "TemplatePrint_RFID/templateRFID.dlt";
|
|
|
+
|
|
|
+ uRet = DSTP2x_Lib_Init("", 0, pSzResult, ref pResultLen);
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("DSTP2x_Lib_Init,error code:[" + uRet.ToString() + "]");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ uRet = DSTP2x_EnumDev(1, pEnumList, ref enumListLen, ref deviceNum); //USB connection
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Enumerate device error,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceNum > 1)
|
|
|
+ {
|
|
|
+ string str = Encoding.UTF8.GetString(pEnumList, 0, enumListLen);
|
|
|
+ string[] enumList = str.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+ device = enumList[0];
|
|
|
+ }
|
|
|
+ else if (deviceNum == 1)
|
|
|
+ device = Encoding.UTF8.GetString(pEnumList, 0, enumListLen);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("No device");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
+
|
|
|
+ //3.Connect the device.
|
|
|
+ uRet = DSTP2x_ConnEnumeratedDev(device, ref dev_prt);
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Failed to connect device,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
|
|
|
+ //Non essential interface. 1-ZPL, 2-TSPL, 3-ESCPOS
|
|
|
+ uRet = DSTP2x_SetPrnEmulation(dev_prt, 1); //ZPL
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Failed to set up print simulation,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
+
|
|
|
+ //4.加在标签文件Load the template.
|
|
|
+ uRet = DSTP2x_LoadLabelTmpl(tmpPath, ref tmp_prt);
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Failed to load label template,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
|
|
|
+ //5.设置打印模式 0-打印 Set the print mode. 0-print, 1-generate the prn file, 2-generate the preview image.
|
|
|
+ uRet = DSTP2x_SetTmplPrnMode(tmp_prt, 0); //set print mode
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Setting whether to print failed,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
|
|
|
//6.设置打印数据 Set the print data.
|
|
|
uRet = DSTP2x_SetTmplPrnData(tmp_prt, "Text-01", "56789VWXYZ"); //The data must be utf-8
|
|
|
@@ -278,7 +340,7 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
|
|
|
//7.设置RFID数据 Set the RFID data.
|
|
|
- uRet = DSTP2x_SetTmplRFIDData(tmp_prt, "EPC-01", sncode.Text, sncode.Text.Length);
|
|
|
+ uRet = DSTP2x_SetTmplRFIDData(tmp_prt, "EPC-01", AsciiToHex(sncode.Text), AsciiToHex(sncode.Text).Length);
|
|
|
if (uRet != 0)
|
|
|
{
|
|
|
OperateResult.AppendText("Failed to set EPC data in template,error code:[" + uRet.ToString() + "]");
|
|
|
@@ -311,12 +373,12 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
|
|
|
//10.Disconnect the device.
|
|
|
- //uRet = DSTP2x_DisconnDev(dev_prt);
|
|
|
- //if (uRet != 0)
|
|
|
- //{
|
|
|
- // OperateResult.AppendText("Delete handle of device failed,error code:[" + uRet.ToString() + "]");
|
|
|
- // goto SAMPLE_END;
|
|
|
- //}
|
|
|
+ uRet = DSTP2x_DisconnDev(dev_prt);
|
|
|
+ if (uRet != 0)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("Delete handle of device failed,error code:[" + uRet.ToString() + "]");
|
|
|
+ goto SAMPLE_END;
|
|
|
+ }
|
|
|
OperateResult.AppendText("This example has been successfully demonstrated!\n");
|
|
|
|
|
|
SAMPLE_END:
|
|
|
@@ -378,6 +440,12 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static string AsciiToHex(string asciiString)
|
|
|
+ {
|
|
|
+ byte[] bytes = Encoding.ASCII.GetBytes(asciiString);
|
|
|
+ return BitConverter.ToString(bytes).Replace("-", "").ToLower();
|
|
|
+ }
|
|
|
private void pr_code_TextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + ma_prodcode.Text + "' and la_templatetype='机身标' and la_statuscode='AUDITED' order by la_isdefault", "select");
|