#pragma once
#include <ctime>
#include <string>
#include <sstream>
#include <iomanip>
#include <QDateTime>
#include <WinSock2.h>
#include <windows.h>
#include <QMutex>

struct _TagProduct_LOG
{
	_TagProduct_LOG(const std::string& waferId, const std::string& msg, const std::string lotID)
	{
		m_sLotId = lotID;
		m_sWaferId = waferId;
		m_msg = msg;
		m_TimeStr = QDateTime::currentDateTime();
	}
	std::string m_msg;
	QDateTime m_TimeStr;
	std::string m_sWaferId;
	std::string m_sLotId;
};


class CRecordProductLog
{
public:
	CRecordProductLog();
	virtual ~CRecordProductLog();

	void AddLog(const std::string& lotId, const std::string& waferId, const QString &msg);

	std::list<_TagProduct_LOG> m_LogVec;
	bool m_bRunning;

	HANDLE CreateThread();

	void	AutoWriteLog();//自动将m_LogVec内容写入文件
	void	Exit();
private:
	
	QMutex	 m_AWLogMutex;//添加&记录日志的锁

	void RecordInfo(const QString& filePath, const std::list<_TagProduct_LOG>& logData);
	QString CreateFilePath(const QString& parentFolder, const QString lotId,const QString& waferId);
	HANDLE m_ThreadHandle;
public:
	QString GetPicNameByCurTime(); //获取当前保存图片的文件名
};

//extern CRecordLog gRecordLog;
