callm 2 днів тому
батько
коміт
5983b174e6

+ 15 - 84
UAS_MES_YDCY/FunctionCode/Make/Make_FuselageLabelPrintRFID.cs

@@ -144,80 +144,7 @@ namespace UAS_MES_NEW.Make
             int pResultLen = 256;
 
             //1.Initialize the Library.
-            uRet = DSTP2x_Lib_Init("", 0, pSzResult, ref pResultLen);
-            if (uRet != 0)
-            {
-                OperateResult.AppendText("DSTP2x_Lib_Init,error code:[" + uRet.ToString() + "]");
-                return;
-            }
-
-            string tmpPath = "TemplatePrint_RFID/templateRFID.dlt";
-
-            //string writeEPCData = "11111111";
-            //string writeUSERData = "123ABC";
-
-            //2.Enumerate devices.   1-USB, 2-NET
-            uRet = DSTP2x_EnumDev(1, pEnumList, ref enumListLen, ref deviceNum); //USB connection
-            if (uRet != 0)
-            {
-                OperateResult.AppendText("Enumerate device error,error code:[" + uRet.ToString() + "]");
-                goto SAMPLE_END;
-            }
-            else
-            {
-                OperateResult.AppendText("设备连接成功\n", Color.Green);
-            }
-
-            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
-            {
-                OperateResult.AppendText("No device");
-                goto SAMPLE_END;
-            }
-
-            //3.Connect the device.
-            uRet = DSTP2x_ConnEnumeratedDev(device, ref dev_prt);
-            if (uRet != 0)
-            {
-                OperateResult.AppendText("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)
-            {
-                OperateResult.AppendText("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)
-            {
-                OperateResult.AppendText("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)
-            {
-                OperateResult.AppendText("Setting whether to print failed,error code:[" + uRet.ToString() + "]");
-                goto SAMPLE_END;
-            }
-
-            
-            SAMPLE_END:
-            //11.DeInit Library.
-            uRet = DSTP2x_Lib_Clear();
+        
         }
 
         private void Ma_code_DbChange(object sender, EventArgs e)
@@ -340,17 +267,14 @@ namespace UAS_MES_NEW.Make
                             //按照打印张数打印
                             //doc = lbl.Documents.Open(PrintLabel.Text);
 
-                            uRet = DSTP2x_SetTmplPrnMode(tmp_prt, 0); //set print mode
-                            if (uRet != 0)
-                            {
-                                OperateResult.AppendText("Setting whether to print failed,error code:[" + uRet.ToString() + "]");
-                            }
+
 
                             //6.设置打印数据 Set the print data.
                             uRet = DSTP2x_SetTmplPrnData(tmp_prt, "Text-01", "56789VWXYZ"); //The data must be utf-8
                             if (uRet != 0)
                             {
                                 OperateResult.AppendText("Failed to set someone data in template,error code:[" + uRet.ToString() + "]");
+                                goto SAMPLE_END;
                             }
 
                             //7.设置RFID数据 Set the RFID data.
@@ -358,6 +282,7 @@ namespace UAS_MES_NEW.Make
                             if (uRet != 0)
                             {
                                 OperateResult.AppendText("Failed to set EPC data in template,error code:[" + uRet.ToString() + "]");
+                                goto SAMPLE_END;
                             }
 
                             //uRet = DSTP2x_SetTmplRFIDData(tmp_prt, "USER-01", writeUSERData, writeUSERData.Length);
@@ -372,6 +297,7 @@ namespace UAS_MES_NEW.Make
                             if (uRet != 0)
                             {
                                 OperateResult.AppendText("Print template failed,error code:[" + uRet.ToString() + "]");
+                                goto SAMPLE_END;
                             }
 
                             OperateResult.AppendText("The RFID data is " + Encoding.UTF8.GetString(szOutRFID, 0, pOutRFIDSize));
@@ -381,15 +307,20 @@ namespace UAS_MES_NEW.Make
                             if (uRet != 0)
                             {
                                 OperateResult.AppendText("Delete handle of template failed,error code:[" + uRet.ToString() + "]");
+                                goto SAMPLE_END;
                             }
 
                             //10.Disconnect the device.
-                            uRet = DSTP2x_DisconnDev(dev_prt);
-                            if (uRet != 0)
-                            {
-                                OperateResult.AppendText("Delete handle of device failed,error code:[" + uRet.ToString() + "]");
-                            }
+                            //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:
+                            //11.DeInit Library.
                             uRet = DSTP2x_Lib_Clear();
 
                             //记录日志