tx-gxx-linux/device/gxx-linux/testusb/main.cpp

117 lines
3.2 KiB
C++
Raw Normal View History

2023-04-08 00:56:20 +00:00
#include <iostream>
#include <iomanip>
#include <memory>
#include <thread>
#include <chrono>
#include "filetools.h"
#include "stringex.hpp"
#include <functional>
#include "usbservice.h"
#include "Capturer.h"
#include "motorboard.h"
#include "itransmit.h"
#include "scannerregs.h"
#include "scanner.h"
#include "inotify.h"
#include "memoryex.h"
#include "usbimageprocqueue.h"
#include "imageusbtesthandler.h"
#include "applog.h"
#include "jsonconfig.h"
using namespace std;
volatile int done_scan = 0;
int menu()
{
int choice;
cout << " **** Menu **** " << endl
<< endl;
cout << "(1) notify." << endl;
cout << "(2) clear notify. " << endl;
cout << "(3/4) autocorrect " << endl;
cout << "(5) color mode change test " << endl;
cout << "(0) Quit. " << endl
<< endl;
cout << ": ";
cin >> choice;
return choice;
}
int main()
{
2023-05-02 01:50:55 +00:00
auto cap = std::shared_ptr<Capturer>(new Capturer());
auto mt = std::shared_ptr<MotorBoard>(new MotorBoard(nullptr));
auto scanner = std::shared_ptr<Scanner>(new Scanner(cap, mt,nullptr));
UsbService us(cap->regs(), mt->regs());
auto notify = us.notify();
std::shared_ptr<UsbImageProcQueue> usbImage(new UsbImageProcQueue(notify));
auto transfer = us.transmiter();
std::shared_ptr<IRegsAccess> regs = std::shared_ptr<IRegsAccess>(new ScannerRegAccess(scanner, usbImage, transfer));
scanner->set_imagehandler(std::shared_ptr<IImageHandler>(new ImageUsbHandler(usbImage)));
us.set_scannerregs(regs);
unsigned int val = 0;
bool exit = false;
int option = 0;
unsigned char data[116] = {0x00};
int count = 0;
2023-04-08 00:56:20 +00:00
2023-05-02 01:50:55 +00:00
// auto mem = std::shared_ptr<VectorMemroy>(new VectorMemroy());
// mem->resize(10);
// memcpy(mem->data(),data,sizeof(data));
for (;;)
{
option = menu();
switch (option)
{
case 0:
exit = true;
break;
case 1:
this_thread::sleep_for(chrono::milliseconds(1));
break;
case 2:
notify->clear();
break;
case 3:
// {
// auto nread= transfer->read_bulk(data,sizeof(data));
// break;
// }
case 4:
scanner->test_autocorrect(option==3);
break;
case 5:
2023-04-08 00:56:20 +00:00
{
2023-05-02 01:50:55 +00:00
HGScanConfig config = {0};
for (size_t i = 0; i < 40; i++)
{
std::string msg=(i % 2 == 0?" mode COLOR ":" mode GRAY ");
std::cout << "Test color mode change index = "<<i<< msg<< std::endl;
//i % 2 == 0 ? config.g200params.color = 1 : config.g200params.color = 0;
config.g200params.color = 0;
config.g200params.dpi = 1;
config.g200params.paper = 2;
scanner->test_cap(config);
this_thread::sleep_for(chrono::milliseconds(1));
}
std::cout << "Please select again! " << std::endl;
break;
}
default:
std::cout << "Please select again! " << std::endl;
break;
}
/* code */
if (exit)
break;
2023-04-08 00:56:20 +00:00
}
std::cout << "exit munu" << std::endl;
return 0;
}