实现策略配置功能

This commit is contained in:
lixiaoyuan
2025-08-28 18:42:37 +08:00
parent 8f6c83147b
commit dda905cda0
47 changed files with 1311 additions and 863 deletions

View File

@@ -20,13 +20,12 @@ std::string GetDateTimeWeekday()
return ss.str();
}
int MaskMain::initUI()
{
//pvSetStyleSheet(p, PV_ID_MAIN, "color: white; font: normal 14px \"微软雅黑\";");
ui.bkg = PvApp::pvid(p);
PvApp::image(p, 0, 0, 0, 1920, 1080, "bkg.png");
PvApp::label(p, PV_ID_MAIN, 0, 0, 1920, 1080, "", "background-color: rgb(1, 32, 54)");
PvApp::image(p, 0, 0, 0, 1920, 90, "bkgHead.png");
ui.datetime = PvApp::label(p, PV_ID_MAIN, 10, 30, 420, 30, GetDateTimeWeekday(), qss::label(20));
pvSetAlignment(p, ui.datetime, AlignCenter);

View File

@@ -5,6 +5,72 @@
#define FONT_NAME "微软雅黑"
PvRect::PvRect()
{
}
PvRect::PvRect(int ix, int iy, int iw, int ih)
: x(ix), y(iy), w(iw), h(ih)
{
}
PvRect& PvRect::set(int ix, int iy, int iw, int ih)
{
x = ix;
y = iy;
w = iw;
h = ih;
return *this;
}
PvRect& PvRect::setx(int ix)
{
x = ix;
return *this;
}
PvRect& PvRect::sety(int iy)
{
y = iy;
return *this;
}
PvRect& PvRect::setw(int iw)
{
w = iw;
return *this;
}
PvRect& PvRect::seth(int ih)
{
h = ih;
return *this;
}
PvRect& PvRect::shiftx(int ix)
{
x += ix;
return *this;
}
PvRect& PvRect::shifty(int iy)
{
y += iy;
return *this;
}
PvRect& PvRect::shiftw(int iw)
{
w += iw;
return *this;
}
PvRect& PvRect::shifth(int ih)
{
h += ih;
return *this;
}
void PvApp::setPvUser(PARAM* p, PvUser* pvuser)
{
p->user = pvuser;
@@ -23,10 +89,8 @@ int PvApp::pvid(PARAM* p)
void PvApp::reset(PARAM* p)
{
// 清理event回调
auto pvuser = PvApp::getPvUser(p);
pvuser->mapEventCallback.clear();
pvuser->pvidIndex = 0;
if (pvuser) { pvuser->reset(); }
}
EPvCode PvApp::getPvCode(std::string name)
@@ -64,7 +128,6 @@ EPvCode PvApp::getPvCode(std::string name)
}
}
void PvApp::bind(PARAM* p, PvEvent eid, int pvid, std::function<void(std::string text)> cb)
{
auto pvuser = PvApp::getPvUser(p);
@@ -99,13 +162,22 @@ int PvApp::widget(PARAM* p, int parent, int x, int y, int w, int h)
int PvApp::label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
{
static const std::string style = "QLabel { border: none; background-color: transparent; } QLabel:disabled { color: gray;}";
int id = PvApp::pvid(p);
pvQLabel(p, id, parent);
pvSetGeometry(p, id, x, y, w, h);
if (!text.empty()) { pvSetText(p, id, text.c_str()); }
pvSetStyleSheet(p, id, qss.empty() ? qss::label().c_str() : qss.c_str());
pvSetStyleSheet(p, id, qss.empty() ? style.c_str() : qss.c_str());
return id;
}
int PvApp::labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
{
int id = PvApp::label(p, parent, x, y, w, h, text, qss);
pvSetAlignment(p, id, AlignCenter);
return id;
}
int PvApp::labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
{
int id = PvApp::label(p, parent, x, y, w, h, text, qss);
@@ -128,7 +200,6 @@ int PvApp::image(PARAM* p, int parent, int x, int y, int w, int h, const char* f
int id = PvApp::pvid(p);
pvQImage(p, id, parent, filename);
pvSetGeometry(p, id, x, y, w, h);
//if (!qss.empty()) { pvSetStyleSheet(p, id, qss.c_str()); }
return id;
}
@@ -147,7 +218,7 @@ int PvApp::combox(PARAM* p, int parent, int x, int y, int w, int h, const std::v
return id;
}
int PvApp::lineEdit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
{
int id = PvApp::pvid(p);
pvQLineEdit(p, id, parent);
@@ -157,11 +228,11 @@ int PvApp::lineEdit(PARAM* p, int parent, int x, int y, int w, int h, std::strin
return id;
}
int PvApp::textEdit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
{
static std::string style =
"QTextEdit { background-color: rgb(12, 39, 58); border: 1px solid rgb(18, 251, 255); border-radius: 5px; color:white; font: bold 15px;}"
"QTextEdit:disabled { border: 1px solid gray; color:rgb(150,150,150);}";
"QTextEdit { background-color: rgb(12, 39, 58); border: 1px solid rgb(18, 251, 255); border-radius: 3px; color:white; font: bold 14px;}"
"QTextEdit:disabled { border: none; color: gray;}";
int id = PvApp::pvid(p);
pvQMultiLineEdit(p, id, parent, true, 10);
pvSetGeometry(p, id, x, y, w, h);
@@ -174,7 +245,7 @@ int PvApp::radioButton(PARAM* p, int parent, int x, int y, int w, int h, std::st
{
static std::string style =
"QRadioButton { background-color: transparent; color:white; font: bold 14px \"微软雅黑\";}"
"QRadioButton:disabled { border: none; color:rgb(150,150,150);}";
"QRadioButton:disabled { border: none; color: gray;}";
int id = PvApp::pvid(p);
pvQRadioButton(p, id, parent);
@@ -188,7 +259,7 @@ int PvApp::timeEdit(PARAM* p, int parent, int x, int y, int w, int h)
{
static std::string style =
"QTimeEdit { background-color: rgb(17, 55, 73); border: 1px solid rgb(0, 185, 208); color:white; font: normal 14px \"微软雅黑\";}"
"QTimeEdit:disabled { border: none; color:rgb(150,150,150);}";
"QTimeEdit:disabled { border: none; color: gray;}";
int id = PvApp::pvid(p);
pvQTimeEdit(p, id, parent);
@@ -197,67 +268,15 @@ int PvApp::timeEdit(PARAM* p, int parent, int x, int y, int w, int h)
return id;
}
PvRect::PvRect()
int PvApp::lineLabel(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val)
{
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, qss::label(14));
return PvApp::label(p, pid, w, 0, rect.w-w, rect.h, val);
}
PvRect::PvRect(int ix, int iy, int width, int height)
: x(ix), y(iy), w(width), h(height)
int PvApp::lineTextedit(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val)
{
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, qss::label(14));
return PvApp::textedit(p, pid, w, 0, rect.w-w, rect.h, val);
}
PvRect& PvRect::set(int ix, int iy, int width, int height)
{
x = ix;
y = iy;
w = width;
h = height;
return *this;
}
PvRect& PvRect::set_x(int ix)
{
x = ix;
return *this;
}
PvRect& PvRect::set_y(int iy)
{
y = iy;
return *this;
}
PvRect& PvRect::set_w(int iw)
{
w = iw;
return *this;
}
PvRect& PvRect::set_h(int ih)
{
h = ih;
return *this;
}
PvRect& PvRect::shift_x(int ix)
{
x += ix;
return *this;
}
PvRect& PvRect::shift_y(int iy)
{
y += iy;
return *this;
}
PvRect& PvRect::shift_w(int iw)
{
w += iw;
return *this;
}
PvRect& PvRect::shift_h(int ih)
{
h += ih;
return *this;
}

View File

@@ -53,6 +53,51 @@ enum class EPvCode
MASK_MGR_ALERTLOG,
};
///////////////////////////////////////////////////////////////////////////////////////////////////
/// === PvRect
class PvRect
{
public:
PvRect();
PvRect(int ix, int iy, int iw, int ih);
PvRect& set(int ix, int iy, int iw, int ih);
PvRect& setx(int ix);
PvRect& sety(int iy);
PvRect& setw(int iw);
PvRect& seth(int ih);
PvRect& shiftx(int ix);
PvRect& shifty(int iy);
PvRect& shiftw(int iw);
PvRect& shifth(int ih);
public:
int x = 0;
int y = 0;
int w = 100;
int h = 30;
};
struct PvColor
{
int r;
int g;
int b;
int a;
PvColor(int r, int g, int b, int a = 255) : r(r), g(g), b(b), a(a) {}
std::string rgb()
{
return "rgb(" + std::to_string(r) + "," + std::to_string(g) + "," + std::to_string(b) + ")";
}
std::string rgba()
{
return "rgb(" + std::to_string(r) + "," + std::to_string(g) + "," + std::to_string(b) + "," + std::to_string(a) + ")";
}
};
class PvObject
{
public:
@@ -93,6 +138,8 @@ public:
static int label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int button(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
@@ -101,57 +148,16 @@ public:
static int combox(PARAM* p, int parent, int x, int y, int w, int h, const std::vector<std::string>& vecItems, int index=0);
static int lineEdit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int textEdit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int radioButton(PARAM* p, int parent, int x, int y, int w, int h, std::string text);
static int timeEdit(PARAM* p, int parent, int x, int y, int w, int h);
static int lineLabel(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val);
static int lineTextedit(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val);
};
///////////////////////////////////////////////////////////////////////////////////////////////////
/// === PvRect
class PvRect
{
public:
PvRect();
PvRect(int ix, int iy, int width, int height);
PvRect& set(int ix, int iy, int width, int height);
PvRect& set_x(int ix);
PvRect& set_y(int iy);
PvRect& set_w(int iw);
PvRect& set_h(int ih);
PvRect& shift_x(int ix);
PvRect& shift_y(int iy);
PvRect& shift_w(int iw);
PvRect& shift_h(int ih);
public:
int x = 0;
int y = 0;
int w = 100;
int h = 32;
};
struct PvColor
{
int r;
int g;
int b;
int a;
PvColor(int r, int g, int b, int a = 255) : r(r), g(g), b(b), a(a) {}
std::string rgb()
{
return "rgb(" + std::to_string(r) + "," + std::to_string(g) + "," + std::to_string(b) + ")";
}
std::string rgba()
{
return "rgb(" + std::to_string(r) + "," + std::to_string(g) + "," + std::to_string(b) + "," + std::to_string(a) + ")";
}
};

View File

@@ -206,7 +206,7 @@ void PvChartBar::updateItem(int index, std::vector<std::pair<std::string, double
/// === PvChartCurve
PvChartCurve::PvChartCurve(PARAM* p, int parent, int x, int y, int w, int h) : PvObject(p)
{
rect_.set(x, y, w, h);
rect.set(x, y, w, h);
pvid_ = PvApp::label(p, parent, x, y, w, h, "", "border: none; border-radius: 0px; background-color: transparent;");
plotId_ = PvApp::pvid(p);
pvQwtPlotWidget(p, plotId_, pvid_, 100, 100);
@@ -242,7 +242,7 @@ PvChartCurve::PvChartCurve(PARAM* p, int parent, int x, int y, int w, int h) : P
yLabelLeft = PvApp::label(p, pvid_, 10, 24, 100, 20, "", "border:none;color:white;font-size:14px;font-weight:bold;");
pvSetAlignment(p, yLabelLeft, AlignLeft);
yLabelRight = PvApp::label(p, pvid_, rect_.w - 100 - 10, 24, 100, 20, "", "border:none;color:white;font-size:14px;font-weight:bold;");
yLabelRight = PvApp::label(p, pvid_, rect.w - 100 - 10, 24, 100, 20, "", "border:none;color:white;font-size:14px;font-weight:bold;");
pvSetAlignment(p, yLabelRight, AlignRight);
}

View File

@@ -92,7 +92,7 @@ public:
void reviseYMax(int pos, double v);
private:
PvRect rect_;
PvRect rect;
int pvid_;
int plotId_;
int start_num_ = 0;

View File

@@ -13,9 +13,9 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
int x = (1920-width) *0.5;
int y = (1080-height) *0.5;
ui.widget = PvApp::widget(p, pvid, x, y, width, height);
PvApp::label(p, ui.widget, 2, 2, width-4, height-4, "", "background-color: rgb(12,39,58); border: 1px solid rgb(31,145,156);");
PvApp::label(p, ui.widget, 0, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 0 5px 5px;");
PvApp::label(p, ui.widget, width-60, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 5px 5px 0;");
ui.bkg = PvApp::label(p, ui.widget, 2, 2, width-4, height-4, "", "background-color: rgb(12,39,58); border: 1px solid rgb(31,145,156);");
ui.bkgL = PvApp::label(p, ui.widget, 0, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 0 5px 5px;");
ui.bkgR = PvApp::label(p, ui.widget, width-60, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 5px 5px 0;");
ui.title = PvApp::label(p, ui.widget, 20, 10, width-20, 30, name, qss::label(20));
PvApp::label(p, ui.widget, 20, 40, width*0.5-20, 3, "", qss::QSS_UNDERLINE);
@@ -24,12 +24,12 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
int x = (width- w*2 - offset) *0.5;
int y = height - h - 40;
int btnOk = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnOk, [=](std::string) {
ui.btnOK = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnOK, [=](std::string) {
if (callbackConfirm) { callbackConfirm(); }
});
int btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnCancel, [=](std::string) {
ui.btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnCancel, [=](std::string) {
this->show(false);
});
}
@@ -43,20 +43,21 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
mapLines[key] = line;
PvApp::label(p, ui.widget, x, y, lineKeyWidth, lineHeight, title, qss::label(15));
if (type == "lineEdit")
if (type == "textedit")
{
line->widget = PvApp::lineEdit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, "");
line->widget = PvApp::textedit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, "");
}
else if (type == "combox")
{
line->widget = PvApp::combox(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, {});
}
else if (type == "textEdit")
else if (type == "multiTextedit")
{
line->widget = PvApp::textEdit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight*4, "");
line->widget = PvApp::multiTextedit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight*4, "");
}
PvApp::bind(p, PvEvent::TEXT_EVENT, line->widget, [=](std::string text) {
line->val = text;
if (callbackTextEvent) callbackTextEvent(key, text);
});
if (!editable) { pvSetEnabled(p, line->widget, 0); }
return line;
@@ -64,12 +65,12 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
void PvPopWidget::addParamLineEdit(std::string key, std::string title, int x, int y, bool editable/*= true*/)
{
this->addParamLine("lineEdit", key, title, x, y, editable);
this->addParamLine("textedit", key, title, x, y, editable);
}
void PvPopWidget::addParamTextEdit(std::string key, std::string title, int x, int y, bool editable/* = true*/)
{
this->addParamLine("textEdit", key, title, x, y, editable);
this->addParamLine("multiTextedit", key, title, x, y, editable);
}
void PvPopWidget::addParamCombox(std::string key, std::string title, int x, int y, std::vector<std::string> items)
@@ -103,6 +104,8 @@ void PvPopWidget::setParamText(std::shared_ptr<ParamLine> line, std::string text
line->val = line->items[0];
pvSetCurrentItem(p, line->widget, 0);
}
// 【注意】combox 设置 item 不会触发 TEXT_EVENT
//if (callbackTextEvent) callbackTextEvent(line->key, line->val);
}
else
{
@@ -194,4 +197,20 @@ void PvPopWidget::setPrimaryKeys(std::vector<std::string> keys)
{
primaryKeys.set(k, "");
}
}
void PvPopWidget::resize(int width, int height)
{
int x = (1920-width) *0.5;
int y = (1080-height) *0.5;
pvSetGeometry(p, ui.widget, x, y, width, height);
pvSetGeometry(p, ui.bkg, 2, 2, width-4, height-4);
pvSetGeometry(p, ui.bkgL, 0, 0, 60, height);
pvSetGeometry(p, ui.bkgR, width-60, 0, 60, height);
int w = 100, h = 40, offset = 50;
x = (width- w*2 - offset) *0.5;
y = height - h - 40;
pvSetGeometry(p, ui.btnOK, x, y, w, h);
pvSetGeometry(p, ui.btnCancel, x+w+offset, y, w, h);
}

View File

@@ -35,6 +35,8 @@ public:
void setCallbackConfirm(std::function<void()> callback) { callbackConfirm = callback; };
void setCallbackTextEvent(std::function<void(std::string, std::string)> callback) { callbackTextEvent = callback; };
void setStatus(std::string text);
void setMsg(std::string msg);
@@ -44,11 +46,14 @@ public:
Fields getChangedData();
void checkChangedData(Fields& fields);
void setLineGeometry(int wKey, int wVal, int h);
void setPrimaryKeys(std::vector<std::string> keys);
int widget() { return ui.widget; }
void resize(int width, int height);
std::string name;
std::string status;
@@ -61,6 +66,11 @@ public:
struct {
int widget;
int bkg;
int bkgL;
int bkgR;
int btnOK;
int btnCancel;
int title;
int msg;
} ui;
@@ -68,6 +78,7 @@ public:
std::map<std::string, std::shared_ptr<ParamLine>> mapLines;
std::function<void()> callbackConfirm = nullptr;
std::function<void(std::string, std::string)> callbackTextEvent = nullptr;
Fields dataOrigin;
Fields primaryKeys;

View File

@@ -48,7 +48,7 @@ namespace qss
const std::string LABEL_BKG_2 = qss::label(14, "", "rgb(8, 54, 91)", "none; border-radius:5px");
const std::string LABEL_BOX = qss::label(14, "", "rgba(200,200,200,20)", "none; border-radius:2px")
const std::string LABEL_BOX = qss::label(16, "", "rgba(200,200,200,20)", "none; border-radius:2px")
+ "QLabel:hover {border: 1px solid rgb(1, 183, 209);}";
const std::string QSS_BOX_ACTIVE =
@@ -88,7 +88,6 @@ namespace qss
const std::string QSS_BTN_MGR =
"QPushButton { background-color:rgb(10, 34, 63); border-radius:5px; border:1px solid rgb(33, 105, 195); color:white; font:bold 16px;}"
"QPushButton:hover { background-color:rgb(10,125,215); border:2px solid rgb(1,239,255); color:rgb(1,239,255)}"
//"QPushButton:pressed{border-width:3px 0 0 3px;background-color:rgb(150,150,150);border-style:inset;}"
"QPushButton:pressed { border-width:3px 0 0 3px;border-style:inset; }"
"QPushButton:disabled{color:rgb(150,150,150);}";

View File

@@ -9,57 +9,56 @@ static const string STYLE_BKG =
//*********************************************************************************************************************
// PvTable
PvTable::PvTable(PARAM* p, int parent, int x, int y, int w, int row, Options& opts)
PvTable::PvTable(PARAM* p, int parent, int x, int y, int w, int irow, Options& opts)
//: PvWidget(p, parent, PvRect(x, y, w, opts.item_height* row + (opts.show_header ? (opts.header_height) : 0))),
: PvObject(p), option_(opts), nRow_(row), nCol_(0)
: PvObject(p), option(opts), nrow(irow), ncol(0)
{
// 计算表格的显示区域
int h = opts.row_height* row + (opts.show_header ? (opts.head_height) : 0);
rect_.set(x, y, w, h);
int h = opts.row_height* irow + (opts.show_header ? (opts.head_height) : 0);
rect.set(x, y, w, h);
// 表格的主窗体QWidget设置样式无效
pvid_ = PvApp::widget(p, parent, x, y, w, h+1);
pvid = PvApp::widget(p, parent, x, y, w, h+1);
// 表格的背景色和边框样式
PvApp::label(p, pvid_, 0, 0, w, h+1, "", qss::QSS_TABLE);
PvApp::label(p, pvid, 0, 0, w, h+1, "", qss::QSS_TABLE);
vecHead_.resize(0);
vecRows_.resize(nRow_);
vecData_.resize(nRow_);
vecHeads.resize(0);
vecRows.resize(nrow);
vecData.resize(nrow);
// 创建行高亮显示背景
for (int row = 0; row < nRow_; row++)
for (int row = 0; row < nrow; row++)
{
int y = item_posy(row);
int y = row * option.row_height + (option.show_header ? option.head_height : 0);
string qss = (row % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1;
int rowBkg = PvApp::label(p, pvid_, 1, y, rect_.w-2, option_.row_height, "", qss);
pvHide(p, rowBkg);
vecRows_[row].bkg = rowBkg;
int widgetRow = PvApp::label(p, pvid, 1, y, rect.w-2, option.row_height, "", qss);
pvHide(p, widgetRow);
vecRows[row].widget = widgetRow;
}
}
void PvTable::addHead(string id, string text, int width, vector<pair<string, string>> mapping)
{
vecHead_.push_back(Head(id, text, width, mapping));
nCol_ = vecHead_.size();
vecHeads.push_back(Head(id, text, width, mapping));
ncol = vecHeads.size();
if (width <= -1) { width = rect_.w-1 - posCol_; }
int col = nCol_ - 1;
if (width <= -1) { width = rect.w-1 - posCol; }
int col = ncol - 1;
// 创建表头的标签
if (option_.show_header)
if (option.show_header)
{
vecHead_[col].pvid = PvApp::label(p, pvid_, posCol_, 0, width, option_.head_height, text, qss::QSS_TABLE_HEAD);
vecHeads[col].pvid = PvApp::label(p, pvid, posCol, 0, width, option.head_height, text, qss::QSS_TABLE_HEAD);
}
// 创建列的单元格
for (int row = 0; row < nRow_; ++row)
for (int row = 0; row < nrow; ++row)
{
int y = item_posy(row);
int pvid = PvApp::label(p, pvid_, posCol_, y, width, option_.row_height, "", qss::QSS_TABLE_CELL);
vecRows_[row].vecCells.push_back(pvid);
PvApp::bind(p, MOUSE_OVER_EVENT, pvid, [=](string s) { highlight(row, (s == "1")); });
int cellId = PvApp::label(p, vecRows[row].widget, posCol, 0, width, option.row_height, "", qss::QSS_TABLE_CELL);
vecRows[row].vecCells.push_back(cellId);
PvApp::bind(p, MOUSE_OVER_EVENT, cellId, [=](string s) { highlight(row, (s == "1")); });
}
posCol_ += width;
posCol += width;
}
void PvTable::addHead(vector<string> vec_text)
@@ -68,24 +67,24 @@ void PvTable::addHead(vector<string> vec_text)
int x = 0;
for (int i = 0; i < vec_text.size(); ++i)
{
int w = float(rect_.w-1) * float(i+1) / float(colSize);
int w = float(rect.w-1) * float(i+1) / float(colSize);
string text = vec_text[i];
this->addHead(text, text, w-x);
x = w;
}
}
void PvTable::setRowVisible(int row, bool v)
void PvTable::setRowVisible(int irow, bool v)
{
if (row < 0 || row >= vecRows_.size())
if (irow < 0 || irow >= vecRows.size())
{
return;
}
auto& rowItem = vecRows_[row];
auto& rowItem = vecRows[irow];
if (rowItem.visible != v)
{
rowItem.visible = v;
rowItem.visible ? pvShow(p, rowItem.bkg) : pvHide(p, rowItem.bkg);
rowItem.visible ? pvShow(p, rowItem.widget) : pvHide(p, rowItem.widget);
if (!v)
{
for (int col = 0; col<rowItem.vecCells.size(); ++col)
@@ -96,31 +95,28 @@ void PvTable::setRowVisible(int row, bool v)
}
}
void PvTable::highlight(int row, bool v)
void PvTable::highlight(int irow, bool v)
{
string qss = ((row % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1);
if (vecRows_.size() > 0 && row <= vecRows_.size())
string qss = ((irow % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1);
if (vecRows.size() > 0 && irow <= vecRows.size())
{
if (v) { qss = "background-color:rgba(14,45,60,200);border:1px solid rgba(255,0,0,100);"; }
pvSetStyleSheet(p, vecRows_[row].bkg, qss.c_str());
pvSetStyleSheet(p, vecRows[irow].widget, qss.c_str());
}
}
void PvTable::addOperate(vector<string> vecOpt)
{
// 创建表头的标签
if (option_.show_header)
if (option.show_header)
{
PvApp::label(p, pvid_, posCol_, 0, rect_.w - posCol_, option_.head_height, "操作", qss::QSS_TABLE_HEAD);
PvApp::label(p, pvid, posCol, 0, rect.w - posCol, option.head_height, "操作", qss::QSS_TABLE_HEAD);
}
for (int row = 0; row < nRow_; ++row)
for (int row = 0; row < nrow; ++row)
{
int y = item_posy(row);
int cellWidget = PvApp::label(p, pvid_, posCol_, y, rect_.w - posCol_, option_.row_height, "", qss::QSS_TABLE_CELL);
//PvInstance::bind_event(p, MOUSE_OVER_EVENT, btn_opt, [=](string s) { highlight(row, (s == "1")); });
vecOpt_.push_back({ cellWidget, vector<int>() });
auto& vec_opt_btn_ = vecOpt_.back().second;
int cellWidget = PvApp::label(p, vecRows[row].widget, posCol, 0, rect.w - posCol, option.row_height, "", qss::QSS_TABLE_CELL);
vecOper.push_back({ cellWidget, vector<int>() });
auto& vec_opt_btn_ = vecOper.back().second;
int x = 5, w = 60;
for (int i = 0; i < vecOpt.size(); i++)
{
@@ -128,87 +124,66 @@ void PvTable::addOperate(vector<string> vecOpt)
w = 20 + 15 * title.size() / 3;
int btn = PvApp::button(p, cellWidget, x, 4, w, 24, title, qss::button(14, "", "", "none; border-radius: 0px"));
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
if (cbOperate_) { cbOperate_(row, 0, title); }
if (callbackOper) { callbackOper(row, 0, title); }
});
vec_opt_btn_.push_back(btn);
x += (w + 5);
}
pvHide(p, cellWidget);
}
}
void PvTable::setOperateCallback(CallbackTableOpt cb)
{
cbOperate_ = cb;
callbackOper = cb;
};
void PvTable::set_text(PARAM* p, int row, int col, string text, string style)
void PvTable::setRow(int irow, Fields& d)
{
if (row < nRow_ && col < nCol_)
if (irow >= nrow) { return; }
vecData[irow] = d;
for (int col = 0; col < vecHeads.size(); ++col)
{
pvSetText(p, vecRows_[row].vecCells[col], text.c_str());
if (!style.empty())
{
int idx = row + 1;
if (idx % 2 != 0)
{
style = item_base_style_ + style;
}
else
{
style = item_base_style_ + style;
}
//style = "qproperty-alignment:AlignCenter;" + style + "}";
string s = "QLabel{" + style + "} QLabel:disabled{color:rgb(150,150,150)}";
pvSetStyleSheet(p, vecRows_[row].vecCells[col], s.c_str());
}
}
}
void PvTable::setRowData(int row, Fields& d)
{
if (row >= nRow_) { return; }
vecData_[row] = d;
for (int col = 0; col < vecHead_.size(); ++col)
{
auto& head = vecHead_[col];
auto& head = vecHeads[col];
string text = d.value(head.id);
text = head.getMapping(text);
pvSetText(p, vecRows_[row].vecCells[col], text.c_str());
pvSetText(p, vecRows[irow].vecCells[col], text.c_str());
}
setRowVisible(row, true);
this->setOperateVisible(row, d.size() > 0);
setRowVisible(irow, true);
}
void PvTable::setRowData(int row, std::vector<std::string> vd)
void PvTable::setRow(int irow, std::vector<std::string> vd)
{
if (row >= nRow_) { return; }
pvShow(p, vecRows_[row].bkg);
for (int col = 0; col < vecHead_.size(); ++col)
if (irow >= nrow) { return; }
pvShow(p, vecRows[irow].widget);
for (int col = 0; col < vecHeads.size(); ++col)
{
if (col < vd.size()) {
auto& head = vecHead_[col];
auto& head = vecHeads[col];
string text = head.getMapping(vd[col]);
pvSetText(p, vecRows_[row].vecCells[col], text.c_str());
pvSetText(p, vecRows[irow].vecCells[col], text.c_str());
}
}
setRowVisible(row, true);
this->setOperateVisible(row, vd.size() > 0);
setRowVisible(irow, true);
}
Fields PvTable::getRowData(int row)
Fields PvTable::row(int irow)
{
static Fields tmp;
return (row >= 0 && row < vecData_.size()) ? vecData_[row] : tmp;
return (irow >= 0 && irow < vecData.size()) ? vecData[irow] : Fields();
}
Fields PvTable::rowMapping(int rowid)
{
Fields d = this->row(rowid);
this->mappingData(d);
return d;
}
void PvTable::mappingData(Fields& fields)
{
for (int i=0; i< vecHead_.size(); ++i)
for (int i=0; i< vecHeads.size(); ++i)
{
auto& head = vecHead_[i];
auto& head = vecHeads[i];
if (fields.contains(head.id))
{
auto& val = fields.value(head.id);
@@ -217,82 +192,23 @@ void PvTable::mappingData(Fields& fields)
}
}
void PvTable::set_border_visible(PARAM* p, bool v)
int PvTable::rowCount()
{
v ? pvShow(p, border_id_) : pvHide(p, border_id_);
return this->nrow;
}
int PvTable::item_posy(int row)
int PvTable::colCount()
{
return option_.show_header ? row * option_.row_height + option_.head_height : row * option_.row_height;
}
void PvTable::add_col_button(PARAM* p, int col, string title, PvRect& rt, string style)
{
if (col >= nCol_)
{
return;
}
for (int row = 0; row < nRow_; ++row)
{
int id = PvApp::button(p, vecRows_[row].vecCells[col], rt.x, rt.y, rt.w, rt.h, title, style);
pvHide(p, id);
vec_col_item_btn_[row].push_back(id);
//PvInstance::bind_event(p, PvEvent::BUTTON_EVENT, id, [=](string s)
//{
// if (cb_operate_)
// {
// cb_operate_(row, col, title);
// }
//});
}
}
void PvTable::add_col_button(PARAM* p, int col, vector<string> vec_title)
{
int x = 5;
int w = 0;
for (int i = 0; i < vec_title.size(); i++)
{
auto& title = vec_title[i];
w = 20 + 20 * title.size() / 3;
this->add_col_button(p, col, title, PvRect(x, 3, w, 28), qss::button());
x += (w + 5);
}
}
void PvTable::setOperateVisible(int row, bool v, int id)
{
if (row < vecOpt_.size())
{
auto& vec_opt_btn = vecOpt_[row].second;
int pvid = id < 0 ? vecOpt_[row].first : ((id < vec_opt_btn.size()) ? vec_opt_btn[id] : PV_ID_NUL);
v ? pvShow(p, pvid) : pvHide(p, pvid);
}
}
int PvTable::border_id()
{
return border_id_;
}
int PvTable::rows()
{
return nRow_;
}
int PvTable::colums()
{
return nCol_;
return this->ncol;
}
vector<Fields> PvTable::data()
{
return vecData_;
return vecData;
}
PvTable::Head& PvTable::header(int col)
{
return vecHead_[col];
return vecHeads[col];
}
static const string STYLE_NORMAL =
@@ -348,32 +264,6 @@ void PvPagination::setPage(int index, int count)
else
{
pvShow(p, btnid);
//if (pageCount > 7)
//{
// if (idx == 4)
// {
// idx = 0;
// }
// else if (idx > 4)
// {
// idx = pageCount - (7 - idx);
// }
//}
//btn.second = idx;
//string text = to_string(idx);
//if (text.empty() || text == "0")
//{
// text = "...";
// pvSetEnabled(p, btnid, false);
//}
////pvMove(p, btnid, x, y);
//pvSetText(p, btnid, text.c_str());
//if (idx == idx)
//{
// this->active_page_button(p, idx, pageIndex);
// pageIndex = idx;
//}
//x += (32);
}
}
int x = (count+1)*32;
@@ -424,7 +314,10 @@ void PvPagination::setCallback(std::function<void(int index)> func)
PageTable::PageTable(PARAM* p) : PvMask(p)
{
table = std::make_shared<PvTable>(p, 0, 20, 210, 1880, pageSize, option);
table->setOperateCallback([=](int row, int col, std::string text) { this->onOperate(row, col, text); });
table->setOperateCallback([=](int irow, int icol, std::string text) {
curRowData = table->row(irow);
this->onOperate(irow, icol, text);
});
pagination = std::make_shared<PvPagination>(p, 0, 20, 780, 20);
pagination->setCallback([=](int index)
@@ -464,7 +357,7 @@ std::shared_ptr<PvPopWidget> PageTable::addPop(int w, int h, int w0, std::string
vecPop.push_back(pop);
return pop;
}
void PageTable::showPop(int index, std::string oper, Fields& fields)
void PageTable::showPop(int index, std::string oper, Fields fields)
{
XLOGD() << "POP set: data=" << fields.toStr();
table->mappingData(fields);
@@ -492,12 +385,12 @@ void PageTable::updateDataFromDB()
pageInfo.size = pageSize;
pageInfo.index = pageIndex;
this->onQueryTable(pageInfo, result);
for (int i = 0; i<table->rows(); ++i)
for (int i = 0; i<table->rowCount(); ++i)
{
if (i<result.size())
{
auto& fields = result[i];
table->setRowData(i, result[i]);
table->setRow(i, result[i]);
}
else
{

View File

@@ -17,8 +17,6 @@ public:
bool show_border = true;
int head_height = 40;
int row_height = 35;
int page_size = 10;
int width = 500;
};
struct Head
@@ -48,72 +46,52 @@ public:
struct Row
{
bool visible = false;
int bkg {PV_ID_NUL};
int widget {PV_ID_NUL};
std::vector<int> vecCells {};
};
public:
PvTable(PARAM* p, int parent, int x, int y, int w, int rows, Options& option);
PvTable(PARAM* p, int parent, int x, int y, int w, int rowCount, Options& option);
void addHead(std::string id, std::string text, int width, std::vector<std::pair<std::string, std::string>> mapping = {});
void addHead(std::vector<std::string> vecText);
void setRowVisible(int row, bool v);
void highlight(int row, bool v);
void setRowVisible(int irow, bool v);
void highlight(int irow, bool v);
void addOperate(std::vector<std::string> vecOpt);
void setOperateCallback(CallbackTableOpt cb);
void set_text(PARAM* p, int row, int col, std::string text, std::string style = "");
void setRowData(int row, Fields& d);
void setRowData(int row, std::vector<std::string> vd);
void setRow(int irow, Fields& d);
void setRow(int irow, std::vector<std::string> vd);
Fields row(int irow);
Fields rowMapping(int irow);
Fields getRowData(int row);
void mappingData(Fields& fields);
void set_border_visible(PARAM* p, bool v);
void add_col_button(PARAM* p, int col, std::string title, PvRect& rt, std::string style);
void add_col_button(PARAM* p, int col, std::vector<std::string> vec_title);
void setOperateVisible(int row, bool v, int id = -1);
int item_posy(int row);
int border_id();
int rows();
int colums();
int rowCount();
int colCount();
std::vector<Fields> data();
PvTable::Head& header(int col);
private:
int pvid_;
PvRect rect_;
Options option;
PvRect rect;
int border_id_;
std::vector<PvTable::Head> vecHeads;
std::vector<PvTable::Row> vecRows;
std::vector<Fields> vecData;
std::vector<PvTable::Head> vecHead_;
std::vector<PvTable::Row> vecRows_;
vector<pair<int, vector<int>>> vecOper;
int nrow;
int ncol;
std::vector<Fields> vecData_;
vector<pair<int, vector<int>>> vecOpt_;
int nRow_;
int nCol_;
string item_base_style_;
Options option_;
unordered_map<int, vector<int>> vec_col_item_btn_;
CallbackTableOpt cbOperate_ = nullptr;
int posCol_ = 0;
int posCol = 0;
CallbackTableOpt callbackOper = nullptr;
};
@@ -144,9 +122,6 @@ private:
// 下一页按钮
int btnNext = PV_ID_NUL;
// 页面跳转按钮
int btn_gopage_ = PV_ID_NUL;
int btnActive = PV_ID_NUL;
int labelInfo = PV_ID_NUL;
@@ -170,7 +145,7 @@ public:
std::shared_ptr<PvPopWidget> addPop(int w, int h, int w0, std::string name, std::vector<std::string> primaryKeys);
void showPop(int index, std::string optr, Fields& fields);
void showPop(int index, std::string optr, Fields fields);
void hidePop(int index);
void updateDataFromDB();
@@ -186,6 +161,7 @@ public:
std::shared_ptr<PvTable> table;
std::shared_ptr<PvPagination> pagination;
std::vector<std::shared_ptr<PvPopWidget>> vecPop;
Fields curRowData;
};
#endif // ! _PvTable_H_

View File

@@ -0,0 +1,7 @@
#include "PvUser.h"
void PvUser::reset()
{
mapEventCallback.clear();
pvidIndex = 0;
}

View File

@@ -6,6 +6,8 @@
class PvUser
{
public:
void reset();
int pvidIndex = 0;
std::map<std::string, std::function<void(std::string text)>> mapEventCallback;
};

View File

@@ -11,12 +11,9 @@
void TestPage(PARAM* p)
{
auto& appdata = Application::data();
auto pagination = new PvPagination(p, 0, 600, 160, 20);
pagination->setPage(5, 10);
int id = PvApp::label(p, 0, 0, 0, 1920, 800, "", qss::label(14, "", "rgb(15, 50, 68)"));
new PanelPolicyPeak(p, id, 0, 0, 1920, 1080);
//auto& appdata = Application::data();
//auto pagination = new PvPagination(p, 0, 600, 160, 20);
//pagination->setPage(5, 10);
}
@@ -192,7 +189,6 @@ public:
}
};
//background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0,stop:1 rgba(0,255,240,200),stop:0 rgba(0,255,240,0));
int MaskPageHome::initUI(EPvCode pvcode)
{
@@ -317,11 +313,8 @@ int MaskPageHome::initUI(EPvCode pvcode)
this->updateUI();
TestPage(p);
return 0;
}
@@ -342,7 +335,7 @@ void MaskPageHome::updateUI()
}
pvSetText(p, ui.labelRunDays, "100 天");
pvSetText(p, ui.labelRunDays, (Utils::toStr(stationNum) + "").c_str());
pvSetText(p, ui.labelStationNum, (Utils::toStr(stationNum) + "").c_str());
pvSetText(p, ui.labelEnergyCapacity, (Utils::toStr(energyCapacity) + " kWh").c_str());
pvSetText(p, ui.labelIncome, (Utils::toStr(incomeTotal) + "").c_str());
pvSetText(p, ui.labelStorageIn, (Utils::toStr(electStorageIn) + " kWh").c_str());

View File

@@ -1,6 +1,10 @@
#include "MaskPageRunning.h"
#include "app/Application.h"
#include "app/AppData.h"
#include "app/Station.h"
#include "app/Device.h"
#include "common/JsonN.h"
static int CreateParamLabel(PARAM* p, int parent, int x, int y, std::string k, std::string v)
{
@@ -8,21 +12,21 @@ static int CreateParamLabel(PARAM* p, int parent, int x, int y, std::string k, s
return PvApp::label(p, parent, x += 70, y, 120, 30, v, qss::LABEL_VAL);
}
class BoxCard : PvObject
class CardDevice : PvObject
{
public:
static std::shared_ptr<BoxCard> create(PARAM* p, int parent, int x, int y)
static std::shared_ptr<CardDevice> create(PARAM* p, int parent, int x, int y)
{
return std::make_shared<BoxCard>(p, parent, x, y);
return std::make_shared<CardDevice>(p, parent, x, y);
}
BoxCard(PARAM* p, int parent, int x, int y) : PvObject(p)
CardDevice(PARAM* p, int parent, int x, int y) : PvObject(p)
{
card_ = PvApp::label(p, parent, x, y, 400, 250, "", qss::QSS_CARD_DEVICE);
PvApp::label(p, card_, 10, 10, 60, 60, "", "border:none; background-color: rgb(39, 158, 145);");
ui.code = PvApp::label(p, card_, 80, 10, 100, 20, "");
ui.name = PvApp::label(p, card_, 80, 30, 100, 20, "");
ui.name = PvApp::label(p, card_, 80, 10, 100, 20, "");
ui.code = PvApp::label(p, card_, 80, 30, 100, 20, "");
ui.type = PvApp::label(p, card_, 80, 50, 100, 20, "", qss::label(14, "rgb(8, 161, 249)"));
int x1 = 190;
@@ -40,14 +44,14 @@ public:
// 默认创建 10 个参数标签:
int n = 10;
vecParamLabel_.resize(n);
vecParamLabel.resize(n);
for (int i = 0; i<n; i++)
{
int row = i/2;
int col = i%2;
int h = 25;
vecParamLabel_[i].first = PvApp::label(p, card_, 10 + 200*col, 115 + h*row, 70, h, "参数"+std::to_string(i) + ":", qss::LABEL_KEY);
vecParamLabel_[i].second = PvApp::label(p, card_, 10 + 200*col + 70, 115 + h*row, 120, h, "---", qss::LABEL_VAL);
vecParamLabel[i].first = PvApp::label(p, card_, 10 + 200*col, 115 + h*row, 70, h, "参数"+std::to_string(i) + ":", qss::LABEL_KEY);
vecParamLabel[i].second = PvApp::label(p, card_, 10 + 200*col + 70, 115 + h*row, 120, h, "---", qss::LABEL_VAL);
}
}
@@ -60,10 +64,10 @@ public:
void setParamkeys(std::vector<std::string> vecKeys)
{
for (int i = 0; i<vecParamLabel_.size(); i++)
for (int i = 0; i<vecParamLabel.size(); i++)
{
auto& labelKey = vecParamLabel_[i].first;
auto& labelVal = vecParamLabel_[i].second;
auto& labelKey = vecParamLabel[i].first;
auto& labelVal = vecParamLabel[i].second;
if (i<vecKeys.size())
{
std::string& title = vecKeys[i] + "";
@@ -96,7 +100,7 @@ public:
int card_;
std::vector<std::pair<int, int>> vecParamLabel_;
std::vector<std::pair<int, int>> vecParamLabel;
std::map<std::string, int> mapParam_;
};
@@ -106,135 +110,199 @@ MaskPageRunning::MaskPageRunning(PARAM* p) : PvMask(p)
int MaskPageRunning::initUI(EPvCode pvcode)
{
auto& appdata = Application::data();
PvApp::label(p, 0, 10, 100, 1900, 850, "", "background-color: rgb(5, 47, 77); border-radius: 10px;");
PvApp::label(p, 0, 10, 150, 220, 790, "", "background-color: rgb(8, 54, 91); border-radius: 10px;");
int workspace = PvApp::label(p, 0, 240, 150, 1670, 790, "", "background-color: rgba(8, 54, 91, 0); border-radius: 10px;");
std::vector<std::string> vecStationNames = Application::data().getStationNames();
std::vector<std::string> vecStationNames = appdata.getStationNames();
PvApp::label(p, 0, 20, 110, 80, 30, "场站切换", "color:white; font: bold 16px;");
PvApp::combox(p, 0, 100, 110, 150, 30, vecStationNames);
ui.comboxStation = PvApp::combox(p, 0, 100, 110, 150, 30, vecStationNames);
if (vecStationNames.size() > 0)
{
station_ = Application::data().getStationByName(vecStationNames[0]);
activeStation = appdata.getStationByName(vecStationNames[0]);
}
PvApp::label(p, 0, 320, 110, 80, 30, "运行模式", "color:white; font: bold 16px;");
PvApp::combox(p, 0, 400, 110, 200, 30, Application::data().getWorkModes());
ui.comboxWorkMode = PvApp::combox(p, 0, 400, 110, 200, 30, appdata.getWorkModes(), activeStation->id - 1);
PvApp::label(p, 0, 670, 110, 80, 30, "策略名称", "color:white; font: bold 16px;");
PvApp::combox(p, 0, 750, 110, 200, 30, Application::data().getPolicyNames());
PvApp::combox(p, 0, 750, 110, 200, 30, appdata.getPolicyNames());
int x = 20, y = 160, w = 200, h = 180;
// 储能设备
{
ui.storage.name = "储能设备";
int pid = ui.storage.box = PvApp::label(p, 0, x, y, w, h, "", qss::LABEL_BOX);
PvApp::label(p, pid, 10, 0, w-10, 30, ui.storage.name, qss::LABEL_TITLE);
ui.storage.btn = PvApp::button(p, pid, 0, 0, w, h, "", "background-color: transparent;");
ui.storage.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
pvHide(p, ui.storage.workspace);
this->initModule(storage, "储能设备", x, y, w, h);
storage.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
pvHide(p, storage.workspace);
// 创建信息卡片
{
vecCard_.resize(12);
for (int i=0; i<vecCard_.size(); ++i)
{
vecCard_[i] = BoxCard::create(p, ui.storage.workspace, (i%4)*410, (i/4)*260);
vecCard_[i] = CardDevice::create(p, storage.workspace, (i%4)*410, (i/4)*260);
}
}
}
// 光伏设备
{
ui.solar.name = "光伏设备";
int pid = ui.solar.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
PvApp::label(p, pid, 10, 0, w-10, 30, ui.solar.name, qss::LABEL_TITLE);
ui.solar.btn = PvApp::button(p, pid, 0, 0, w, h, "", "background-color: transparent;");
ui.solar.workspace = ui.storage.workspace;
pvHide(p, ui.solar.workspace);
this->initModule(solar, "光伏设备", x, y += (h+10), w, h);
solar.workspace = storage.workspace;
pvHide(p, solar.workspace);
}
// 充电设备
{
ui.charge.name = "充电设备";
int pid = ui.charge.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
PvApp::label(p, pid, 10, 0, w-10, 30, ui.solar.name, qss::LABEL_TITLE);
ui.charge.btn = PvApp::button(p, pid, 0, 0, w, h, "", "background-color: transparent;");
ui.charge.workspace = ui.storage.workspace;
pvHide(p, ui.charge.workspace);
this->initModule(charge, "充电设备", x, y += (h+10), w, h);
charge.workspace = storage.workspace;
pvHide(p, charge.workspace);
}
// 环境与安防设备
{
ui.security.name = "环境与安防设备";
int pid = ui.security.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
PvApp::label(p, pid, 10, 0, w-10, 30, ui.security.name, qss::LABEL_TITLE);
this->initModule(security, "环境与安防设备", x, y += (h+10), w, h);
security.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
pvHide(p, security.workspace);
ui.security.btn = PvApp::button(p, pid, 0, 0, w, h, "", "background-color: transparent;");
ui.security.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
pvHide(p, ui.security.workspace);
{
std::string style = qss::label(20, "white; padding: 0px 0px 0px 10px;", "rgb(8, 54, 91)", "none; border-radius: 5px;");
for (int i = 0; i<12; ++i)
{
int w = 320, h = 240;
int x = 0+(w+10)*(i%4), y = 0+(h+10)*(i/4);
int cardId = PvApp::label(p, security.workspace, x, y, w, h, "监控点 " + std::to_string(i+1), style);
pvSetAlignment(p, cardId, AlignLeft | AlignTop);
PvApp::label(p, cardId, 10, 40, w-20, h-50, "", qss::label(14, "", "", "8px solid black; border-radius: 0px;"));
PvApp::image(p, cardId, (w-77)*0.5, 40+(h-40-77)*0.5, 77, 77, "play1.png");
}
}
{
int w = 320, h = 50;
int pid = PvApp::label(p, security.workspace, 1320, 10, w, 200, "环境温度信息", qss::label(20, "", "", "none;"));
pvSetAlignment(p, pid, AlignLeft | AlignTop);
PvApp::label(p, pid, 0, 30, w, 5, "", qss::QSS_UNDERLINE);
int x = 0, y = 50;
PvApp::label(p, pid, x, y, w, h, "", qss::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*2, "", qss::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
{
w = w/3;
PvApp::labelCenter(p, pid, x, y, w, h, "点位");
PvApp::labelCenter(p, pid, x+w, y, w, h, "温度");
PvApp::labelCenter(p, pid, x+w*2, y, w, h, "湿度");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#1");
PvApp::labelCenter(p, pid, x+w, y, w, h, "20 ℃");
PvApp::labelCenter(p, pid, x+w*2, y, w, h, "30 %");
}
}
{
int w = 320, h = 50;
int pid = PvApp::label(p, security.workspace, 1320, 200, w, 500, "消防信息", qss::label(20, "", "", "none;"));
pvSetAlignment(p, pid, AlignLeft | AlignTop);
PvApp::label(p, pid, 0, 30, w, 5, "", qss::QSS_UNDERLINE);
int x = 0, y = 50;
PvApp::label(p, pid, x, y, w, h, "", qss::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*9, "", qss::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
{
w = w/2;
PvApp::labelCenter(p, pid, x, y, w, h, "点位");
PvApp::labelCenter(p, pid, x+w, y, w, h, "烟感状态");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#1");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#2");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#3");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#4");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#5");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#6");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#7");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
PvApp::labelCenter(p, pid, x, y += h, w, h, "#8");
PvApp::labelCenter(p, pid, x+w, y, w, h, "XXX");
}
}
}
activeBoxPanel(ui.storage);
activeBoxPanel(&storage);
{
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.comboxStation, [=](std::string s) { this->onComboxStation(s); });
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.comboxWorkMode, [=](std::string s) { this->onComboxWorkMode(s); });
}
return 0;
}
void MaskPageRunning::initModule(Module& module, std::string name, int x, int y, int w, int h)
{
module.name = name;
int deviceNum = activeStation->getDeviceNumByGroup(name);
int pid = module.widget = PvApp::label(p, 0, x, y, w, h, "", qss::LABEL_BOX);
PvApp::label(p, module.widget, 10, 20, w, 30, module.name, qss::LABEL_TITLE);
pvSetAlignment(p, module.widget, AlignTop | AlignLeft);
module.labelPower = PvApp::lineLabel(p, pid, PvRect(10, 80, 180, 30), 70, "总功率:", "60 W");
module.labelNum = PvApp::lineLabel(p, pid, PvRect(10, 110, 180, 30), 70, "设备数量:", std::to_string(deviceNum).c_str());
module.btn = PvApp::button(p, pid, 0, 0, w, h, "", "background-color: transparent;");
}
EPvCode MaskPageRunning::onEventButton(int pvid)
{
if (pvid == ui.storage.btn) { activeBoxPanel(ui.storage); }
else if (pvid == ui.solar.btn) { activeBoxPanel(ui.solar); }
else if (pvid == ui.charge.btn) { activeBoxPanel(ui.charge); }
else if (pvid == ui.security.btn) { activeBoxPanel(ui.security); }
if (pvid == storage.btn) { activeBoxPanel(&storage); }
else if (pvid == solar.btn) { activeBoxPanel(&solar); }
else if (pvid == charge.btn) { activeBoxPanel(&charge); }
else if (pvid == security.btn) { activeBoxPanel(&security); }
return EPvCode::NUL;
}
std::map<std::string, std::vector<std::string>> mapDeviceTypes =
void MaskPageRunning::activeBoxPanel(Module* module)
{
{"储能设备", {"储能预制舱", "储能电池", "储能电池", "储能电池"}},
{"光伏设备", {"光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板"}},
{"充电设备", {"充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩"}},
};
std::map<std::string, std::vector<std::string>> mapDeviceParams =
{
{"储能预制舱", {"运行模式", "冷却方式", "实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数", "电池容量"}},
{"储能电池", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数", "电池容量"}},
{"逆变器", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
{"光伏板", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
{"充电桩", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
};
if (activeBox)
{
pvSetStyleSheet(p, activeBox->widget, qss::LABEL_BOX.c_str());
pvHide(p, activeBox->workspace);
}
activeBox = module;
if (activeBox)
{
pvSetStyleSheet(p, activeBox->widget, qss::QSS_BOX_ACTIVE.c_str());
pvShow(p, activeBox->workspace);
}
void MaskPageRunning::activeBoxPanel(BoxPanel& panel)
{
static int activeBox = PV_ID_NUL;
static int activeWorkspace = PV_ID_NUL;
if (activeBox != PV_ID_NUL) { pvSetStyleSheet(p, activeBox, qss::LABEL_BOX.c_str()); }
if (activeBox = panel.box) { pvSetStyleSheet(p, activeBox, qss::QSS_BOX_ACTIVE.c_str()); }
if (activeWorkspace != PV_ID_NUL) { pvHide(p, activeWorkspace); }
if (activeWorkspace = panel.workspace) { pvShow(p, activeWorkspace); }
if (panel.workspace != ui.security.workspace)
auto& appdata = Application::data();
if (activeBox->workspace != security.workspace)
{
std::vector<std::string> vecDeviceInfo = mapDeviceTypes[panel.name];
// 更新卡片:
std::vector<std::shared_ptr<Device>> vecDevice;
activeStation->getDeviceByGroup(module->name, vecDevice);
pvSetText(p, module->labelNum, std::to_string(vecDevice.size()).c_str());
// 读取储能设备信息
for (int i = 0; i<vecCard_.size(); ++i)
{
auto& card = vecCard_[i];
if (i < vecDeviceInfo.size())
if (i < vecDevice.size())
{
std::string type = vecDeviceInfo[i];
auto device = vecDevice[i];
auto typeDef = appdata.getDeviceTypeDef(device->type);
if (typeDef)
{
std::vector<std::string> vecKeys;
NJson::parse(typeDef->fieldsAttr.value("key"), vecKeys);
card->setCard(typeDef->name, device->name, device->code);
card->setParamkeys(vecKeys);
}
card->show(1);
card->setCard(type, type+"-"+std::to_string(i), type+"-"+std::to_string(i));
card->setParamkeys(mapDeviceParams[type]);
}
else
{
@@ -242,4 +310,38 @@ void MaskPageRunning::activeBoxPanel(BoxPanel& panel)
}
}
}
}
void MaskPageRunning::updateWorkspace()
{
}
void MaskPageRunning::onComboxStation(std::string stationName)
{
if (!activeStation) return;
auto& appdata = Application::data();
activeStation = appdata.getStationByName(stationName);
// 更新运行模式和策略
{
int index = activeStation->workModeId - 1;
if (index < 0) { index = 0; }
pvSetCurrentItem(p, ui.comboxWorkMode, index);
}
this->activeBoxPanel(activeBox);
}
void MaskPageRunning::onComboxWorkMode(std::string modeName)
{
if (!activeStation) return;
auto& appdata = Application::data();
int workModeId = appdata.getWorkModeIdByName(modeName);
activeStation->setWorkMode(workModeId);
}

View File

@@ -2,34 +2,48 @@
#include "pv/PvApp.h"
class BoxCard;
class CardDevice;
class Station;
class MaskPageRunning : public PvMask
{
public:
struct BoxPanel {
struct Module {
std::string name;
int box;
int widget;
int btn;
int workspace;
int labelPower;
int labelNum;
};
MaskPageRunning(PARAM* p);
int initUI(EPvCode pvcode);
void initModule(Module& module, std::string name, int x, int y, int w, int h);
virtual EPvCode onEventButton(int pvid);
void activeBoxPanel(BoxPanel& panel);
void activeBoxPanel(Module* module);
void updateWorkspace();
void onComboxStation(std::string stationName);
void onComboxWorkMode(std::string modeName);
struct {
BoxPanel storage;
BoxPanel solar;
BoxPanel charge;
BoxPanel security;
int comboxStation;
int comboxWorkMode;
} ui;
std::vector<std::shared_ptr<BoxCard>> vecCard_;
std::shared_ptr<Station> station_ = nullptr;
Module storage;
Module solar;
Module charge;
Module security;
Module* activeBox {};
std::vector<std::shared_ptr<CardDevice>> vecCard_;
std::shared_ptr<Station> activeStation = nullptr;
};

View File

@@ -5,7 +5,9 @@
#include "database/Dao.h"
#include "database/DataModelDef.h"
#include "common/Snowflake.h"
#include "pv/pages/PanelPolicy.h"
std::vector<std::string> g_comboxList_isOpen = {"启用", "禁用"};
///////////////////////////////////////////////////////////////////////////////////////////////////
// === PageUser ===
@@ -42,7 +44,7 @@ void PageUser::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryUserList(pageInfo, result);
}
void PageUser::onOperate(int row, int col, std::string oper)
void PageUser::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -52,7 +54,7 @@ void PageUser::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
};
std::string PageUser::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -84,7 +86,7 @@ PageRole::PageRole(PARAM* p, EPvCode pvcode) : PageTable(p)
{
auto& appdata = Application::data();
table->addHead(DMRole::ROLE_ID, "角色编号", 200, {});
table->addHead(DMRole::ROLE_ID, "角色编号", 180, {});
table->addHead(DMRole::NAME, "角色名称", 200, {});
table->addHead(DMRole::DESCRIBE, "角色描述", 900, {});
table->addHead(DMRole::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
@@ -97,7 +99,7 @@ PageRole::PageRole(PARAM* p, EPvCode pvcode) : PageTable(p)
auto pop = this->addPop(500, 600, 180, "角色信息", {DMUser::USER_ID});
pop->addParamLineEdit(DMRole::ROLE_ID, "编号", x, y, false);
pop->addParamLineEdit(DMRole::NAME, "名称", x, y += h);
pop->addParamCombox(DMUser::IS_OPEN, "是否启用", x, y += h, {"启用", "禁用"});
pop->addParamCombox(DMUser::IS_OPEN, "是否启用", x, y += h, g_comboxList_isOpen);
pop->addParamTextEdit(DMRole::DESCRIBE, "描述", x, y += h);
}
@@ -105,7 +107,7 @@ void PageRole::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryRoleList(pageInfo, result);
}
void PageRole::onOperate(int row, int col, std::string oper)
void PageRole::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -115,7 +117,7 @@ void PageRole::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PageRole::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -133,7 +135,7 @@ std::string PageRole::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& fie
PagePermission::PagePermission(PARAM* p, EPvCode pvcode) : PageTable(p)
{
auto& appdata = Application::data();
table->addHead(DMPermission::PERMISSION_ID, "权限编号", 200, {});
table->addHead(DMPermission::PERMISSION_ID, "权限编号", 180, {});
table->addHead(DMPermission::NAME, "权限名称", 200, {});
table->addHead(DMPermission::DESCRIBE, "权限描述", 900, {});
table->addHead(DMPermission::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
@@ -143,17 +145,17 @@ PagePermission::PagePermission(PARAM* p, EPvCode pvcode) : PageTable(p)
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnNew, [=](std::string) { this->onOperate(-1, -1, POP_OPER_NEW); });
int x = 80, y = 80, h = 60;
auto pop = this->addPop(500, 600, 180, "角色信息", {DMPermission::PERMISSION_ID});
auto pop = this->addPop(500, 600, 240, "角色信息", {DMPermission::PERMISSION_ID});
pop->addParamLineEdit(DMPermission::PERMISSION_ID, "编号", x, y, false);
pop->addParamLineEdit(DMPermission::NAME, "名称", x, y += h);
pop->addParamCombox(DMPermission::IS_OPEN, "是否启用", x, y += h, {"启用", "禁用"});
pop->addParamCombox(DMPermission::IS_OPEN, "是否启用", x, y += h, g_comboxList_isOpen);
pop->addParamTextEdit(DMPermission::DESCRIBE, "描述", x, y += h);
}
void PagePermission::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryPermissionList(pageInfo, result);
}
void PagePermission::onOperate(int row, int col, std::string oper)
void PagePermission::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -163,7 +165,7 @@ void PagePermission::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PagePermission::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -180,7 +182,7 @@ std::string PagePermission::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Field
PageStation::PageStation(PARAM* p, EPvCode pvcode) : PageTable(p)
{
auto& appdata = Application::data();
table->addHead(DMStation::STATION_ID, "场站编号", 200, {});
table->addHead(DMStation::STATION_ID, "场站编号", 180, {});
table->addHead(DMStation::NAME, "场站名称", 200, {});
table->addHead(DMStation::ADDRESS, "地址", 200, {});
table->addHead(DMStation::LONGITUDE, "经度", 200, {});
@@ -200,13 +202,13 @@ PageStation::PageStation(PARAM* p, EPvCode pvcode) : PageTable(p)
pop->addParamLineEdit(DMStation::LONGITUDE, "经度", x, y += h);
pop->addParamLineEdit(DMStation::LATITUDE, "维度", x, y += h);
pop->addParamLineEdit(DMStation::TEL, "电话", x, y += h);
pop->addParamCombox(DMStation::STATUS, "状态", x, y += h, {"启用", "禁用"});
pop->addParamCombox(DMStation::STATUS, "状态", x, y += h, g_comboxList_isOpen);
}
void PageStation::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryStationList(pageInfo, result);
}
void PageStation::onOperate(int row, int col, std::string oper)
void PageStation::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -216,7 +218,7 @@ void PageStation::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PageStation::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -246,6 +248,7 @@ PageDevice::PageDevice(PARAM* p, EPvCode pvcode) : PageTable(p)
{
auto& appdata = Application::data();
table->addHead(DMDevice::DEVICE_ID, "设备编号", 120, {});
table->addHead(DMDevice::STATION_ID, "所属场站", 120, appdata.mapping.stationName);
table->addHead(DMDevice::TYPE, "设备类型", 120, appdata.mapping.deviceType);
table->addHead(DMDevice::NAME, "设备名称", 180, {});
table->addHead(DMDevice::CODE, "设备编码", 160, {});
@@ -262,20 +265,21 @@ PageDevice::PageDevice(PARAM* p, EPvCode pvcode) : PageTable(p)
int x = 50, y = 80, w = 350, h = 60;
auto pop = this->addPop(700, 520, 180, "设备信息", {DMDevice::DEVICE_ID});
pop->addParamLineEdit(DMDevice::DEVICE_ID, "设备编号", x, y, false);
pop->addParamCombox(DMDevice::TYPE, "类型", x+w, y, appdata.getDeviceTypeNames());
pop->addParamLineEdit(DMDevice::NAME, "设备名称", x, y += h);
pop->addParamLineEdit(DMDevice::CODE, "设备编码", x+w, y);
pop->addParamLineEdit(DMDevice::MODEL, "设备型号", x, y += h);
pop->addParamLineEdit(DMDevice::FACTORY, "厂家", x+w, y);
pop->addParamLineEdit(DMDevice::TEL, "厂家电话", x, y += h);
pop->addParamCombox(DMDevice::IS_OPEN, "是否启用", x+w, y, {"启用", "禁用"});
pop->addParamLineEdit(DMDevice::ATTRS, "设备参数", x, y += h);
pop->addParamCombox(DMDevice::STATION_ID, "所属场站", x+w, y, appdata.getStationNames());
pop->addParamCombox(DMDevice::TYPE, "类型", x, y += h, appdata.getDeviceTypeNames());
pop->addParamLineEdit(DMDevice::NAME, "设备名称", x+w, y);
pop->addParamLineEdit(DMDevice::CODE, "设备编码", x, y += h);
pop->addParamLineEdit(DMDevice::MODEL, "设备型号", x+w, y);
pop->addParamLineEdit(DMDevice::FACTORY, "厂家", x, y += h);
pop->addParamLineEdit(DMDevice::TEL, "厂家电话", x+w, y);
pop->addParamCombox(DMDevice::IS_OPEN, "是否启用", x, y += h, g_comboxList_isOpen);
pop->addParamLineEdit(DMDevice::ATTRS, "设备参数", x + w, y);
}
void PageDevice::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryDeviceList(pageInfo, result);
}
void PageDevice::onOperate(int row, int col, std::string oper)
void PageDevice::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -285,7 +289,7 @@ void PageDevice::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PageDevice::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -316,12 +320,12 @@ std::string PageDevice::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& f
PagePolicy::PagePolicy(PARAM* p, EPvCode pvcode) : PageTable(p)
{
auto& appdata = Application::data();
table->addHead(DMPolicy::POLICY_ID, "策略编号", 200, {});
table->addHead(DMPolicy::TYPE, "策略类型", 200, {});
table->addHead(DMPolicy::NAME, "策略名称", 200, {});
table->addHead(DMPolicy::DESCRIBE, "策略描述", 400, {});
table->addHead(DMPolicy::VALUE, "策略参数", 400, {});
table->addHead(DMPolicy::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
table->addHead(DMPolicy::POLICY_ID, "策略编号", 120, {});
table->addHead(DMPolicy::TYPE, "策略类型", 120, appdata.mapping.policyType);
table->addHead(DMPolicy::NAME, "策略名称", 160, {});
table->addHead(DMPolicy::DESCRIBE, "策略描述", 300, {});
table->addHead(DMPolicy::VALUE, "策略参数", 900, {});
table->addHead(DMPolicy::IS_OPEN, "是否启用", 80, appdata.mapping.isopen);
table->addOperate({ "编辑"});
int btnNew = PvApp::button(p, PV_ID_MAIN, 20, 160, 80, 35, POP_OPER_NEW);
@@ -331,36 +335,78 @@ PagePolicy::PagePolicy(PARAM* p, EPvCode pvcode) : PageTable(p)
auto pop = this->addPop(1620, 800, 180, "策略信息", {DMPolicy::POLICY_ID});
//pop->addParamLineEdit(DMPolicy::POLICY_ID, "编号", x, y, false);
{
pop->addParamLineEdit("1", "策略名称", x, y);
pop->addParamCombox("2", "策略类型", x+w, y, {"峰谷套利"});
pop->addParamLineEdit("3", "尖峰电价", x, y += 50);
pop->addParamLineEdit("4", "高峰电价", x+w, y);
pop->addParamLineEdit("5", "平段电价", x+w*2, y);
pop->addParamLineEdit("6", "低谷电价", x+w*3, y);
pop->addParamLineEdit(DMPolicy::NAME, "策略名称", x, y);
pop->addParamCombox(DMPolicy::TYPE, "策略类型", x+w, y, Application::data().getPolicyTypeNames());
pop->addParamCombox(DMPolicy::IS_OPEN, "是否启用", x, y+=40, g_comboxList_isOpen),
//pop->addParamLineEdit("3", "尖峰电价", x, y += 50);
//pop->addParamLineEdit("4", "高峰电价", x+w, y);
//pop->addParamLineEdit("5", "平段电价", x+w*2, y);
//pop->addParamLineEdit("6", "低谷电价", x+w*3, y);
pop->setCallbackTextEvent([=](std::string k, std::string text) {
if (k == DMPolicy::TYPE)
{
int policyTypeId = Application::data().getPolicyTypeId(text);
this->setPanel(policyTypeId, "{}");
}
});
panelPeak = std::make_shared<PanelPolicyPeak>(p, pop->widget(), 10, y+=40, 1600, 540);
panelRequire = std::make_shared<PanelPolicyRequire>(p, pop->widget(), 10, y, 620, 220);
panelSelf = std::make_shared<PanelPolicySelf>(p, pop->widget(), 10, y, 620, 220);
}
}
void PagePolicy::setPanel(int policyTypeId, std::string attrVal)
{
auto pop = vecPop[0];
panelPeak->show(0);
panelRequire->show(0);
panelSelf->show(0);
if (policyTypeId == 1)
{
panelPeak->parseAttr(attrVal);
panelPeak->show(1);
pop->resize(1620, 800);
}
else if (policyTypeId == 2)
{
panelRequire->parseAttr(attrVal);
panelRequire->show(1);
pop->resize(640, 600);
}
else if (policyTypeId == 3)
{
panelSelf->parseAttr(attrVal);
panelSelf->show(1);
pop->resize(640, 600);
}
}
std::string PagePolicy::getPanelAttr(int policyTypeId)
{
std::string attrVal = "{}";
if (policyTypeId == 1) { attrVal = panelPeak->dumpAttr(); }
else if (policyTypeId == 2) { attrVal = panelRequire->dumpAttr(); }
else if (policyTypeId == 3) { attrVal = panelSelf->dumpAttr(); }
return attrVal;
}
void PagePolicy::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::queryPolicyList(pageInfo, result);
}
void PagePolicy::onOperate(int row, int col, std::string oper)
void PagePolicy::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
Fields fields;
this->showPop(0, oper, fields);
this->showPop(0, oper, Fields());
this->setPanel(1, {});
}
else if (oper == POP_OPER_EDIT)
{
table->getRowData(row);
auto& appdata = Application::data();
Fields fields;
fields.set("3", appdata.electPriceSuperPeak);
fields.set("4", appdata.electPricePeak);
fields.set("5", appdata.electPriceShoulder);
fields.set("6", appdata.electPriceOffPeak);
this->showPop(0, oper, fields);
int policyTypeId = curRowData.get<int>(DMPolicy::TYPE);
std::string attrVal = curRowData.value(DMPolicy::VALUE);
this->setPanel(policyTypeId, attrVal);
this->showPop(0, oper, curRowData);
}
}
std::string PagePolicy::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -369,9 +415,23 @@ std::string PagePolicy::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& f
};
std::string PagePolicy::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& fields)
{
if (pop->status == POP_OPER_NEW)
{
int policyTypeId = fields.get<int>(DMPolicy::TYPE);
fields.set(DMPolicy::VALUE, this->getPanelAttr(policyTypeId));
Errcode err = DAO::insertPolicy(fields);
if (err == Errcode::OK) { return ""; }
else { return "系统错误"; }
}
else if (pop->status == POP_OPER_EDIT)
{
int policyTypeId = curRowData.get<int>(DMPolicy::TYPE);
fields.set(DMPolicy::POLICY_ID, policyTypeId);
fields.set(DMPolicy::VALUE, this->getPanelAttr(policyTypeId));
Errcode err = DAO::updatePolicyById(fields);
if (err == Errcode::OK) { return ""; }
else { return "系统错误"; }
}
return "";
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -390,7 +450,7 @@ void PageSyslog::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
DAO::querySystemLogList(pageInfo, result);
}
void PageSyslog::onOperate(int row, int col, std::string oper)
void PageSyslog::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -400,7 +460,7 @@ void PageSyslog::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PageSyslog::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
@@ -429,7 +489,7 @@ void PageAlertlog::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
{
//DAO::queryAlertLogList(pageInfo, result);
}
void PageAlertlog::onOperate(int row, int col, std::string oper)
void PageAlertlog::onOperate(int irow, int icol, std::string oper)
{
if (oper == POP_OPER_NEW)
{
@@ -439,7 +499,7 @@ void PageAlertlog::onOperate(int row, int col, std::string oper)
}
else if (oper == POP_OPER_EDIT)
{
this->showPop(0, oper, table->getRowData(row));
this->showPop(0, oper, table->row(irow));
}
}
std::string PageAlertlog::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)

View File

@@ -71,17 +71,24 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////
// === PagePolicy ===
class PanelPolicyPeak;
class PanelPolicyRequire;
class PanelPolicySelf;
class PagePolicy : public PageTable
{
public:
PagePolicy(PARAM* p, EPvCode pvcode);
void setPanel(int policyTypeId, std::string attrVal);
std::string getPanelAttr(int policyTypeId);
virtual void onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result) override;
virtual void onOperate(int row, int col, std::string oper) override;
virtual std::string onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields) override;
virtual std::string onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& fields) override;
std::shared_ptr<PanelPolicyPeak> panelPeak {};
std::shared_ptr<PanelPolicyRequire> panelRequire {};
std::shared_ptr<PanelPolicySelf> panelSelf {};
};
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -2,30 +2,55 @@
#include "app/Application.h"
#include "app/AppData.h"
#include "common/JsonN.h"
#include "common/Utils.h"
//const std::string QSS_COMBOX_1 =
//"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(255, 89, 0); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
//"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
//"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
//"QComboBox:disabled { color:rgb(150,150,150);}";
//
//const std::string QSS_COMBOX_2 =
//"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(255, 255, 0); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
//"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
//"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
//"QComboBox:disabled { color:rgb(150,150,150);}";
//
//const std::string QSS_COMBOX_3 =
//"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(121, 191, 226); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
//"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
//"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
//"QComboBox:disabled { color:rgb(150,150,150);}";
//
//const std::string QSS_COMBOX_4 =
//"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(0, 255, 58); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
//"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
//"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
//"QComboBox:disabled { color:rgb(150,150,150);}";
const std::string QSS_COMBOX_1 =
"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(255, 89, 0); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
"QComboBox { background-color: transparent; border: 1px solid rgb(255, 89, 0); color: rgb(255, 89, 0); border-radius: 3px; font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 3px; color:white;}"
"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
"QComboBox:disabled { color:rgb(150,150,150);}";
"QComboBox:disabled {border: none; color: gray;}";
const std::string QSS_COMBOX_2 =
"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(255, 255, 0); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
"QComboBox { background-color: transparent; border: 1px solid rgb(255, 255, 0); color: rgb(255, 255, 0); border-radius: 3px; font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 3px; color:white;}"
"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
"QComboBox:disabled { color:rgb(150,150,150);}";
"QComboBox:disabled { border: none; color: gray;}";
const std::string QSS_COMBOX_3 =
"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(121, 191, 226); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
"QComboBox { background-color: transparent; border: 1px solid rgb(121, 191, 226); color: rgb(121, 191, 226); border-radius: 3px; font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 3px; color:white;}"
"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
"QComboBox:disabled { color:rgb(150,150,150);}";
"QComboBox:disabled { border: none; color: gray;}";
const std::string QSS_COMBOX_4 =
"QComboBox {border: 1px solid rgb(18, 251, 255); background-color: rgb(0, 255, 58); border-radius: 3px; color: rgb(30,30,30); font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 5px; color:white;}"
"QComboBox { background-color: transparent; border: 1px solid rgb(0, 255, 58);color: rgb(0, 255, 58); border-radius: 3px; font: bold 14px;}"
"QComboBox QAbstractItemView { border: 1px solid gray; background-color: rgba(8, 54, 91); border-radius: 3px; color:white;}"
"QComboBox::drop-down { border-radius: 5px; width: 30px; }"
"QComboBox:disabled { color:rgb(150,150,150);}";
"QComboBox:disabled { border: none; color: gray;}";
static std::string GetPeriodQss(int v)
{
@@ -51,182 +76,180 @@ static int GetPeriod(std::string text)
else if (text == "低谷") { return 4; }
else { return 3; }
}
PanelPolicyPeak::PanelPolicyPeak(PARAM* p, int parent, int x, int y, int w, int h) : PvObject(p)
PanelPolicyPeak::PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, int ih) : PvObject(p)
{
data.vecPeriods.resize(12, std::vector<int>(24, 3));
ui.parent = parent;
ui.widget = PvApp::widget(p, parent, x, y, w, h);
pvid = PvApp::widget(p, parent, ix, iy, iw, ih);
auto& appdata = Application::data();
std::vector<std::string> vecPeriods = {"尖峰", "高峰", "平段", "低谷"};
ui.vecComboxs.resize(12, std::vector<int>(24, PV_ID_NUL));
int x = 0, y = 10, w = 64, h = 30;
for (int row = 0; row<=12; row++)
{
int parent = ui.widget;
int x = 10, y = 180, w = 64, h = 30;
for (int row = 0; row<=12; row++)
for (int col = 0; col<=24; ++col)
{
for (int col = 0; col<=24; ++col)
std::string text;
if (row == 0)
{
std::string text;
if (row == 0)
{
text = (col == 0) ? "月份" : std::to_string(col-1) + "-" + std::to_string(col) + "";
}
else
{
text = (col == 0) ? std::to_string(row) : "";
}
if (row == 0 || col == 0)
{
std::string qssLabel = (row==0) ? qss::label(14, "", "rgb(19, 93, 114)") : "";
int label = PvApp::label(p, parent, x+w*col, y+h*row, w, h, text, qssLabel);
pvSetAlignment(p, label, AlignCenter);
}
else
{
int periodVal = data.vecPeriods[row-1][col-1];
int combox = PvApp::combox(p, parent, x+w*col, y+h*row+3, w-3, 24, vecPeriods, periodVal);
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
ui.vecComboxs[row-1][col-1] = combox;
PvApp::bind(p, PvEvent::TEXT_EVENT, combox, [=](std::string text) {
pvSetStyleSheet(p, combox, GetPeriodQss(text).c_str());
data.vecPeriods[row-1][col-1] = GetPeriod(text);
});
}
text = (col == 0) ? "月份" : std::to_string(col-1) + "-" + std::to_string(col) + "";
}
else
{
text = (col == 0) ? std::to_string(row) : "";
}
if (row == 0 || col == 0)
{
std::string qssLabel = (row==0) ? qss::label(14, "", "rgb(19, 93, 114)") : "";
int label = PvApp::label(p, pvid, x+w*col, y+h*row, w, h, text, qssLabel);
pvSetAlignment(p, label, AlignCenter);
}
else
{
int periodVal = data.vecPeriods[row-1][col-1];
int combox = PvApp::combox(p, pvid, x+w*col, y+h*row+3, w-3, 24, vecPeriods, periodVal-1);
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
ui.vecComboxs[row-1][col-1] = combox;
PvApp::bind(p, PvEvent::TEXT_EVENT, combox, [=](std::string text) {
pvSetStyleSheet(p, combox, GetPeriodQss(text).c_str());
data.vecPeriods[row-1][col-1] = GetPeriod(text);
});
}
}
const int H = 24;
int labelPolicy = PvApp::label(p, parent, 20, 600, 300, H, "充电策略");
ui.radioPolicy1 = PvApp::radioButton(p, labelPolicy, 80, 0, 80, H, "一充一放");
ui.radioPolicy2 = PvApp::radioButton(p, labelPolicy, 170, 0, 80, H, "两充两放");
ui.label1 = PvApp::label(p, parent, 10, 640, 610, 90, "第一次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
int y0 = 70;
int labelChargeT = PvApp::label(p, ui.label1, 10, 30, 300, H, "充电时间");
ui.attr1TimeCharge0 = PvApp::timeEdit(p, labelChargeT, y0, 0, 60, H);
PvApp::label(p, labelChargeT, 150, 0, 10, H, "--");
ui.attr1TimeCharge1 = PvApp::timeEdit(p, labelChargeT, 170, 0, 60, H);
int labelDischargeT = PvApp::label(p, ui.label1, 320, 30, 300, H, "放电时间");
ui.attr1TimeDischarge0 = PvApp::timeEdit(p, labelDischargeT, y0 = 70, 0, 60, H);
PvApp::label(p, labelDischargeT, y0+=70, 0, 10, H, "--");
ui.attr1TimeDischarge1 = PvApp::timeEdit(p, labelDischargeT, y0+=20, 0, 60, H);
int labelPowerIn = PvApp::label(p, ui.label1, 10, 60, 300, H, "充电功率");
ui.attr1RadioPowerInAuto = PvApp::radioButton(p, labelPowerIn, y0 = 70, 0, 60, H, "自动");
ui.attr1RadioPowerIn = PvApp::radioButton(p, labelPowerIn, y0 += 60, 0, 64, H, "自定义");
ui.arrt1LabelPowerIn = PvApp::lineEdit(p, labelPowerIn, y0 += 70, 0, 80, H, "");
int labelPowerOut = PvApp::label(p, ui.label1, 320, 60, 300, H, "放电功率");
ui.attr1RadioPowerOutAuto = PvApp::radioButton(p, labelPowerOut, y0 = 70, 0, 60, H, "自动");
ui.attr1RadioPowerOut = PvApp::radioButton(p, labelPowerOut, y0 += 60, 0, 64, H, "自定义");
ui.arrt1LabelPowerOut = PvApp::lineEdit(p, labelPowerOut, y0 += 70, 0, 80, H, "");
}
ui.label2 = PvApp::label(p, parent, 630, 640, 610, 90, "第二次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label2, AlignLeft | AlignTop);
{
int y0 = 70;
int labelChargeT = PvApp::label(p, ui.label2, 10, 30, 300, H, "充电时间");
XLOGD() << "labelChargeT=" << labelChargeT;
ui.attr2TimeCharge0 = PvApp::timeEdit(p, labelChargeT, y0, 0, 60, H);
PvApp::label(p, labelChargeT, 150, 0, 10, H, "--");
ui.attr2TimeCharge1 = PvApp::timeEdit(p, labelChargeT, 170, 0, 60, H);
int labelDischargeT = PvApp::label(p, ui.label2, 320, 30, 300, H, "放电时间");
ui.attr2TimeDischarge0 = PvApp::timeEdit(p, labelDischargeT, y0 = 70, 0, 60, H);
PvApp::label(p, labelDischargeT, y0 += 70, 0, 10, H, "--");
ui.attr2TimeDischarge1 = PvApp::timeEdit(p, labelDischargeT, y0 += 20, 0, 60, H);
int labelPowerIn = PvApp::label(p, ui.label2, 10, 60, 300, H, "充电功率");
ui.attr2RadioPowerInAuto = PvApp::radioButton(p, labelPowerIn, y0 = 70, 0, 60, H, "自动");
ui.attr2RadioPowerIn = PvApp::radioButton(p, labelPowerIn, y0 += 60, 0, 64, H, "自定义");
ui.arrt2LabelPowerIn = PvApp::lineEdit(p, labelPowerIn, y0 += 70, 0, 80, H, "");
int labelPowerOut = PvApp::label(p, ui.label2, 320, 60, 300, H, "放电功率");
ui.attr2RadioPowerOutAuto = PvApp::radioButton(p, labelPowerOut, y0 = 70, 0, 60, H, "自动");
ui.attr2RadioPowerOut = PvApp::radioButton(p, labelPowerOut, y0 += 60, 0, 64, H, "自定义");
ui.arrt2LabelPowerOut = PvApp::lineEdit(p, labelPowerOut, y0 += 70, 0, 80, H, "");
}
PvApp::bind(p, PvEvent::RADIOBUTTON_EVENT, ui.radioPolicy1, [=](std::string s) {
this->data.times = 1;
pvHide(p, ui.label2);
//setTimeText(ui.attr2TimeCharge0, "");
//setTimeText(ui.attr2TimeCharge1, "");
//setTimeText(ui.attr2TimeDischarge0, "");
//setTimeText(ui.attr2TimeDischarge1, "");
//pvSetChecked(p, ui.attr2RadioPowerInAuto, 1);
//pvSetChecked(p, ui.attr2RadioPowerOutAuto, 1);
//pvSetText(p, ui.arrt2LabelPowerOut, "");
//data.attr2.chargePower = data.attr2.dischargePower = 0.0;
//data.attr2.chargeTimeStart = data.attr2.chargeTimeEnd = data.attr2.dischargeTimeStart = data.attr2.dischargeTimeEnd = "";
});
PvApp::bind(p, PvEvent::RADIOBUTTON_EVENT, ui.radioPolicy2, [=](std::string s) {
this->data.times = 2;
pvShow(p, ui.label2);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeCharge0, [=](std::string s) {
data.attr1.chargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeCharge1, [=](std::string s) {
data.attr1.chargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeDischarge0, [=](std::string s) {
data.attr1.dischargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeDischarge1, [=](std::string s) {
data.attr1.dischargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeCharge0, [=](std::string s) {
data.attr2.chargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeCharge1, [=](std::string s) {
data.attr2.chargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeDischarge0, [=](std::string s) {
data.attr2.dischargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeDischarge1, [=](std::string s) {
data.attr2.dischargeTimeEnd = s.substr(0, 8);
});
{
int btn = PvApp::button(p, ui.widget, 10, 750, 100, 30, "DUMP");
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
XLOGD() << dumpAttr();
});
}
{
int btn = PvApp::button(p, ui.widget, 110, 750, 100, 30, "PARSE1");
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
std::string s = R"({"cycle":[{"charge_end":"","charge_power":0.0,"charge_start":"","discharge_end":"","discharge_power":0.0,"discharge_start":""}],
"period":[[1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]],
"times":1})";
parseAttr(s);
});
}
{
int btn = PvApp::button(p, ui.widget, 210, 750, 100, 30, "PARSE2");
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
std::string s = R"({"cycle":[{"charge_end":"09:00:00","charge_power":0.0,"charge_start":"00:00:00","discharge_end":"","discharge_power":0.0,"discharge_start":""}],
"period":[[1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]],
"times":2})";
parseAttr(s);
});
}
}
const int H = 24;
int labelPolicy = PvApp::label(p, pvid, 20, y = 420, 300, H, "充电策略");
ui.radioPolicy1 = PvApp::radioButton(p, labelPolicy, 80, 0, 80, H, "一充一放");
ui.radioPolicy2 = PvApp::radioButton(p, labelPolicy, 170, 0, 80, H, "两充两放");
ui.label1 = PvApp::label(p, pvid, 10, y+=30, 610, 90, "第一次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
int y0 = 70;
int labelChargeT = PvApp::label(p, ui.label1, 10, 30, 300, H, "充电时间");
ui.attr1TimeCharge0 = PvApp::timeEdit(p, labelChargeT, y0, 0, 90, H);
PvApp::label(p, labelChargeT, y0 += 100, 0, 10, H, "--");
ui.attr1TimeCharge1 = PvApp::timeEdit(p, labelChargeT, y0 =+ 20, 0, 90, H);
int labelDischargeT = PvApp::label(p, ui.label1, 320, 30, 300, H, "放电时间");
ui.attr1TimeDischarge0 = PvApp::timeEdit(p, labelDischargeT, y0 = 70, 0, 90, H);
PvApp::label(p, labelDischargeT, y0 += 100, 0, 10, H, "--");
ui.attr1TimeDischarge1 = PvApp::timeEdit(p, labelDischargeT, y0 += 20, 0, 90, H);
int labelPowerIn = PvApp::label(p, ui.label1, 10, 60, 300, H, "充电功率");
ui.attr1RadioPowerInAuto = PvApp::radioButton(p, labelPowerIn, y0 = 70, 0, 60, H, "自动");
ui.attr1RadioPowerIn = PvApp::radioButton(p, labelPowerIn, y0 += 60, 0, 64, H, "自定义");
ui.arrt1LabelPowerIn = PvApp::textedit(p, labelPowerIn, y0 += 70, 0, 80, H, "");
int labelPowerOut = PvApp::label(p, ui.label1, 320, 60, 300, H, "放电功率");
ui.attr1RadioPowerOutAuto = PvApp::radioButton(p, labelPowerOut, y0 = 70, 0, 60, H, "自动");
ui.attr1RadioPowerOut = PvApp::radioButton(p, labelPowerOut, y0 += 60, 0, 64, H, "自定义");
ui.arrt1LabelPowerOut = PvApp::textedit(p, labelPowerOut, y0 += 70, 0, 80, H, "");
}
ui.label2 = PvApp::label(p, pvid, 630, y, 610, 90, "第二次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label2, AlignLeft | AlignTop);
{
int y0 = 70;
int labelChargeT = PvApp::label(p, ui.label2, 10, 30, 300, H, "充电时间");
XLOGD() << "labelChargeT=" << labelChargeT;
ui.attr2TimeCharge0 = PvApp::timeEdit(p, labelChargeT, y0, 0, 60, H);
PvApp::label(p, labelChargeT, 150, 0, 10, H, "--");
ui.attr2TimeCharge1 = PvApp::timeEdit(p, labelChargeT, 170, 0, 60, H);
int labelDischargeT = PvApp::label(p, ui.label2, 320, 30, 300, H, "放电时间");
ui.attr2TimeDischarge0 = PvApp::timeEdit(p, labelDischargeT, y0 = 70, 0, 60, H);
PvApp::label(p, labelDischargeT, y0 += 70, 0, 10, H, "--");
ui.attr2TimeDischarge1 = PvApp::timeEdit(p, labelDischargeT, y0 += 20, 0, 60, H);
int labelPowerIn = PvApp::label(p, ui.label2, 10, 60, 300, H, "充电功率");
ui.attr2RadioPowerInAuto = PvApp::radioButton(p, labelPowerIn, y0 = 70, 0, 60, H, "自动");
ui.attr2RadioPowerIn = PvApp::radioButton(p, labelPowerIn, y0 += 60, 0, 64, H, "自定义");
ui.arrt2LabelPowerIn = PvApp::textedit(p, labelPowerIn, y0 += 70, 0, 80, H, "");
int labelPowerOut = PvApp::label(p, ui.label2, 320, 60, 300, H, "放电功率");
ui.attr2RadioPowerOutAuto = PvApp::radioButton(p, labelPowerOut, y0 = 70, 0, 60, H, "自动");
ui.attr2RadioPowerOut = PvApp::radioButton(p, labelPowerOut, y0 += 60, 0, 64, H, "自定义");
ui.arrt2LabelPowerOut = PvApp::textedit(p, labelPowerOut, y0 += 70, 0, 80, H, "");
}
PvApp::bind(p, PvEvent::RADIOBUTTON_EVENT, ui.radioPolicy1, [=](std::string s) {
this->data.times = 1;
pvHide(p, ui.label2);
//setTimeText(ui.attr2TimeCharge0, "");
//setTimeText(ui.attr2TimeCharge1, "");
//setTimeText(ui.attr2TimeDischarge0, "");
//setTimeText(ui.attr2TimeDischarge1, "");
//pvSetChecked(p, ui.attr2RadioPowerInAuto, 1);
//pvSetChecked(p, ui.attr2RadioPowerOutAuto, 1);
//pvSetText(p, ui.arrt2LabelPowerOut, "");
//data.attr2.chargePower = data.attr2.dischargePower = 0.0;
//data.attr2.chargeTimeStart = data.attr2.chargeTimeEnd = data.attr2.dischargeTimeStart = data.attr2.dischargeTimeEnd = "";
});
PvApp::bind(p, PvEvent::RADIOBUTTON_EVENT, ui.radioPolicy2, [=](std::string s) {
this->data.times = 2;
pvShow(p, ui.label2);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeCharge0, [=](std::string s) {
data.attr1.chargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeCharge1, [=](std::string s) {
data.attr1.chargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeDischarge0, [=](std::string s) {
data.attr1.dischargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr1TimeDischarge1, [=](std::string s) {
data.attr1.dischargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeCharge0, [=](std::string s) {
data.attr2.chargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeCharge1, [=](std::string s) {
data.attr2.chargeTimeEnd = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeDischarge0, [=](std::string s) {
data.attr2.dischargeTimeStart = s.substr(0, 8);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.attr2TimeDischarge1, [=](std::string s) {
data.attr2.dischargeTimeEnd = s.substr(0, 8);
});
// {
// int btn = PvApp::button(p, pvid, 10, y+=100, 90, 30, "DUMP");
// PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
// XLOGD() << dumpAttr();
// });
// }
// {
// int btn = PvApp::button(p, pvid, 110, y, 90, 30, "PARSE1");
// PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
// std::string s = R"({"cycle":[{"charge_end":"","charge_power":0.0,"charge_start":"","discharge_end":"","discharge_power":0.0,"discharge_start":""}],
//"period":[[1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]],
//"times":1})";
// parseAttr(s);
// });
// }
// {
// int btn = PvApp::button(p, pvid, 210, y, 90, 30, "PARSE2");
// PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
// std::string s = R"({"cycle":[
//{"charge_end":"09:00:00","charge_power":0.0,"charge_start":"00:00:00","discharge_end":"","discharge_power":0.0,"discharge_start":""},
//{"charge_end":"23:59:00","charge_power":0.0,"charge_start":"20:00:00","discharge_end":"13:00","discharge_power":0.0,"discharge_start":"09:00"}
//],
//"period":[[1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]],
//"times":2})";
// parseAttr(s);
// });
// }
}
void PanelPolicyPeak::updateUI()
@@ -284,7 +307,7 @@ void PanelPolicyPeak::parseAttr(std::string str)
periodVal = tmpVal;
// 更新UI (时段下拉列表)
auto combox = ui.vecComboxs[row][col];
pvSetCurrentItem(p, combox, periodVal);
pvSetCurrentItem(p, combox, periodVal-1);
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
}
}
@@ -333,7 +356,6 @@ void PanelPolicyPeak::parseAttr(std::string str)
}
std::string PanelPolicyPeak::dumpAttr()
{
NJsonNode jsonroot;
@@ -363,4 +385,117 @@ std::string PanelPolicyPeak::dumpAttr()
}
jsonroot["cycle"] = nodeCycle;
return jsonroot.dump();
}
PanelPolicyRequire::PanelPolicyRequire(PARAM* p, int parent, int ix, int iy, int iw, int ih) : PvObject(p)
{
pvid = PvApp::widget(p, parent, ix, iy, iw, ih);
int y = 10;
const int H = 24;
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 80, "响应削峰指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
ui.dischargeSoc = PvApp::lineTextedit(p, ui.label1, PvRect(10, 40, 270, H), 100, "电池SOC阈值", "");
ui.dischargePower = PvApp::lineTextedit(p, ui.label1, PvRect(300, 40, 270, H), 70, "放电功率", "");
}
ui.label2 = PvApp::label(p, pvid, 10, y += 90, 600, 90, "响应填谷指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label2, AlignLeft | AlignTop);
{
ui.chargeSoc = PvApp::lineTextedit(p, ui.label2, PvRect(10, 40, 270, H), 100, "电池SOC阈值", "");
ui.chargePower = PvApp::lineTextedit(p, ui.label2, PvRect(300, 40, 270, H), 70, "充电功率", "");
}
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.dischargeSoc, [=](std::string s) {
data.dischargeSoc = Utils::toInt(s);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.dischargePower, [=](std::string s) {
data.dischargePower = Utils::toInt(s);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.chargeSoc, [=](std::string s) {
data.chargeSoc = Utils::toInt(s);
});
PvApp::bind(p, PvEvent::TEXT_EVENT, ui.chargePower, [=](std::string s) {
data.chargePower = Utils::toInt(s);
});
}
void PanelPolicyRequire::parseAttr(std::string str)
{
NJsonNode jsonroot;
bool ret = NJson::parse(str, jsonroot);
if (!ret)
{
return;
}
NJson::read(jsonroot, "charge_soc", data.chargeSoc);
NJson::read(jsonroot, "charge_power", data.chargePower);
NJson::read(jsonroot, "discharge_soc", data.dischargeSoc);
NJson::read(jsonroot, "discharge_power", data.dischargePower);
// 更新UI
pvSetText(p, ui.chargeSoc, std::to_string(data.chargeSoc).c_str());
pvSetText(p, ui.chargePower, std::to_string(data.chargePower).c_str());
pvSetText(p, ui.dischargeSoc, std::to_string(data.dischargeSoc).c_str());
pvSetText(p, ui.dischargePower, std::to_string(data.dischargePower).c_str());
}
std::string PanelPolicyRequire::dumpAttr()
{
NJsonNode jsonroot;
jsonroot["discharge_soc"] = data.dischargeSoc;
jsonroot["discharge_power"] = data.dischargePower;
jsonroot["charge_soc"] = data.chargeSoc;
jsonroot["charge_power"] = data.chargePower;
return jsonroot.dump();
}
PanelPolicySelf::PanelPolicySelf(PARAM* p, int parent, int ix, int iy, int iw, int ih) : PvObject(p)
{
pvid = PvApp::widget(p, parent, ix, iy, iw, ih);
int y = 10;
const int H = 24;
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 120, "响应削峰指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
ui.usedSoc = PvApp::lineTextedit(p, ui.label1, PvRect(10, 40, 270, H), 100, "自用电量比值", "");
ui.gridSoc = PvApp::lineTextedit(p, ui.label1, PvRect(10, 80, 270, H), 100, "上网电量比值", "");
ui.chargePower = PvApp::lineTextedit(p, ui.label1, PvRect(320, 40, 250, H), 70, "充电功率", "");
ui.dischargePower = PvApp::lineTextedit(p, ui.label1, PvRect(320, 80, 250, H), 70, "放电功率", "");
}
}
void PanelPolicySelf::parseAttr(std::string str)
{
NJsonNode jsonroot;
bool ret = NJson::parse(str, jsonroot);
if (!ret)
{
return;
}
NJson::read(jsonroot, "used_soc", data.usedSoc);
NJson::read(jsonroot, "grid_soc", data.gridSoc);
NJson::read(jsonroot, "charge_power", data.chargePower);
NJson::read(jsonroot, "discharge_power", data.dischargePower);
// 更新UI
pvSetText(p, ui.usedSoc, std::to_string(data.usedSoc).c_str());
pvSetText(p, ui.gridSoc, std::to_string(data.gridSoc).c_str());
pvSetText(p, ui.chargePower, std::to_string(data.chargePower).c_str());
pvSetText(p, ui.dischargePower, std::to_string(data.dischargePower).c_str());
}
std::string PanelPolicySelf::dumpAttr()
{
NJsonNode jsonroot;
jsonroot["used_soc"] = data.usedSoc;
jsonroot["grid_soc"] = data.gridSoc;
jsonroot["charge_power"] = data.chargePower;
jsonroot["discharge_power"] = data.dischargePower;
return jsonroot.dump();
}

View File

@@ -6,7 +6,7 @@
class PanelPolicyPeak : public PvObject
{
public:
PanelPolicyPeak(PARAM* p, int parent, int x, int y, int w, int h);
PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, int ih);
void updateUI();
@@ -17,7 +17,6 @@ public:
struct {
int parent {};
int widget {PV_ID_NUL};
int label1 {PV_ID_NUL};
int label2 {PV_ID_NUL};
@@ -72,4 +71,59 @@ public:
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;
};

View File

@@ -4,7 +4,7 @@
void pvInitResource(PARAM* p)
{
pvDownloadFile(p, "assets/pv/bkg.png");
pvDownloadFile(p, "assets/pv/bkgHead.png");
pvDownloadFile(p, "assets/pv/icon1.png");
pvDownloadFile(p, "assets/pv/icon2.png");
pvDownloadFile(p, "assets/pv/icon3.png");
@@ -14,6 +14,7 @@ void pvInitResource(PARAM* p)
pvDownloadFile(p, "assets/pv/map.png");
pvDownloadFile(p, "assets/pv/mapMarker.png");
pvDownloadFile(p, "assets/pv/downFill.png");
pvDownloadFile(p, "assets/pv/play1.png");
}
int onPvThreadCleanup(void* ptr)
@@ -29,6 +30,7 @@ int pvMain(PARAM* p)
// 管理客户端的连接信息
PvUser pvuser;
PvApp::setPvUser(p, &pvuser);
XLOGD() << "Browser client connect: s= " << int(p->s) << ", user=" << int(&pvuser);
// 客户端断开时回调
pvSetCleanup(p, onPvThreadCleanup, p);
@@ -38,7 +40,7 @@ int pvMain(PARAM* p)
while (1)
{
// 重置控件的ID值
// 重置控件的ID值、回调函数表
PvApp::reset(p);
std::shared_ptr<MaskMain> mask;
@@ -48,14 +50,13 @@ int pvMain(PARAM* p)
pvStartDefinition(p, 2048);
if (mask)
{
pvSetFont(p, PV_ID_MAIN, "微软雅黑", 12, 1, 0, 0, 0);
pvSetStyleSheet(p, PV_ID_MAIN, "QWidget { color: white; font: bold 14px 微软雅黑; }");
mask->initUI();
}
pvQLayoutVbox(p, 0, -1);
pvEndDefinition(p);
XLOGD() << "===>>> pvidIndex=" << PvApp::pvid(p);
char event[MAX_EVENT_LENGTH];
char text[MAX_EVENT_LENGTH];
int pvid;
@@ -68,37 +69,36 @@ int pvMain(PARAM* p)
if (mask)
{
PvApp::dispatch(p, pvEventId, pvid, text);
switch (pvEventId)
{
case NULL_EVENT: {
pvcode = mask->onEventNull(pvid);
} break;
case BUTTON_EVENT: {
pvcode = mask->onEventButton(pvid); std::cout << "EVENT: (" << pvid << ")BUTTON\n";
pvcode = mask->onEventButton(pvid); std::cout << "PvEvent: (" << pvid << ") BUTTON\n";
} break;
case TEXT_EVENT: { std::cout << "EVENT: (" << pvid << ")TEXT_EVENT\n"; } break;
case SLIDER_EVENT: { std::cout << "EVENT: (" << pvid << ")SLIDER_EVENT\n"; } break;
case CHECKBOX_EVENT: { std::cout << "EVENT: (" << pvid << ")CHECKBOX_EVENT\n"; } break;
case RADIOBUTTON_EVENT: { std::cout << "EVENT: (" << pvid << ")RADIOBUTTON_EVENT\n"; } break;
case GL_IDLE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_IDLE_EVENT\n"; } break;
case GL_PAINT_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_PAINT_EVENT\n"; } break;
case GL_INITIALIZE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_INITIALIZE_EVENT\n"; } break;
case GL_RESIZE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_RESIZE_EVENT\n"; } break;
case TAB_EVENT: { std::cout << "EVENT: (" << pvid << ")TAB_EVENT\n"; } break;
case TABLE_CLICKED_EVENT: { std::cout << "EVENT: (" << pvid << ")TABLE_CLICKED_EVENT\n"; } break;
case TABLE_TEXT_EVENT: { std::cout << "EVENT: (" << pvid << ")TABLE_TEXT_EVENT\n"; } break;
case SELECTION_EVENT: { std::cout << "EVENT: (" << pvid << ")SELECTION_EVENT\n"; } break;
case CLIPBOARD_EVENT: { std::cout << "EVENT: (" << pvid << ")CLIPBOARD_EVENT\n"; } break;
case BUTTON_PRESSED_EVENT: { std::cout << "EVENT: (" << pvid << ")BUTTON_PRESSED_EVENT\n"; } break;
case BUTTON_RELEASED_EVENT: { std::cout << "EVENT: (" << pvid << ")BUTTON_RELEASED_EVENT\n"; } break;
case RIGHT_MOUSE_EVENT: { std::cout << "EVENT: (" << pvid << ")RIGHT_MOUSE_EVENT\n"; } break;
case KEYBOARD_EVENT: { std::cout << "EVENT: (" << pvid << ")KEYBOARD_EVENT\n"; } break;
case PLOT_MOUSE_MOVED_EVENT: { std::cout << "EVENT: (" << pvid << ")PLOT_MOUSE_MOVED_EVENT\n"; } break;
case PLOT_MOUSE_PRESSED_EVENT: { std::cout << "EVENT: (" << pvid << ")PLOT_MOUSE_PRESSED_EVENT\n"; } break;
case PLOT_MOUSE_RELEASED_EVENT: { std::cout << "EVENT: (" << pvid << ")PLOT_MOUSE_RELEASED_EVENT\n"; } break;
case USER_EVENT: { std::cout << "EVENT: (" << pvid << ")USER_EVENT\n"; } break;
case MOUSE_OVER_EVENT: { /*std::cout << "EVENT: (" << pvid << ")MOUSE_OVER_EVENT\n";*/ } break;
case TEXT_EVENT: { std::cout << "PvEvent: (" << pvid << ") TEXT_EVENT\n"; } break;
case SLIDER_EVENT: { std::cout << "PvEvent: (" << pvid << ") SLIDER_EVENT\n"; } break;
case CHECKBOX_EVENT: { std::cout << "PvEvent: (" << pvid << ") CHECKBOX_EVENT\n"; } break;
case RADIOBUTTON_EVENT: { std::cout << "PvEvent: (" << pvid << ") RADIOBUTTON_EVENT\n"; } break;
case GL_IDLE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_IDLE_EVENT\n"; } break;
case GL_PAINT_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_PAINT_EVENT\n"; } break;
case GL_INITIALIZE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_INITIALIZE_EVENT\n"; } break;
case GL_RESIZE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_RESIZE_EVENT\n"; } break;
case TAB_EVENT: { std::cout << "PvEvent: (" << pvid << ") TAB_EVENT\n"; } break;
case TABLE_CLICKED_EVENT: { std::cout << "PvEvent: (" << pvid << ") TABLE_CLICKED_EVENT\n"; } break;
case TABLE_TEXT_EVENT: { std::cout << "PvEvent: (" << pvid << ") TABLE_TEXT_EVENT\n"; } break;
case SELECTION_EVENT: { std::cout << "PvEvent: (" << pvid << ") SELECTION_EVENT\n"; } break;
case CLIPBOARD_EVENT: { std::cout << "PvEvent: (" << pvid << ") CLIPBOARD_EVENT\n"; } break;
case BUTTON_PRESSED_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") BUTTON_PRESSED_EVENT\n";*/ } break;
case BUTTON_RELEASED_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") BUTTON_RELEASED_EVENT\n";*/ } break;
case RIGHT_MOUSE_EVENT: { std::cout << "PvEvent: (" << pvid << ") RIGHT_MOUSE_EVENT\n"; } break;
case KEYBOARD_EVENT: { std::cout << "PvEvent: (" << pvid << ") KEYBOARD_EVENT\n"; } break;
case PLOT_MOUSE_MOVED_EVENT: { std::cout << "PvEvent: (" << pvid << ") PLOT_MOUSE_MOVED_EVENT\n"; } break;
case PLOT_MOUSE_PRESSED_EVENT: { std::cout << "PvEvent: (" << pvid << ") PLOT_MOUSE_PRESSED_EVENT\n"; } break;
case PLOT_MOUSE_RELEASED_EVENT: { std::cout << "PvEvent: (" << pvid << ") PLOT_MOUSE_RELEASED_EVENT\n"; } break;
case USER_EVENT: { std::cout << "PvEvent: (" << pvid << ") USER_EVENT\n"; } break;
case MOUSE_OVER_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") MOUSE_OVER_EVENT\n";*/ } break;
default: {} break;
}
}