#pragma once #include #include #include #include "scanservices_utils.h" template std::string string_format(const std::string& format, Args ... args) { size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; std::unique_ptr buf(new char[size]); snprintf(buf.get(), size, format.c_str(), args ...); return std::string(buf.get(), buf.get() + size - 1); } template void write_dev(std::string path, T value) { std::ofstream ofout(path); ofout << value; } extern int read_dev_i(std::string path); extern std::string read_dev_s(std::string path); enum PIN_PORT_7010 { //通道0-------------START SCAN_SENSOR = 0 + 1019, //扫描传感器 HAVE_OR_NO_PAPER = 3 + 1019, //有无纸(0:无纸,1:有纸) OPEN_COVER_SENSOR = 4 + 1019, //是否开盖(0:未开盖,1:开盖) ULTRASONIC_SENSORS_OUT0 = 18 + 901, ULTRASONIC_SENSORS_OUT1 = 17 + 901, ULTRASONIC_SENSORS_ON = 20 + 901, ULTRASONIC_SENSORS_ADJ = 19 + 901, //通道0-------------END SENSOR_POWER = 66 + 1019, //通道1-------------START BUTTON_1_POWER = 21+1019, //按键1 电源 BUTTON_2 = 22+1019, //按键2 BUTTON_3 = 23+1019, //按键3 LED_0_GREEN = 24+1019, LED_1_WHITE = 25+1019, LED_2_RED = 26+1019, //PWM0 电机1-START CUOZHI_PIN_DIR = 54+901, //方向(顺:0) CUOZHI_PIN_ENABEL = 55+901, //使能(有效:0) CUOZHI_PIN_RESET = 56+901, //重启 (1:电机转动,一般默认为1) CUOZHI_PIN_SLEEP = 57+901, //睡眠 (1:电机转动,一般默认为1) //PWM0 电机1-END //PWM1 电机2-START ZOUZHI_PIN_DIR = 59+901, //方向(顺:0) ZOUZHI_PIN_ENABEL = 60+901, //使能(有效:0) ZOUZHI_PIN_RESET = 61+901, //重启 (1:电机转动,一般默认为1) ZOUZHI_PIN_SLEEP = 62+901, //睡眠 (1:电机转动,一般默认为1) //PWM1 电机2-END //通道1-------------END MOTOR_POWER_1 = 64 + 901, //电机1 电源开关 MOTOR_POWER_2 = 65 + 901, //电机2 电源开关 }; enum PORTS { //Start = 171, //Stop = 49, //Power = 5, Fpga_InitN = 7,//GPIO0_A7 Fpga_Load = 8,//GPIO0_B7 #ifndef G300 Power_12v_Off = 12, #endif //MotorPower = 48, //CuoZhiMotor_Reset = 56, //CuoZhiMotor_Sleep = 57, //CuoZhiMotor_Enable = 58, //CuoZhiMotor_Direction = 62, //CuoZhiMotor_Decay = 63, //CuoZhiMotor_Home = 184, //CuoZhiMotor_Fault = 185, //CuoZhiMotor_Mode0 = 59, //CuoZhiMotor_Mode1 = 60, //CuoZhiMotor_Mode2 = 61, //Cover = 189,// 'GPIO6A5' opened:0 ; closed:1 //Paper = 225,// 'GPIO7B1' has paper:0 ; no paper:1 //Scan = 226,// 'GPIO7B2' no paper:0 ; has paper:1 //PaperJam = 102, //Double_Paper = 219,// 'GPIO7A3' not doubled:0 ; doubled:1 SW_NOR_FLASH = 221, //Double_Enable = 250,// 'GPIO8A2' off: 0 ; on: 1 //ZouZhiMotor_Reset = 64, //ZouZhiMotor_Sleep = 65, //ZouZhiMotor_Enable = 66, //ZouZhiMotor_Direction = 70, //ZouZhiMotor_Decay = 71, //ZouZhiMotor_Home = 187, //ZouZhiMotor_Fault = 188, //ZouZhiMotor_Mode0 = 67, //ZouZhiMotor_Mode1 = 68, //ZouZhiMotor_Mode2 = 69, CIS_3v3_Off = 96, CIS_5v_En = 98, Fpga_InitDone = 99, Image_In_Transfer = 101, Fpga_Reset = 232, CIS_T_S0=190, CIS_T_S1=191, CIS_T_S2=234, CIS_T_S3=233 }; class DeviceExport { public: DeviceExport(); private: const int ports[17] = { MOTOR_POWER_1, CUOZHI_PIN_RESET, CUOZHI_PIN_SLEEP,CUOZHI_PIN_ENABEL, CUOZHI_PIN_DIR, MOTOR_POWER_2, ZOUZHI_PIN_RESET, ZOUZHI_PIN_SLEEP,ZOUZHI_PIN_ENABEL, ZOUZHI_PIN_DIR, SCAN_SENSOR,HAVE_OR_NO_PAPER, OPEN_COVER_SENSOR,ULTRASONIC_SENSORS_OUT0,ULTRASONIC_SENSORS_OUT1,ULTRASONIC_SENSORS_ON}; const int pwms[3] = { 0, 1 ,2}; };