| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #pragma once
- #include "../pch/pch.h"
- #include "../order/CWaimaiOrder.h"
- //SetupDiGetInterfaceDeviceDetail所需要的输出长度,定义足够大
- #define INTERFACE_DETAIL_SIZE 1024
- //设备数量上限,假设16台上限
- #define MAX_DEVICE 16
- //USB类的GUID
- //const GUID USB_GUID = {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed}};
- const GUID USB_GUID = {0x28d78fad, 0x5a12, 0x11d1, {0xae, 0x5b, 0x00, 0x00, 0xf8, 0x03, 0xa8, 0xc2 }};
- //存储打印端口句柄的结构
- class PrinterHandle
- {
- public:
- HANDLE hPort;
- int type; //句柄类型 1:usb 2:并口 3:串口
- };
- class CPosPrinter
- {
- public:
- CPosPrinter();
- ~CPosPrinter();
- void PrintWaimaiOrderShouyin(CWaimaiOrder& order);
- void PrintWaimaiOrderChufang(CWaimaiOrder& order);
- private:
- bool InitShouyin();
- int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
- int WriteData(string meg);
- int WriteBuf(const char* buf, int len);
- bool PortTest(HANDLE hPort);
- int POS_Reset(void);
- int POS_FeedLine(void);
- int POS_Feed(void);
- int POS_SetMotionUnit(int x, int y);
- //设置横向跳格位置
- int POS_SET_MOVE_X();
- int POS_MOVE_X();
- int POS_SET_ABS_X(int x, int y);
- int POS_SET_PRINT_AREA(int x, int y);
- int POS_TextOut(string abc, bool is_double_width = false, bool is_double_height = false, int align_type = 0);
- int POS_CutPaper();
- int POS_OutQRCode();
- //字符空格计算的辅助函数
- void CalWord(string s, int& nHanzi, int& nZimu);
- //对名字进行换行处理
- std::vector<std::string> HandleFoodname(std::string oldname, int guige = 1);
- std::string HandleFoodItemPrice(std::string oldprice, int guige = 1);
- std::string HandleFoodQuantity(std::string oldquantity, int guige = 1);
- std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
- private:
- std::vector<PrinterHandle> m_hPorts;
- boost::asio::io_service m_io;
- boost::asio::ip::tcp::socket m_socket;
- //这个是当前的输出模式,是收银模式还是厨房打印模式
- int m_type;
- };
|