#pragma once
#include "pch.h"
#include "AbsFSController.h"
#include "DataFileProcessor.h"
#include "BD357Ctrl.h"
#include "MakeDarkCurrentTable.h"
#include <atomic>
#include <vector>

class CMainGrabber :public QObject
{
	Q_OBJECT
public:
	CMainGrabber(QObject* parent = nullptr);
	~CMainGrabber();
public:
	void SetRunParams(OneFSContext struFSRunParams);
	int  SetContext(BD357Controller &pctrlGPS, DataFileProcessor &dfpDataSaver);

	int  Initialize();
public:
	atomic_int           m_iFlagIsCapture;
private:
	MakeDCT m_DCTable;

	OneFSContext         m_struFSRunParams;

	DataFileProcessor   *m_dfpDataSaver;
	CAbsFSController    *m_pctrlFS;
	BD357Controller     *m_pctrlGPS;

	std::vector<DataFrame> m_vecDataFrame;
	DataFrame              m_dfBackground;
	DeviceAttribute        m_struDeviceAttr;
private:
	void Delay_MSec(ZZ_U16 usMS);
	int InitializeWorkers();
	int SetupMsgPipelines();
	int LoadDCT();
	int CheckExposureTime(DataFrame dfTemp);
	int RemoveBackground (DataFrame &dfTemp);
public slots:
	int StartGrab();
	int Initialize_Self();
signals:
	void Signal_InitSelf();
	void Signal_InitFinished();
};