callm пре 9 часа
родитељ
комит
a091258c83
1 измењених фајлова са 26 додато и 29 уклоњено
  1. 26 29
      UAS_MES_YDCY/FunctionCode/Make/Make_FuselageLabelPrintRFID.cs

+ 26 - 29
UAS_MES_YDCY/FunctionCode/Make/Make_FuselageLabelPrintRFID.cs

@@ -274,14 +274,14 @@ namespace UAS_MES_NEW.Make
                             uRet = DSTP2x_Lib_Init("", 0, pSzResult, ref pResultLen);
                             if (uRet != 0)
                             {
-                                Console.WriteLine("DSTP2x_Lib_Init,error code:[" + uRet.ToString() + "]");
+                                OperateResult.AppendText("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() + "]");
+                                 OperateResult.AppendText("Enumerate device error,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
@@ -295,7 +295,7 @@ namespace UAS_MES_NEW.Make
                                 device = Encoding.UTF8.GetString(pEnumList, 0, enumListLen);
                             else
                             {
-                                Console.WriteLine("No device");
+                                 OperateResult.AppendText("No device");
                                 goto SAMPLE_END;
                             }
 
@@ -303,7 +303,7 @@ namespace UAS_MES_NEW.Make
                             uRet = DSTP2x_ConnEnumeratedDev(device, ref dev_prt);
                             if (uRet != 0)
                             {
-                                Console.WriteLine("Failed to connect device,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Failed to connect device,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
@@ -311,65 +311,64 @@ namespace UAS_MES_NEW.Make
                             uRet = DSTP2x_SetPrnEmulation(dev_prt, 1); //ZPL
                             if (uRet != 0)
                             {
-                                Console.WriteLine("Failed to set up print simulation,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Failed to set up print simulation,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
-                            //4.加在标签文件Load the template.
+                            //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() + "]");
+                                 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.
+                            //5.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() + "]");
+                                 OperateResult.AppendText("Setting whether to print failed,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
-                            //6.设置打印数据 Set the print data.
+                            //6.Set the print data.
                             uRet = DSTP2x_SetTmplPrnData(tmp_prt, "Text-01", sncode.Text); //The data must be utf-8
                             if (uRet != 0)
                             {
-                                OperateResult.AppendText("Failed to set someone data in template,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Failed to set someone data in template,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
-                            //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",Hex.Checked? AsciiToHex(sncode.Text): sncode.Text, Hex.Checked? AsciiToHex(sncode.Text).Length:sncode.Text.Length);
+                            //7.Set the RFID data.
+                            uRet = DSTP2x_SetTmplRFIDData(tmp_prt, "EPC-01", Hex.Checked?AsciiToHex(sncode.Text): sncode.Text, Hex.Checked ? AsciiToHex(sncode.Text).Length : sncode.Text.Length);
                             if (uRet != 0)
                             {
-                                OperateResult.AppendText("Failed to set EPC data in template,error code:[" + uRet.ToString() + "]");
+                                 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);
-                            //if (uRet != 0)
-                            //{
-                            //     OperateResult.AppendText("Failed to set USER data in template,error code:[" + uRet.ToString() + "]");
-                            //    goto SAMPLE_END;
-                            //}
+                            uRet = DSTP2x_SetTmplRFIDData(tmp_prt, "USER-01", "123ABC", "123ABC".Length);
+                            if (uRet != 0)
+                            {
+                                 OperateResult.AppendText("Failed to set USER data in template,error code:[" + uRet.ToString() + "]");
+                                goto SAMPLE_END;
+                            }
 
                             //8.Print template and get the RFID data.
                             uRet = DSTP2x_PrintTmpl(dev_prt, tmp_prt, szOutFile, ref pOutFileSize, szOutRFID, ref pOutRFIDSize);
                             if (uRet != 0)
                             {
-                                OperateResult.AppendText("Print template failed,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Print template failed,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
-                            OperateResult.AppendText("The RFID data is " + Encoding.UTF8.GetString(szOutRFID, 0, pOutRFIDSize));
+                             OperateResult.AppendText("The RFID data is " + Encoding.UTF8.GetString(szOutRFID, 0, pOutRFIDSize));
 
                             //9.Delete the handle of template.
                             uRet = DSTP2x_DeleteTmpl(tmp_prt);
                             if (uRet != 0)
                             {
-                                OperateResult.AppendText("Delete handle of template failed,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Delete handle of template failed,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
 
@@ -377,17 +376,15 @@ namespace UAS_MES_NEW.Make
                             uRet = DSTP2x_DisconnDev(dev_prt);
                             if (uRet != 0)
                             {
-                                OperateResult.AppendText("Delete handle of device failed,error code:[" + uRet.ToString() + "]");
+                                 OperateResult.AppendText("Delete handle of device failed,error code:[" + uRet.ToString() + "]");
                                 goto SAMPLE_END;
                             }
-                            OperateResult.AppendText("This example has been successfully demonstrated!\n");
-
-                            bool Passed=true;
                             SAMPLE_END:
                             {
                                 uRet = DSTP2x_Lib_Clear();
-                                Passed = false;
                             }
+                            bool Passed=true;
+                           
 
                             if (Passed) {
                                 //记录日志