| 1 |
// -*- C++ -*- |
| 2 |
// $Id: LabelWriterLanguageMonitor.h 15006 2011-04-28 15:25:02Z aleksandr $ |
| 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 h6d0799cd_6eab_4e0d_9c2b_acb6fbb54d11 |
| 22 |
#define h6d0799cd_6eab_4e0d_9c2b_acb6fbb54d11 |
| 23 |
|
| 24 |
#include "PrinterDriver.h" |
| 25 |
#include "LabelWriterDriver.h" |
| 26 |
|
| 27 |
namespace DymoPrinterDriver |
| 28 |
{ |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
LanguageMonitor for LabelWriter printers |
| 33 |
Supported features are: reprinting last page on end of roll |
| 34 |
*/ |
| 35 |
class CLabelWriterLanguageMonitor: public ILanguageMonitor |
| 36 |
{ |
| 37 |
public: |
| 38 |
enum status_bits |
| 39 |
{ |
| 40 |
TOF_BIT = 0x02, |
| 41 |
ROLL_CHANGED_BIT = 0x08, |
| 42 |
PAPER_OUT_BIT = 0x20, |
| 43 |
PAPER_FEED_BIT = 0x40, |
| 44 |
ERROR_BIT = 0x80, |
| 45 |
}; |
| 46 |
|
| 47 |
CLabelWriterLanguageMonitor(IPrintEnvironment& Environment, bool UseSleep = true, size_t ReadStatusTimeout = 10); |
| 48 |
virtual ~CLabelWriterLanguageMonitor(); |
| 49 |
|
| 50 |
virtual void StartDoc(); |
| 51 |
virtual void EndDoc(); |
| 52 |
|
| 53 |
virtual void StartPage(); |
| 54 |
virtual void EndPage(); |
| 55 |
|
| 56 |
virtual void ProcessData(const buffer_t& Data); |
| 57 |
|
| 58 |
// some values used by driver is also interesting for the language monitor |
| 59 |
void SetPaperType(CLabelWriterDriver::paper_type_t Value); |
| 60 |
void SetRoll(CLabelWriterDriverTwinTurbo::roll_t Value); |
| 61 |
|
| 62 |
|
| 63 |
protected: |
| 64 |
private: |
| 65 |
// check if printer is locally connected, i.e. to usb port |
| 66 |
bool IsLocal(); |
| 67 |
|
| 68 |
// send reset command to reset from probably nonproper finished previous job |
| 69 |
void ResetPrinter(); |
| 70 |
|
| 71 |
// send ESC q as first command to synchronize roll used by drivers and the device |
| 72 |
// it is needed to properly read status byte from the active roll |
| 73 |
void SynchronizeRoll(); |
| 74 |
|
| 75 |
// checks status and reprint label if needed |
| 76 |
void CheckStatusAndReprint(); |
| 77 |
|
| 78 |
// Read status byte from the printer |
| 79 |
// return true if status has been read, false otherwise |
| 80 |
bool ReadStatus(byte& Status); |
| 81 |
|
| 82 |
// request status while the status become OK |
| 83 |
// return true on success, false - otherwise |
| 84 |
bool PollUntilPaperIn(); |
| 85 |
|
| 86 |
// update job status based on status read from the printer |
| 87 |
void SetJobStatus(byte Status); |
| 88 |
|
| 89 |
// reprint cached label |
| 90 |
void ReprintLabel(); |
| 91 |
|
| 92 |
IPrintEnvironment& Environment_; |
| 93 |
|
| 94 |
CLabelWriterDriver::paper_type_t PaperType_; |
| 95 |
CLabelWriterDriverTwinTurbo::roll_t Roll_; |
| 96 |
bool RollUsed_; |
| 97 |
bool IsFirstPage_; |
| 98 |
|
| 99 |
buffer_t PageData_; |
| 100 |
|
| 101 |
bool UseSleep_; // for test purpose only |
| 102 |
byte LastStatus_; |
| 103 |
bool LastReadStatusResult_; |
| 104 |
|
| 105 |
size_t ReadStatusTimeout_; |
| 106 |
}; |
| 107 |
|
| 108 |
|
| 109 |
}; //namespace |
| 110 |
|
| 111 |
#endif |
| 112 |
|
| 113 |
/* |
| 114 |
* End of "$Id: LabelWriterLanguageMonitor.h 15006 2011-04-28 15:25:02Z aleksandr $". |
| 115 |
*/ |