Терминальный проект КиберПлат [open source]
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
9.3KB

  1. /* @file Константы купюроприемника на протоколе SSP. */
  2. #pragma once
  3. // Modules
  4. #include "Hardware/Common/DeviceCodeSpecification.h"
  5. #include "Hardware/Common/WaitingData.h"
  6. #include "Hardware/Protocols/CashAcceptor/SSPDataTypes.h"
  7. // Project
  8. #include "Hardware/CashAcceptors/CashAcceptorStatusCodes.h"
  9. //--------------------------------------------------------------------------------
  10. namespace CSSP
  11. {
  12. /// Адреса устройств
  13. namespace Addresses
  14. {
  15. const char Validator = 0x00; /// Купюроприемник, диспенсер (пристегивается к купюрнику).
  16. const char Hopper = 0x10; /// Хоппер.
  17. const char Printer1 = 0x40; /// Принтер Smart Ticket (печать по шаблонам или "на лету" (?).
  18. const char Printer2 = 0x41; /// Принтер Coupon Printer (печатает на фальцованной бумаге) и Flatbed Printer (обычный термопринтер).
  19. }
  20. namespace Result
  21. {
  22. struct SData
  23. {
  24. int code;
  25. QString description;
  26. SData() : code(CommandResult::OK) {}
  27. SData(int aCode, const QString & aDescription) : code(aCode), description(aDescription) {}
  28. };
  29. class CData: public CSpecification<char, SData>
  30. {
  31. public:
  32. CData()
  33. {
  34. append('\xF0', SData(CommandResult::OK, "OK"));
  35. append('\xF2', SData(CommandResult::Driver, "Unknown command"));
  36. append('\xF3', SData(CommandResult::Driver, "Wrong parameter quantity"));
  37. append('\xF4', SData(CommandResult::Driver, "Wrong parameter(s)"));
  38. append('\xF5', SData(CommandResult::Device, "Runtime error"));
  39. append('\xF6', SData(CommandResult::Device, "Firmware error"));
  40. append('\xF8', SData(CommandResult::Device, "Command fail"));
  41. append('\xFA', SData(CommandResult::Device, "Key not set"));
  42. setDefault(SData(CommandResult::Driver, "Unknown error"));
  43. }
  44. };
  45. static CData Data;
  46. }
  47. /// Размер блока данных 1 номинала в ответе на запрос номиналов.
  48. const int NominalSize = 4;
  49. /// Стартовый номер протокола при поиске актуальной поддерживаемой версии протокола.
  50. const int StartingProtocolNumber = 4;
  51. /// Таймаут после Reset-а, [мс].
  52. const double NominalMultiplier = 0.01;
  53. /// Ожидание отвала после резета, [мс].
  54. const SWaitingData NotReadyWaiting = SWaitingData(150, 1000);
  55. /// Ожидание готовности, [мс].
  56. const SWaitingData ReadyWaiting = SWaitingData(150, 15 * 1000);
  57. /// Виртуальный статус Enabled.
  58. const char EnabledStatus[] = "Enabled status";
  59. //--------------------------------------------------------------------------------
  60. /// Команды.
  61. namespace Commands
  62. {
  63. const char GetBillTable = '\x00'; /// Запрос таблицы номиналов.
  64. const char Reset = '\x01'; /// Перезагрузка.
  65. const char SetInhibit = '\x02'; /// Установить запрещения номиналов.
  66. const char GetSetupData = '\x05'; /// Получить данные устройства.
  67. const char SetProtocolVersion = '\x06'; /// Попробовать установить версию протокола.
  68. const char Poll = '\x07'; /// Запрос статуса.
  69. const char Return = '\x08'; /// Выбросить купюру.
  70. const char Disable = '\x09'; /// Выключить на прием денег.
  71. const char Enable = '\x0A'; /// Включить на прием денег.
  72. const char GetSerial = '\x0C'; /// Запрос серийного номера.
  73. const char Sync = '\x11'; /// Синхронизация байта последовательности.
  74. const char GetFirmware = '\x20'; /// Запрос версии прошивки.
  75. const char GetDataset = '\x21'; /// Запрос версии биллсета.
  76. const char Stack = '\x43'; /// Уложить в стекер.
  77. const char GetBuild = '\x4F'; /// Запрос версии билда.
  78. class CData: public CSpecification<char, SData>
  79. {
  80. public:
  81. CData()
  82. {
  83. add(GetSetupData, 1000);
  84. add(Sync, true);
  85. }
  86. private:
  87. void add(char aCommand, int aTimeout) { append(aCommand, SData(aTimeout, false)); }
  88. void add(char aCommand, bool aSetSync) { append(aCommand, SData(DefaultTimeout, aSetSync)); }
  89. };
  90. static CData Data;
  91. }
  92. //--------------------------------------------------------------------------------
  93. /// Спецификация статусов.
  94. class DeviceCodeSpecification : public CommonDeviceCodeSpecification
  95. {
  96. public:
  97. DeviceCodeSpecification()
  98. {
  99. /// Состояния.
  100. addStatus('\xE0', BillAcceptorStatusCode::BillOperation::Unknown, "Note path open");
  101. addStatus('\xE4', DeviceStatusCode::OK::Initialization, "Stacker replaced");
  102. addStatus('\xE1', DeviceStatusCode::OK::Initialization, "Note cleared from front (power up with note in validator)");
  103. addStatus('\xE2', DeviceStatusCode::OK::Initialization, "Note cleared into stacker (power up with note about in stacker)");
  104. addStatus('\xB6', DeviceStatusCode::OK::Initialization);
  105. addStatus('\xF1', DeviceStatusCode::OK::Initialization, "Reseting after power up");
  106. addStatus('\xE8', BillAcceptorStatusCode::Normal::Disabled);
  107. addStatus('\xB5', BillAcceptorStatusCode::Normal::Disabled, "all note channels have been inhibited");
  108. addStatus('\xEF', BillAcceptorStatusCode::BillOperation::Accepting, "reading note");
  109. addStatus('\xEE', BillAcceptorStatusCode::BillOperation::Escrow);
  110. addStatus('\xCC', BillAcceptorStatusCode::BillOperation::Stacking);
  111. addStatus('\xEB', BillAcceptorStatusCode::BillOperation::Stacked);
  112. addStatus('\xED', BillAcceptorStatusCode::Busy::Returning);
  113. addStatus('\xEC', BillAcceptorStatusCode::Busy::Returned);
  114. /// Ошибки.
  115. addStatus('\xE6', BillAcceptorStatusCode::Warning::Cheated);
  116. addStatus('\xEA', BillAcceptorStatusCode::MechanicFailure::JammedInStacker, "safely jammed");
  117. addStatus('\xE9', BillAcceptorStatusCode::MechanicFailure::JammedInValidator, "unsafely jammed");
  118. addStatus('\xE7', BillAcceptorStatusCode::MechanicFailure::StackerFull);
  119. addStatus('\xE3', BillAcceptorStatusCode::MechanicFailure::StackerOpen);
  120. addStatus('\xE3', DeviceStatusCode::OK::OK, "after stacker open");
  121. /// Режекты.
  122. addStatus('\x01', BillAcceptorStatusCode::Reject::Length);
  123. addStatus('\x02', BillAcceptorStatusCode::Reject::Verification);
  124. addStatus('\x03', BillAcceptorStatusCode::Reject::Verification);
  125. addStatus('\x04', BillAcceptorStatusCode::Reject::Verification);
  126. addStatus('\x05', BillAcceptorStatusCode::Reject::Verification);
  127. addStatus('\x06', BillAcceptorStatusCode::Reject::InhibitNote);
  128. addStatus('\x07', BillAcceptorStatusCode::Reject::LengthDoubling);
  129. addStatus('\x08', BillAcceptorStatusCode::Busy::Returned);
  130. addStatus('\x09', BillAcceptorStatusCode::Reject::Verification);
  131. addStatus('\x0A', BillAcceptorStatusCode::Reject::Verification, "Invalid note read");
  132. addStatus('\x0B', BillAcceptorStatusCode::Reject::Length, "Note too long");
  133. addStatus('\x0C', BillAcceptorStatusCode::Reject::UserDefined, "Validator disabled");
  134. addStatus('\x0D', BillAcceptorStatusCode::Reject::Cheated, "Mechanism slow/stalled");
  135. addStatus('\x0E', BillAcceptorStatusCode::Reject::Cheated, "Strimming attempt");
  136. addStatus('\x0F', BillAcceptorStatusCode::Reject::InhibitNote, "Fraud channel reject");
  137. addStatus('\x10', BillAcceptorStatusCode::Reject::Insertion, "No notes inserted");
  138. addStatus('\x11', BillAcceptorStatusCode::Reject::Verification, "Peak detect fail");
  139. addStatus('\x12', BillAcceptorStatusCode::Reject::WidthDoubling);
  140. addStatus('\x13', BillAcceptorStatusCode::Reject::EscrowTimeout);
  141. addStatus('\x14', BillAcceptorStatusCode::Reject::Barcode);
  142. addStatus('\x15', BillAcceptorStatusCode::Reject::Verification, "Invalid note read");
  143. addStatus('\x16', BillAcceptorStatusCode::Reject::Verification, "Invalid note read");
  144. addStatus('\x17', BillAcceptorStatusCode::Reject::Verification, "Invalid note read");
  145. addStatus('\x18', BillAcceptorStatusCode::Reject::Verification, "Invalid note read");
  146. addStatus('\x19', BillAcceptorStatusCode::Reject::Width);
  147. addStatus('\x1A', BillAcceptorStatusCode::Reject::Length, "Note too short");
  148. }
  149. /// Получить спецификации девайс-кодов по байт-массиву. байт-массив не должен содержать лишних байтов перед статусными байтами.
  150. virtual void getSpecification(const QByteArray & aBuffer, TDeviceCodeSpecifications & aSpecifications)
  151. {
  152. if (aBuffer == EnabledStatus)
  153. {
  154. aSpecifications.insert(aBuffer.toHex().data(), SDeviceCodeSpecification(BillAcceptorStatusCode::Normal::Enabled, ""));
  155. }
  156. else
  157. {
  158. CommonDeviceCodeSpecification::getSpecification(aBuffer, aSpecifications);
  159. }
  160. }
  161. };
  162. }
  163. //--------------------------------------------------------------------------------