#ifndef AKBMONITORPAGE_H
#define AKBMONITORPAGE_H

#include <QWidget>
#include <QLineEdit>
#include <QTimer>

#include "bmsinterface.h"


namespace Ui {
class AkbMonitorPage;
}

class AkbMonitorPage : public QFrame
{
    Q_OBJECT

public:
    explicit AkbMonitorPage(QWidget *parent = nullptr);
    ~AkbMonitorPage();

    void clearControlls();

    BMSInterface *bms() const;
    void setDieBieMS(BMSInterface *dieBieMS);

public slots:
    void onLoadParams();

private slots:
    void timerSlot();
    void valuesReceived(BMS_VALUES values);
    // void cellsReceived(int cellCount, QVector<double> cellVoltageArray);

private:
    Ui::AkbMonitorPage *ui;

    BMSInterface *mDieBieMS;


//    bool addParamRow(QLineEdit* edit, ConfigParams *params, QString paramName);

    //
    QVector<double> mSoc;

    QVector<double> mPackVoltage;
    QVector<double> mPackCurrent;

    QVector<double> mLCLoadVoltage;
    QVector<double> mLCLoadCurrent;

    QVector<double> mHCLoadVoltage;
    QVector<double> mHCLoadCurrent;

    QVector<double> mChargerVoltage;

    QVector<double> mAuxVoltage;
    QVector<double> mAuxCurrent;

    QVector<double> mCellVHigh;
    QVector<double> mCellVAverage;
    QVector<double> mCellVLow;

    QVector<double> mTempBMSHigh;
    QVector<double> mTempBMSAverage;
    QVector<double> mTempBMSLow;

    QVector<double> mTempBattHigh;
    QVector<double> mTempBattAverage;
    QVector<double> mTempBattLow;

    QVector<double> mHumidity;

    QVector<double> mSeconds;

    double mSecondCounter;
    qint64 mLastUpdateTime;
    bool mUpdateValPlot;

    QTimer* mTimer;

    void initForPlot();

    void initForCharts();

    void appendDoubleAndTrunc(QVector<double> *vec, double num, int maxSize);
};

#endif // AKBMONITORPAGE_H
