diff --git a/ECTrainer2/ECTrainer.cpp b/ECTrainer2/ECTrainer.cpp index 2560f56..0fa1082 100644 --- a/ECTrainer2/ECTrainer.cpp +++ b/ECTrainer2/ECTrainer.cpp @@ -39,6 +39,9 @@ // ������ bool ECTrainer::Process() { + PWorker()->EventLog(_T("")); + PWorker()->EventLog(_T("Software Start")); + // �v���Z�X������ for (int i = 0; i < (int)PROC::NUM; i++) { if (!_pProcs[i]->Init()) return false; diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 0e3db05..b40426b 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -6,8 +6,8 @@ //#define TOBII_ADDR "192.168.71.50" #define TOBII_ADDR "192.168.23.155" -#define EYEDEVICE_GLASS2 -//#define EYEDEVICE_NONE +//#define EYEDEVICE_GLASS2 +#define EYEDEVICE_NONE class BaseProcess; class ECTrainerGUI; diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 3b70790..345fe5d 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -18,7 +18,6 @@ // �R���X�g���N�^ ECTrainerGUI::ECTrainerGUI(ECTrainer* pEct) : BaseProcess(pEct) , _hWndMain(NULL) - , _Booting(true) { } @@ -157,12 +156,6 @@ ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SOFTWARE_END); } - // �����GUI�\�������������Ƃ���ŋN�����b�Z�[�W���M - if (_Booting) { - _Booting = false; - ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SOFTWARE_START); - } - Sleep(1); return true; diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 5062b8e..361d6c0 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -26,7 +26,6 @@ cv::Mat _Logo; // ���S cv::Mat _blank; // �u�����N HWND _hWndMain; // ���C���E�C���h�E�̃n���h�� - BOOL _Booting; // �N������t���O // ��{���� bool Routine(); diff --git a/ECTrainer2/SceneCamera.cpp b/ECTrainer2/SceneCamera.cpp index 99ef7e0..c5c6676 100644 --- a/ECTrainer2/SceneCamera.cpp +++ b/ECTrainer2/SceneCamera.cpp @@ -25,7 +25,8 @@ _pEct->PWorker()->EventLog(_T("Generic camera connected.")); #endif if (!_SceneCam.isOpened()) { - MessageBox(NULL, _T("cannot open camera " TOBII_ADDR), NULL, 0); + MessageBox(NULL, _T("Cannot connect camera."), NULL, 0); + _pEct->PWorker()->EventLog(_T("Cannot connect camera.")); return false; } // �摜�T�C�Y��ۑ� diff --git a/ECTrainer2/TobiiREST.cpp b/ECTrainer2/TobiiREST.cpp index 4167f1e..523be25 100644 --- a/ECTrainer2/TobiiREST.cpp +++ b/ECTrainer2/TobiiREST.cpp @@ -1,6 +1,7 @@ #include "ECTrainer.h" #include "TobiiREST.h" #include "ECTrainerGUI.h" +#include "Worker.h" #include "myWinUtils.h" // �R���X�g���N�^ @@ -33,6 +34,7 @@ catch (const std::exception & e) { UNREFERENCED_PARAMETER(e); // e.what() ���}���`�o�C�g������Ȃ̂Ŏg���Ȃ� + _pEct->PWorker()->EventLog(_T("Can't connect Tobii Device.")); _pEct->MsgBox(_T("Can't connect Tobii Device."), MB_ICONERROR); return false; } diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 79f88db..667b49c 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -33,13 +33,6 @@ // ������ bool Worker::Init() { - if (_tfopen_s(&_fpLogData, DATA_LOG_FILE, _T("w")) != 0) { - _pEct->MsgBox(_T("Can't open data log file."), MB_ICONERROR); - return false; - } - _ftprintf(_fpLogData, _T("time,stimNo,stimTime,gazeVx,gazeVy,gazeIx,gazeIy,target,contact time,Feedback,RR," - "H11,H12,H13,H21,H22,H23,H31,H32,H33\n")); - _AppStatus = APP_STATUS::IDLE; @@ -119,14 +112,14 @@ } // ���O�o�� - if (stimNo >= 0) { + if (stimNo >= 0 && _fpLogData != NULL) { _ftprintf(_fpLogData, _T("%.3f"), _pExpTimer->Elapse() / 1000.); // �o�ߎ��� _ftprintf(_fpLogData, _T(",%d"), stimNo); // �h���f�[�^�ԍ� _ftprintf(_fpLogData, _T(",%.3f"), _pEct->PStimulus()->GetStimTime() / 1000.); // �h���񎦂̌o�ߎ��� _ftprintf(_fpLogData, _T(",%.1f,%.1f"), gazeV.x, gazeV.y); // �����_�i����J�������W�j _ftprintf(_fpLogData, _T(",%.1f,%.1f"), gazeI.x, gazeI.y); // �����_�i�摜���W�j _ftprintf(_fpLogData, _T(",%d"), hit + 1); // �^�[�Q�b�g���� - _ftprintf(_fpLogData, _T(",%.2f"), hit < 0 ? -1 : _pContactTimer->Elapse()/1000.); // �ڕW�R���^�N�g���� + _ftprintf(_fpLogData, _T(",%.2f"), hit < 0 ? -1 : _pContactTimer->Elapse() / 1000.); // �ڕW�R���^�N�g���� _ftprintf(_fpLogData, _T(",%d"), fb); // �t�B�[�h�o�b�N _ftprintf(_fpLogData, _T(",%d"), _pEct->PBitalMonitor()->GetRR()); // �o�C�^���o��(RR�Ԋu�j // �z���O���t�B�s��o�� @@ -156,7 +149,6 @@ switch (msg.message) { case (int)ECTMSG::SOFTWARE_START: // �\�t�g�E�F�A�N�� - this->EventLog(_T("\nSoftware Start")); break; case (int)ECTMSG::SOFTWARE_END: // �\�t�g�E�F�A�I�� @@ -188,7 +180,7 @@ case (int)ECTMSG::EXP_START: // �����J�n if (_AppStatus == APP_STATUS::IDLE) { - + this->OpenDataLog(); this->EventLog(_T("Experiment Start")); _pExpTimer->Reset(); this->ResetParams(); @@ -199,6 +191,7 @@ case (int)ECTMSG::EXP_STOP: // ������~ if (_AppStatus == APP_STATUS::STIM) { + this->CloseDataLog(); _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::EXP_STOP); this->EventLog(_T("Experiment Stopped")); @@ -207,7 +200,7 @@ case (int)ECTMSG::EXP_END: // �����I�� if (_AppStatus == APP_STATUS::STIM) { - if (_fpLogData) fclose(_fpLogData); + this->CloseDataLog(); _AppStatus = APP_STATUS::IDLE; ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::EXP_END); this->EventLog(_T("Experiment Finished")); @@ -258,6 +251,30 @@ return true; } +// �f�[�^���O�t�@�C�����J�� +void Worker::OpenDataLog() { + this->CloseDataLog(); // �O�̂��ߕ‚��� + + auto filename = DATA_LOG_FILE + mwut::Multi2Wide(mwut::DateTimeStr()) + _T(".csv"); + + if (_tfopen_s(&_fpLogData, filename.c_str(), _T("w")) != 0) { + _pEct->MsgBox(_T("Can't open data log file."), MB_ICONERROR); + return; + } + + // �w�b�_�s + _ftprintf(_fpLogData, _T("time,stimNo,stimTime,gazeVx,gazeVy,gazeIx,gazeIy,target,contact time,Feedback,RR," + "H11,H12,H13,H21,H22,H23,H31,H32,H33\n")); +} + +// �f�[�^���O�t�@�C�����J�� +void Worker::CloseDataLog() { + if (_fpLogData) { + fclose(_fpLogData); + _fpLogData = NULL; + } +} + // �C�x���g���O�o�� void Worker::EventLog(const TCHAR* msg) { @@ -267,9 +284,13 @@ return; } - std::wstring datestr = mwut::Multi2Wide(mwut::DateTimeStr()); - _ftprintf(fp, _T("%s %s\n"), datestr.c_str(), msg); - mwut::DebugPrintf(_T("%s %s\n"), datestr.c_str(), msg); + if (_tcslen(msg) < 1) { + _ftprintf(fp, _T("\n")); + } else { + std::wstring datestr = mwut::Multi2Wide(mwut::DateTimeStr()); + _ftprintf(fp, _T("%s %s\n"), datestr.c_str(), msg); + mwut::DebugPrintf(_T("%s %s\n"), datestr.c_str(), msg); + } fclose(fp); } diff --git a/ECTrainer2/Worker.h b/ECTrainer2/Worker.h index 906f7d0..29083ba 100644 --- a/ECTrainer2/Worker.h +++ b/ECTrainer2/Worker.h @@ -27,7 +27,7 @@ const TCHAR* SOUND_GREAT = _T("../voices/Great_S.wav"); const TCHAR* SOUND_EXCELLENT = _T("../voices/Excellent_S.wav"); const TCHAR* SOUND_GOOUT = _T("../voices/KbdKeyTap.wav"); - const TCHAR* DATA_LOG_FILE = _T("LogData.csv"); + const TCHAR* DATA_LOG_FILE = _T("LogData"); const TCHAR* EVENT_LOG_FILE = _T("LogEvent.txt"); const int FEEDBACK_TIME = 3000; // �t�B�[�h�o�b�N�̎��ԁi1���x���jmsec const int NOHIT_TIME = 100; // �������O�ꂽ�Ɣ��肷�鎞�� msec @@ -47,6 +47,10 @@ bool EventProc(MSG& msg); // ����p�����[�^�����Z�b�g void ResetParams(); + // �f�[�^���O�t�@�C�����J�� + void OpenDataLog(); + // �f�[�^���O�t�@�C�����J�� + void CloseDataLog(); std::string ClassName() { return "Worker"; } // FPS�\��