| | |
| | | capture = new L2DataCapture(); |
| | | recognitionManager = new RecognitionManager(); |
| | | limitUpCapture = new LimitUpCapture(); |
| | | buySuccessCapture = new BuySuccessCapture(); |
| | | tradeListCapture = new TradeListCapture(); |
| | | industryCapture = new IndustryCapture(); |
| | | gpDataCapture = new THSGPDataCapture(); |
| | | } |
| | | |
| | | void CappDlg::DoDataExchange(CDataExchange* pDX) |
| | |
| | | DDX_Control(pDX, IDC_INDUSTRY, industryBtn); |
| | | DDX_Control(pDX, IDC_BUTTON5, btnL2); |
| | | DDX_Control(pDX, IDC_BUTTON8, uploadGPBtn); |
| | | DDX_Control(pDX, IDC_BUTTON_TRADE_DELEGATE, delegateBtn); |
| | | } |
| | | |
| | | BEGIN_MESSAGE_MAP(CappDlg, CDialogEx) |
| | |
| | | ON_BN_CLICKED(IDC_BUTTON12, &CappDlg::OnBnClickedButton12) |
| | | ON_BN_CLICKED(IDC_BUTTON_TRADE, &CappDlg::OnBnClickedButtonTrade) |
| | | ON_BN_CLICKED(IDC_INDUSTRY, &CappDlg::OnBnClickedIndustry) |
| | | ON_BN_CLICKED(IDC_BUTTON_TRADE_DELEGATE, &CappDlg::OnBnClickedButtonTradeDelegate) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | ((CButton*)GetDlgItem(IDC_CHECK1))->SetCheck(TRUE); |
| | | ((CButton*)GetDlgItem(IDC_CHECK2))->SetCheck(TRUE); |
| | | ((CButton*)GetDlgItem(IDC_CHECK3))->SetCheck(TRUE); |
| | | ((CButton*)GetDlgItem(IDC_CHECK4))->SetCheck(TRUE); |
| | | |
| | | |
| | | if (authoritySet.count(AUTHORITY_L2) > 0) { |
| | |
| | | tradeBtn.EnableWindow(FALSE); |
| | | } |
| | | |
| | | |
| | | if (authoritySet.count(AUTHORITY_TRADE_DELEGATE) > 0) { |
| | | delegateBtn.EnableWindow(TRUE); |
| | | } |
| | | else { |
| | | delegateBtn.EnableWindow(FALSE); |
| | | } |
| | | |
| | | |
| | | |
| | | if (authoritySet.count(AUTHORITY_THS_INDUSTRY) > 0) { |
| | | industryBtn.EnableWindow(TRUE); |
| | | }else{ |
| | | } |
| | | else { |
| | | industryBtn.EnableWindow(FALSE); |
| | | } |
| | | |
| | |
| | | |
| | | CString st; |
| | | |
| | | CString idStr(to_string( clientNum).c_str()); |
| | | CString idStr(to_string(clientNum).c_str()); |
| | | |
| | | st.Format(_T("客户端ID:%s"), idStr); |
| | | GetDlgItem(IDC_STATIC3)->SetWindowTextW(st); |
| | |
| | | app->socketManager->resetClient(8); |
| | | app->socketManager->Connect(8); |
| | | } |
| | | cout << "####交易成功数据处理时间:" << (clock() - time_start) << endl; |
| | | } |
| | | } |
| | | |
| | | void CappDlg::OnTradeDelegateDataCallback(list<TradeDelegateData> dataList, string money, void* context) |
| | | { |
| | | //转为json |
| | | CappDlg* app = (CappDlg*)context; |
| | | //cout << "回调:" << std::this_thread::get_id() << ":" << index << endl; |
| | | CButton* btn = (CButton*)app->GetDlgItem(IDC_CHECK4); |
| | | bool check = btn->GetCheck(); |
| | | if (check) { |
| | | string data = JsonUtil::loadTradeDelegateData(dataList); |
| | | clock_t time_start = clock(); |
| | | |
| | | |
| | | try { |
| | | app->socketManager->sendMsg(8, data.c_str()); |
| | | } |
| | | catch (string st) { |
| | | //重新连接服务器 |
| | | app->socketManager->resetClient(8); |
| | | app->socketManager->Connect(8); |
| | | } |
| | | |
| | | |
| | | //上传账户可用余额 |
| | | data = JsonUtil::loadAvailableMoney(app->clientNum, money); |
| | | try { |
| | | app->socketManager->sendMsg(8, data.c_str()); |
| | | } |
| | | catch (string st) { |
| | | app->socketManager->resetClient(8); |
| | | app->socketManager->Connect(8); |
| | | } |
| | | |
| | | cout << "####交易成功数据处理时间:" << (clock() - time_start) << endl; |
| | | } |
| | | } |
| | |
| | | clock_t time = clock(); |
| | | |
| | | CString path = GUITool::selectImage(); |
| | | std:string p = Tool::cstring2String(path); |
| | | std:string p = Tool::cstring2String(path); |
| | | if (p.length() <= 0) { |
| | | return; |
| | | } |
| | |
| | | //股票代码识别 |
| | | void CappDlg::OnBnClickedButton7() |
| | | { |
| | | if (!capture->isInited()) |
| | | |
| | | if (!gpDataCapture->isInited()) |
| | | { |
| | | try { |
| | | capture->init(OnL2DataCallback, OnTradeQueueDataCallback, this); |
| | | gpDataCapture->init(); |
| | | } |
| | | catch (string st) { |
| | | CString msg(st.c_str()); |
| | |
| | | } |
| | | } |
| | | list<CString> paths = GUITool::selectMulImages(); |
| | | std::list<string> fResultList; |
| | | std::list<IndustryData> fResultList; |
| | | |
| | | for (list<CString>::iterator ele = paths.begin();ele != paths.end();ele++) { |
| | | CString path = *ele; |
| | | std:string p = Tool::cstring2String(path); |
| | | std::list<string> resultList = THSActionUtil::recognitionGPCode(cv::imread(p), recognitionManager); |
| | | for (std::list<string>::iterator ele1 = resultList.begin();ele1 != resultList.end();ele1++) { |
| | | cv::Mat grayImg = gpDataCapture->grayImgs(cv::imread(p)); |
| | | |
| | | SplitType types[] = { NUM_TYPE_MONEY, NUM_TYPE_CODE }; |
| | | |
| | | list<list<GPDataStruct>> resultList = gpDataCapture->captureGPData(grayImg, types, 6); |
| | | |
| | | for (list<list<GPDataStruct>>::iterator ele1 = resultList.begin();ele1 != resultList.end();ele1++) { |
| | | IndustryData industryData = IndustryData(); |
| | | |
| | | list<GPDataStruct>::iterator e = (*ele1).begin(); |
| | | industryData.zyltMoney = (*e).content; |
| | | industryData.zyltMoneyUnit = (*e).unit; |
| | | advance(e, 1); |
| | | industryData.code = (*e).content; |
| | | if (industryData.code == "000000") { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | |
| | | bool contains = false; |
| | | for (std::list<string>::iterator e = fResultList.begin();e != fResultList.end();e++) { |
| | | if (*e == *ele1) { |
| | | for (std::list<IndustryData>::iterator e = fResultList.begin();e != fResultList.end();e++) { |
| | | if ((*e).code == industryData.code) { |
| | | contains = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!contains) { |
| | | fResultList.push_back(*ele1); |
| | | fResultList.push_back(industryData); |
| | | } |
| | | } |
| | | |
| | | } |
| | | codesDataDlog::codeData = fResultList; |
| | | codesDataDlog::upload = false; |
| | |
| | | //截图上传股票代码 |
| | | void CappDlg::OnBnClickedButton8() |
| | | { |
| | | // |
| | | if (!capture->isInited()) |
| | | if (!gpDataCapture->isInited()) |
| | | { |
| | | try { |
| | | capture->init(OnL2DataCallback, OnTradeQueueDataCallback, this); |
| | | gpDataCapture->init(); |
| | | } |
| | | catch (string st) { |
| | | CString msg(st.c_str()); |
| | |
| | | } |
| | | } |
| | | list<CString> paths = GUITool::selectMulImages(); |
| | | std::list<string> fResultList; |
| | | std::list<IndustryData> fResultList; |
| | | |
| | | for (list<CString>::iterator ele = paths.begin();ele != paths.end();ele++) { |
| | | CString path = *ele; |
| | | std:string p = Tool::cstring2String(path); |
| | | std::list<string> resultList = THSActionUtil::recognitionGPCode(cv::imread(p), recognitionManager); |
| | | for (std::list<string>::iterator ele1 = resultList.begin();ele1 != resultList.end();ele1++) { |
| | | cv::Mat grayImg = gpDataCapture->grayImgs(cv::imread(p)); |
| | | |
| | | SplitType types[] = { NUM_TYPE_MONEY, NUM_TYPE_CODE }; |
| | | |
| | | list<list<GPDataStruct>> resultList = gpDataCapture->captureGPData(grayImg, types, 6); |
| | | |
| | | for (list<list<GPDataStruct>>::iterator ele1 = resultList.begin();ele1 != resultList.end();ele1++) { |
| | | IndustryData industryData = IndustryData(); |
| | | |
| | | list<GPDataStruct>::iterator e = (*ele1).begin(); |
| | | industryData.zyltMoney = (*e).content; |
| | | industryData.zyltMoneyUnit = (*e).unit; |
| | | advance(e, 1); |
| | | industryData.code = (*e).content; |
| | | if (industryData.code == "000000") { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | |
| | | bool contains = false; |
| | | for (std::list<string>::iterator e = fResultList.begin();e != fResultList.end();e++) { |
| | | if (*e == *ele1) { |
| | | for (std::list<IndustryData>::iterator e = fResultList.begin();e != fResultList.end();e++) { |
| | | if ((*e).code == industryData.code) { |
| | | contains = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!contains) { |
| | | fResultList.push_back(*ele1); |
| | | fResultList.push_back(industryData); |
| | | } |
| | | } |
| | | |
| | | } |
| | | codesDataDlog::codeData = fResultList; |
| | | codesDataDlog::upload = TRUE; |
| | |
| | | { |
| | | |
| | | |
| | | if (!buySuccessCapture->isInited()) { |
| | | if (!tradeListCapture->isInited()) { |
| | | try |
| | | { |
| | | buySuccessCapture->init(OnTradeSuccessDataCallback, this); |
| | | tradeListCapture->init(OnTradeSuccessDataCallback, OnTradeDelegateDataCallback, this); |
| | | } |
| | | catch (string st) |
| | | { |
| | |
| | | } |
| | | } |
| | | if ( |
| | | buySuccessCapture->isRunning()) { |
| | | buySuccessCapture->stop(); |
| | | tradeListCapture->isRunningTradeSuccess()) { |
| | | tradeListCapture->stopTradeSuccess(); |
| | | tradeBtn.SetWindowTextW(_T("启动成交识别任务")); |
| | | } |
| | | else { |
| | | try |
| | | { |
| | | buySuccessCapture->refreshHWND(); |
| | | tradeListCapture->refreshTradeSuccessHWND(); |
| | | } |
| | | catch (string st) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | buySuccessCapture->start(); |
| | | tradeListCapture->startTradeSuccess(); |
| | | tradeBtn.SetWindowTextW(_T("暂停成交识别任务")); |
| | | } |
| | | } |
| | |
| | | industryBtn.SetWindowTextW(_T("开始行业识别")); |
| | | } |
| | | } |
| | | |
| | | //委托识别任务 |
| | | void CappDlg::OnBnClickedButtonTradeDelegate() |
| | | { |
| | | |
| | | |
| | | |
| | | |
| | | if (!tradeListCapture->isInited()) { |
| | | try |
| | | { |
| | | tradeListCapture->init(OnTradeSuccessDataCallback, OnTradeDelegateDataCallback, this); |
| | | } |
| | | catch (string st) |
| | | { |
| | | CString msg(st.c_str()); |
| | | AfxMessageBox(msg); |
| | | return; |
| | | } |
| | | } |
| | | if ( |
| | | tradeListCapture->isRunningTradeDelegate()) { |
| | | tradeListCapture->stopTradeDelegate(); |
| | | delegateBtn.SetWindowTextW(_T("启动委托识别任务")); |
| | | } |
| | | else { |
| | | try |
| | | { |
| | | tradeListCapture->refreshTradeDelegateHWND(); |
| | | } |
| | | catch (string st) |
| | | { |
| | | CString msg(st.c_str()); |
| | | AfxMessageBox(msg); |
| | | return; |
| | | } |
| | | |
| | | tradeListCapture->startTradeDelegate(); |
| | | delegateBtn.SetWindowTextW(_T("暂停委托识别任务")); |
| | | } |
| | | |
| | | |
| | | |
| | | } |