diff --git a/ECTrainer2/ECTrainer.cpp b/ECTrainer2/ECTrainer.cpp index 95e4bae..5c16551 100644 --- a/ECTrainer2/ECTrainer.cpp +++ b/ECTrainer2/ECTrainer.cpp @@ -1,10 +1,13 @@ - #include "ECTrainer.h" #include "ECTrainerGUI.h" #include "SceneCamera.h" #include "Stimulus.h" +#ifdef _DEBUG +#include +#endif + // �R���X�g���N�^ ECTrainer::ECTrainer() : _pGui(NULL) @@ -28,18 +31,23 @@ bool ECTrainer::Process() { if (!_pGui->Init()) return false; if (!_pSceneCam->Init()) return false; + if (!_pStimulus->Init()) return false; - DWORD dwThreadId; - HANDLE hThSceneCam = CreateThread(NULL, 0, SceneCamThreadEntry, this, 0, &dwThreadId); + DWORD dwThreadIdSceneCam, dwThreadIdStimulus; + HANDLE hThreadSceneCam = CreateThread(NULL, 0, SceneCamThreadEntry, this, 0, &dwThreadIdSceneCam); + HANDLE hThreadStimulus = CreateThread(NULL, 0, StimulusThreadEntry, this, 0, &dwThreadIdStimulus); _pGui->MainLoop(); - if (WaitForSingleObject(hThSceneCam, 1000) == WAIT_OBJECT_0) { + HANDLE handles[] = { hThreadSceneCam , hThreadStimulus }; + DWORD timeOut = 1000; // �^�C���A�E�g(ms) + if (WaitForMultipleObjects(sizeof(handles) / sizeof(HANDLE), handles, TRUE, timeOut) != WAIT_TIMEOUT) { #ifdef _DEBUG - std::cout << "Scene Cam thread end." << std::endl; + std::cout << "All threads properly ended." << std::endl; #endif } - CloseHandle(hThSceneCam); + CloseHandle(hThreadSceneCam); + CloseHandle(hThreadStimulus); return true; } @@ -69,3 +77,9 @@ ((ECTrainer*)lpParameter)->_pSceneCam->MainLoop(); return 0; } + +// �h���摜�X���b�h�J�n�_ +DWORD WINAPI ECTrainer::StimulusThreadEntry(LPVOID lpParameter) { + ((ECTrainer*)lpParameter)->_pStimulus->MainLoop(); + return 0; +} diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 5e635cd..fc5e269 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -16,6 +16,7 @@ bool _Running; // �X���b�h�J�n�_ static DWORD SceneCamThreadEntry(LPVOID lpParameter); + static DWORD StimulusThreadEntry(LPVOID lpParameter); public: ECTrainer(); diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index b8ca59a..d3c3144 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -7,6 +7,21 @@ Stimulus::Stimulus(ECTrainer* pEct) :_pEct(pEct) { } +// ������ +bool Stimulus::Init() { + return true; +} + +// ���[�v +bool Stimulus::MainLoop() { + while (_pEct->IsRunning()) { + Sleep(100); + } + + return true; +} + + // �L�����u���[�V�����J�n void Stimulus::StartCalib() { cv::Mat calibImg = cv::imread(CALIB_FILE); diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h index 013a684..cd877ab 100644 --- a/ECTrainer2/Stimulus.h +++ b/ECTrainer2/Stimulus.h @@ -12,6 +12,8 @@ public: Stimulus(ECTrainer* pEct); + bool Init(); + bool MainLoop(); void StartCalib(); void StartImage(); void StartMovie();