62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
#ifndef POS_PRINTER_H
|
|
#define POS_PRINTER_H
|
|
|
|
#include <core/sale.h>
|
|
#include <core/seller.h>
|
|
|
|
#include <memory>
|
|
|
|
#include <libusb-1.0/libusb.h>
|
|
|
|
#ifdef DELETE
|
|
#undef DELETE
|
|
#endif
|
|
|
|
struct SupportedPrinters {
|
|
std::array<std::tuple<int, int, int>, 2> models{
|
|
// {Vendor ID, Model ID, Endpoint}
|
|
std::make_tuple(0x0456, 0x0808, 0x03),
|
|
std::make_tuple(0x0416, 0x5011, 0x03),
|
|
};
|
|
};
|
|
|
|
struct PrinterDevice {
|
|
int idVendor{};
|
|
int idProduct{};
|
|
int endpoint{};
|
|
};
|
|
|
|
class PosPrinter
|
|
{
|
|
public:
|
|
PosPrinter();
|
|
PosPrinter(const PrinterDevice& printerDevice);
|
|
~PosPrinter();
|
|
void write(const std::string& text);
|
|
void printHeader(const std::string& commune = "Musterhausen");
|
|
void printTest();
|
|
void printSaleReceipt(Sale* sale, const std::string& commune = "Dettingen");
|
|
void printSellerReceipt(Seller* seller, const int percent, const int maxFeeInCent,
|
|
const std::string& commune = "Dettingen");
|
|
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_{};
|
|
int printerEndpoint_{0x03};
|
|
};
|
|
|
|
#endif
|