CPosPrinter.h 1.4 KB

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