#ifndef CAMERAFLIR_H
#define CAMERAFLIR_H

#include <thread>
#include <vector>

#include "FLIRstatus.h"
#include "../ISensor.h"

#define KERNEL_BUFFER_SZ 2000

struct ICamera
{
    ICamera()
    {

    }
    ICamera(std::string serial)
    {
        this->serial = serial;
    }
    std::string name;
    std::string serial;
};

class SerialHandler;

class CameraFLIR : public ISensor
{
    // ISensor interface
public:
    bool connect();
    bool disconnect();
    void setDirectory(std::string path);
    void setRecord(bool recording);
    void sharedStatusMemory(void *status);

public:
    CameraFLIR();
    ~CameraFLIR();

    void addCamera(std::string sn);
    void addCamera(ICamera camera);
    bool makeFile(std::string snapPath);
    void startRecord();
    void stopRecord();

    void forceRecord();
    std::string getLastFilePath(int id);

    void setDMITarget(int count);

    void setConfig(int num);
    void saveConfig(int num);
    void setController(std::string name);

private:
    void update(int id);
    void mainHandler();
    bool _recorded;
    int _cameraCount;

    int _dmiCount;
    int _targetCount;

    int _countBuf;

    std::string _controller;

    std::vector<ICamera> _iCamList;

    FLIRStatus *_status;
    std::thread **_statusThread;
    std::thread *_mainThread;
    SerialHandler *_serialHandler;

    int _config[9];
};

#endif // CAMERAFLIR_H
