#pragma once
#include <stdio.h>
#include <Windows.h>
#include <tchar.h>
#include "GOpenCV.h"
#include "RingBuffer.h"
#include "myWinUtils.h"
namespace mwut {
class HPTimer;
};
class BaseProcess;
class ECTrainer;
enum class APP_STATUS;
// ワーカークラス
// アプリケーションの状態管理
// アイコンタクト判定
// ログ出力
class Worker : public BaseProcess
{
const TCHAR* SOUND_OK = _T("../voices/OK_S.wav");
const TCHAR* SOUND_GOOD = _T("../voices/Good_S.wav");
const TCHAR* SOUND_NICE = _T("../voices/Nice_S.wav");
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* EVENT_LOG_FILE = _T("LogEvent.txt");
const int FEEDBACK_TIME = 3000; // フィードバックの時間(1レベル)msec
const int NOHIT_TIME = 100; // 視線が外れたと判定する時間 msec
APP_STATUS _AppStatus; // アプリケーション状態
FILE* _fpLogData; // データログファイルポインタ
FILE* _fpLogEvent; // イベントログファイルポインタ
mwut::HPTimer* _pExpTimer; // 実験経過時間
mwut::HPTimer* _pContactTimer; // 目標コンタクト時間
mwut::HPTimer* _pNohitTimer; // 視線外れ時間
RingBuffer<cv::Mat> _TargetImage; // ターゲット画像
int _FBLevel; // フィードバックレベル 1〜5
bool _IsInside; // 視線がターゲットにあるか
// イベントログ出力
void EventLog(const TCHAR* msg);
// 基本処理
bool Routine();
// イベント処理
bool EventProc(MSG& msg);
// 判定パラメータをリセット
void ResetParams();
public:
// コンストラクタ
Worker(ECTrainer* pEct);
// デストラクタ
~Worker();
// 初期化
bool Init();
// アプリケーション状態の取得
APP_STATUS GetAppStatus() { return _AppStatus; }
// ターゲット画像の更新状態
bool IsNewTargetImg() { return _TargetImage.IsNew(); }
// ターゲット画像取得
cv::Mat GetTargetImg() { return _TargetImage.Get(); }
};