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
Toshihiro Shimizu 890ddd
class TScannerEpson : public TScanner
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	enum SettingsMode {
Toshihiro Shimizu 890ddd
		OLD_STYLE,
Toshihiro Shimizu 890ddd
		NEW_STYLE
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TScannerIO *m_scannerIO;
Toshihiro Shimizu 890ddd
	bool m_hasADF;
Toshihiro Shimizu 890ddd
	bool m_isOpened;
Toshihiro Shimizu 890ddd
	SettingsMode m_settingsMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TScannerEpson();
Toshihiro Shimizu 890ddd
	~TScannerEpson();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void selectDevice();
Toshihiro Shimizu 890ddd
	bool isDeviceAvailable();
Toshihiro Shimizu 890ddd
	bool isDeviceSelected();
Toshihiro Shimizu 890ddd
	void updateParameters(TScannerParameters ¶m); // vedi TScanner
Toshihiro Shimizu 890ddd
	void acquire(const TScannerParameters ¶ms, int paperCount);
Toshihiro Shimizu 890ddd
	bool isAreaSupported();
Toshihiro Shimizu 890ddd
	void closeIO();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	void doSettings(const TScannerParameters ¶ms, bool isFirstSheet);
Toshihiro Shimizu 890ddd
	void collectInformation(char *lev0, char *lev1, unsigned short *lowRes, unsigned short *hiRes, unsigned short *hMax, unsigned short *vMax);
Toshihiro Shimizu 890ddd
	bool resetScanner();
Shinya Kitaoka 3bfa54
	void reportError(std::string errMsg); // debug only
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	char *ESCI_inquiry(char cmd); /* returns 0 if failed */
Toshihiro Shimizu 890ddd
	bool ESCI_command(char cmd, bool checkACK);
Toshihiro Shimizu 890ddd
	bool ESCI_command_1b(char cmd, unsigned char p0, bool checkACK);
Toshihiro Shimizu 890ddd
	bool ESCI_command_2b(char cmd, unsigned char p0, unsigned char p1, bool checkACK);
Toshihiro Shimizu 890ddd
	bool ESCI_command_2w(char cmd, unsigned short p0, unsigned short p1, bool checkACK);
Toshihiro Shimizu 890ddd
	bool ESCI_command_4w(char cmd, unsigned short p0, unsigned short p1, unsigned short p2, unsigned short p3, bool checkACK);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 6a4e01
	std::unique_ptr<unsigned char[]=""> ESCI_read_data2(unsigned long &size);</unsigned>
Toshihiro Shimizu 890ddd
	void ESCI_readLineData(unsigned char &stx, unsigned char &status, unsigned short &counter, unsigned short &lines, bool &areaEnd);
Toshihiro Shimizu 890ddd
	void ESCI_readLineData2(unsigned char &stx, unsigned char &status, unsigned short &counter);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int receive(unsigned char *buffer, int size);
Toshihiro Shimizu 890ddd
	int send(unsigned char *buffer, int size);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool ESCI_doADF(bool on);
Toshihiro Shimizu 890ddd
	int sendACK();
Toshihiro Shimizu 890ddd
	bool expectACK();
Toshihiro Shimizu 890ddd
	void scanArea2pix(const TScannerParameters ¶ms, unsigned short &offsetx, unsigned short &offsety,
Toshihiro Shimizu 890ddd
					  unsigned short &dimlx, unsigned short &dimly, const TRectD &scanArea);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif