diff --git a/ECTrainer2/ECTrainer.cpp b/ECTrainer2/ECTrainer.cpp index 19ab040..a37b28e 100644 --- a/ECTrainer2/ECTrainer.cpp +++ b/ECTrainer2/ECTrainer.cpp @@ -149,3 +149,8 @@ cv::Point2f ECTrainer::GetEyeL() { return _pStimulus->GetEyeL(); } + +// �o�b�e���[�c�ʎ擾 +int ECTrainer::BatteryLevel() { + return _pTobiiREST->BatteryLevel(); +} \ No newline at end of file diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 428c3c6..e9d9d94 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -45,6 +45,7 @@ void SetSceneBuffer(cv::Mat& img); void SetDispBuffer(cv::Mat& img); void SetGazeV(cv::Point gazeV); + int BatteryLevel(); cv::Point GetGazeV(); cv::Point2f GetGazeI(); cv::Point2f GetEyeR(); diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index d251e43..183f1e6 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -27,7 +27,7 @@ , _pSource(NULL) , _pCGB2(NULL) , _pMediaCont(NULL) - , pMediaEvent(NULL) + , _pMediaEvent(NULL) , _hWnd(NULL) , _SceneBufferHeight(0) , _DispImageHeight(0) @@ -46,7 +46,7 @@ // �f�X�g���N�^ ECTrainerGUI::~ECTrainerGUI() { - SAFE_RELEASE(pMediaEvent); + SAFE_RELEASE(_pMediaEvent); SAFE_RELEASE(_pMediaCont); SAFE_RELEASE(_pCGB2); SAFE_RELEASE(_pSource); @@ -274,6 +274,7 @@ cvui::printf("View Gaze %d, %d", _pEct->GetGazeV().x, _pEct->GetGazeV().y); cvui::printf("Img Gaze %.2f, %.2f", _pEct->GetGazeI().x, _pEct->GetGazeI().y); cvui::text(_pEct->GetHomographyStatus() ? "Homography OK" : "No homography"); + cvui::printf("Battery %d %%", _pEct->BatteryLevel()); bool snapshot = cvui::button(140, 30, "SNAPSHOT"); if (cvui::button(140, 30, "QUIT")) _pEct->Stop(); cvui::endColumn(); @@ -282,9 +283,9 @@ cvui::text(_MainFrame, DISP_IMAGE_POS.x, 100, "STIMULUS IMAGE"); cvui::image(_MainFrame, DISP_IMAGE_POS.x, DISP_IMAGE_POS.y, _DispImage); - if (pMediaEvent) { + if (_pMediaEvent) { long eventCode; - pMediaEvent->WaitForCompletion(1, &eventCode);//����̏�Ԃ�⑫ + _pMediaEvent->WaitForCompletion(1, &eventCode);//����̏�Ԃ�⑫ if (eventCode != 0) { if (!StopMovie()) _pEct->Stop(); _PlayIndex = (_PlayIndex + 1) % _MovieFiles.size(); @@ -376,7 +377,7 @@ CHECK(_pGB->QueryInterface(IID_IMediaControl, (void**)&_pMediaCont)); // ���f�B�A�C�x���g�C���^�[�t�F�C�X�̎擾 - CHECK(_pGB->QueryInterface(IID_IMediaEvent, (void**)&pMediaEvent)); + CHECK(_pGB->QueryInterface(IID_IMediaEvent, (void**)&_pMediaEvent)); ShowWindow(_hWnd, SW_SHOWNORMAL); _pMediaCont->Run(); @@ -387,13 +388,14 @@ // �����~ bool ECTrainerGUI::StopMovie() { _pMediaCont->Stop(); - SAFE_RELEASE(pMediaEvent); + SAFE_RELEASE(_pMediaEvent); SAFE_RELEASE(_pMediaCont); SAFE_RELEASE(_pCGB2); SAFE_RELEASE(_pSource); SAFE_RELEASE(_pVMR9); SAFE_RELEASE(_pGB); //pMediaPosition->Release(); + ShowWindow(_hWnd, SW_HIDE); return true; } diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 48e0b28..76e1a53 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -45,7 +45,7 @@ IBaseFilter* _pSource; ICaptureGraphBuilder2* _pCGB2; IMediaControl* _pMediaCont; - IMediaEvent* pMediaEvent; + IMediaEvent* _pMediaEvent; bool InitDx(HINSTANCE hInstance); bool PlayMovie(); diff --git a/ECTrainer2/TobiiREST.cpp b/ECTrainer2/TobiiREST.cpp index c63bcdb..0ff1218 100644 --- a/ECTrainer2/TobiiREST.cpp +++ b/ECTrainer2/TobiiREST.cpp @@ -93,3 +93,17 @@ return 0; } } + +// �o�b�e���[�c�ʎ擾 +int TobiiREST::BatteryLevel() { + try { + std::wstring url = SERVER _T("/api/system/status"); + auto response = REST_Handler::GET_Request(url.c_str()); + json::value json = response.extract_json().get(); + return json[L"sys_battery"][L"level"].as_integer(); + + } catch (const std::exception & e) { + std::cout << "Error " << e.what() << std::endl; + return 0; + } +} diff --git a/ECTrainer2/TobiiREST.h b/ECTrainer2/TobiiREST.h index a9788f0..c092c00 100644 --- a/ECTrainer2/TobiiREST.h +++ b/ECTrainer2/TobiiREST.h @@ -21,4 +21,5 @@ bool Init(); bool MainLoop(); void Start() { if (!_Start) _Start = true; }; + int BatteryLevel(); }; diff --git a/RESTtest/RESTtest.cpp b/RESTtest/RESTtest.cpp index 1ca3f5a..b0321b1 100644 --- a/RESTtest/RESTtest.cpp +++ b/RESTtest/RESTtest.cpp @@ -139,23 +139,55 @@ auto caId = json[_T("ca_id")].as_string(); std::wcout << "caId=" << caId << std::endl; - std::wstring url = SERVER _T("/api/calibrations/") + caId + _T("/start"); - json = POST_request(url.c_str()).extract_json().get(); + // バッテリー残量取得 + //std::wstring url = SERVER _T("/api/system/status"); + //auto response = GET_request(url.c_str()); + //json = response.extract_json().get(); + //std::wcout << json[L"sys_battery"][L"level"].as_integer() << std::endl; - url = SERVER _T("/api/calibrations/") + caId + _T("/status"); - std::vector values; - values.push_back(_T("failed")); - values.push_back(_T("calibrated")); - std::wstring status = WaitForStatus(url.c_str(), _T("ca_state"), values); - if (status == _T("failed")) { - std::wcout << _T("Calibration failed.") << std::endl; - } else { - std::wcout << _T("Calibration successful.") << std::endl; - } + // カメラ設定取得 + std::wstring url = SERVER _T("/api/system/conf"); + auto response = GET_request(url.c_str()); + json = response.extract_json().get(); + std::wcout << "sys_sc_preset=" << json[L"sys_sc_preset"].as_string() << std::endl; + + // WLAN設定取得 + url = SERVER _T("/api/system/wlan"); + response = GET_request(url.c_str()); + json = response.extract_json().get(); + std::wcout << "sys_wlan_mode=" << json[L"sys_wlan_mode"].as_string() << std::endl; + std::wcout << "sys_wlan_ap_ssid=" << json[L"sys_wlan_ap_ssid"].as_string() << std::endl; + std::wcout << "sys_wlan_ap_key=" << json[L"sys_wlan_ap_key"].as_string() << std::endl; + + // カメラ設定更新 + //json::value postData3; + //postData3[L"sys_sc_preset"] = json::value::string(L"Auto"); + //json = POST_request(SERVER _T("/api/system/conf"), postData3).extract_json().get(); + //auto result = json[_T("sys_sc_preset")].as_string(); + //std::wcout << "sys_sc_preset=" << result << std::endl; + + // キャリブレーション開始 + //std::wstring url = SERVER _T("/api/calibrations/") + caId + _T("/start"); + //json = POST_request(url.c_str()).extract_json().get(); + + // キャリブレーション結果取得 + //url = SERVER _T("/api/calibrations/") + caId + _T("/status"); + //std::vector values; + //values.push_back(_T("failed")); + //values.push_back(_T("calibrated")); + //std::wstring status = WaitForStatus(url.c_str(), _T("ca_state"), values); + //if (status == _T("failed")) { + // std::wcout << _T("Calibration failed.") << std::endl; + //} else { + // std::wcout << _T("Calibration successful.") << std::endl; + //} getchar(); + return 0; } catch (const std::exception & e) { std::cout << "Error " << e.what() << std::endl; + getchar(); + return 1; } }