kima2/src/printer/posprinter.h

55 lines
1.3 KiB
C++

#ifndef POS_PRINTER_H
#define POS_PRINTER_H
#include <sale.h>
#include <seller.h>
#include <memory>
#include <libusb-1.0/libusb.h>
struct SupportedPrinters {
std::array<std::pair<int, int>, 2> models{
// {Vendor ID, Model ID}
std::make_pair(0x0456, 0x0808),
std::make_pair(0x0416, 0x5011),
};
};
struct PrinterDevice {
int idVendor{};
int idProduct{};
};
class PosPrinter
{
public:
PosPrinter();
PosPrinter(const PrinterDevice& printerDevice);
~PosPrinter();
void write(const std::string& text);
void printHeader();
void printTest();
void printSaleReceipt(Sale* sale);
void printSellerReceipt(Seller* seller, int percent, int maxFeeInCent);
bool isValid();
struct Command {
static const std::string RESET;
static const std::string ENCODING;
static const std::string CENTERING;
static const std::string LEFT_ALIGN;
static const std::string RIGHT_ALIGN;
static const std::string FONT_SIZE_BIG;
static const std::string FONT_SIZE_NORMAL;
static const std::string FEED;
};
private:
libusb_context* contextPtr_{};
libusb_device_handle* devicePtr_{};
SupportedPrinters supportedPrinters_;
PrinterDevice printerDevice_{};
};
#endif