Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TSCANNER_EPSON_INCLUDED
Toshihiro Shimizu 890ddd
#define TSCANNER_EPSON_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tscanner.h"
Toshihiro Shimizu 890ddd
#include "TScannerIO/TScannerIO.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 6526c7
#include <memory></memory>
Shinya Kitaoka 6526c7
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
PLEASE DO NOT REMOVE unreferenced methods... they are useful for debugging  :)
Toshihiro Shimizu 890ddd
max
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class TScannerEpson final : public TScanner {
Shinya Kitaoka 120a6e
  enum SettingsMode { OLD_STYLE, NEW_STYLE };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TScannerIO *m_scannerIO;
Shinya Kitaoka 120a6e
  bool m_hasADF;
Shinya Kitaoka 120a6e
  bool m_isOpened;
Shinya Kitaoka 120a6e
  SettingsMode m_settingsMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TScannerEpson();
Shinya Kitaoka 120a6e
  ~TScannerEpson();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void selectDevice() override;
Shinya Kitaoka 473e70
  bool isDeviceAvailable() override;
Shinya Kitaoka 473e70
  bool isDeviceSelected() override;
Shinya Kitaoka 473e70
  void updateParameters(TScannerParameters ¶m) override;  // vedi TScanner
Shinya Kitaoka 473e70
  void acquire(const TScannerParameters ¶ms, int paperCount) override;
Shinya Kitaoka 120a6e
  bool isAreaSupported();
Shinya Kitaoka 120a6e
  void closeIO();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  void doSettings(const TScannerParameters ¶ms, bool isFirstSheet);
Shinya Kitaoka 120a6e
  void collectInformation(char *lev0, char *lev1, unsigned short *lowRes,
Shinya Kitaoka 120a6e
                          unsigned short *hiRes, unsigned short *hMax,
Shinya Kitaoka 120a6e
                          unsigned short *vMax);
Shinya Kitaoka 120a6e
  bool resetScanner();
Shinya Kitaoka 120a6e
  void reportError(std::string errMsg);  // debug only
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  char *ESCI_inquiry(char cmd); /* returns 0 if failed */
Shinya Kitaoka 120a6e
  bool ESCI_command(char cmd, bool checkACK);
Shinya Kitaoka 120a6e
  bool ESCI_command_1b(char cmd, unsigned char p0, bool checkACK);
Shinya Kitaoka 120a6e
  bool ESCI_command_2b(char cmd, unsigned char p0, unsigned char p1,
Shinya Kitaoka 120a6e
                       bool checkACK);
Shinya Kitaoka 120a6e
  bool ESCI_command_2w(char cmd, unsigned short p0, unsigned short p1,
Shinya Kitaoka 120a6e
                       bool checkACK);
Shinya Kitaoka 120a6e
  bool ESCI_command_4w(char cmd, unsigned short p0, unsigned short p1,
Shinya Kitaoka 120a6e
                       unsigned short p2, unsigned short p3, bool checkACK);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::unique_ptr<unsigned char[]=""> ESCI_read_data2(unsigned long &size);</unsigned>
Shinya Kitaoka 120a6e
  void ESCI_readLineData(unsigned char &stx, unsigned char &status,
Shinya Kitaoka 120a6e
                         unsigned short &counter, unsigned short &lines,
Shinya Kitaoka 120a6e
                         bool &areaEnd);
Shinya Kitaoka 120a6e
  void ESCI_readLineData2(unsigned char &stx, unsigned char &status,
Shinya Kitaoka 120a6e
                          unsigned short &counter);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int receive(unsigned char *buffer, int size);
Shinya Kitaoka 120a6e
  int send(unsigned char *buffer, int size);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ESCI_doADF(bool on);
Shinya Kitaoka 120a6e
  int sendACK();
Shinya Kitaoka 120a6e
  bool expectACK();
Shinya Kitaoka 120a6e
  void scanArea2pix(const TScannerParameters ¶ms, unsigned short &offsetx,
Shinya Kitaoka 120a6e
                    unsigned short &offsety, unsigned short &dimlx,
Shinya Kitaoka 120a6e
                    unsigned short &dimly, const TRectD &scanArea);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif