Newer
Older
PrismSoftware / ECTrainer2 / Worker.h
#pragma once

#include <stdio.h>
#include <Windows.h>
#include <tchar.h>
#include "GOpenCV.h"
#include "RingBuffer.h"

namespace mwut {
	class HPTimer;
};

class BaseProcess;
class ECTrainer;
enum class APP_STATUS;

// ワーカークラス
// アプリケーションの状態管理
// アイコンタクト判定
// ログ出力
class Worker : public BaseProcess
{
	const TCHAR* DATA_LOG_FILE = _T("LogData.csv");
	const TCHAR* EVENT_LOG_FILE = _T("LogEvent.txt");
	APP_STATUS _AppStatus;	// アプリケーション状態
	FILE* _fpLogData;		// データログファイルポインタ
	FILE* _fpLogEvent;		// イベントログファイルポインタ
	mwut::HPTimer* _pExpTimer;	// 実験経過時間
	mwut::HPTimer* _pContactTimer;	// 目標コンタクト時間
	RingBuffer<cv::Mat> _TargetImage;	// ターゲット画像

	// イベントログ出力
	void EventLog(const TCHAR* msg);
	// 基本処理
	bool Routine();
	// イベント処理
	bool EventProc(MSG& msg);

public:
	// コンストラクタ
	Worker(ECTrainer* pEct);
	// デストラクタ
	~Worker();
	// 初期化
	bool Init();
	// アプリケーション状態の取得
	APP_STATUS GetAppStatus() { return _AppStatus; }
	// ターゲット画像の更新状態
	bool IsNewTargetImg() { return _TargetImage.IsNew(); }
	// ターゲット画像取得
	cv::Mat GetTargetImg() { return _TargetImage.Get(); }

};