CPosPrinter.h 1.5 KB

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