iPrinter.h
1 #pragma once
2 
3 #include <boost/system/error_code.hpp>
4 #include <boost/asio.hpp>
5 #include <boost/chrono.hpp>
6 #include <math.h>
7 #include <bits/basic_ios.h>
8 
9 #include "iJob.h"
10 
11 namespace dpyPrinter {
14 {
15  GENERIC = 0, APSECP2324 = 1, APSECP3324 = 2
16 };
17 
20 {
22  PRINTING = 1,
24  UPDATING = 4
25 };
26 
29 {
31  CUTS_LIMIT = 1,
35  COVER_OPEN = 5,
36  PAPER_JAM = 6,
38 };
39 
42 {
44  LOW_PAPER = 2,
46  HIGH_PAPER = 4,
47  FULL_PAPER = 5,
49 };
50 
53 {
54  std::string model;
55  std::string serialnumber;
57  std::list<PrinterEvent> events;
59 };
60 
63 {
64  std::int32_t dotsPerLine;
65  std::int32_t maxPaperWidht;
66  std::int32_t maxUpperMargin;
67  std::int32_t maxBottomMargin;
68  std::int32_t cutterMargin;
69  std::int32_t minimalImageWidth;
70  std::int32_t minimalImageLength;
71  std::int32_t maxCutsNumber;
72  std::int32_t maxPaperKm;
74 };
75 
76 struct NVImage
77 {
78  int slotId = -1;
79  std::string path = "";
80  size_t width = 0;
81  size_t height = 0;
82  std::string md5 = "";
83  std::string md5Base64 = "";
84 };
85 
86 }
87 
93 {
94 public:
100  virtual void PrinterStatusChange(std::string printerid, const dpyPrinter::PrinterStatus& status) = 0;
101 
108  virtual void PrinterNewEvent(std::string printerid, const dpyPrinter::PrinterEvent& event, bool active) = 0;
109 
116  virtual void PaperNewEvent(boost::system::error_code ec, const std::string &printerid, const dpyPrinter::PaperLevel& event) = 0;
121  {
122  }
123 };
124 
130 class IPrinter
131 {
132 protected:
133  std::string m_printerid;
134  std::vector<PrinterObserver*> mObserversList;
135 
136 public:
137  virtual ~IPrinter();
138 
143  const std::string& getPrinterid() const
144  {
145  return m_printerid;
146  }
147 
148  virtual boost::system::error_code printImage(const std::string& uri, std::list<PrintConfig> configs, boost::shared_ptr<IJob>& job) = 0;
149  virtual boost::system::error_code printHtml(const std::string& uri, std::list<PrintConfig> configs, boost::shared_ptr<IJob>& job) = 0;
150  virtual boost::system::error_code getJobList(std::list<boost::shared_ptr<IJob>>& jobList) = 0;
151  virtual boost::system::error_code getDefaultconfiguration(std::list<PrintConfig>& configs) = 0;
152  virtual boost::system::error_code setDefaultconfiguration(const PrintConfig& printConfig) = 0;
153  virtual boost::system::error_code printTestTicket() = 0;
154  virtual boost::system::error_code deleteJob(boost::shared_ptr<IJob> job) = 0;
155  virtual boost::system::error_code getPrinterInformation(dpyPrinter::PrinterInfo& printConfig) = 0;
156 
157  boost::system::error_code subscribe(PrinterObserver* observer);
158  boost::system::error_code unsubscribe(PrinterObserver* observer);
159 };
Paper jam error.
Definition: iPrinter.h:36
std::string model
Printer model.
Definition: iPrinter.h:54
Autocutter error.
Definition: iPrinter.h:37
std::int32_t cutterMargin
cutter margin
Definition: iPrinter.h:68
Abstract class which implements all the minimum necessary logic which all printer must have...
Definition: iPrinter.h:130
Printer Info.
Definition: iPrinter.h:52
Represents a configuration for printing.
Definition: printConfig.h:62
std::int32_t maxCutsNumber
max cuts number
Definition: iPrinter.h:71
std::string serialnumber
Printer serial number.
Definition: iPrinter.h:55
const std::string & getPrinterid() const
Definition: iPrinter.h:143
Printer OK.
Definition: iPrinter.h:21
PrinterStatus printerStatus
Printer status.
Definition: iPrinter.h:56
Head temperature error.
Definition: iPrinter.h:33
Printer in use.
Definition: iPrinter.h:22
virtual ~PrinterObserver()
Destructor.
Definition: iPrinter.h:120
High paper level.
Definition: iPrinter.h:46
Deepsy Printer namespace that includes the different enums, structs or method signatures that should ...
Definition: printerApi.h:13
std::int32_t minimalImageWidth
minimal image width
Definition: iPrinter.h:69
End of paper error.
Definition: iPrinter.h:32
Printer firmware updating.
Definition: iPrinter.h:24
PaperLevel
Paper level.
Definition: iPrinter.h:41
std::list< PrinterEvent > events
List of printer events.
Definition: iPrinter.h:57
Printer Limits.
Definition: iPrinter.h:62
std::int32_t minimalImageLength
minimal image length
Definition: iPrinter.h:70
Printer error.
Definition: iPrinter.h:23
PrinterStatus
Possible Printer Status.
Definition: iPrinter.h:19
Paper error.
Definition: iPrinter.h:48
PaperLevel paperLevel
Paper level.
Definition: iPrinter.h:58
Low paper level.
Definition: iPrinter.h:44
PrinterEvent
Printer events.
Definition: iPrinter.h:28
std::int32_t maxPaperKm
max km of printed paper
Definition: iPrinter.h:72
Medium paper level.
Definition: iPrinter.h:45
Cuts limit reached.
Definition: iPrinter.h:31
Printer Observer class.
Definition: iPrinter.h:92
Paper limit reached.
Definition: iPrinter.h:30
std::int32_t maxPaperWidht
max paper width
Definition: iPrinter.h:65
Power supply error.
Definition: iPrinter.h:34
std::int32_t maxUpperMargin
max upper margin
Definition: iPrinter.h:66
std::int32_t resolutionDotsPerMillimeter
resolution
Definition: iPrinter.h:73
std::int32_t dotsPerLine
dots per line
Definition: iPrinter.h:64
Cover open error.
Definition: iPrinter.h:35
Definition: iPrinter.h:76
std::int32_t maxBottomMargin
max bottom margin
Definition: iPrinter.h:67
High paper level.
Definition: iPrinter.h:47
Critical paper level.
Definition: iPrinter.h:43
PrinterType
Printer types.
Definition: iPrinter.h:13