diff --git a/ECTrainer2/DShowMovie.cpp b/ECTrainer2/DShowMovie.cpp index b3ada17..2dd8ddd 100644 --- a/ECTrainer2/DShowMovie.cpp +++ b/ECTrainer2/DShowMovie.cpp @@ -161,7 +161,9 @@ bool DShowMovie::IsReachToEnd() { if (!_pMediaEvent) return false; long eventCode; - return (_pMediaEvent->WaitForCompletion(0, &eventCode) == S_OK); + auto rv = _pMediaEvent->WaitForCompletion(0, &eventCode); + //mwut::DebugPrintf(_T("eventCode %d (%d,%d,%d)\n"), eventCode, EC_COMPLETE, EC_ERRORABORT, EC_USERABORT); + return (eventCode == EC_COMPLETE); } // �Đ��ʒu�̎擾 diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 2e99ee1..2a58427 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -23,7 +23,9 @@ // ���b�Z�[�W�ꗗ enum class ECTMSG { QUIT = WM_QUIT, - CALIB_START = WM_USER, // �L�����u���[�V�����J�n + SOFTWARE_START = WM_USER, // �\�t�g�E�F�A�N�� + SOFTWARE_END, // �\�t�g�E�F�A�I�� + CALIB_START, // �L�����u���[�V�����J�n CALIB_OK, // �L�����u���[�V�������� CALIB_FAILED, // �L�����u���[�V�������s CALIB_ERR, // �L�����u���[�V�����G���[ diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 1ac54a3..15ded95 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -72,7 +72,7 @@ cv::Mat sceneBuf = _pEct->PImageProc()->GetImage(); if (sceneBuf.empty()) sceneBuf = _blank; - // �\���o�b�t�@���� + // �\���o�b�t�@�����i��������Worker�N���X�̐����摜�C���������Stimulus�N���X�̉摜���g���j bool fTarget = _pEct->PWorker()->GetAppStatus() == APP_STATUS::STIM; bool isNew = fTarget ? _pEct->PWorker()->IsNewTargetImg() : _pEct->PStimulus()->IsNewDisplay(); cv::Mat dispBuf = fTarget ? _pEct->PWorker()->GetTargetImg().clone() : _pEct->PStimulus()->GetDisplay().clone(); @@ -98,7 +98,7 @@ break; case APP_STATUS::STIM: if (cvui::button(140, 30, "STOP")) { - if (!_dsm->StopMovie()) _pEct->StopApp(); + _dsm->StopMovie(); ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::EXP_STOP); } //cvui::trackbar(140, &targetSize, (float)0, (float)3.0); @@ -115,7 +115,9 @@ cvui::printf("Movie pos: %.1f", _dsm->GetPlayPos()); } bool snapshot = cvui::button(140, 30, "SNAPSHOT"); - if (cvui::button(140, 30, "QUIT")) _pEct->StopApp(); + if (cvui::button(140, 30, "QUIT")) { + ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::SOFTWARE_END); + } if (_pEct->PBitalMonitor()->IsUseDevice()) { cvui::printf("HeartBeat (bpm)"); cvui::text(cv::format("%3d", _pEct->PBitalMonitor()->GetHB()), 2.0); @@ -149,6 +151,10 @@ } } } + // ����̖����܂ōĐ��`�F�b�N + if (_dsm->IsReachToEnd()) { + ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::MOVIE_END); + } // ��ʕ\�� cvui::update(); @@ -168,7 +174,9 @@ case '7': PlaySound(_T("../voices/Great_L.wav"), NULL, SND_FILENAME | SND_ASYNC); break; case '8': PlaySound(_T("../voices/Excellent_L.wav"), NULL, SND_FILENAME | SND_ASYNC); break; } - if (key == KEY_ESC) _pEct->StopApp(); + if (key == KEY_ESC) { + ((BaseProcess*)_pEct->PWorker())->Tell(ECTMSG::SOFTWARE_END); + } return true; } diff --git a/ECTrainer2/MyWinUtils.h b/ECTrainer2/MyWinUtils.h index 70c35b5..eec65fa 100644 --- a/ECTrainer2/MyWinUtils.h +++ b/ECTrainer2/MyWinUtils.h @@ -40,6 +40,9 @@ // ���S�ȃf���[�g void SafeDelete(void** ptr); + // ���t����������擾 + std::string DateTimeStr(); + // �����x�^�C�}�[�N���X class HPTimer { LARGE_INTEGER _nFreq; // ���g�� diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index 1c40a68..2b52b0e 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -66,7 +66,7 @@ _cap.set(cv::CAP_PROP_POS_MSEC, eTime); cv::Mat frame; _cap >> frame; - _Display.Put(frame); + if (!frame.empty()) _Display.Put(frame); } } diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 84c0ff6..84bb38f 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -127,6 +127,16 @@ // �C�x���g���� bool Worker::EventProc(MSG& msg) { switch (msg.message) { + + case (int)ECTMSG::SOFTWARE_START: // �\�t�g�E�F�A�N�� + this->EventLog(_T("Software Start")); + break; + + case (int)ECTMSG::SOFTWARE_END: // �\�t�g�E�F�A�I�� + this->EventLog(_T("Software End")); + _pEct->StopApp(); + break; + case (int)ECTMSG::CALIB_START: // �L�����u���[�V�����J�n if (_AppStatus == APP_STATUS::IDLE) { _AppStatus = APP_STATUS::CALIB; @@ -205,6 +215,8 @@ // �C�x���g���O�o�� void Worker::EventLog(const TCHAR* msg) { - _ftprintf(_fpLogEvent, _T("%.1f"), _pExpTimer->Elapse()); - _ftprintf(_fpLogEvent, _T(" %s\n"), msg); + std::wstring datestr = mwut::Multi2Wide(mwut::DateTimeStr()); + + _ftprintf(_fpLogEvent, _T("%s %s\n"), datestr.c_str(), msg); + mwut::DebugPrintf(_T("%s %s\n"), datestr.c_str(), msg); } diff --git a/ECTrainer2/myWinUtils.cpp b/ECTrainer2/myWinUtils.cpp index 4b7b17c..038c70e 100644 --- a/ECTrainer2/myWinUtils.cpp +++ b/ECTrainer2/myWinUtils.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace mwut { @@ -109,6 +110,17 @@ } } + // ���t����������擾 (C++20�ɂȂ����� std::format �g�������j + std::string DateTimeStr() { + SYSTEMTIME st; + ::GetLocalTime(&st); + + char buf[20]; + sprintf_s(buf, 19, "%04d%02d%02d_%02d%02d%02d", + st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); + std::string str = buf; + return str; + } // �����x�^�C�}�[�N���X