#include "pch.h"
#include "Logger.h"
#include "Source/Settings/SysConfigger.h"
#include "BD357Ctrl.h"
#include "MainGrabber.h"
#include "ZZ_Types.h"
#include "DataFileProcessor.h"
#include "MakeDarkCurrentTable.h"
using namespace std;

int main(int argc, char* argv[])
{
	using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
	using namespace ZZ_MISCDEF::MISC_DETECTOR;

	QCoreApplication a(argc, argv);

	//long long int a1;// 8
	//long long b;     // 8
	//double c;        // 8
	//qDebug()<<sizeof(a1)<< sizeof(b)<<sizeof(c);
	/////
	bool bRes = false;
	
	OneFSContext m_struFSParam;
	GPSInfo      m_struGPSInfo;
	//FodisRP      m_struMiscRunParams;
		 
	ZZ_SysConfigger       m_syscfSettings;
	BD357Controller       m_ctrlGPS;
	CMainGrabber          m_mgMainGrabber;
	DataFileProcessor     m_dfpDataSaver;

	///configger
	m_syscfSettings.Initialize();
	bRes = m_syscfSettings.LoadSettings_FS(m_struFSParam);
	if (!bRes)
	{
		qDebug() << "LoadSettings_FS Err." << endl;
		return 1;
	}
	bRes = m_syscfSettings.LoadSettings_GPS(m_struGPSInfo);
	if (!bRes)
	{
		qDebug() << "LoadSettings_GPS Err." << endl;
		return 1;
	}
	/////
	m_ctrlGPS.Initialize(m_struGPSInfo);

	QThread* m_pqDataGrabberThreadHolder = new QThread();
	m_mgMainGrabber.moveToThread(m_pqDataGrabberThreadHolder);

	m_mgMainGrabber.SetRunParams(m_struFSParam);
	m_mgMainGrabber.SetContext(m_ctrlGPS, m_dfpDataSaver);

	m_mgMainGrabber.Initialize();

	m_pqDataGrabberThreadHolder->start();

	m_ctrlGPS.SyncDateOnce();
	cout << "Hello CMake." << endl;
	///////
	//MakeDCT m_test;
	//m_test.SetRunParams(m_struFSParam);
	//m_test.Initialize_Part();
	//m_test.MakeTable();
	////m_test.LoadTable();


	return a.exec();
}