CPosPrinter.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. class CPosPrinter
  11. {
  12. public:
  13. //print_type为1表示收银打印,为2表示厨房打印
  14. CPosPrinter(int print_type = 1);
  15. ~CPosPrinter();
  16. bool Init();
  17. bool InitChufang();
  18. //type为1表示58mmm,为2表示80mmm
  19. void PrintWaimaiOrder(std::string order_id, std::string order_no);
  20. void PrintWaimaiOrder(CWaimaiOrder& order);
  21. private:
  22. int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
  23. int WriteData(string meg);
  24. int WriteBuf(char *buf, int len);
  25. int POS_Reset(void);
  26. int POS_FeedLine(void);
  27. int POS_Feed(void);
  28. int POS_SetMotionUnit(int x, int y);
  29. //设置横向跳格位置
  30. int POS_SET_MOVE_X();
  31. int POS_MOVE_X();
  32. int POS_SET_ABS_X(int x, int y);
  33. int POS_SET_PRINT_AREA(int x, int y);
  34. int POS_TextOut(string abc, bool is_double = false, int align_type = 0);
  35. int POS_CutPaper();
  36. int POS_OutQRCode();
  37. //字符空格计算的辅助函数
  38. void CalWord(string s, int& nHanzi, int& nZimu);
  39. //对名字进行换行处理
  40. std::vector<std::string> HandleFoodname(std::string oldname, int guige = 1);
  41. std::string HandleFoodItemPrice(std::string oldprice, int guige = 1);
  42. std::string HandleFoodQuantity(std::string oldquantity, int guige = 1);
  43. std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
  44. private:
  45. int m_type;
  46. HANDLE m_hPort = NULL;
  47. boost::asio::io_service m_io;
  48. boost::asio::ip::tcp::socket m_socket;
  49. };