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.

169 lines
3.8 KiB

3 years ago
using System.Runtime.InteropServices;
using System.Text;
namespace EC.AutoWeightServer.IfManager.YkPos
{
internal class YkPosSDK
{
[DllImport("YkPosdll.dll")]
public static extern int YkOpenDevice(int iport, int baud);
[DllImport("YkPosdll.dll")]
private static extern int YkCloseDevice();
[DllImport("YkPosdll.dll")]
private static extern int YkIsConnected();
[DllImport("YkPosdll.dll")]
private static extern int YkInitPrinter();
[DllImport("YkPosdll.dll", CharSet = CharSet.Ansi, EntryPoint = "YkPrintStr", CallingConvention = CallingConvention.StdCall)]
private static extern int YkPrintStr([MarshalAs(UnmanagedType.LPStr)] StringBuilder pstr);
[DllImport("YkPosdll.dll")]
private static extern int YkFeedPaper();
[DllImport("YkPosdll.dll")]
private static extern int YkGetStatus(byte n);
[DllImport("YkPosdll.dll")]
private static extern int YkGetPrinterStatus(byte n);
[DllImport("YkPosdll.dll", CharSet = CharSet.Ansi, EntryPoint = "YkPrintRasterBmp", CallingConvention = CallingConvention.StdCall)]
private static extern int YkPrintRasterBmp([MarshalAs(UnmanagedType.LPStr)] StringBuilder pBmpFile);
[DllImport("YkPosdll.dll", CharSet = CharSet.Ansi, EntryPoint = "YkPrintBitmap", CallingConvention = CallingConvention.StdCall)]
private static extern int YkPrintBitmap([MarshalAs(UnmanagedType.LPStr)] StringBuilder pBmpFile, int m);
[DllImport("YkPosdll.dll", CharSet = CharSet.Ansi, EntryPoint = "YkPrintBarCode", CallingConvention = CallingConvention.StdCall)]
private static extern int YkPrintBarCode(int m, int n, [MarshalAs(UnmanagedType.LPStr)] StringBuilder barcode);
[DllImport("YkPosdll.dll")]
private static extern int YkCutPaper(int m, int n);
[DllImport("YkPosdll.dll")]
private static extern int YkSetAlign(int n);
[DllImport("YkPosdll.dll")]
private static extern int YkSetEmphasized(int n);
[DllImport("YkPosdll.dll")]
private static extern int YkSetLeftMargin(int nL, int nH);
[DllImport("YkPosdll.dll")]
private static extern int YkSetCharSize(int hsize, int vsize);
public static int OpenDevice()
{
int i;
i = YkOpenDevice(13, 0);
return i;
}
public static int CloseDevice()
{
int i;
i = YkCloseDevice();
return i;
}
public static int IsConnected()
{
int i;
i = YkIsConnected();
return i;
}
public static int InitPrinter()
{
int i;
i = YkInitPrinter();
return i;
}
public static int PrintStr([MarshalAs(UnmanagedType.LPStr)] StringBuilder pstr)
{
int i;
i = YkPrintStr(pstr);
return i;
}
public static int PrintRasterBmp([MarshalAs(UnmanagedType.LPStr)] StringBuilder pBmpFile)
{
int i;
i = YkPrintRasterBmp(pBmpFile);
return i;
}
public static int PrintBitmap([MarshalAs(UnmanagedType.LPStr)] StringBuilder pBmpFile)
{
int i;
i = YkPrintBitmap(pBmpFile, 33);
return i;
}
public static int FeedPaper()
{
int i;
i = YkFeedPaper();
return i;
}
public static int GetStatus(byte n)
{
int i;
i = YkGetStatus(n);
return i;
}
public static int GetPrinterStatus(byte n)
{
int i;
i = YkGetPrinterStatus(n);
return i;
}
public static int PrintBarCode([MarshalAs(UnmanagedType.LPStr)] StringBuilder barcode)
{
int i;
int n = barcode.Length;
i = YkPrintBarCode(72, n, barcode);
return i;
}
public static int CutPaper()
{
int i;
i = YkCutPaper(66, 0);
return i;
}
public static int SetAlign(int n)
{
int i;
i = YkSetAlign(n);
return i;
}
public static int SetEmphasized(int n)
{
int i;
i = YkSetEmphasized(n);
return i;
}
public static int SetLeftMargin(int nL, int nH)
{
int i;
i = YkSetLeftMargin(nL, nH);
return i;
}
public static int SetCharSize(int hsize, int vsize)
{
int i;
i = YkSetCharSize(hsize, vsize);
return i;
}
}
}