From 60feedf43a35a9ca69d05095a01c5d1797b1bdc3 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 09 九月 2022 18:47:14 +0800
Subject: [PATCH] '完善'

---
 ConsoleApplication/L2DataCapture.cpp |   29 +++++------------------------
 1 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/ConsoleApplication/L2DataCapture.cpp b/ConsoleApplication/L2DataCapture.cpp
index 4f0910e..50ee635 100644
--- a/ConsoleApplication/L2DataCapture.cpp
+++ b/ConsoleApplication/L2DataCapture.cpp
@@ -4,6 +4,7 @@
 #include "THSActionUtil.h"
 #include <thread>
 #include "TaskChecker.h"
+#include "GPUtil.h"
 bool L2DataCapture::inited;
 bool L2DataCapture::tradeTimeCapture;
 
@@ -25,18 +26,7 @@
 
 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)
@@ -46,13 +36,7 @@
 			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;
 			}
@@ -63,8 +47,10 @@
 			//识别数据
 			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 (...) {
 
@@ -104,11 +90,6 @@
 
 string L2DataCapture::getGPCode(int index) {
 	return	gpCodes[index];
-}
-
-void L2DataCapture::setTradeTimeCapture(bool enable)
-{
-	tradeTimeCapture = enable;
 }
 
 static string getGPCode(int index);

--
Gitblit v1.8.0