You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
274 lines
13 KiB
274 lines
13 KiB
2 years ago
|
using System.Runtime.InteropServices;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace EC.AutoWeightServer.IfManager.Pos
|
||
|
{
|
||
|
public class PosSDK
|
||
|
{
|
||
|
#region Custom
|
||
|
|
||
|
public struct PosParam
|
||
|
{
|
||
|
private string lpName;
|
||
|
private string portType;
|
||
|
private bool bFile;
|
||
|
private string path;
|
||
|
}
|
||
|
|
||
|
#endregion Custom
|
||
|
|
||
|
#region Const
|
||
|
|
||
|
// pritner connect way
|
||
|
public const int POS_PT_COM = 1000;
|
||
|
|
||
|
public const int POS_PT_LPT = 1001;
|
||
|
public const int POS_PT_USB = 1002;
|
||
|
public const int POS_PT_NET = 1003;
|
||
|
|
||
|
// printer state
|
||
|
public const int POS_PS_NORMAL = 3001;
|
||
|
|
||
|
public const int POS_PS_PAPEROUT = 3002;
|
||
|
public const int POS_PS_HEAT = 3003;
|
||
|
public const int POS_PS_DOOROPEN = 3004;
|
||
|
public const int POS_PS_BUFFEROUT = 3005;
|
||
|
public const int POS_PS_CUT = 3006;
|
||
|
public const int POS_PS_DRAWERHIGH = 3007;
|
||
|
|
||
|
public const int POS_ES_PAPERENDING = 6; //纸将尽
|
||
|
public const int POS_ES_DRAWERHIGH = 5; //钱箱高电平
|
||
|
public const int POS_ES_CUT = 4; //切刀未复位
|
||
|
public const int POS_ES_DOOROPEN = 3; //纸仓门开
|
||
|
public const int POS_ES_HEAT = 2; //机头过热
|
||
|
public const int POS_ES_PAPEROUT = 1; //打印机缺纸
|
||
|
public const int POS_ES_SUCCESS = 0; //成功/发送成功/状态正常/打印完成
|
||
|
public const int POS_ES_INVALIDPARA = -1; //参数错误
|
||
|
public const int POS_ES_WRITEFAIL = -2; //写失败
|
||
|
public const int POS_ES_READFAIL = -3; //读失败
|
||
|
public const int POS_ES_NONMONOCHROMEBITMAP = -4; //非单色位图
|
||
|
public const int POS_ES_OVERTIME = -5; //超时/写超时/读超时/打印未完成
|
||
|
public const int POS_ES_FILEOPENERROR = -6; //文件/图片打开失败
|
||
|
public const int POS_ES_OTHERERRORS = -100; //其他原因导致的错误
|
||
|
|
||
|
// barcode type
|
||
|
public const int POS_BT_UPCA = 4001;
|
||
|
|
||
|
public const int POS_BT_UPCE = 4002;
|
||
|
public const int POS_BT_JAN13 = 4003;
|
||
|
public const int POS_BT_JAN8 = 4004;
|
||
|
public const int POS_BT_CODE39 = 4005;
|
||
|
public const int POS_BT_ITF = 4006;
|
||
|
public const int POS_BT_CODABAR = 4007;
|
||
|
public const int POS_BT_CODE93 = 4073;
|
||
|
public const int POS_BT_CODE128 = 4074;
|
||
|
|
||
|
// 2D barcode type
|
||
|
public const int POS_BT_PDF417 = 4100;
|
||
|
|
||
|
public const int POS_BT_DATAMATRIX = 4101;
|
||
|
public const int POS_BT_QRCODE = 4102;
|
||
|
|
||
|
// HRI type
|
||
|
public const int POS_HT_NONE = 4011;
|
||
|
|
||
|
public const int POS_HT_UP = 4012;
|
||
|
public const int POS_HT_DOWN = 4013;
|
||
|
public const int POS_HT_BOTH = 4014;
|
||
|
|
||
|
//TSPL
|
||
|
public const int TSPL_PRINTER_STATUS_OUTPAPER = 1;//打印机缺纸
|
||
|
|
||
|
public const int TSPL_PRINTER_STATUS_WORK = 2; //打印中
|
||
|
public const int TSPL_PRINTER_STATUS_ENCLOSURENOCLOSE = 3; //机壳未关
|
||
|
public const int TSPL_PRINTER_STATUS_ERROR = 4; //打印机内部错误
|
||
|
|
||
|
public const int TSPL_PARAM_LESS_EQUAL_ZERO = -2; //参数小于等于0
|
||
|
public const int TSPL_PARAM_GREAT_RANGE = -3; //参数大于指定范围
|
||
|
public const int TSPL_SUCCESS = 0;
|
||
|
public const int TSPL_IDERROR = -1;
|
||
|
|
||
|
#endregion Const
|
||
|
|
||
|
#region Method
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Port_OpenA")]
|
||
|
public static extern int POS_Port_OpenA(string lpName, int iPort, bool bFile, string path);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintstringA")]
|
||
|
public static extern int POS_Output_PrintstringA(int printID, string strBuff);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintData")]
|
||
|
public static extern int POS_Output_PrintData(int printID, byte[] strBuff, int ilen);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Port_Close")]
|
||
|
public static extern int POS_Port_Close(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_CutPaper")]
|
||
|
public static extern int POS_Control_CutPaper(int printID, int type, int len);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_CashDraw")]
|
||
|
public static extern int POS_Control_CashDraw(int printID, int iNum, int time1, int time2);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_QueryStatus")]
|
||
|
public static extern int POS_Status_QueryStatus(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_RTQueryStatus")]
|
||
|
public static extern int POS_Status_RTQueryStatus(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_RTQueryTypeStatus")]
|
||
|
public static extern int POS_Status_RTQueryTypeStatus(int printID, int n);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_DownloadBmpToFlashA")]
|
||
|
public static extern int POS_Output_DownloadBmpToFlashA(int printID, string strPath);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_DownloadBmpToFlashNumA")]
|
||
|
public static extern int POS_Control_DownloadBmpToFlashNumA(int printID, string strPath, int num);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintBmpDirectA")]
|
||
|
public static extern int POS_Output_PrintBmpDirectA(int printID, string strPath);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintFontStringA")]
|
||
|
public static extern int POS_Output_PrintFontStringA(int printID, int iFont, int iThick, int iWidth, int iHeight, int iUnderLine, string lpString);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Input_PrinterId")]
|
||
|
public static extern int POS_Input_PrinterId(int printID, StringBuilder Buff);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_BlackMark")]
|
||
|
public static extern int POS_Control_BlackMark(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetPrintPosition")]
|
||
|
public static extern int POS_Control_SetPrintPosition(int printID, int iLeft, int iWidth);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Status_QueryTaskStatus")]
|
||
|
public static extern int POS_Status_QueryTaskStatus(int printID, int second);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintFlashBmp")]
|
||
|
public static extern int POS_Output_PrintFlashBmp(int printID, int n);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintOneDimensionalBarcodeA")]
|
||
|
public static extern int POS_Output_PrintOneDimensionalBarcodeA(int printID, int iType, int iWidth, int iHeight, int hri, string lpstring);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintTwoDimensionalBarcodeA")]
|
||
|
public static extern int POS_Output_PrintTwoDimensionalBarcodeA(int printID, int iType, int parameter1, int parameter2, int parameter3, string lpstring);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_DownloadRamBmpA")]
|
||
|
public static extern int POS_Output_DownloadRamBmpA(int printID, string lpFilePath);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_PrintRamBmp")]
|
||
|
public static extern int POS_Output_PrintRamBmp(int printID, int n);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_PrintTestpage")]
|
||
|
public static extern int POS_Control_PrintTestpage(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "Color24_GrayBW")]
|
||
|
public static extern int Color24_GrayBW(string szSourceFile, string szTargetFile);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetRotaryPrint")]
|
||
|
public static extern int POS_Control_SetRotaryPrint(int printID, int n);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_OppositeColor")]
|
||
|
public static extern int POS_Control_OppositeColor(int printID, bool bOppsite);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_AlignType")]
|
||
|
public static extern int POS_Control_SetRotaryPrint(int printID, bool iAlignType);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Output_SendLocalFileA")]
|
||
|
public static extern int POS_Output_SendLocalFileA(int printID, string lpFilePath);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_ReSet")]
|
||
|
public static extern int POS_Control_ReSet(int printID);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetPrintFontC")]
|
||
|
public static extern int POS_Control_SetPrintFontC(int printID, bool iDoubleWidth, bool iDoubleHeight, bool iUnderLine);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_SetInvertedPrint")]
|
||
|
public static extern int POS_Control_SetInvertedPrint(int printID, int n);
|
||
|
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "POS_Control_AlignType")]
|
||
|
public static extern int POS_Control_AlignType(int printID, int iAlignType);
|
||
|
|
||
|
//--------------ztongli.20170123--------------
|
||
|
//设置页宽页高
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PageSetupTSPL")]
|
||
|
public static extern int PageSetupTSPL(int printID, int PageWidth, int PageHeight);
|
||
|
|
||
|
//画线
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawLineTSPL")]
|
||
|
public static extern int DrawLineTSPL(int printID, int StartX, int StartY, int LineWidth, int LineHeight);
|
||
|
|
||
|
//TL51打印
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PrintTSPL")]
|
||
|
public static extern int PrintTSPL(int printID, int Set, int Copy);
|
||
|
|
||
|
//画矩形
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawBorderTSPL")]
|
||
|
public static extern int DrawBorderTSPL(int printID, int LineWidth, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y);
|
||
|
|
||
|
//文字
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawTextTSPL")]
|
||
|
public static extern int DrawTextTSPL(int printID, int start_x, int start_y, bool isSimplifiedChinese, int xMultiplication, int yMultiplication, int rotate, string content);
|
||
|
|
||
|
//一维条码
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DrawBarCodeTSPL")]
|
||
|
public static extern int DrawBarCodeTSPL(int printID, int start_x, int start_y, string type, int height, bool isReadable, int rotate, int narrowWidth, int wideWidth, string content);
|
||
|
|
||
|
////清空缓冲区
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "ClearBuffTSPL")]
|
||
|
public static extern int ClearBuffTSPL(int printID);
|
||
|
|
||
|
//二维条码
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "Draw2DBarCodeTSPL")]
|
||
|
public static extern int Draw2DBarCodeTSPL(int printID, int start_x, int start_y, string Max, string content);
|
||
|
|
||
|
//下载位图
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DownLoadBitMapTSPL")]
|
||
|
public static extern int DownLoadBitMapTSPL(int printID, bool isMoveFlash, string PathName);
|
||
|
|
||
|
//将图片刷到缓冲区
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PutBitMapTSPL")]
|
||
|
public static extern int PutBitMapTSPL(int printID, int start_x, int start_y, string fileName);
|
||
|
|
||
|
//得到打印机状态
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "GetPrinterStatusTSPL")]
|
||
|
public static extern int GetPrinterStatusTSPL(int printID);
|
||
|
|
||
|
//控制蜂鸣器发出一声响
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "DriveBeepTSPL")]
|
||
|
public static extern int DriveBeepTSPL(int printID);
|
||
|
|
||
|
//设置国际字符集
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetCharsetNameTSPL")]
|
||
|
public static extern int SetCharsetNameTSPL(int printID, string CharsetName);
|
||
|
|
||
|
//控制进纸或退纸距离
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetPaperbackOrPaperFeedTSPL")]
|
||
|
public static extern int SetPaperbackOrPaperFeedTSPL(int printID, bool isFeedBack, int mDot);
|
||
|
|
||
|
//指定的区域反相打印命令
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "ReverseAreaTSPL")]
|
||
|
public static extern int ReverseAreaTSPL(int printID, int start_x, int start_y, int width, int height);
|
||
|
|
||
|
//选择字符代码页
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SelectCodePageTSPL")]
|
||
|
public static extern int SelectCodePageTSPL(int printID, int value);
|
||
|
|
||
|
//设置标签间垂直间距
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetGAPTSPL")]
|
||
|
public static extern int SetGAPTSPL(int printID, double value);
|
||
|
|
||
|
//定义标签的参考坐标原点命令
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetLabelReferenceTSPL")]
|
||
|
public static extern int SetLabelReferenceTSPL(int printID, int x, int y);
|
||
|
|
||
|
//TL21打印
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "PrintTSPL21")]
|
||
|
public static extern int PrintTSPL21(int printID, int Set);
|
||
|
|
||
|
//用于确认机型是TL21便于内部区别指令以及相关条件
|
||
|
[DllImport("POS_SDK.dll", CharSet = CharSet.Ansi, EntryPoint = "SetIs21")]
|
||
|
public static extern int SetIs21();
|
||
|
|
||
|
#endregion Method
|
||
|
}
|
||
|
}
|