CPosPrinter.h 1.4 KB

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