ReceiptSnbc.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // ReceiptSnbc.cpp: implementation of the ReceiptSnbc class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "ReceiptSnbc.h"
  5. //////////////////////////////////////////////////////////////////////
  6. // Construction/Destruction
  7. //////////////////////////////////////////////////////////////////////
  8. ReceiptSnbc::ReceiptSnbc()
  9. {
  10. }
  11. ReceiptSnbc::~ReceiptSnbc()
  12. {
  13. }
  14. //打印机初始化
  15. int ReceiptSnbc::Init()
  16. {
  17. int iRet = ReceiptBase::Init();
  18. if (iRet != 0) return iRet;
  19. unsigned char szSendBuf[20];
  20. szSendBuf[0] = 0x1d;
  21. szSendBuf[1] = 0x45;
  22. szSendBuf[2] = 0x20;//打印低速20,中速10,高速 00
  23. SendData(szSendBuf,3,3000);
  24. szSendBuf[0] = 0x1d;
  25. szSendBuf[1] = 0x28;
  26. szSendBuf[2] = 0x4b;//
  27. szSendBuf[3] = 0x02;//
  28. szSendBuf[4] = 0x00;//
  29. szSendBuf[5] = 0x31;//
  30. szSendBuf[6] = 6; //清晰度,-6->6 数字越高越清晰
  31. //新北洋位-6 至 6,证通为 0 至 14
  32. SendData(szSendBuf,7,3000);
  33. SetPrintArea(640);
  34. return RECEIPT_SUCCESS;
  35. }
  36. int ReceiptSnbc::GetStateData(const char* sCmd1, const char* sCmd2, const char* sCmd3, const char* sCmd4)
  37. {
  38. if(sCmd2[1] == '1' || sCmd3[4]=='1') //打印机故障
  39. return RECEIPT_ERR_DEV_ERR;
  40. if(sCmd2[5] == '1') //打印机头抬起
  41. return RECEIPT_WARN_HEAD_UP;
  42. if(sCmd4[7] == '1') //卡纸
  43. return RECEIPT_WARN_JAMMED;
  44. if(sCmd4[2] == '1') //缺纸
  45. return RECEIPT_WARN_NO_MEDIA;
  46. if(sCmd4[4] == '1') //纸将尽
  47. return RECEIPT_WARN_PAP_LOW;
  48. return RECEIPT_SUCCESS;
  49. }