Debian Codegraph @

src/lm/LabelManagerLanguageMonitor.h

raw
1 // -*- C++ -*-
2 // $Id$
3
4 // DYMO LabelWriter Drivers
5 // Copyright (C) 2008 Sanford L.P.
6
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 #ifndef __LabelManagerLanguageMonitorH__
22 #define __LabelManagerLanguageMonitorH__
23
24 #include "PrinterDriver.h"
25 #include "LabelManagerDriver.h"
26
27 namespace DymoPrinterDriver
28 {
29 /**
30 LanguageMonitor for LabelManager printers
31 Supported features are:
32 */
33 class CLabelManagerLanguageMonitor: public ILanguageMonitor
34 {
35 public:
36 enum status_bits
37 {
38 CASSETTE_SIZET0_BIT = 0x01,
39 CASSETTE_SIZET1_BIT = 0x02,
40 CASSETTE_SIZE_BITS = (CASSETTE_SIZET0_BIT | CASSETTE_SIZET1_BIT),
41 GENERAL_ERROR_BIT = 0x04,
42 HEAD_OVERHEAT_BIT = 0x08,
43 SLOT_STATUS_BIT = 0x10,
44 BUSY_BIT = 0x20,
45 CASSETTE_PRESENT_BIT= 0x40,
46 AUTO_CUTTER_BIT = 0x80,
47 NO_POWER_BIT = 0x80,
48 INCORRECT_SIZE_BIT = 0xFF
49 };
50
51 CLabelManagerLanguageMonitor(IPrintEnvironment& Environment, bool UseSleep = true, size_t ReadStatusTimeout = 10);
52 virtual ~CLabelManagerLanguageMonitor();
53
54 virtual void StartDoc();
55 virtual void EndDoc();
56
57 virtual void StartPage();
58 virtual void EndPage();
59
60 virtual void ProcessData(const buffer_t& Data);
61
62 void SetDeviceName(const std::string& Value);
63 void SetTapeWidth(CLabelManagerDriver::tape_width_t Value);
64
65 protected:
66 private:
67 // check if printer is locally connected, i.e. to usb port
68 bool IsLocal();
69
70 // checks status
71 void CheckStatus();
72
73 // Read status byte from the printer
74 // return true if status has been read, false otherwise
75 bool ReadStatus(buffer_t& Status);
76
77 // update job status based on status read from the printer
78 void SetJobStatus(byte Status);
79 bool CheckTapeSize(buffer_t Status);
80
81 IPrintEnvironment& Environment_;
82 bool IsFirstPage_;
83 buffer_t PageData_;
84
85 std::string DeviceName_;
86 CLabelManagerDriver::tape_width_t TapeWidth_;
87
88 bool UseSleep_; // for test purpose only
89 bool LastReadStatusResult_;
90
91 size_t ReadStatusTimeout_;
92 };
93
94
95 }; //namespace
96
97 #endif
98
99 /*
100 * End of "$Id$".
101 */