#ifndef CMOS_H
#define CMOS_H

#include "binning.h"
#include "capabilities.h"
#include "flip.h"
#include "imageparameters.h"
#include "limits.h"
#include "roi.h"
#include "save2filetexts.h"
#include "skip.h"
#include <QObject>

typedef enum { global, rolling } shutterType;

class CMOS : public QObject {
  Q_OBJECT
public:
  CMOS();

  QString getSensorName() { return this->sensorName; }
  bool getAEC() { return this->AEC; }
  bool getAGC() { return this->AGC; }
  bool getHDR() { return this->HDR; }
  bool getTest() { return this->test; }
  uint8_t getBrightness() { return this->brightness; }
  uint8_t getManualGain() { return this->manual_gain; }
  uint32_t getExposureTime() { return this->exposure_time; }
  shutterType getShutterType() { return this->shut; }
  Capabilities getCapabilities() { return this->cap; }
  Flip getFlip() { return this->flp; }
  Binning getBinning() { return this->bin; }
  Skip getSkip() { return this->skip; }
  Limits getLimits() { return this->lim; }
  ROI getROI() { return this->roi; }
  ImageParameters getImg() { return this->img; }

  float gainToReal(uint8_t gain);
  uint8_t gainToSensor(float gain);

  bool saveCMOS(QString name);
  bool loadCMOS(QString name);

  void copyParameters(CMOS *toCopy);

private:
  QString sensorName;
  bool AEC;
  bool AGC;
  bool HDR;
  bool test;
  uint8_t brightness;
  uint8_t manual_gain;
  uint32_t exposure_time;
  shutterType shut;
  Capabilities cap;
  Flip flp;
  Binning bin;
  Skip skip;
  Limits lim;
  ROI roi;
  ImageParameters img;

signals:
  void sensorDataUpdated(uint8_t);
public slots:
  void processSensorData(uint8_t, QByteArray &);
  void refreshAEC(void);
  void refreshAGC(void);
  void refreshHDR(void);
  void refreshBright(void);
  void refreshExposure(void);
  void refreshGain(void);
  void refreshBinning(void);
  void refreshSkip(void);
  void refreshFlip(void);
  void refreshROI(void);
};

#endif // CMOS_H
