#include "THSL2RepairTool.h"
|
#include "Win32Util.h"
|
#include "THSActionUtil.h"
|
|
THSL2RepairTool::THSL2RepairTool()
|
{
|
openCLExcuter = new OpenCLExcuter();
|
openCLExcuter->init();
|
}
|
|
void THSL2RepairTool::repairL2Data(RecognitionManager *recognitionManager, int index, string code, double min_price, double max_price)
|
{
|
try {
|
list<TradeData> dataList;
|
try {
|
dataList = L2DataCapture::captureLevel2TradeData(openCLExcuter, CaptureUtil::capture(index, CAPTURE_TYPE_L2), index);
|
}
|
catch (int c) {
|
cout << "»ñÈ¡L2Êý¾Ý³ö´í£ºcode-" << c << endl;
|
}
|
cout << "»ñÈ¡µ½µÄÊý¾Ý£º" << dataList.size() << endl;
|
if (dataList.size() == 0) {//ÐÞÕýÊý¾Ý
|
//ÉÏϹö¶¯Êó±ê¹öÂÖ1´Î
|
HWND win = CaptureUtil::getHWND(index, CAPTURE_TYPE_L2);
|
cout << "L2 win£º" << win << endl;
|
RECT rect;
|
Win32Util::getWindowRect(win, &rect);
|
cout << "L2 rect£º" << rect.left << rect.top << endl;
|
Win32Util::rollMouseWheel(false, win, rect.left + 20, rect.top + 10);
|
Sleep(100);
|
Win32Util::rollMouseWheel(true, win, rect.left + 20, rect.top + 10);
|
Sleep(500);
|
try {
|
dataList = L2DataCapture::captureLevel2TradeData(openCLExcuter, CaptureUtil::capture(index, CAPTURE_TYPE_L2), index);
|
cout << "»ñÈ¡µ½µÄÊý¾Ý£º" << dataList.size() << endl;
|
}
|
catch (int c) {
|
cout << "»ñÈ¡L2Êý¾Ý³ö´í£ºcode-" << c << endl;
|
}
|
}
|
|
//´ò¿ªL2¼à¿ØÆÁÄ»
|
THSActionUtil::openL2Screen();
|
|
bool success = false;
|
int retryCount = 0;
|
while (!success)
|
{
|
if (retryCount > 3) {
|
break;
|
}
|
//µã»÷´úÂë
|
retryCount++;
|
THSActionUtil::setListenL2GP(index, code, recognitionManager);
|
Sleep(1000);
|
bool normal = true;
|
|
for (list<TradeData>::iterator ele = dataList.begin();ele != dataList.end();++ele) {
|
double price = stod((*ele).price);
|
if (price >= max_price + 0.0001) {
|
normal = false;
|
break;
|
}
|
else if (price <= min_price - 0.0001) {
|
normal = false;
|
break;
|
}
|
}
|
|
cout << code << "-repairL2DataÊÇ·ñÐÞ¸´³É¹¦:" << normal << endl;
|
|
success = normal;
|
}
|
}
|
catch (int code) {
|
throw string("´íÎóÂ룺" + code);
|
}
|
catch (string st) {
|
throw st;
|
}
|
catch (...) {
|
std::exception_ptr p = std::current_exception();
|
throw string("δ֪´íÎó(unknown error)");
|
}
|
|
}
|