#pragma once
#include "pv/PvApp.h"

// 峰谷套利策、需求响应、自发自用

class PanelPolicyPeak : public PvObject
{
public:
    PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, int ih);

    void updateUI();

    void setTimeText(int id, std::string s);

    void parseAttr(std::string str);
    std::string dumpAttr();

    struct {
        int parent {};

        int label1 {PV_ID_NUL};
        int label2 {PV_ID_NUL};

        int radioPolicy1 {PV_ID_NUL};
        int radioPolicy2 {PV_ID_NUL};

        int attr1TimeCharge0 {PV_ID_NUL};
        int attr1TimeCharge1 {PV_ID_NUL};
        int attr1TimeDischarge0 {PV_ID_NUL};
        int attr1TimeDischarge1 {PV_ID_NUL};

        int attr1RadioPowerInAuto {PV_ID_NUL};
        int attr1RadioPowerIn {PV_ID_NUL};
        int arrt1LabelPowerIn {PV_ID_NUL};

        int attr1RadioPowerOutAuto {PV_ID_NUL};
        int attr1RadioPowerOut {PV_ID_NUL};
        int arrt1LabelPowerOut {PV_ID_NUL};

        int attr2TimeCharge0 {PV_ID_NUL};
        int attr2TimeCharge1 {PV_ID_NUL};
        int attr2TimeDischarge0 {PV_ID_NUL};
        int attr2TimeDischarge1 {PV_ID_NUL};

        int attr2RadioPowerInAuto {PV_ID_NUL};
        int attr2RadioPowerIn {PV_ID_NUL};
        int arrt2LabelPowerIn {PV_ID_NUL};

        int attr2RadioPowerOutAuto {PV_ID_NUL};
        int attr2RadioPowerOut {PV_ID_NUL};
        int arrt2LabelPowerOut {PV_ID_NUL};

        std::vector<std::vector<int>> vecComboxs {};
        
    } ui;

    struct ChargeAttr
    {
        std::string chargeTimeStart;
        std::string chargeTimeEnd;
        double chargePower {0.0};

        std::string dischargeTimeStart;
        std::string dischargeTimeEnd;
        double dischargePower {0.0};
    };

    struct {
        int times {1};
        ChargeAttr attr1;
        ChargeAttr attr2;
        std::vector<std::vector<int>> vecPeriods;
    } data;
};


class PanelPolicyRequire : public PvObject
{
public:
    PanelPolicyRequire(PARAM* p, int parent, int ix, int iy, int iw, int ih);

    void parseAttr(std::string str);
    std::string dumpAttr();

    struct {
        int label1;
        int label2;

        int chargeSoc;
        int chargePower;

        int dischargeSoc;
        int dischargePower;
    } ui;

    struct {
        int chargeSoc {};
        int chargePower {};

        int dischargeSoc {};
        int dischargePower {};
    } data;
};

class PanelPolicySelf : public PvObject
{
public:
    PanelPolicySelf(PARAM* p, int parent, int x, int y, int w, int h);

    void parseAttr(std::string str);
    std::string dumpAttr();

    struct {
        int label1;
        int usedSoc;
        int gridSoc;

        int chargePower;
        int dischargePower;
    } ui;

    struct {
        int usedSoc {};
        int gridSoc {};

        int chargePower {};
        int dischargePower {};
    } data;
};