admin
2022-10-28 086ec74e94654e92b3a1c6f42612d12ef33ff4b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#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)");
    }
 
}