c# 斑马打印机通信


本实例是用C#开发的和斑马打印机通信的实例程序,支持串口、USB口和并口。
资源截图
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Collections;
using System.Runtime.InteropServices;
using System.IO;
using System.xml;
using System.xml.Serialization;

namespace Colibri.CommonModule
{
    /// 
    /// Common Class that contains static common functions
    /// 

    /// 
    public class Parameter
    {
        public static string ScanBarcode1 = “Barcode1“;            //条码枪1
        public static string ScanBarcode2 = “Barcode2“;            //条码枪2
        public static string ScanBarcode3 = “Barcode3“;            //条码枪3
        public static string ScanBarcode4 = “Barcode4“;            //条码枪4
        public static int DutCountName = 0;

        public static string Scan1 = “ScanSleep“;
        public static string Scan2 = “ScanSleep“;

        public static int phonelen = 0;
        public static int chargelen = 0;
        public static int boxlen = 0;

        public static string Print1 = “00“;
        public static string Print2 = “00“;
    }
 
    public class CommonClass
    {
        #region valid
        /// 
        /// Check the type of obj is not null and is the type that sepecified by the second parameter
        /// 

        /// Checking object instance
        /// Expected type
        /// Checking result true means valid
        public static bool IsValidType(object obj Type type)
        {
            return obj != null && obj.GetType() == type;
        }
        #endregion

        #region Get Random result for test
        /// 
        /// Get random result 
        /// 

        /// specify fail rate 0~1
        /// random result pass or fail based on fail rate
        public static bool GetRandomResult(double failRate = 0.5)
        {
            Random random = new Random();
            double value = random.NextDouble();
            return value > failRate;
        }
        #endregion

        #region Time string
        /// 
        /// Get time string for current time with default format(“yyyy-MM-dd HH:mm:ss.fff“)
        /// 

        /// string of current time
        public static string GetNowTimeString()
        {
            return GetTimeString(System.DateTime.Now);
        }

        /// 
        /// Get time string for current time with specified format
        /// 

        /// the string format
        /// string of current time
        public static string GetNowTimeString(string format)
        {
            return GetTimeString(System.DateTime.Nowformat);
        }

        /// 

        /// Get time string for the spe

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.    328192  2017-01-06 14:08  BarcodePrinter170705.vsBarcodePrinterv14.suo

    ..A..H.    301056  2016-10-27 13:29  BarcodePrinter170705BarcodePrinter.vsBarcodePrinterv14.suo

     文件        974  2016-11-18 14:48  BarcodePrinter170705BarcodePrinterApp.config

     文件       8715  2017-06-25 21:05  BarcodePrinter170705BarcodePrinterBarcodePrinter.csproj

     文件        932  2016-10-20 15:23  BarcodePrinter170705BarcodePrinterBarcodePrinter.sln

    ..A..H.    295936  2016-10-23 17:42  BarcodePrinter170705BarcodePrinterBarcodePrinter.v11.suo

     文件      31996  2016-11-25 13:27  BarcodePrinter170705BarcodePrinterin1.txt

     文件       4911  2016-11-25 13:28  BarcodePrinter170705BarcodePrinterin2.txt

     文件        546  2016-11-25 13:28  BarcodePrinter170705BarcodePrinterin3.txt

     文件     196608  2017-08-31 13:47  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.exe

     文件        974  2016-11-18 14:48  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.exe.config

     文件     323072  2017-08-31 13:47  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.pdb

     文件      22984  2017-09-23 16:10  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.vshost.exe

     文件        974  2016-11-18 14:48  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.vshost.exe.config

     文件       3301  2016-10-28 09:08  BarcodePrinter170705BarcodePrinterinDebugBarcodePrinter.vshost.exe.manifest

     文件       2208  2016-11-17 22:15  BarcodePrinter170705BarcodePrinterinDebuglogs2016-11-17-Error.log

     文件       8336  2016-11-17 22:15  BarcodePrinter170705BarcodePrinterinDebuglogs2016-11-17-Print.log

     文件       2163  2016-12-15 10:28  BarcodePrinter170705BarcodePrinterinDebuglogs2016-12-15-Error.log

     文件       4582  2016-12-15 10:28  BarcodePrinter170705BarcodePrinterinDebuglogs2016-12-15-Print.log

     文件        276  2016-12-21 10:35  BarcodePrinter170705BarcodePrinterinDebuglogs2016-12-21-Error.log

     文件      25042  2016-12-21 10:37  BarcodePrinter170705BarcodePrinterinDebuglogs2016-12-21-Print.log

     文件       3576  2017-06-22 17:00  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-22-Error.log

     文件       5824  2017-06-22 17:22  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-22-Print.log

     文件       2931  2017-06-24 19:58  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-24-Error.log

     文件     146390  2017-06-24 19:59  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-24-Print.log

     文件       2325  2017-06-25 15:49  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-25-Error.log

     文件      14379  2017-06-25 15:49  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-25-Print.log

     文件       1754  2017-06-27 17:42  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-27-Error.log

     文件      23203  2017-06-27 17:56  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-27-Print.log

     文件       3916  2017-06-28 16:00  BarcodePrinter170705BarcodePrinterinDebuglogs2017-06-28-Error.log

............此处省略139个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)