diff --git a/ECTrainer2/BaseProcess.h b/ECTrainer2/BaseProcess.h index 95a7d8c..c9b07df 100644 --- a/ECTrainer2/BaseProcess.h +++ b/ECTrainer2/BaseProcess.h @@ -32,7 +32,7 @@ // �X���b�h�{�́iprotected, ��virtual) virtual bool MainLoop(); // �X���b�h�I���҂� - bool WaitForExit(DWORD timeOut = 3000); + virtual bool WaitForExit(DWORD timeOut = 3000); // ���b�Z�[�W�𑗂� - bool Tell(ECTMSG msg, WPARAM wp = 0, LPARAM lp = 0); + virtual bool Tell(ECTMSG msg, WPARAM wp = 0, LPARAM lp = 0); }; diff --git a/ECTrainer2/ECTrainer.cpp b/ECTrainer2/ECTrainer.cpp index bedcf71..0b9a46f 100644 --- a/ECTrainer2/ECTrainer.cpp +++ b/ECTrainer2/ECTrainer.cpp @@ -15,8 +15,7 @@ // �R���X�g���N�^ ECTrainer::ECTrainer(HINSTANCE hInstance) - : _AppRunning(true) - , _hInstance(hInstance) + : _hInstance(hInstance) { _pMarker = new Marker(); _pProcs[(int)PROC::GUI] = new ECTrainerGUI(this); @@ -62,7 +61,6 @@ // �A�v���P�[�V�������~ void ECTrainer::StopApp() { - _AppRunning = false; for (int i = 0; i < (int)PROC::NUM; i++) _pProcs[i]->Tell(ECTMSG::QUIT); } diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 3d50459..663cc86 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -24,13 +24,14 @@ // ���b�Z�[�W�ꗗ enum class ECTMSG { QUIT = WM_QUIT, - CALIB_START = WM_USER, - CALIB_OK, - CALIB_FAILED, - CALIB_ERR, - STIM_START, - STIM_STOP, - STIM_END, + CALIB_START = WM_USER, // �L�����u���[�V�����J�n + CALIB_OK, // �L�����u���[�V�������� + CALIB_FAILED, // �L�����u���[�V�������s + CALIB_ERR, // �L�����u���[�V�����G���[ + STIM_START, // �����J�n + STIM_STOP, // ������~ + STIM_END, // �����I�� + STIM_NEXT, // ���̎h���Ɉړ� }; // �A�v���P�[�V������� @@ -38,11 +39,6 @@ BOOT, IDLE, CALIB, STIM }; -//// �h���y�[�W -//enum class STIM_PAGE { -// OPENING, CALIB, CALIB_COMPLETE, CALIB_FAILED, START, STOP, NEXT, BACK, WHITE -//}; - class ECTrainer { // �v���Z�X�ꗗ�i���������j GUI�擪, SCNCAM->ALIVE->EYETR @@ -51,7 +47,6 @@ BaseProcess* _pProcs[(int)PROC::NUM]; Marker* _pMarker; HINSTANCE _hInstance; - bool _AppRunning; // ���s���t���O std::wstring _MovieToShow; // �Đ����铮��t�@�C�� // �X���b�h�J�n�_ @@ -71,15 +66,19 @@ BitalMonitor* PBitalMonitor() { return (BitalMonitor*)_pProcs[(int)PROC::BITAL]; } Worker* PWorker() { return (Worker*)_pProcs[(int)PROC::WORKER]; } Marker* PMarker() { return _pMarker; } - bool Process(); - // �C�����C���֐� - HINSTANCE GetInstance() { return _hInstance; } // �C���X�^���X�n���h�� - bool IsAppRun() { return _AppRunning; } // �A�v���P�[�V�������s�����ǂ��� + // ���C������ + bool Process(); + // �C���X�^���X�n���h���擾 + HINSTANCE GetInstance() { return _hInstance; } + // �A�v���P�[�V�������s�����ǂ��� + //bool IsAppRun() { return _AppRunning; } // �A�v���P�[�V�������~ void StopApp(); // ���b�Z�[�W�{�b�N�X�\�� void MsgBox(LPCWSTR msg, UINT icon = 0); + + //�p�~�\�� void SetMovieToShow(std::wstring file) { _MovieToShow = file; } std::wstring GetMovieToShow() { return _MovieToShow; } }; diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 6f4736d..1a82cf3 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -31,6 +31,7 @@ , _DispImageHeight(0) , _SceneBufferScale(1.F) , _hWndMain(NULL) + , _AppRunning(true) { } @@ -266,16 +267,22 @@ return true; } -// �C�x���g���[�v +// �C�x���g���[�v�iGUI�̓��C���X���b�h�̂��߃��b�Z�[�W�������Ȃ�) bool ECTrainerGUI::MainLoop() { - while (_pEct->IsAppRun() && cv::getWindowProperty(WIN_MAIN, 0) >= 0) { + while (_AppRunning && cv::getWindowProperty(WIN_MAIN, 0) >= 0) { this->Routine(); } _pEct->StopApp(); return true; } +// ���b�Z�[�W�ʒm�iGUI�̓��C���X���b�h�̂��ߒ��ڏ���) +bool ECTrainerGUI::Tell(ECTMSG msg, WPARAM wp, LPARAM lp) { + if (msg == ECTMSG::QUIT) _AppRunning = false; + return true; +} + // ����Đ� bool ECTrainerGUI::PlayMovie(std::wstring movie) { //if (_PlayIndex < 0 || _PlayIndex >= _MovieFiles.size()) return false; diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 24c44f3..b67f56f 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -36,6 +36,7 @@ float _SceneBufferScale; int _DispImageHeight; HWND _hWndMain; + bool _AppRunning; // ���s���t���O RECT _DispRect; // DirectShow����\���ʒu HWND _hWnd; @@ -53,13 +54,14 @@ bool PlayMovie(std::wstring movie); bool StopMovie(); bool IsPlaying(); + bool Routine(); + bool MainLoop(); public: ECTrainerGUI(ECTrainer* pEct); ~ECTrainerGUI(); bool Init(); - bool Routine(); - bool MainLoop(); + bool Tell(ECTMSG msg, WPARAM wp = 0, LPARAM lp = 0); HWND GetMainHWnd() { return _hWndMain; } void SetDispBuffer(cv::Mat& img); }; diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index 85363bf..e7e4d21 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -53,17 +53,13 @@ DWORD current = GetTickCount(); if ((float)(current - _StartTime) / 1000.F > _StimInfoSet[_StimNo].dulation) { if (_StimInfoSet[_StimNo].type == 2) { - //SetPage(STIM_PAGE::WHITE); _pEct->SetMovieToShow(L"STOP"); } if (++_StimNo < _StimInfoSet.size()) { SetStimulus(); + ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::STIM_NEXT); } else { ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::STIM_END); - //_StimNo = -1; - //_DispBuffer = cv::imread(OPENING_FILE); - //_pEct->PECTrainerGUI()->SetDispBuffer(_DispBuffer); - //SetPage(STIM_PAGE::STOP); } } } diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index a85d795..3c3098f 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -14,7 +14,6 @@ , _fpLogEvent(NULL) , _pTimer(NULL) { - } // �f�X�g���N�^ @@ -63,28 +62,28 @@ _AppStatus = APP_STATUS::CALIB; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::CALIB_START); ((BaseProcess*)_pEct->PTobiiREST())->Tell(ECTMSG::CALIB_START); - this->EventLog(_T("Calibration start.")); + this->EventLog(_T("Calibration start")); } break; case (int)ECTMSG::CALIB_OK: // �L�����u���[�V�������� _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::CALIB_OK); - this->EventLog(_T("Calibration complete.")); + this->EventLog(_T("Calibration complete")); break; case (int)ECTMSG::CALIB_FAILED: // �L�����u���[�V�������s case (int)ECTMSG::CALIB_ERR: // �L�����u���[�V�����G���[ _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::CALIB_FAILED); - this->EventLog(_T("Calibration failed.")); + this->EventLog(_T("Calibration failed")); break; case (int)ECTMSG::STIM_START: // �����J�n if (_AppStatus == APP_STATUS::IDLE) { _AppStatus = APP_STATUS::STIM; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::STIM_START); - this->EventLog(_T("Stimulation start.")); + this->EventLog(_T("Stimulation start")); } break; @@ -92,17 +91,21 @@ if (_AppStatus == APP_STATUS::STIM) { _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::STIM_STOP); - this->EventLog(_T("Stimulation stop.")); + this->EventLog(_T("Stimulation stop")); } break; - case (int)ECTMSG::STIM_END: // ������~ + case (int)ECTMSG::STIM_END: // �����I�� if (_AppStatus == APP_STATUS::STIM) { _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->Tell(ECTMSG::STIM_STOP); - this->EventLog(_T("Stimulation end.")); + this->EventLog(_T("Stimulation end")); } break; + + case (int)ECTMSG::STIM_NEXT: // ���̎h���Ɉړ� + this->EventLog(_T("Stimulation move next")); + break; } return true; }