kima2/src/printer/posprinter.h

48 lines
1.1 KiB
C
Raw Normal View History

2018-08-05 21:51:30 +02:00
#ifndef POS_PRINTER_H
#define POS_PRINTER_H
2018-08-06 16:14:45 +02:00
#include <sale.h>
2018-08-06 16:38:55 +02:00
#include <seller.h>
2018-08-06 16:14:45 +02:00
2018-08-05 21:51:30 +02:00
#include <memory>
#include <libusb-1.0/libusb.h>
2018-08-06 09:59:06 +02:00
struct SupportedPrinters {
std::array<std::pair<int, int>, 2> models{
// {Vendor ID, Model ID}
std::make_pair(0x0456, 0x0808),
std::make_pair(0x0416, 0x5011),
};
};
2018-08-05 21:51:30 +02:00
class PosPrinter
{
public:
PosPrinter();
~PosPrinter();
2018-08-06 12:52:45 +02:00
void write(const std::string& text);
void printHeader();
void printTest();
2018-08-06 16:38:55 +02:00
void printSaleReceipt(Sale* sale);
2018-08-06 21:24:10 +02:00
void printSellerReceipt(Seller* seller, int percent, int maxFeeInCent);
2018-08-06 20:57:12 +02:00
bool isValid();
2018-08-06 12:52:45 +02:00
struct Command {
static const std::string RESET;
static const std::string ENCODING;
static const std::string CENTERING;
2018-08-06 16:14:45 +02:00
static const std::string LEFT_ALIGN;
static const std::string RIGHT_ALIGN;
2018-08-06 12:52:45 +02:00
static const std::string FONT_SIZE_BIG;
static const std::string FONT_SIZE_NORMAL;
static const std::string FEED;
};
2018-08-06 09:59:06 +02:00
private:
2018-08-05 21:51:30 +02:00
libusb_context* contextPtr_{};
libusb_device_handle* devicePtr_{};
2018-08-06 09:59:06 +02:00
SupportedPrinters supportedPrinters_;
2018-08-05 21:51:30 +02:00
};
#endif