| | |
| | | #include "THSActionUtil.h" |
| | | #include <thread> |
| | | #include "TaskChecker.h" |
| | | #include "GPUtil.h" |
| | | bool L2DataCapture::inited; |
| | | bool L2DataCapture::tradeTimeCapture; |
| | | |
| | |
| | | |
| | | void* L2DataCapture::context; |
| | | |
| | | //将当前时间换算成秒 |
| | | int getNowSecondTime() { |
| | | time_t timep; |
| | | time(&timep); |
| | | char tmp_h[64]; |
| | | strftime(tmp_h, sizeof(tmp_h), "%H", localtime(&timep)); |
| | | char tmp_m[64]; |
| | | strftime(tmp_m, sizeof(tmp_m), "%M", localtime(&timep)); |
| | | char tmp_s[64]; |
| | | strftime(tmp_s, sizeof(tmp_s), "%S", localtime(&timep)); |
| | | return stoi(string(tmp_h)) * 3600 + stoi(string(tmp_m)) * 60 + stoi(string(tmp_s)); |
| | | } |
| | | |
| | | |
| | | //运行 |
| | | void L2DataCapture::_run(int index) |
| | |
| | | break; |
| | | TaskChecker::clientLiveTime.l2[index] = clock(); |
| | | if (tradeTimeCapture) { |
| | | int time = getNowSecondTime(); |
| | | //9:20-11:31 12:59-15:01 |
| | | bool in = false; |
| | | if ((time >= 9 * 3600 + 20 * 60 && time <= 11 * 3600 + 31 * 60) || (time >= 12 * 3600 + 59 * 60 && time <= 15 * 3600 + 1 * 60)) { |
| | | in = true; |
| | | } |
| | | if (!in) { |
| | | if (!GPUtil::isTradeTime()) { |
| | | Sleep(2); |
| | | continue; |
| | | } |
| | |
| | | //识别数据 |
| | | string code = gpCodes[index]; |
| | | try { |
| | | clock_t start = clock(); |
| | | list<TradeData> resultList = captureLevel2TradeData(CaptureUtil::capture(index, CAPTURE_TYPE_L2), index); |
| | | data_callback(index, code, resultList, context); |
| | | cout << "时间消耗:" << clock() - start << endl; |
| | | } |
| | | catch (...) { |
| | | |
| | |
| | | |
| | | string L2DataCapture::getGPCode(int index) { |
| | | return gpCodes[index]; |
| | | } |
| | | |
| | | void L2DataCapture::setTradeTimeCapture(bool enable) |
| | | { |
| | | tradeTimeCapture = enable; |
| | | } |
| | | |
| | | static string getGPCode(int index); |