#ifndef TANK_H
#define TANK_H

#include"Standard.h"
#include <QObject>
#include<QMetaType>

#define MAX_COMPARTMENT_NUM  (4)

#define VRS_VISUAL_INSPECTION_ITEMS_NUM (8)  //油气回收系统 外观检查项个数
#define BLS_VISUAL_INSPECTION_ITEMS_NUM (5)  //底部装油系统 外观检查项个数

#define   RESULT_QUALIFIED (0)
#define   RESULT_NONCONFORM (1)
#define   RESULT_NOITEM (2)


class PressureItem{
public:
    QDateTime m_datetime;
    int m_testDirection;
    int m_testStage;
    int m_testStep;
    double m_pressure;
};

class TestResult{
public:
    double sysstart_pressure;
    double sysend_pressure;
    double delta_sys_pressure;
    bool  pass_sys_pressure;
    bool  sys_test_finished;

    double valvestart_pressure;
    double valveend_pressure;
    double delta_valve_pressure;
    bool  pass_valve_pressure;
    bool  valve_test_finished;
};


class Compartment{
public:
    Compartment();
    ~Compartment();


    int get_addpressure_timeout();
    int get_adjust_timeout();
    void clear_result();

    int m_id;
    int m_volume;

    double m_currentpressure;

    TestResult  m_result;
    bool m_testfinished;

    StandardItem m_standarditem;

    QVector<PressureItem> m_pressuredata;

};

class LeakageValue{
public:
    LeakageValue();
    ~LeakageValue();
    double couplevalve;
    double manhole;

};


class Tanker
{
public:
    Tanker();
    ~Tanker();
    Compartment& get_compartment(int id);

    QString  licenseplate_str;
    QString  companyname_str;
    int compartment_num;
    int total_volume;

    LeakageValue m_leakagevalue;

    Compartment m_comparts[MAX_COMPARTMENT_NUM];

    int vrs_results[VRS_VISUAL_INSPECTION_ITEMS_NUM];
    int bls_results[BLS_VISUAL_INSPECTION_ITEMS_NUM];

    QJsonObject get_vrs_items();
    QJsonObject get_bls_items();
    bool set_item_result(const QString& jsonStr );

    bool set_leakage_value(const QString& jsonStr);
};

Q_DECLARE_METATYPE(Tanker);

#endif // TANK_H
