CPosPrinter.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "../pch/pch.h"
  3. #include "../order/CWaimaiOrder.h"
  4. //SetupDiGetInterfaceDeviceDetail所需要的输出长度,定义足够大
  5. #define INTERFACE_DETAIL_SIZE 1024
  6. //设备数量上限,假设16台上限
  7. #define MAX_DEVICE 16
  8. //USB类的GUID
  9. //const GUID USB_GUID = {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed}};
  10. const GUID USB_GUID = {0x28d78fad, 0x5a12, 0x11d1, {0xae, 0x5b, 0x00, 0x00, 0xf8, 0x03, 0xa8, 0xc2 }};
  11. //存储打印端口句柄的结构
  12. class PrinterHandle
  13. {
  14. public:
  15. HANDLE hPort;
  16. int type; //句柄类型 1:usb 2:并口 3:串口
  17. };
  18. class CPosPrinter
  19. {
  20. public:
  21. CPosPrinter();
  22. ~CPosPrinter();
  23. void PrintWaimaiOrderShouyin(CWaimaiOrder& order);
  24. void PrintWaimaiOrderChufang(CWaimaiOrder& order);
  25. private:
  26. bool InitShouyin();
  27. int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
  28. int WriteData(string meg);
  29. int WriteBuf(const char* buf, int len);
  30. bool PortTest(HANDLE hPort);
  31. int POS_Reset(void);
  32. int POS_FeedLine(void);
  33. int POS_Feed(void);
  34. int POS_SetMotionUnit(int x, int y);
  35. //设置横向跳格位置
  36. int POS_SET_MOVE_X();
  37. int POS_MOVE_X();
  38. int POS_SET_ABS_X(int x, int y);
  39. int POS_SET_PRINT_AREA(int x, int y);
  40. int POS_TextOut(string abc, bool is_double_width = false, bool is_double_height = false, int align_type = 0);
  41. int POS_CutPaper();
  42. int POS_OutQRCode();
  43. //字符空格计算的辅助函数
  44. void CalWord(string s, int& nHanzi, int& nZimu);
  45. //对名字进行换行处理
  46. std::vector<std::string> HandleFoodname(std::string oldname, int guige = 1);
  47. std::string HandleFoodItemPrice(std::string oldprice, int guige = 1);
  48. std::string HandleFoodQuantity(std::string oldquantity, int guige = 1);
  49. std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
  50. private:
  51. std::vector<PrinterHandle> m_hPorts;
  52. boost::asio::io_service m_io;
  53. boost::asio::ip::tcp::socket m_socket;
  54. //这个是当前的输出模式,是收银模式还是厨房打印模式
  55. int m_type;
  56. };