mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
实现策略配置功能
This commit is contained in:
BIN
bin/Release/assets/pv/bkgHead.png
Normal file
BIN
bin/Release/assets/pv/bkgHead.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
BIN
bin/Release/assets/pv/play1.png
Normal file
BIN
bin/Release/assets/pv/play1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
@@ -51,10 +51,11 @@ void AppData::initFromDB()
|
|||||||
DAO::queryWorkModeDef(dao, result);
|
DAO::queryWorkModeDef(dao, result);
|
||||||
for (auto& fields: result)
|
for (auto& fields: result)
|
||||||
{
|
{
|
||||||
std::string workModeId = fields.value(DMDefWorkMode::WORK_MODE_ID);
|
int workModeId = fields.get<int>(DMDefWorkMode::WORK_MODE_ID);
|
||||||
std::string name = fields.value(DMDefWorkMode::NAME);
|
std::string name = fields.value(DMDefWorkMode::NAME);
|
||||||
this->mapping.workMode.push_back({workModeId, name});
|
this->mapping.workMode.push_back({std::to_string(workModeId), name});
|
||||||
str += ("工作模式: {" + workModeId + ":" + name + "},");
|
this->mapWorkMode[workModeId] = name;
|
||||||
|
str += ("工作模式: {" + std::to_string(workModeId)+":" + name + "},");
|
||||||
}
|
}
|
||||||
XLOGD() << str;
|
XLOGD() << str;
|
||||||
}
|
}
|
||||||
@@ -63,10 +64,11 @@ void AppData::initFromDB()
|
|||||||
DAO::queryPolicyTypeDef(dao, result);
|
DAO::queryPolicyTypeDef(dao, result);
|
||||||
for (auto& fields: result)
|
for (auto& fields: result)
|
||||||
{
|
{
|
||||||
std::string policyTypeId = fields.value(DMDefPolicyType::POLICY_TYPE_ID);
|
int policyTypeId = fields.get<int>(DMDefPolicyType::POLICY_TYPE_ID);
|
||||||
std::string name = fields.value(DMDefWorkMode::NAME);
|
std::string name = fields.value(DMDefWorkMode::NAME);
|
||||||
this->mapping.workMode.push_back({policyTypeId, name});
|
this->mapping.policyType.push_back({std::to_string(policyTypeId), name});
|
||||||
str += ("策略类型: {" + policyTypeId + ":" + name + "},");
|
this->mapPolicyType[policyTypeId] = name;
|
||||||
|
str += ("策略类型: {" + std::to_string(policyTypeId) + ":" + name + "},");
|
||||||
}
|
}
|
||||||
XLOGD() << str;
|
XLOGD() << str;
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,9 @@ void AppData::initFromDB()
|
|||||||
auto item = std::make_shared<DeviceType>();
|
auto item = std::make_shared<DeviceType>();
|
||||||
item->typeId = fields.get<int>(DMDefDeviceType::DEVICE_TYPE_ID);
|
item->typeId = fields.get<int>(DMDefDeviceType::DEVICE_TYPE_ID);
|
||||||
item->name = fields.value(DMDefDeviceType::NAME);
|
item->name = fields.value(DMDefDeviceType::NAME);
|
||||||
item->attrs = fields.value(DMDefDeviceType::ATTRS);
|
item->group = fields.value(DMDefDeviceType::GROUP);
|
||||||
|
item->attr = fields.value(DMDefDeviceType::ATTRS);
|
||||||
|
item->fieldsAttr.parseJson(item->attr);
|
||||||
mapDeviceType[item->typeId] = item;
|
mapDeviceType[item->typeId] = item;
|
||||||
mapping.deviceType.push_back({std::to_string(item->typeId), item->name});
|
mapping.deviceType.push_back({std::to_string(item->typeId), item->name});
|
||||||
str += ("设备类型: {" + std::to_string(item->typeId) + ":" + item->name + "},");
|
str += ("设备类型: {" + std::to_string(item->typeId) + ":" + item->name + "},");
|
||||||
@@ -106,12 +110,11 @@ void AppData::initFromDB()
|
|||||||
DAO::queryStationList(dao, result);
|
DAO::queryStationList(dao, result);
|
||||||
for (auto& fields: result)
|
for (auto& fields: result)
|
||||||
{
|
{
|
||||||
int stationId = fields.get<int>(DMStation::STATION_ID);
|
auto station = std::make_shared<Station>();
|
||||||
auto station = std::make_shared<Station>(stationId);
|
station->setFields(fields);
|
||||||
station->name = fields.value(DMStation::NAME);
|
this->mapStation[station->id] = station;
|
||||||
station->energyCapacity = fields.get<double>(DMStation::CAPACITY);
|
mapping.stationName.push_back({std::to_string(station->id), station->name});
|
||||||
this->mapStation[stationId] = station;
|
str += ("场站: {" + std::to_string(station->id) + ":" + station->name + "},");
|
||||||
str += ("场站: {" + std::to_string(stationId) + ":" + station->name + "},");
|
|
||||||
}
|
}
|
||||||
XLOGD() << str;
|
XLOGD() << str;
|
||||||
}
|
}
|
||||||
@@ -126,6 +129,8 @@ void AppData::initFromDB()
|
|||||||
if (station)
|
if (station)
|
||||||
{
|
{
|
||||||
auto device = Device::create(fields);
|
auto device = Device::create(fields);
|
||||||
|
auto deviceTypeDef = this->getDeviceTypeDef(device->type);
|
||||||
|
device->group = deviceTypeDef->group;
|
||||||
station->addDevice(deviceId, device);
|
station->addDevice(deviceId, device);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,9 +252,24 @@ std::shared_ptr<Device> AppData::getDevice(int stationId, int deviceId)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<int, std::shared_ptr<DeviceType>>& AppData::getDeviceTypeDef()
|
std::string AppData::getDeviceNameById(int typeId)
|
||||||
{
|
{
|
||||||
return mapDeviceType;
|
auto iter = mapDeviceType.find(typeId);
|
||||||
|
if (iter != mapDeviceType.end())
|
||||||
|
{
|
||||||
|
return iter->second->name;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DeviceType> AppData::getDeviceTypeDef(int typeId)
|
||||||
|
{
|
||||||
|
auto iter = mapDeviceType.find(typeId);
|
||||||
|
if (iter != mapDeviceType.end())
|
||||||
|
{
|
||||||
|
return iter->second;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppData::loadStatData()
|
void AppData::loadStatData()
|
||||||
@@ -261,8 +281,18 @@ void AppData::initUser()
|
|||||||
{
|
{
|
||||||
auto dao = DaoEntity::create("");
|
auto dao = DaoEntity::create("");
|
||||||
std::vector<Fields> result;
|
std::vector<Fields> result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppData::getWorkModeIdByName(std::string name)
|
||||||
|
{
|
||||||
|
for (auto iter = mapWorkMode.begin(); iter!=mapWorkMode.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->second == name)
|
||||||
|
{
|
||||||
|
return iter->first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> AppData::getRoleNames()
|
std::vector<std::string> AppData::getRoleNames()
|
||||||
@@ -331,6 +361,16 @@ std::vector<std::string> AppData::getPolicyNames()
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AppData::getPolicyTypeId(std::string name)
|
||||||
|
{
|
||||||
|
for (auto iter = mapPolicyType.begin(); iter != mapPolicyType.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->second == name) { return iter->first; }
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> AppData::getElectPreiodVals(int month)
|
std::vector<std::string> AppData::getElectPreiodVals(int month)
|
||||||
{
|
{
|
||||||
if (month > 0 && month-1 < vecElectPeriods.size())
|
if (month > 0 && month-1 < vecElectPeriods.size())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "common/Fields.h"
|
||||||
|
|
||||||
class Station;
|
class Station;
|
||||||
class Device;
|
class Device;
|
||||||
@@ -16,7 +17,9 @@ struct DeviceType
|
|||||||
{
|
{
|
||||||
int typeId {};
|
int typeId {};
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string attrs;
|
std::string group;
|
||||||
|
std::string attr;
|
||||||
|
Fields fieldsAttr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Role
|
struct Role
|
||||||
@@ -47,19 +50,26 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
void initFromDB();
|
void initFromDB();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 读取统计数据: 今日统计数据,累计统计数据
|
||||||
|
void loadStatData();
|
||||||
|
|
||||||
|
void initUser();
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Station> getStation(int stationId);
|
std::shared_ptr<Station> getStation(int stationId);
|
||||||
|
|
||||||
std::shared_ptr<Station> getStationByName(std::string name);
|
std::shared_ptr<Station> getStationByName(std::string name);
|
||||||
|
|
||||||
std::shared_ptr<Device> getDevice(int stationId, int deviceId);
|
std::shared_ptr<Device> getDevice(int stationId, int deviceId);
|
||||||
|
|
||||||
|
std::string getDeviceNameById(int typeId);
|
||||||
|
|
||||||
// 获取设备类型定义
|
// 获取设备类型定义
|
||||||
std::unordered_map<int, std::shared_ptr<DeviceType>>& getDeviceTypeDef();
|
std::shared_ptr<DeviceType> getDeviceTypeDef(int typeId);
|
||||||
|
|
||||||
// 读取统计数据: 今日统计数据,累计统计数据
|
int getWorkModeIdByName(std::string name);
|
||||||
void loadStatData();
|
|
||||||
|
|
||||||
void initUser();
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// 获取角色名称列表
|
// 获取角色名称列表
|
||||||
@@ -74,6 +84,9 @@ public:
|
|||||||
std::vector<std::string> getPolicyTypeNames();
|
std::vector<std::string> getPolicyTypeNames();
|
||||||
// 获取策略名称
|
// 获取策略名称
|
||||||
std::vector<std::string> getPolicyNames();
|
std::vector<std::string> getPolicyNames();
|
||||||
|
// 根据策略类型ID获取策略类型名称
|
||||||
|
// 根据策略类型名称获取策略类型ID
|
||||||
|
int getPolicyTypeId(std::string name);
|
||||||
|
|
||||||
std::vector<std::string> getElectPreiodVals(int month);
|
std::vector<std::string> getElectPreiodVals(int month);
|
||||||
|
|
||||||
@@ -103,6 +116,9 @@ public:
|
|||||||
VecPairSS deviceType;
|
VecPairSS deviceType;
|
||||||
|
|
||||||
VecPairSS workMode;
|
VecPairSS workMode;
|
||||||
|
|
||||||
|
VecPairSS policyType;
|
||||||
|
VecPairSS stationName;
|
||||||
} mapping;
|
} mapping;
|
||||||
|
|
||||||
double electPriceSuperPeak {};
|
double electPriceSuperPeak {};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "common/Logger.h"
|
#include "common/Logger.h"
|
||||||
#include "common/Utils.h"
|
#include "common/Utils.h"
|
||||||
#include "protocol/Communicator.h"
|
#include "protocol/CommEntity.h"
|
||||||
#include "common/JsonN.h"
|
#include "common/JsonN.h"
|
||||||
|
|
||||||
//int DeviceEntity::getAttrInt(std::string key)
|
//int DeviceEntity::getAttrInt(std::string key)
|
||||||
@@ -56,7 +56,7 @@ int Device::startComm()
|
|||||||
// 创建新的通讯
|
// 创建新的通讯
|
||||||
if (!commEntity)
|
if (!commEntity)
|
||||||
{
|
{
|
||||||
commEntity = Communicator::createEntity(attrs);
|
commEntity = CommEntity::create(attrs);
|
||||||
if (!commEntity) { return -1; }
|
if (!commEntity) { return -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,14 @@ public:
|
|||||||
int type = -1;
|
int type = -1;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string code;
|
std::string code;
|
||||||
|
std::string group;
|
||||||
bool isOpen = false;
|
bool isOpen = false;
|
||||||
std::string attrsJson = "";
|
std::string attrsJson = "";
|
||||||
|
|
||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int online = 0;
|
int online = 0;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
|
|
||||||
//std::map<std::string, std::string> mapAttrs;
|
//std::map<std::string, std::string> mapAttrs;
|
||||||
Fields attrs;
|
Fields attrs;
|
||||||
|
|
||||||
@@ -41,16 +40,3 @@ public:
|
|||||||
|
|
||||||
static std::shared_ptr<Device> create(Fields& fields);
|
static std::shared_ptr<Device> create(Fields& fields);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//class Device
|
|
||||||
//{
|
|
||||||
//public:
|
|
||||||
// static void add(DataFields& fields);
|
|
||||||
//
|
|
||||||
// static std::vector<std::shared_ptr<DeviceEntity>> getDeviceByType(int type);
|
|
||||||
//
|
|
||||||
//public:
|
|
||||||
// static std::map<int, std::shared_ptr<DeviceEntity>> mapDevices;
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,70 @@
|
|||||||
#include "Station.h"
|
#include "Station.h"
|
||||||
#include "database/DAO.h"
|
#include "database/DAO.h"
|
||||||
#include "database/SQL.h"
|
#include "database/SQL.h"
|
||||||
|
#include "common/fields.h"
|
||||||
|
#include "app/Device.h"
|
||||||
|
|
||||||
Station::Station(int id) : id(id)
|
|
||||||
|
Station::Station() : id(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Station::setFields(Fields& fields)
|
||||||
|
{
|
||||||
|
this->id = fields.get<int>(DMStation::STATION_ID);
|
||||||
|
this->name = fields.value(DMStation::NAME);
|
||||||
|
this->energyCapacity = fields.get<double>(DMStation::CAPACITY);
|
||||||
|
this->workModeId = fields.get<int>(DMStation::WORK_MODE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
|
void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
|
||||||
{
|
{
|
||||||
mapDevice_[deviceId] = device;
|
mapDevice[deviceId] = device;
|
||||||
|
mapDeviceGroupNum[device->group]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Device> Station::getDevice(int deviceId)
|
std::shared_ptr<Device> Station::getDevice(int deviceId)
|
||||||
{
|
{
|
||||||
auto iter = mapDevice_.find(deviceId);
|
auto iter = mapDevice.find(deviceId);
|
||||||
if (iter!=mapDevice_.end())
|
if (iter!=mapDevice.end())
|
||||||
{
|
{
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Station::getDeviceByType(int typeId, std::vector<std::shared_ptr<Device>>& res)
|
||||||
|
{
|
||||||
|
for (auto iter = mapDevice.begin(); iter!=mapDevice.end(); ++iter)
|
||||||
|
{
|
||||||
|
auto device = iter->second;
|
||||||
|
if (device->type == typeId)
|
||||||
|
{
|
||||||
|
res.push_back(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Station::getDeviceNumByGroup(std::string name)
|
||||||
|
{
|
||||||
|
return mapDeviceGroupNum[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Station::getDeviceByGroup(std::string name, std::vector<std::shared_ptr<Device>>& res)
|
||||||
|
{
|
||||||
|
for (auto iter = mapDevice.begin(); iter!=mapDevice.end(); ++iter)
|
||||||
|
{
|
||||||
|
auto device = iter->second;
|
||||||
|
if (device->group == name)
|
||||||
|
{
|
||||||
|
res.push_back(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Station::setWorkMode(int modeId)
|
void Station::setWorkMode(int modeId)
|
||||||
{
|
{
|
||||||
|
this->workModeId = modeId;
|
||||||
std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME)
|
std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME)
|
||||||
.update(DMStation::WORK_MODE_ID, std::to_string(modeId))
|
.update(DMStation::WORK_MODE_ID, std::to_string(modeId))
|
||||||
.where(DMStation::STATION_ID + "=" + std::to_string(id)).str();
|
.where(DMStation::STATION_ID + "=" + std::to_string(id)).str();
|
||||||
|
|||||||
@@ -2,27 +2,35 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "common/Fields.h"
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
class Station
|
class Station
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Station(int id);
|
Station();
|
||||||
|
|
||||||
|
void setFields(Fields& fields);
|
||||||
|
|
||||||
void addDevice(int deviceId, std::shared_ptr<Device> device);
|
void addDevice(int deviceId, std::shared_ptr<Device> device);
|
||||||
std::shared_ptr<Device> getDevice(int deviceId);
|
std::shared_ptr<Device> getDevice(int deviceId);
|
||||||
|
|
||||||
|
void getDeviceByType(int typeId, std::vector<std::shared_ptr<Device>>& res);
|
||||||
|
int getDeviceNumByGroup(std::string name);
|
||||||
|
void getDeviceByGroup(std::string name, std::vector<std::shared_ptr<Device>>& res);
|
||||||
|
|
||||||
void setWorkMode(int modeId);
|
void setWorkMode(int modeId);
|
||||||
void setPolicy(int policyId);
|
void setPolicy(int policyId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int id {};
|
int id {};
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
int workModeId; // 运行模式
|
int workModeId {}; // 运行模式
|
||||||
int runPolicyId; // 运行策略
|
int runPolicyId {}; // 运行策略
|
||||||
|
|
||||||
// 储能容量
|
// 储能容量
|
||||||
double energyCapacity {};
|
double energyCapacity {};
|
||||||
@@ -77,5 +85,7 @@ public:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// === 设备信息 ===
|
/// === 设备信息 ===
|
||||||
std::unordered_map<int, std::shared_ptr<Device>> mapDevice_;
|
std::unordered_map<int, std::shared_ptr<Device>> mapDevice;
|
||||||
|
|
||||||
|
std::map<std::string, int> mapDeviceGroupNum;
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Fields.h"
|
#include "Fields.h"
|
||||||
#include "common/Utils.h"
|
#include "common/Utils.h"
|
||||||
|
#include "common/JsonN.h"
|
||||||
|
|
||||||
std::string& Fields::value(std::string key)
|
std::string& Fields::value(std::string key)
|
||||||
{
|
{
|
||||||
@@ -14,14 +14,16 @@ bool Fields::contains(std::string key)
|
|||||||
return (mapFields.find(key) != mapFields.end());
|
return (mapFields.find(key) != mapFields.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<string, string>::iterator Fields::remove(string key)
|
std::string Fields::remove(string key)
|
||||||
{
|
{
|
||||||
|
std::string val;
|
||||||
auto it = mapFields.find(key);
|
auto it = mapFields.find(key);
|
||||||
if (it != mapFields.end())
|
if (it != mapFields.end())
|
||||||
{
|
{
|
||||||
it = mapFields.erase(it);
|
val = it->second;
|
||||||
|
mapFields.erase(it);
|
||||||
}
|
}
|
||||||
return it;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fields::append(Fields& datafield)
|
void Fields::append(Fields& datafield)
|
||||||
@@ -177,6 +179,13 @@ string Fields::toSqlUpdate(string tableName, std::vector<std::string> vecKeys, s
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Fields::parseJson(std::string jsonstr)
|
||||||
|
{
|
||||||
|
NJsonNode jsonroot;
|
||||||
|
NJson::parse(jsonstr, jsonroot);
|
||||||
|
|
||||||
|
for (auto& item : jsonroot.items())
|
||||||
|
{
|
||||||
|
this->set(item.key(), item.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,8 @@ struct PageInfo
|
|||||||
class Fields
|
class Fields
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Fields() {};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void set(string key, T val, int precision=6)
|
void set(string key, T val, int precision=6)
|
||||||
{
|
{
|
||||||
@@ -42,7 +44,6 @@ public:
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取值
|
* 获取值
|
||||||
* @param: [string key] 索引名称
|
* @param: [string key] 索引名称
|
||||||
@@ -60,7 +61,7 @@ public:
|
|||||||
* 删除指定索引的值
|
* 删除指定索引的值
|
||||||
* @param: [string key] 索引名称
|
* @param: [string key] 索引名称
|
||||||
*/
|
*/
|
||||||
std::unordered_map<string, string>::iterator remove(string key);
|
std::string remove(string key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 追加合并
|
* 追加合并
|
||||||
@@ -136,6 +137,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
string toSqlUpdate(string tableName, std::vector<std::string> vecKeys, string condition);
|
string toSqlUpdate(string tableName, std::vector<std::string> vecKeys, string condition);
|
||||||
|
|
||||||
|
void parseJson(std::string jsonstr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<string, string> mapFields;
|
std::unordered_map<string, string> mapFields;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -91,6 +91,15 @@ public:
|
|||||||
std::cout << "JSON read error: " << e.what() << std::endl;
|
std::cout << "JSON read error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void parse(std::string jsonstr, std::vector<std::string>& vd)
|
||||||
|
{
|
||||||
|
NJsonNode jsonroot;
|
||||||
|
if (NJson::parse(jsonstr, jsonroot))
|
||||||
|
{
|
||||||
|
vd = jsonroot.get<std::vector<std::string>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
std::mutex g_mutex;
|
std::mutex g_mutex;
|
||||||
|
|
||||||
Logger::Logger(Logger::ELogType logtype, std::string filename, int lineEdit) : line_(lineEdit)
|
Logger::Logger(Logger::ELogType logtype, std::string filename, int edit) : line_(edit)
|
||||||
{
|
{
|
||||||
auto index = filename.find_last_of('\\');
|
auto index = filename.find_last_of('\\');
|
||||||
if (index != std::string::npos)
|
if (index != std::string::npos)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Logger(Logger::ELogType logType, std::string filename, int lineEdit);
|
Logger(Logger::ELogType logType, std::string filename, int edit);
|
||||||
~Logger();
|
~Logger();
|
||||||
std::stringstream& Stream() { return oss_; }
|
std::stringstream& Stream() { return oss_; }
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ Errcode DAO::insertUser(Fields& params)
|
|||||||
auto dao = DaoEntity::create(DMUser::TABLENAME);
|
auto dao = DaoEntity::create(DMUser::TABLENAME);
|
||||||
std::string account = params.value(DMUser::ACCOUNT);
|
std::string account = params.value(DMUser::ACCOUNT);
|
||||||
|
|
||||||
|
std::string userRoleId = params.remove(DMRole::ROLE_ID);
|
||||||
|
|
||||||
|
|
||||||
// step1: 查询
|
// step1: 查询
|
||||||
std::vector<Fields> result;
|
std::vector<Fields> result;
|
||||||
bool ret = dao->exec("SELECT * from user WHERE account='" + account + "';", result);
|
bool ret = dao->exec("SELECT * from user WHERE account='" + account + "';", result);
|
||||||
@@ -101,11 +104,14 @@ Errcode DAO::insertUser(Fields& params)
|
|||||||
{
|
{
|
||||||
return Errcode::ERR_DB_SQL;
|
return Errcode::ERR_DB_SQL;
|
||||||
}
|
}
|
||||||
Fields paramsUserRole;
|
if (!userRoleId.empty())
|
||||||
paramsUserRole.set(DMUser::USER_ID, params.value(DMUser::USER_ID));
|
{
|
||||||
paramsUserRole.set(DMRole::ROLE_ID, params.value(DMRole::ROLE_ID));
|
Fields paramsUserRole;
|
||||||
paramsUserRole.set(DMUser::UPDATETIME, createTime);
|
paramsUserRole.set(DMUser::USER_ID, params.value(DMUser::USER_ID));
|
||||||
ret = dao->duplicateUpdate(paramsUserRole, {DMUser::USER_ID});
|
paramsUserRole.set(DMRole::ROLE_ID, userRoleId);
|
||||||
|
paramsUserRole.set(DMUser::UPDATETIME, createTime);
|
||||||
|
ret = dao->duplicateUpdate(paramsUserRole, {DMUser::USER_ID});
|
||||||
|
}
|
||||||
return Errcode::OK;
|
return Errcode::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,30 +133,28 @@ bool DAO::queryUserList(PageInfo& pageInfo, vector<Fields>& result)
|
|||||||
|
|
||||||
Errcode DAO::updateUserById(Fields& params)
|
Errcode DAO::updateUserById(Fields& params)
|
||||||
{
|
{
|
||||||
std::string createTime = Utils::timeStr();
|
|
||||||
std::string userId = params.value(DMUser::USER_ID);
|
|
||||||
std::string roleId = "";
|
|
||||||
if (params.contains(DMRole::ROLE_ID))
|
|
||||||
{
|
|
||||||
roleId = params.value(DMRole::ROLE_ID);
|
|
||||||
params.remove(DMUser::USER_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto dao = DaoEntity::create(DMUser::TABLENAME);
|
auto dao = DaoEntity::create(DMUser::TABLENAME);
|
||||||
bool ret = dao->updateFields(params, "WHERE " + DMUser::USER_ID + "='" + userId + "'");
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
return Errcode::ERR_DB_SQL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
std::string createTime = Utils::timeStr();
|
||||||
|
std::string userId = params.remove(DMUser::USER_ID);
|
||||||
|
std::string roleId = params.remove(DMRole::ROLE_ID);
|
||||||
|
|
||||||
|
if (params.size() > 0)
|
||||||
|
{
|
||||||
|
bool ret = dao->updateFields(params, "WHERE " + DMUser::USER_ID + "='" + userId + "'");
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
return Errcode::ERR_DB_SQL;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!roleId.empty())
|
if (!roleId.empty())
|
||||||
{
|
{
|
||||||
dao->setTableName(DMUserRole::TABLENAME);
|
dao->setTableName(DMUserRole::TABLENAME);
|
||||||
Fields paramsUserRole;
|
Fields paramsUserRole;
|
||||||
paramsUserRole.set(DMUserRole::USER_ID, params.value(DMUserRole::USER_ID));
|
paramsUserRole.set(DMUserRole::USER_ID, userId);
|
||||||
paramsUserRole.set(DMUserRole::ROLE_ID, params.value(DMUserRole::ROLE_ID));
|
paramsUserRole.set(DMUserRole::ROLE_ID, roleId);
|
||||||
paramsUserRole.set(DMUserRole::UPDATETIME, createTime);
|
paramsUserRole.set(DMUserRole::UPDATETIME, createTime);
|
||||||
ret = dao->duplicateUpdate(paramsUserRole, {DMUser::USER_ID});
|
bool ret = dao->duplicateUpdate(paramsUserRole, {DMUserRole::ROLE_ID});
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
return Errcode::ERR_DB_SQL;
|
return Errcode::ERR_DB_SQL;
|
||||||
@@ -298,6 +302,20 @@ Errcode DAO::queryPolicyList(std::shared_ptr<DaoEntity> dao, vector<Fields>& res
|
|||||||
std::string sql = "SELECT * FROM " + DMPolicy::TABLENAME;
|
std::string sql = "SELECT * FROM " + DMPolicy::TABLENAME;
|
||||||
return DAO::exec(dao, sql, result);
|
return DAO::exec(dao, sql, result);
|
||||||
}
|
}
|
||||||
|
Errcode DAO::insertPolicy(Fields& params)
|
||||||
|
{
|
||||||
|
return DAO::exec(NULL, params.toSqlInsert(DMPolicy::TABLENAME));
|
||||||
|
}
|
||||||
|
Errcode DAO::updatePolicyById(Fields& params)
|
||||||
|
{
|
||||||
|
std::string policyId = params.value(DMPolicy::POLICY_ID);
|
||||||
|
if (policyId.empty())
|
||||||
|
{
|
||||||
|
return Errcode::ERR_DB_SQL;
|
||||||
|
}
|
||||||
|
std::string sql = params.toSqlUpdate(DMPolicy::TABLENAME, "WHERE " + DMPolicy::POLICY_ID + "='" + policyId + "'");
|
||||||
|
return DAO::exec(NULL, sql);
|
||||||
|
}
|
||||||
|
|
||||||
// 系统日志管理
|
// 系统日志管理
|
||||||
bool DAO::querySystemLogList(PageInfo& pageInfo, vector<Fields>& result)
|
bool DAO::querySystemLogList(PageInfo& pageInfo, vector<Fields>& result)
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public:
|
|||||||
|
|
||||||
static Errcode queryPolicyList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result);
|
static Errcode queryPolicyList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result);
|
||||||
|
|
||||||
|
static Errcode insertPolicy(Fields& params);
|
||||||
|
static Errcode updatePolicyById(Fields& params);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// === 系统日志管理 ===
|
// === 系统日志管理 ===
|
||||||
// 分页查询系统日志列表
|
// 分页查询系统日志列表
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//#include "PvInstance.h"
|
//#include "PvInstance.h"
|
||||||
//#include "spdlogger.h"
|
//#include "spdlogger.h"
|
||||||
|
|
||||||
MysqlOption DaoEntity::option_;
|
MysqlOption DaoEntity::option;
|
||||||
|
|
||||||
DaoEntity::DaoEntity(string tb_name)
|
DaoEntity::DaoEntity(string tb_name)
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@ DaoEntity::DaoEntity(string tb_name)
|
|||||||
//opts.password = "123456";
|
//opts.password = "123456";
|
||||||
//opts.port = 3306;
|
//opts.port = 3306;
|
||||||
//opts.dbname = "pvb";
|
//opts.dbname = "pvb";
|
||||||
db_ = make_shared<MysqlClient>(DaoEntity::option_);
|
db_ = make_shared<MysqlClient>(DaoEntity::option);
|
||||||
if (!db_->isConnected())
|
if (!db_->isConnected())
|
||||||
{
|
{
|
||||||
//Global::data().status_msg = "数据库连接异常!";
|
//Global::data().status_msg = "数据库连接异常!";
|
||||||
@@ -28,15 +28,15 @@ DaoEntity::~DaoEntity()
|
|||||||
|
|
||||||
MysqlOption& DaoEntity::mysqlOption()
|
MysqlOption& DaoEntity::mysqlOption()
|
||||||
{
|
{
|
||||||
return DaoEntity::option_;
|
return DaoEntity::option;
|
||||||
}
|
}
|
||||||
void DaoEntity::setOption(std::string host, int port, std::string user, std::string pwd, std::string dbname)
|
void DaoEntity::setOption(std::string host, int port, std::string user, std::string pwd, std::string dbname)
|
||||||
{
|
{
|
||||||
option_.host = host;
|
option.host = host;
|
||||||
option_.port = port;
|
option.port = port;
|
||||||
option_.user = user;
|
option.user = user;
|
||||||
option_.password = pwd;
|
option.password = pwd;
|
||||||
option_.dbname = dbname;
|
option.dbname = dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
|
std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
|
||||||
@@ -46,13 +46,13 @@ std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
|
|||||||
|
|
||||||
bool DaoEntity::execOnce(string sql)
|
bool DaoEntity::execOnce(string sql)
|
||||||
{
|
{
|
||||||
auto db = make_shared<MysqlClient>(DaoEntity::option_);
|
auto db = make_shared<MysqlClient>(DaoEntity::option);
|
||||||
return db->exec(sql);
|
return db->exec(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaoEntity::execOnce(string sql, vector<Fields>& result)
|
bool DaoEntity::execOnce(string sql, vector<Fields>& result)
|
||||||
{
|
{
|
||||||
auto db = make_shared<MysqlClient>(DaoEntity::option_);
|
auto db = make_shared<MysqlClient>(DaoEntity::option);
|
||||||
return db->exec(sql, result);
|
return db->exec(sql, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,27 +130,27 @@ bool DaoEntity::insertFields(vector<Fields>& vec_fields)
|
|||||||
bool DaoEntity::duplicateUpdate(Fields& fields, const vector<string>& keys)
|
bool DaoEntity::duplicateUpdate(Fields& fields, const vector<string>& keys)
|
||||||
{
|
{
|
||||||
//insert into device_attr(device_id, attr_id, attr_val) values('26', 'model', '型号1') on duplicate key update attr_val='型号1';
|
//insert into device_attr(device_id, attr_id, attr_val) values('26', 'model', '型号1') on duplicate key update attr_val='型号1';
|
||||||
string s_key;
|
string key;
|
||||||
string s_val;
|
string val;
|
||||||
for (auto& item : fields.map())
|
for (auto& item : fields.map())
|
||||||
{
|
{
|
||||||
if (!s_key.empty())
|
if (!key.empty())
|
||||||
{
|
{
|
||||||
s_key += ","; s_val += ",";
|
key += ","; val += ",";
|
||||||
}
|
}
|
||||||
s_key += (item.first);
|
key += (item.first);
|
||||||
s_val += ("'" + item.second + "'");
|
val += ("'" + item.second + "'");
|
||||||
}
|
}
|
||||||
string s_data;
|
string str;
|
||||||
for (auto& k : keys)
|
for (auto& k : keys)
|
||||||
{
|
{
|
||||||
if (!s_data.empty())
|
if (!str.empty())
|
||||||
{
|
{
|
||||||
s_data += ",";
|
str += ",";
|
||||||
}
|
}
|
||||||
s_data += (k + "='" + fields.value(k) + "'");
|
str += (k + "='" + fields.value(k) + "'");
|
||||||
}
|
}
|
||||||
string sql = "INSERT INTO " + tableName_ + "(" + s_key + ") VALUES (" + s_val + ") ON duplicate KEY UPDATE " + s_data;
|
string sql = "INSERT INTO " + tableName_ + "(" + key + ") VALUES (" + val + ") ON duplicate KEY UPDATE " + str;
|
||||||
return this->db_->exec(sql);
|
return this->db_->exec(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
bool updateFields(Fields& fields, vector<string> vecKeys, const string& cond);
|
bool updateFields(Fields& fields, vector<string> vecKeys, const string& cond);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static MysqlOption option_;
|
static MysqlOption option;
|
||||||
|
|
||||||
// mysql 数据库操作对象
|
// mysql 数据库操作对象
|
||||||
std::shared_ptr<MysqlClient> db_ = nullptr;
|
std::shared_ptr<MysqlClient> db_ = nullptr;
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ namespace DMDefDeviceType
|
|||||||
const string TABLENAME = "def_device_type";
|
const string TABLENAME = "def_device_type";
|
||||||
const string DEVICE_TYPE_ID = "device_type_id";
|
const string DEVICE_TYPE_ID = "device_type_id";
|
||||||
const string NAME = "name";
|
const string NAME = "name";
|
||||||
|
const string GROUP = "group";
|
||||||
const string ATTRS = "attrs";
|
const string ATTRS = "attrs";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//#include "Spdlogger.h"
|
//#include "Spdlogger.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
MysqlClient::MysqlClient(MysqlOption option) : option_(option)
|
MysqlClient::MysqlClient(MysqlOption option) : option(option)
|
||||||
{
|
{
|
||||||
conn();
|
conn();
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ int MysqlClient::conn()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mysql_ = mysql_init(nullptr);
|
mysql_ = mysql_init(nullptr);
|
||||||
MYSQL* ret = mysql_real_connect(mysql_, option_.host.c_str(), option_.user.c_str(), option_.password.c_str(), option_.dbname.c_str(), option_.port, NULL, 0);
|
MYSQL* ret = mysql_real_connect(mysql_, option.host.c_str(), option.user.c_str(), option.password.c_str(), option.dbname.c_str(), option.port, NULL, 0);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
std::string err = mysql_error(mysql_);
|
std::string err = mysql_error(mysql_);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ private:
|
|||||||
MYSQL* mysql_ = nullptr;
|
MYSQL* mysql_ = nullptr;
|
||||||
|
|
||||||
// 数据库连接信息
|
// 数据库连接信息
|
||||||
MysqlOption option_;
|
MysqlOption option;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !!! _DbMysql_H_
|
#endif // !!! _DbMysql_H_
|
||||||
|
|||||||
20
src/main.cpp
20
src/main.cpp
@@ -18,7 +18,9 @@
|
|||||||
#include "pv/PvApp.h"
|
#include "pv/PvApp.h"
|
||||||
#include "pv/PvUser.h"
|
#include "pv/PvUser.h"
|
||||||
|
|
||||||
|
#include "rlsocket.h"
|
||||||
|
|
||||||
|
#define wsa rlwsa
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// 设置控制台输出为 UTF-8 编码
|
// 设置控制台输出为 UTF-8 编码
|
||||||
@@ -52,6 +54,24 @@ int main(int argc, char** argv)
|
|||||||
std::cout << jsonroot1.dump();
|
std::cout << jsonroot1.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<int, bool> mapT;
|
||||||
|
bool ff = mapT[1];
|
||||||
|
|
||||||
|
//rlwsa();
|
||||||
|
//rlSocket socket("127.0.0.1", 19801, 1);
|
||||||
|
//int ret = socket.connect();
|
||||||
|
//std::string s1 = "helloworld";
|
||||||
|
//socket.write(s1.c_str(), s1.size());
|
||||||
|
|
||||||
|
//std::vector<char> buf(1024, 0);
|
||||||
|
//while (true)
|
||||||
|
//{
|
||||||
|
// int len = socket.read(&buf[0], 1, 0);
|
||||||
|
// if (len > 0)
|
||||||
|
// {
|
||||||
|
// std::cout << "===>>> " << std::string(buf.begin(), buf.end());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
std::cout << "===>>> main start ... " << std::endl;
|
std::cout << "===>>> main start ... " << std::endl;
|
||||||
|
|
||||||
////std::cout << Snowflake::instance().getId() << std::endl;
|
////std::cout << Snowflake::instance().getId() << std::endl;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Communicator.h"
|
#include "CommEntity.h"
|
||||||
#include "TcpEntity.h"
|
#include "TcpEntity.h"
|
||||||
|
|
||||||
std::shared_ptr<CommEntity> Communicator::createEntity(Fields& data)
|
std::shared_ptr<CommEntity> CommEntity::create(Fields& data)
|
||||||
{
|
{
|
||||||
std::string commType = data.value("commType");
|
std::string commType = data.value("commType");
|
||||||
std::string ip = data.value("ip");
|
std::string ip = data.value("ip");
|
||||||
@@ -11,6 +11,8 @@ public:
|
|||||||
CommEntity() {}
|
CommEntity() {}
|
||||||
CommEntity(std::string type) : type(type) {}
|
CommEntity(std::string type) : type(type) {}
|
||||||
|
|
||||||
|
static std::shared_ptr<CommEntity> create(Fields& data);
|
||||||
|
|
||||||
void setType(std::string type) { this->type = type; }
|
void setType(std::string type) { this->type = type; }
|
||||||
|
|
||||||
// 启动通讯连接
|
// 启动通讯连接
|
||||||
@@ -30,10 +32,3 @@ public:
|
|||||||
bool isCloseRequest_ = false;
|
bool isCloseRequest_ = false;
|
||||||
std::string type;
|
std::string type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Communicator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static std::shared_ptr<CommEntity> createEntity(Fields& data);
|
|
||||||
};
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "Communicator.h"
|
#include "CommEntity.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ std::string GetDateTimeWeekday()
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int MaskMain::initUI()
|
int MaskMain::initUI()
|
||||||
{
|
{
|
||||||
//pvSetStyleSheet(p, PV_ID_MAIN, "color: white; font: normal 14px \"微软雅黑\";");
|
//pvSetStyleSheet(p, PV_ID_MAIN, "color: white; font: normal 14px \"微软雅黑\";");
|
||||||
ui.bkg = PvApp::pvid(p);
|
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));
|
ui.datetime = PvApp::label(p, PV_ID_MAIN, 10, 30, 420, 30, GetDateTimeWeekday(), qss::label(20));
|
||||||
pvSetAlignment(p, ui.datetime, AlignCenter);
|
pvSetAlignment(p, ui.datetime, AlignCenter);
|
||||||
|
|||||||
159
src/pv/PvApp.cpp
159
src/pv/PvApp.cpp
@@ -5,6 +5,72 @@
|
|||||||
|
|
||||||
#define FONT_NAME "微软雅黑"
|
#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)
|
void PvApp::setPvUser(PARAM* p, PvUser* pvuser)
|
||||||
{
|
{
|
||||||
p->user = pvuser;
|
p->user = pvuser;
|
||||||
@@ -23,10 +89,8 @@ int PvApp::pvid(PARAM* p)
|
|||||||
|
|
||||||
void PvApp::reset(PARAM* p)
|
void PvApp::reset(PARAM* p)
|
||||||
{
|
{
|
||||||
// 清理event回调
|
|
||||||
auto pvuser = PvApp::getPvUser(p);
|
auto pvuser = PvApp::getPvUser(p);
|
||||||
pvuser->mapEventCallback.clear();
|
if (pvuser) { pvuser->reset(); }
|
||||||
pvuser->pvidIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EPvCode PvApp::getPvCode(std::string name)
|
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)
|
void PvApp::bind(PARAM* p, PvEvent eid, int pvid, std::function<void(std::string text)> cb)
|
||||||
{
|
{
|
||||||
auto pvuser = PvApp::getPvUser(p);
|
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)
|
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);
|
int id = PvApp::pvid(p);
|
||||||
pvQLabel(p, id, parent);
|
pvQLabel(p, id, parent);
|
||||||
pvSetGeometry(p, id, x, y, w, h);
|
pvSetGeometry(p, id, x, y, w, h);
|
||||||
if (!text.empty()) { pvSetText(p, id, text.c_str()); }
|
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;
|
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 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);
|
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);
|
int id = PvApp::pvid(p);
|
||||||
pvQImage(p, id, parent, filename);
|
pvQImage(p, id, parent, filename);
|
||||||
pvSetGeometry(p, id, x, y, w, h);
|
pvSetGeometry(p, id, x, y, w, h);
|
||||||
//if (!qss.empty()) { pvSetStyleSheet(p, id, qss.c_str()); }
|
|
||||||
return id;
|
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;
|
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);
|
int id = PvApp::pvid(p);
|
||||||
pvQLineEdit(p, id, parent);
|
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;
|
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 =
|
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 { background-color: rgb(12, 39, 58); border: 1px solid rgb(18, 251, 255); border-radius: 3px; color:white; font: bold 14px;}"
|
||||||
"QTextEdit:disabled { border: 1px solid gray; color:rgb(150,150,150);}";
|
"QTextEdit:disabled { border: none; color: gray;}";
|
||||||
int id = PvApp::pvid(p);
|
int id = PvApp::pvid(p);
|
||||||
pvQMultiLineEdit(p, id, parent, true, 10);
|
pvQMultiLineEdit(p, id, parent, true, 10);
|
||||||
pvSetGeometry(p, id, x, y, w, h);
|
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 =
|
static std::string style =
|
||||||
"QRadioButton { background-color: transparent; color:white; font: bold 14px \"微软雅黑\";}"
|
"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);
|
int id = PvApp::pvid(p);
|
||||||
pvQRadioButton(p, id, parent);
|
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 =
|
static std::string style =
|
||||||
"QTimeEdit { background-color: rgb(17, 55, 73); border: 1px solid rgb(0, 185, 208); color:white; font: normal 14px \"微软雅黑\";}"
|
"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);
|
int id = PvApp::pvid(p);
|
||||||
pvQTimeEdit(p, id, parent);
|
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;
|
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)
|
int PvApp::lineTextedit(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val)
|
||||||
: x(ix), y(iy), w(width), h(height)
|
|
||||||
{
|
{
|
||||||
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
100
src/pv/PvApp.h
100
src/pv/PvApp.h
@@ -53,6 +53,51 @@ enum class EPvCode
|
|||||||
MASK_MGR_ALERTLOG,
|
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
|
class PvObject
|
||||||
{
|
{
|
||||||
public:
|
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 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 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 = "");
|
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 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 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 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) + ")";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void PvChartBar::updateItem(int index, std::vector<std::pair<std::string, double
|
|||||||
/// === PvChartCurve
|
/// === PvChartCurve
|
||||||
PvChartCurve::PvChartCurve(PARAM* p, int parent, int x, int y, int w, int h) : PvObject(p)
|
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;");
|
pvid_ = PvApp::label(p, parent, x, y, w, h, "", "border: none; border-radius: 0px; background-color: transparent;");
|
||||||
plotId_ = PvApp::pvid(p);
|
plotId_ = PvApp::pvid(p);
|
||||||
pvQwtPlotWidget(p, plotId_, pvid_, 100, 100);
|
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;");
|
yLabelLeft = PvApp::label(p, pvid_, 10, 24, 100, 20, "", "border:none;color:white;font-size:14px;font-weight:bold;");
|
||||||
pvSetAlignment(p, yLabelLeft, AlignLeft);
|
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);
|
pvSetAlignment(p, yLabelRight, AlignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
void reviseYMax(int pos, double v);
|
void reviseYMax(int pos, double v);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PvRect rect_;
|
PvRect rect;
|
||||||
int pvid_;
|
int pvid_;
|
||||||
int plotId_;
|
int plotId_;
|
||||||
int start_num_ = 0;
|
int start_num_ = 0;
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
|
|||||||
int x = (1920-width) *0.5;
|
int x = (1920-width) *0.5;
|
||||||
int y = (1080-height) *0.5;
|
int y = (1080-height) *0.5;
|
||||||
ui.widget = PvApp::widget(p, pvid, x, y, width, height);
|
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);");
|
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);");
|
||||||
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.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;");
|
||||||
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.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));
|
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);
|
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 x = (width- w*2 - offset) *0.5;
|
||||||
int y = height - h - 40;
|
int y = height - h - 40;
|
||||||
|
|
||||||
int btnOk = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
|
ui.btnOK = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
|
||||||
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnOk, [=](std::string) {
|
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnOK, [=](std::string) {
|
||||||
if (callbackConfirm) { callbackConfirm(); }
|
if (callbackConfirm) { callbackConfirm(); }
|
||||||
});
|
});
|
||||||
int btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
|
ui.btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
|
||||||
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnCancel, [=](std::string) {
|
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnCancel, [=](std::string) {
|
||||||
this->show(false);
|
this->show(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -43,20 +43,21 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
|
|||||||
mapLines[key] = line;
|
mapLines[key] = line;
|
||||||
|
|
||||||
PvApp::label(p, ui.widget, x, y, lineKeyWidth, lineHeight, title, qss::label(15));
|
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")
|
else if (type == "combox")
|
||||||
{
|
{
|
||||||
line->widget = PvApp::combox(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, {});
|
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) {
|
PvApp::bind(p, PvEvent::TEXT_EVENT, line->widget, [=](std::string text) {
|
||||||
line->val = text;
|
line->val = text;
|
||||||
|
if (callbackTextEvent) callbackTextEvent(key, text);
|
||||||
});
|
});
|
||||||
if (!editable) { pvSetEnabled(p, line->widget, 0); }
|
if (!editable) { pvSetEnabled(p, line->widget, 0); }
|
||||||
return line;
|
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*/)
|
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*/)
|
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)
|
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];
|
line->val = line->items[0];
|
||||||
pvSetCurrentItem(p, line->widget, 0);
|
pvSetCurrentItem(p, line->widget, 0);
|
||||||
}
|
}
|
||||||
|
// 【注意】combox 设置 item 不会触发 TEXT_EVENT
|
||||||
|
//if (callbackTextEvent) callbackTextEvent(line->key, line->val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -195,3 +198,19 @@ void PvPopWidget::setPrimaryKeys(std::vector<std::string> keys)
|
|||||||
primaryKeys.set(k, "");
|
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);
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
|
|
||||||
void setCallbackConfirm(std::function<void()> callback) { callbackConfirm = callback; };
|
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 setStatus(std::string text);
|
||||||
|
|
||||||
void setMsg(std::string msg);
|
void setMsg(std::string msg);
|
||||||
@@ -44,11 +46,14 @@ public:
|
|||||||
Fields getChangedData();
|
Fields getChangedData();
|
||||||
void checkChangedData(Fields& fields);
|
void checkChangedData(Fields& fields);
|
||||||
|
|
||||||
|
|
||||||
void setLineGeometry(int wKey, int wVal, int h);
|
void setLineGeometry(int wKey, int wVal, int h);
|
||||||
|
|
||||||
void setPrimaryKeys(std::vector<std::string> keys);
|
void setPrimaryKeys(std::vector<std::string> keys);
|
||||||
|
|
||||||
|
int widget() { return ui.widget; }
|
||||||
|
|
||||||
|
void resize(int width, int height);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string status;
|
std::string status;
|
||||||
|
|
||||||
@@ -61,6 +66,11 @@ public:
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
int widget;
|
int widget;
|
||||||
|
int bkg;
|
||||||
|
int bkgL;
|
||||||
|
int bkgR;
|
||||||
|
int btnOK;
|
||||||
|
int btnCancel;
|
||||||
int title;
|
int title;
|
||||||
int msg;
|
int msg;
|
||||||
} ui;
|
} ui;
|
||||||
@@ -68,6 +78,7 @@ public:
|
|||||||
std::map<std::string, std::shared_ptr<ParamLine>> mapLines;
|
std::map<std::string, std::shared_ptr<ParamLine>> mapLines;
|
||||||
|
|
||||||
std::function<void()> callbackConfirm = nullptr;
|
std::function<void()> callbackConfirm = nullptr;
|
||||||
|
std::function<void(std::string, std::string)> callbackTextEvent = nullptr;
|
||||||
|
|
||||||
Fields dataOrigin;
|
Fields dataOrigin;
|
||||||
Fields primaryKeys;
|
Fields primaryKeys;
|
||||||
|
|||||||
@@ -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_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);}";
|
+ "QLabel:hover {border: 1px solid rgb(1, 183, 209);}";
|
||||||
|
|
||||||
const std::string QSS_BOX_ACTIVE =
|
const std::string QSS_BOX_ACTIVE =
|
||||||
@@ -88,7 +88,6 @@ namespace qss
|
|||||||
const std::string QSS_BTN_MGR =
|
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 { 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: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:pressed { border-width:3px 0 0 3px;border-style:inset; }"
|
||||||
"QPushButton:disabled{color:rgb(150,150,150);}";
|
"QPushButton:disabled{color:rgb(150,150,150);}";
|
||||||
|
|
||||||
|
|||||||
@@ -9,57 +9,56 @@ static const string STYLE_BKG =
|
|||||||
|
|
||||||
//*********************************************************************************************************************
|
//*********************************************************************************************************************
|
||||||
// PvTable
|
// 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))),
|
//: 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);
|
int h = opts.row_height* irow + (opts.show_header ? (opts.head_height) : 0);
|
||||||
rect_.set(x, y, w, h);
|
rect.set(x, y, w, h);
|
||||||
// 表格的主窗体(QWidget设置样式无效)
|
// 表格的主窗体(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);
|
vecHeads.resize(0);
|
||||||
vecRows_.resize(nRow_);
|
vecRows.resize(nrow);
|
||||||
vecData_.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;
|
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);
|
int widgetRow = PvApp::label(p, pvid, 1, y, rect.w-2, option.row_height, "", qss);
|
||||||
pvHide(p, rowBkg);
|
pvHide(p, widgetRow);
|
||||||
vecRows_[row].bkg = rowBkg;
|
vecRows[row].widget = widgetRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PvTable::addHead(string id, string text, int width, vector<pair<string, string>> mapping)
|
void PvTable::addHead(string id, string text, int width, vector<pair<string, string>> mapping)
|
||||||
{
|
{
|
||||||
vecHead_.push_back(Head(id, text, width, mapping));
|
vecHeads.push_back(Head(id, text, width, mapping));
|
||||||
nCol_ = vecHead_.size();
|
ncol = vecHeads.size();
|
||||||
|
|
||||||
if (width <= -1) { width = rect_.w-1 - posCol_; }
|
if (width <= -1) { width = rect.w-1 - posCol; }
|
||||||
int col = nCol_ - 1;
|
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 cellId = PvApp::label(p, vecRows[row].widget, posCol, 0, width, option.row_height, "", qss::QSS_TABLE_CELL);
|
||||||
int pvid = PvApp::label(p, pvid_, posCol_, y, width, option_.row_height, "", qss::QSS_TABLE_CELL);
|
vecRows[row].vecCells.push_back(cellId);
|
||||||
vecRows_[row].vecCells.push_back(pvid);
|
PvApp::bind(p, MOUSE_OVER_EVENT, cellId, [=](string s) { highlight(row, (s == "1")); });
|
||||||
PvApp::bind(p, MOUSE_OVER_EVENT, pvid, [=](string s) { highlight(row, (s == "1")); });
|
|
||||||
}
|
}
|
||||||
posCol_ += width;
|
posCol += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PvTable::addHead(vector<string> vec_text)
|
void PvTable::addHead(vector<string> vec_text)
|
||||||
@@ -68,24 +67,24 @@ void PvTable::addHead(vector<string> vec_text)
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i < vec_text.size(); ++i)
|
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];
|
string text = vec_text[i];
|
||||||
this->addHead(text, text, w-x);
|
this->addHead(text, text, w-x);
|
||||||
x = w;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
auto& rowItem = vecRows_[row];
|
auto& rowItem = vecRows[irow];
|
||||||
if (rowItem.visible != v)
|
if (rowItem.visible != v)
|
||||||
{
|
{
|
||||||
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)
|
if (!v)
|
||||||
{
|
{
|
||||||
for (int col = 0; col<rowItem.vecCells.size(); ++col)
|
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);
|
string qss = ((irow % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1);
|
||||||
if (vecRows_.size() > 0 && row <= vecRows_.size())
|
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);"; }
|
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)
|
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, vecRows[row].widget, posCol, 0, rect.w - posCol, option.row_height, "", qss::QSS_TABLE_CELL);
|
||||||
int cellWidget = PvApp::label(p, pvid_, posCol_, y, rect_.w - posCol_, option_.row_height, "", qss::QSS_TABLE_CELL);
|
vecOper.push_back({ cellWidget, vector<int>() });
|
||||||
//PvInstance::bind_event(p, MOUSE_OVER_EVENT, btn_opt, [=](string s) { highlight(row, (s == "1")); });
|
auto& vec_opt_btn_ = vecOper.back().second;
|
||||||
vecOpt_.push_back({ cellWidget, vector<int>() });
|
|
||||||
auto& vec_opt_btn_ = vecOpt_.back().second;
|
|
||||||
|
|
||||||
int x = 5, w = 60;
|
int x = 5, w = 60;
|
||||||
for (int i = 0; i < vecOpt.size(); i++)
|
for (int i = 0; i < vecOpt.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -128,87 +124,66 @@ void PvTable::addOperate(vector<string> vecOpt)
|
|||||||
w = 20 + 15 * title.size() / 3;
|
w = 20 + 15 * title.size() / 3;
|
||||||
int btn = PvApp::button(p, cellWidget, x, 4, w, 24, title, qss::button(14, "", "", "none; border-radius: 0px"));
|
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) {
|
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);
|
vec_opt_btn_.push_back(btn);
|
||||||
x += (w + 5);
|
x += (w + 5);
|
||||||
}
|
}
|
||||||
pvHide(p, cellWidget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PvTable::setOperateCallback(CallbackTableOpt cb)
|
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());
|
auto& head = vecHeads[col];
|
||||||
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];
|
|
||||||
string text = d.value(head.id);
|
string text = d.value(head.id);
|
||||||
text = head.getMapping(text);
|
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);
|
setRowVisible(irow, true);
|
||||||
this->setOperateVisible(row, d.size() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PvTable::setRowData(int row, std::vector<std::string> vd)
|
void PvTable::setRow(int irow, std::vector<std::string> vd)
|
||||||
{
|
{
|
||||||
if (row >= nRow_) { return; }
|
if (irow >= nrow) { return; }
|
||||||
pvShow(p, vecRows_[row].bkg);
|
pvShow(p, vecRows[irow].widget);
|
||||||
for (int col = 0; col < vecHead_.size(); ++col)
|
for (int col = 0; col < vecHeads.size(); ++col)
|
||||||
{
|
{
|
||||||
if (col < vd.size()) {
|
if (col < vd.size()) {
|
||||||
auto& head = vecHead_[col];
|
auto& head = vecHeads[col];
|
||||||
string text = head.getMapping(vd[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);
|
setRowVisible(irow, true);
|
||||||
this->setOperateVisible(row, vd.size() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Fields PvTable::getRowData(int row)
|
Fields PvTable::row(int irow)
|
||||||
{
|
{
|
||||||
static Fields tmp;
|
return (irow >= 0 && irow < vecData.size()) ? vecData[irow] : Fields();
|
||||||
return (row >= 0 && row < vecData_.size()) ? vecData_[row] : tmp;
|
}
|
||||||
|
|
||||||
|
Fields PvTable::rowMapping(int rowid)
|
||||||
|
{
|
||||||
|
Fields d = this->row(rowid);
|
||||||
|
this->mappingData(d);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PvTable::mappingData(Fields& fields)
|
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))
|
if (fields.contains(head.id))
|
||||||
{
|
{
|
||||||
auto& val = fields.value(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::colCount()
|
||||||
int PvTable::item_posy(int row)
|
|
||||||
{
|
{
|
||||||
return option_.show_header ? row * option_.row_height + option_.head_height : row * option_.row_height;
|
return this->ncol;
|
||||||
}
|
|
||||||
|
|
||||||
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_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Fields> PvTable::data()
|
vector<Fields> PvTable::data()
|
||||||
{
|
{
|
||||||
return vecData_;
|
return vecData;
|
||||||
}
|
}
|
||||||
|
|
||||||
PvTable::Head& PvTable::header(int col)
|
PvTable::Head& PvTable::header(int col)
|
||||||
{
|
{
|
||||||
return vecHead_[col];
|
return vecHeads[col];
|
||||||
}
|
}
|
||||||
|
|
||||||
static const string STYLE_NORMAL =
|
static const string STYLE_NORMAL =
|
||||||
@@ -348,32 +264,6 @@ void PvPagination::setPage(int index, int count)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pvShow(p, btnid);
|
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;
|
int x = (count+1)*32;
|
||||||
@@ -424,7 +314,10 @@ void PvPagination::setCallback(std::function<void(int index)> func)
|
|||||||
PageTable::PageTable(PARAM* p) : PvMask(p)
|
PageTable::PageTable(PARAM* p) : PvMask(p)
|
||||||
{
|
{
|
||||||
table = std::make_shared<PvTable>(p, 0, 20, 210, 1880, pageSize, option);
|
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 = std::make_shared<PvPagination>(p, 0, 20, 780, 20);
|
||||||
pagination->setCallback([=](int index)
|
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);
|
vecPop.push_back(pop);
|
||||||
return 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();
|
XLOGD() << "POP set: data=" << fields.toStr();
|
||||||
table->mappingData(fields);
|
table->mappingData(fields);
|
||||||
@@ -492,12 +385,12 @@ void PageTable::updateDataFromDB()
|
|||||||
pageInfo.size = pageSize;
|
pageInfo.size = pageSize;
|
||||||
pageInfo.index = pageIndex;
|
pageInfo.index = pageIndex;
|
||||||
this->onQueryTable(pageInfo, result);
|
this->onQueryTable(pageInfo, result);
|
||||||
for (int i = 0; i<table->rows(); ++i)
|
for (int i = 0; i<table->rowCount(); ++i)
|
||||||
{
|
{
|
||||||
if (i<result.size())
|
if (i<result.size())
|
||||||
{
|
{
|
||||||
auto& fields = result[i];
|
auto& fields = result[i];
|
||||||
table->setRowData(i, result[i]);
|
table->setRow(i, result[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ public:
|
|||||||
bool show_border = true;
|
bool show_border = true;
|
||||||
int head_height = 40;
|
int head_height = 40;
|
||||||
int row_height = 35;
|
int row_height = 35;
|
||||||
int page_size = 10;
|
|
||||||
int width = 500;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Head
|
struct Head
|
||||||
@@ -48,72 +46,52 @@ public:
|
|||||||
struct Row
|
struct Row
|
||||||
{
|
{
|
||||||
bool visible = false;
|
bool visible = false;
|
||||||
int bkg {PV_ID_NUL};
|
int widget {PV_ID_NUL};
|
||||||
std::vector<int> vecCells {};
|
std::vector<int> vecCells {};
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
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::string id, std::string text, int width, std::vector<std::pair<std::string, std::string>> mapping = {});
|
||||||
void addHead(std::vector<std::string> vecText);
|
void addHead(std::vector<std::string> vecText);
|
||||||
|
|
||||||
void setRowVisible(int row, bool v);
|
void setRowVisible(int irow, bool v);
|
||||||
void highlight(int row, bool v);
|
void highlight(int irow, bool v);
|
||||||
|
|
||||||
void addOperate(std::vector<std::string> vecOpt);
|
void addOperate(std::vector<std::string> vecOpt);
|
||||||
void setOperateCallback(CallbackTableOpt cb);
|
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 setRow(int irow, Fields& d);
|
||||||
void setRowData(int row, std::vector<std::string> vd);
|
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 mappingData(Fields& fields);
|
||||||
|
|
||||||
void set_border_visible(PARAM* p, bool v);
|
int rowCount();
|
||||||
|
int colCount();
|
||||||
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();
|
|
||||||
|
|
||||||
std::vector<Fields> data();
|
std::vector<Fields> data();
|
||||||
|
|
||||||
PvTable::Head& header(int col);
|
PvTable::Head& header(int col);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int pvid_;
|
Options option;
|
||||||
PvRect rect_;
|
PvRect rect;
|
||||||
|
|
||||||
int border_id_;
|
std::vector<PvTable::Head> vecHeads;
|
||||||
|
std::vector<PvTable::Row> vecRows;
|
||||||
|
std::vector<Fields> vecData;
|
||||||
|
|
||||||
std::vector<PvTable::Head> vecHead_;
|
vector<pair<int, vector<int>>> vecOper;
|
||||||
std::vector<PvTable::Row> vecRows_;
|
int nrow;
|
||||||
|
int ncol;
|
||||||
|
|
||||||
std::vector<Fields> vecData_;
|
int posCol = 0;
|
||||||
|
|
||||||
vector<pair<int, vector<int>>> vecOpt_;
|
CallbackTableOpt callbackOper = nullptr;
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +122,6 @@ private:
|
|||||||
// 下一页按钮
|
// 下一页按钮
|
||||||
int btnNext = PV_ID_NUL;
|
int btnNext = PV_ID_NUL;
|
||||||
|
|
||||||
// 页面跳转按钮
|
|
||||||
int btn_gopage_ = PV_ID_NUL;
|
|
||||||
|
|
||||||
int btnActive = PV_ID_NUL;
|
int btnActive = PV_ID_NUL;
|
||||||
|
|
||||||
int labelInfo = 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);
|
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 hidePop(int index);
|
||||||
|
|
||||||
void updateDataFromDB();
|
void updateDataFromDB();
|
||||||
@@ -186,6 +161,7 @@ public:
|
|||||||
std::shared_ptr<PvTable> table;
|
std::shared_ptr<PvTable> table;
|
||||||
std::shared_ptr<PvPagination> pagination;
|
std::shared_ptr<PvPagination> pagination;
|
||||||
std::vector<std::shared_ptr<PvPopWidget>> vecPop;
|
std::vector<std::shared_ptr<PvPopWidget>> vecPop;
|
||||||
|
Fields curRowData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! _PvTable_H_
|
#endif // ! _PvTable_H_
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include "PvUser.h"
|
||||||
|
|
||||||
|
void PvUser::reset()
|
||||||
|
{
|
||||||
|
mapEventCallback.clear();
|
||||||
|
pvidIndex = 0;
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
class PvUser
|
class PvUser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void reset();
|
||||||
|
|
||||||
int pvidIndex = 0;
|
int pvidIndex = 0;
|
||||||
std::map<std::string, std::function<void(std::string text)>> mapEventCallback;
|
std::map<std::string, std::function<void(std::string text)>> mapEventCallback;
|
||||||
};
|
};
|
||||||
@@ -11,12 +11,9 @@
|
|||||||
|
|
||||||
void TestPage(PARAM* p)
|
void TestPage(PARAM* p)
|
||||||
{
|
{
|
||||||
auto& appdata = Application::data();
|
//auto& appdata = Application::data();
|
||||||
auto pagination = new PvPagination(p, 0, 600, 160, 20);
|
//auto pagination = new PvPagination(p, 0, 600, 160, 20);
|
||||||
pagination->setPage(5, 10);
|
//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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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));
|
//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)
|
int MaskPageHome::initUI(EPvCode pvcode)
|
||||||
{
|
{
|
||||||
@@ -317,11 +313,8 @@ int MaskPageHome::initUI(EPvCode pvcode)
|
|||||||
|
|
||||||
this->updateUI();
|
this->updateUI();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TestPage(p);
|
TestPage(p);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +335,7 @@ void MaskPageHome::updateUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
pvSetText(p, ui.labelRunDays, "100 天");
|
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.labelEnergyCapacity, (Utils::toStr(energyCapacity) + " kWh").c_str());
|
||||||
pvSetText(p, ui.labelIncome, (Utils::toStr(incomeTotal) + " 元").c_str());
|
pvSetText(p, ui.labelIncome, (Utils::toStr(incomeTotal) + " 元").c_str());
|
||||||
pvSetText(p, ui.labelStorageIn, (Utils::toStr(electStorageIn) + " kWh").c_str());
|
pvSetText(p, ui.labelStorageIn, (Utils::toStr(electStorageIn) + " kWh").c_str());
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#include "MaskPageRunning.h"
|
#include "MaskPageRunning.h"
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
#include "app/AppData.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)
|
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);
|
return PvApp::label(p, parent, x += 70, y, 120, 30, v, qss::LABEL_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BoxCard : PvObject
|
class CardDevice : PvObject
|
||||||
{
|
{
|
||||||
public:
|
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);
|
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);");
|
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, 10, 100, 20, "");
|
||||||
ui.name = PvApp::label(p, card_, 80, 30, 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)"));
|
ui.type = PvApp::label(p, card_, 80, 50, 100, 20, "", qss::label(14, "rgb(8, 161, 249)"));
|
||||||
|
|
||||||
int x1 = 190;
|
int x1 = 190;
|
||||||
@@ -40,14 +44,14 @@ public:
|
|||||||
|
|
||||||
// 默认创建 10 个参数标签:
|
// 默认创建 10 个参数标签:
|
||||||
int n = 10;
|
int n = 10;
|
||||||
vecParamLabel_.resize(n);
|
vecParamLabel.resize(n);
|
||||||
for (int i = 0; i<n; i++)
|
for (int i = 0; i<n; i++)
|
||||||
{
|
{
|
||||||
int row = i/2;
|
int row = i/2;
|
||||||
int col = i%2;
|
int col = i%2;
|
||||||
int h = 25;
|
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].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].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)
|
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& labelKey = vecParamLabel[i].first;
|
||||||
auto& labelVal = vecParamLabel_[i].second;
|
auto& labelVal = vecParamLabel[i].second;
|
||||||
if (i<vecKeys.size())
|
if (i<vecKeys.size())
|
||||||
{
|
{
|
||||||
std::string& title = vecKeys[i] + ":";
|
std::string& title = vecKeys[i] + ":";
|
||||||
@@ -96,7 +100,7 @@ public:
|
|||||||
|
|
||||||
int card_;
|
int card_;
|
||||||
|
|
||||||
std::vector<std::pair<int, int>> vecParamLabel_;
|
std::vector<std::pair<int, int>> vecParamLabel;
|
||||||
std::map<std::string, int> mapParam_;
|
std::map<std::string, int> mapParam_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,135 +110,199 @@ MaskPageRunning::MaskPageRunning(PARAM* p) : PvMask(p)
|
|||||||
|
|
||||||
int MaskPageRunning::initUI(EPvCode pvcode)
|
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, 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;");
|
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;");
|
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::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)
|
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::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::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;
|
int x = 20, y = 160, w = 200, h = 180;
|
||||||
// 储能设备
|
// 储能设备
|
||||||
{
|
{
|
||||||
ui.storage.name = "储能设备";
|
this->initModule(storage, "储能设备", x, y, w, h);
|
||||||
int pid = ui.storage.box = PvApp::label(p, 0, x, y, w, h, "", qss::LABEL_BOX);
|
storage.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
|
||||||
PvApp::label(p, pid, 10, 0, w-10, 30, ui.storage.name, qss::LABEL_TITLE);
|
pvHide(p, storage.workspace);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 创建信息卡片
|
// 创建信息卡片
|
||||||
{
|
{
|
||||||
vecCard_.resize(12);
|
vecCard_.resize(12);
|
||||||
for (int i=0; i<vecCard_.size(); ++i)
|
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 = "光伏设备";
|
this->initModule(solar, "光伏设备", x, y += (h+10), w, h);
|
||||||
int pid = ui.solar.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
|
solar.workspace = storage.workspace;
|
||||||
PvApp::label(p, pid, 10, 0, w-10, 30, ui.solar.name, qss::LABEL_TITLE);
|
pvHide(p, solar.workspace);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
// 充电设备
|
// 充电设备
|
||||||
{
|
{
|
||||||
ui.charge.name = "充电设备";
|
this->initModule(charge, "充电设备", x, y += (h+10), w, h);
|
||||||
int pid = ui.charge.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
|
charge.workspace = storage.workspace;
|
||||||
PvApp::label(p, pid, 10, 0, w-10, 30, ui.solar.name, qss::LABEL_TITLE);
|
pvHide(p, charge.workspace);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
// 环境与安防设备
|
// 环境与安防设备
|
||||||
{
|
{
|
||||||
ui.security.name = "环境与安防设备";
|
this->initModule(security, "环境与安防设备", x, y += (h+10), w, h);
|
||||||
int pid = ui.security.box = PvApp::label(p, 0, x, y += (h+10), w, h, "", qss::LABEL_BOX);
|
security.workspace = PvApp::widget(p, workspace, 0, 0, 1670, 790);
|
||||||
PvApp::label(p, pid, 10, 0, w-10, 30, ui.security.name, qss::LABEL_TITLE);
|
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);
|
std::string style = qss::label(20, "white; padding: 0px 0px 0px 10px;", "rgb(8, 54, 91)", "none; border-radius: 5px;");
|
||||||
pvHide(p, ui.security.workspace);
|
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;
|
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)
|
EPvCode MaskPageRunning::onEventButton(int pvid)
|
||||||
{
|
{
|
||||||
if (pvid == ui.storage.btn) { activeBoxPanel(ui.storage); }
|
if (pvid == storage.btn) { activeBoxPanel(&storage); }
|
||||||
else if (pvid == ui.solar.btn) { activeBoxPanel(ui.solar); }
|
else if (pvid == solar.btn) { activeBoxPanel(&solar); }
|
||||||
else if (pvid == ui.charge.btn) { activeBoxPanel(ui.charge); }
|
else if (pvid == charge.btn) { activeBoxPanel(&charge); }
|
||||||
else if (pvid == ui.security.btn) { activeBoxPanel(ui.security); }
|
else if (pvid == security.btn) { activeBoxPanel(&security); }
|
||||||
|
|
||||||
return EPvCode::NUL;
|
return EPvCode::NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::vector<std::string>> mapDeviceTypes =
|
void MaskPageRunning::activeBoxPanel(Module* module)
|
||||||
{
|
{
|
||||||
{"储能设备", {"储能预制舱", "储能电池", "储能电池", "储能电池"}},
|
if (activeBox)
|
||||||
{"光伏设备", {"光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板", "光伏板"}},
|
|
||||||
{"充电设备", {"充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩", "充电桩"}},
|
|
||||||
};
|
|
||||||
std::map<std::string, std::vector<std::string>> mapDeviceParams =
|
|
||||||
{
|
|
||||||
{"储能预制舱", {"运行模式", "冷却方式", "实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数", "电池容量"}},
|
|
||||||
{"储能电池", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数", "电池容量"}},
|
|
||||||
{"逆变器", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
|
|
||||||
{"光伏板", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
|
|
||||||
{"充电桩", {"实时电压", "额定电压", "实时电流", "额定电流", "实时功率", "额定功率", "功率因数"}},
|
|
||||||
};
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string> vecDeviceInfo = mapDeviceTypes[panel.name];
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& appdata = Application::data();
|
||||||
|
if (activeBox->workspace != security.workspace)
|
||||||
|
{
|
||||||
|
// 更新卡片:
|
||||||
|
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)
|
for (int i = 0; i<vecCard_.size(); ++i)
|
||||||
{
|
{
|
||||||
auto& card = vecCard_[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->show(1);
|
||||||
card->setCard(type, type+"-"+std::to_string(i), type+"-"+std::to_string(i));
|
|
||||||
card->setParamkeys(mapDeviceParams[type]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -243,3 +311,37 @@ 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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,34 +2,48 @@
|
|||||||
|
|
||||||
#include "pv/PvApp.h"
|
#include "pv/PvApp.h"
|
||||||
|
|
||||||
class BoxCard;
|
class CardDevice;
|
||||||
class Station;
|
class Station;
|
||||||
|
|
||||||
class MaskPageRunning : public PvMask
|
class MaskPageRunning : public PvMask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct BoxPanel {
|
struct Module {
|
||||||
std::string name;
|
std::string name;
|
||||||
int box;
|
int widget;
|
||||||
int btn;
|
int btn;
|
||||||
int workspace;
|
int workspace;
|
||||||
|
|
||||||
|
int labelPower;
|
||||||
|
int labelNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
MaskPageRunning(PARAM* p);
|
MaskPageRunning(PARAM* p);
|
||||||
int initUI(EPvCode pvcode);
|
int initUI(EPvCode pvcode);
|
||||||
|
void initModule(Module& module, std::string name, int x, int y, int w, int h);
|
||||||
|
|
||||||
virtual EPvCode onEventButton(int pvid);
|
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 {
|
struct {
|
||||||
BoxPanel storage;
|
int comboxStation;
|
||||||
BoxPanel solar;
|
int comboxWorkMode;
|
||||||
BoxPanel charge;
|
|
||||||
BoxPanel security;
|
|
||||||
} ui;
|
} ui;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<BoxCard>> vecCard_;
|
Module storage;
|
||||||
std::shared_ptr<Station> station_ = nullptr;
|
Module solar;
|
||||||
|
Module charge;
|
||||||
|
Module security;
|
||||||
|
|
||||||
|
Module* activeBox {};
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<CardDevice>> vecCard_;
|
||||||
|
std::shared_ptr<Station> activeStation = nullptr;
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,9 @@
|
|||||||
#include "database/Dao.h"
|
#include "database/Dao.h"
|
||||||
#include "database/DataModelDef.h"
|
#include "database/DataModelDef.h"
|
||||||
#include "common/Snowflake.h"
|
#include "common/Snowflake.h"
|
||||||
|
#include "pv/pages/PanelPolicy.h"
|
||||||
|
|
||||||
|
std::vector<std::string> g_comboxList_isOpen = {"启用", "禁用"};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// === PageUser ===
|
// === PageUser ===
|
||||||
@@ -42,7 +44,7 @@ void PageUser::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
|||||||
{
|
{
|
||||||
DAO::queryUserList(pageInfo, 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)
|
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)
|
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)
|
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();
|
auto& appdata = Application::data();
|
||||||
|
|
||||||
table->addHead(DMRole::ROLE_ID, "角色编号", 200, {});
|
table->addHead(DMRole::ROLE_ID, "角色编号", 180, {});
|
||||||
table->addHead(DMRole::NAME, "角色名称", 200, {});
|
table->addHead(DMRole::NAME, "角色名称", 200, {});
|
||||||
table->addHead(DMRole::DESCRIBE, "角色描述", 900, {});
|
table->addHead(DMRole::DESCRIBE, "角色描述", 900, {});
|
||||||
table->addHead(DMRole::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
|
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});
|
auto pop = this->addPop(500, 600, 180, "角色信息", {DMUser::USER_ID});
|
||||||
pop->addParamLineEdit(DMRole::ROLE_ID, "编号", x, y, false);
|
pop->addParamLineEdit(DMRole::ROLE_ID, "编号", x, y, false);
|
||||||
pop->addParamLineEdit(DMRole::NAME, "名称", x, y += h);
|
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);
|
pop->addParamTextEdit(DMRole::DESCRIBE, "描述", x, y += h);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -105,7 +107,7 @@ void PageRole::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
|||||||
{
|
{
|
||||||
DAO::queryRoleList(pageInfo, 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)
|
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)
|
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)
|
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)
|
PagePermission::PagePermission(PARAM* p, EPvCode pvcode) : PageTable(p)
|
||||||
{
|
{
|
||||||
auto& appdata = Application::data();
|
auto& appdata = Application::data();
|
||||||
table->addHead(DMPermission::PERMISSION_ID, "权限编号", 200, {});
|
table->addHead(DMPermission::PERMISSION_ID, "权限编号", 180, {});
|
||||||
table->addHead(DMPermission::NAME, "权限名称", 200, {});
|
table->addHead(DMPermission::NAME, "权限名称", 200, {});
|
||||||
table->addHead(DMPermission::DESCRIBE, "权限描述", 900, {});
|
table->addHead(DMPermission::DESCRIBE, "权限描述", 900, {});
|
||||||
table->addHead(DMPermission::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
|
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); });
|
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnNew, [=](std::string) { this->onOperate(-1, -1, POP_OPER_NEW); });
|
||||||
|
|
||||||
int x = 80, y = 80, h = 60;
|
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::PERMISSION_ID, "编号", x, y, false);
|
||||||
pop->addParamLineEdit(DMPermission::NAME, "名称", x, y += h);
|
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);
|
pop->addParamTextEdit(DMPermission::DESCRIBE, "描述", x, y += h);
|
||||||
}
|
}
|
||||||
void PagePermission::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
void PagePermission::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
||||||
{
|
{
|
||||||
DAO::queryPermissionList(pageInfo, 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)
|
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)
|
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)
|
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)
|
PageStation::PageStation(PARAM* p, EPvCode pvcode) : PageTable(p)
|
||||||
{
|
{
|
||||||
auto& appdata = Application::data();
|
auto& appdata = Application::data();
|
||||||
table->addHead(DMStation::STATION_ID, "场站编号", 200, {});
|
table->addHead(DMStation::STATION_ID, "场站编号", 180, {});
|
||||||
table->addHead(DMStation::NAME, "场站名称", 200, {});
|
table->addHead(DMStation::NAME, "场站名称", 200, {});
|
||||||
table->addHead(DMStation::ADDRESS, "地址", 200, {});
|
table->addHead(DMStation::ADDRESS, "地址", 200, {});
|
||||||
table->addHead(DMStation::LONGITUDE, "经度", 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::LONGITUDE, "经度", x, y += h);
|
||||||
pop->addParamLineEdit(DMStation::LATITUDE, "维度", x, y += h);
|
pop->addParamLineEdit(DMStation::LATITUDE, "维度", x, y += h);
|
||||||
pop->addParamLineEdit(DMStation::TEL, "电话", 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)
|
void PageStation::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
||||||
{
|
{
|
||||||
DAO::queryStationList(pageInfo, 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)
|
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)
|
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)
|
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();
|
auto& appdata = Application::data();
|
||||||
table->addHead(DMDevice::DEVICE_ID, "设备编号", 120, {});
|
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::TYPE, "设备类型", 120, appdata.mapping.deviceType);
|
||||||
table->addHead(DMDevice::NAME, "设备名称", 180, {});
|
table->addHead(DMDevice::NAME, "设备名称", 180, {});
|
||||||
table->addHead(DMDevice::CODE, "设备编码", 160, {});
|
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;
|
int x = 50, y = 80, w = 350, h = 60;
|
||||||
auto pop = this->addPop(700, 520, 180, "设备信息", {DMDevice::DEVICE_ID});
|
auto pop = this->addPop(700, 520, 180, "设备信息", {DMDevice::DEVICE_ID});
|
||||||
pop->addParamLineEdit(DMDevice::DEVICE_ID, "设备编号", x, y, false);
|
pop->addParamLineEdit(DMDevice::DEVICE_ID, "设备编号", x, y, false);
|
||||||
pop->addParamCombox(DMDevice::TYPE, "类型", x+w, y, appdata.getDeviceTypeNames());
|
pop->addParamCombox(DMDevice::STATION_ID, "所属场站", x+w, y, appdata.getStationNames());
|
||||||
pop->addParamLineEdit(DMDevice::NAME, "设备名称", x, y += h);
|
pop->addParamCombox(DMDevice::TYPE, "类型", x, y += h, appdata.getDeviceTypeNames());
|
||||||
pop->addParamLineEdit(DMDevice::CODE, "设备编码", x+w, y);
|
pop->addParamLineEdit(DMDevice::NAME, "设备名称", x+w, y);
|
||||||
pop->addParamLineEdit(DMDevice::MODEL, "设备型号", x, y += h);
|
pop->addParamLineEdit(DMDevice::CODE, "设备编码", x, y += h);
|
||||||
pop->addParamLineEdit(DMDevice::FACTORY, "厂家", x+w, y);
|
pop->addParamLineEdit(DMDevice::MODEL, "设备型号", x+w, y);
|
||||||
pop->addParamLineEdit(DMDevice::TEL, "厂家电话", x, y += h);
|
pop->addParamLineEdit(DMDevice::FACTORY, "厂家", x, y += h);
|
||||||
pop->addParamCombox(DMDevice::IS_OPEN, "是否启用", x+w, y, {"启用", "禁用"});
|
pop->addParamLineEdit(DMDevice::TEL, "厂家电话", x+w, y);
|
||||||
pop->addParamLineEdit(DMDevice::ATTRS, "设备参数", x, y += h);
|
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)
|
void PageDevice::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
||||||
{
|
{
|
||||||
DAO::queryDeviceList(pageInfo, 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)
|
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)
|
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)
|
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)
|
PagePolicy::PagePolicy(PARAM* p, EPvCode pvcode) : PageTable(p)
|
||||||
{
|
{
|
||||||
auto& appdata = Application::data();
|
auto& appdata = Application::data();
|
||||||
table->addHead(DMPolicy::POLICY_ID, "策略编号", 200, {});
|
table->addHead(DMPolicy::POLICY_ID, "策略编号", 120, {});
|
||||||
table->addHead(DMPolicy::TYPE, "策略类型", 200, {});
|
table->addHead(DMPolicy::TYPE, "策略类型", 120, appdata.mapping.policyType);
|
||||||
table->addHead(DMPolicy::NAME, "策略名称", 200, {});
|
table->addHead(DMPolicy::NAME, "策略名称", 160, {});
|
||||||
table->addHead(DMPolicy::DESCRIBE, "策略描述", 400, {});
|
table->addHead(DMPolicy::DESCRIBE, "策略描述", 300, {});
|
||||||
table->addHead(DMPolicy::VALUE, "策略参数", 400, {});
|
table->addHead(DMPolicy::VALUE, "策略参数", 900, {});
|
||||||
table->addHead(DMPolicy::IS_OPEN, "是否启用", 200, appdata.mapping.isopen);
|
table->addHead(DMPolicy::IS_OPEN, "是否启用", 80, appdata.mapping.isopen);
|
||||||
table->addOperate({ "编辑"});
|
table->addOperate({ "编辑"});
|
||||||
|
|
||||||
int btnNew = PvApp::button(p, PV_ID_MAIN, 20, 160, 80, 35, POP_OPER_NEW);
|
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});
|
auto pop = this->addPop(1620, 800, 180, "策略信息", {DMPolicy::POLICY_ID});
|
||||||
//pop->addParamLineEdit(DMPolicy::POLICY_ID, "编号", x, y, false);
|
//pop->addParamLineEdit(DMPolicy::POLICY_ID, "编号", x, y, false);
|
||||||
{
|
{
|
||||||
pop->addParamLineEdit("1", "策略名称", x, y);
|
pop->addParamLineEdit(DMPolicy::NAME, "策略名称", x, y);
|
||||||
pop->addParamCombox("2", "策略类型", x+w, y, {"峰谷套利"});
|
pop->addParamCombox(DMPolicy::TYPE, "策略类型", x+w, y, Application::data().getPolicyTypeNames());
|
||||||
pop->addParamLineEdit("3", "尖峰电价", x, y += 50);
|
pop->addParamCombox(DMPolicy::IS_OPEN, "是否启用", x, y+=40, g_comboxList_isOpen),
|
||||||
pop->addParamLineEdit("4", "高峰电价", x+w, y);
|
//pop->addParamLineEdit("3", "尖峰电价", x, y += 50);
|
||||||
pop->addParamLineEdit("5", "平段电价", x+w*2, y);
|
//pop->addParamLineEdit("4", "高峰电价", x+w, y);
|
||||||
pop->addParamLineEdit("6", "低谷电价", x+w*3, 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)
|
void PagePolicy::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
||||||
{
|
{
|
||||||
DAO::queryPolicyList(pageInfo, 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)
|
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)
|
else if (oper == POP_OPER_EDIT)
|
||||||
{
|
{
|
||||||
table->getRowData(row);
|
int policyTypeId = curRowData.get<int>(DMPolicy::TYPE);
|
||||||
auto& appdata = Application::data();
|
std::string attrVal = curRowData.value(DMPolicy::VALUE);
|
||||||
Fields fields;
|
|
||||||
fields.set("3", appdata.electPriceSuperPeak);
|
this->setPanel(policyTypeId, attrVal);
|
||||||
fields.set("4", appdata.electPricePeak);
|
this->showPop(0, oper, curRowData);
|
||||||
fields.set("5", appdata.electPriceShoulder);
|
|
||||||
fields.set("6", appdata.electPriceOffPeak);
|
|
||||||
this->showPop(0, oper, fields);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string PagePolicy::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
|
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)
|
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 "";
|
return "";
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -390,7 +450,7 @@ void PageSyslog::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
|
|||||||
{
|
{
|
||||||
DAO::querySystemLogList(pageInfo, 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)
|
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)
|
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)
|
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);
|
//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)
|
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)
|
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)
|
std::string PageAlertlog::onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields)
|
||||||
|
|||||||
@@ -71,17 +71,24 @@ public:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// === PagePolicy ===
|
// === PagePolicy ===
|
||||||
|
class PanelPolicyPeak;
|
||||||
|
class PanelPolicyRequire;
|
||||||
|
class PanelPolicySelf;
|
||||||
class PagePolicy : public PageTable
|
class PagePolicy : public PageTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PagePolicy(PARAM* p, EPvCode pvcode);
|
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 onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result) override;
|
||||||
virtual void onOperate(int row, int col, std::string oper) 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 onValidation(std::shared_ptr<PvPopWidget> pop, Fields& fields) override;
|
||||||
virtual std::string onPopConfirm(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 {};
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -2,30 +2,55 @@
|
|||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
#include "app/AppData.h"
|
#include "app/AppData.h"
|
||||||
#include "common/JsonN.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 =
|
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 { 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: 5px; color:white;}"
|
"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::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 =
|
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 { 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: 5px; color:white;}"
|
"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::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 =
|
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 { 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: 5px; color:white;}"
|
"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::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 =
|
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 { 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: 5px; color:white;}"
|
"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::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)
|
static std::string GetPeriodQss(int v)
|
||||||
{
|
{
|
||||||
@@ -51,182 +76,180 @@ static int GetPeriod(std::string text)
|
|||||||
else if (text == "低谷") { return 4; }
|
else if (text == "低谷") { return 4; }
|
||||||
else { return 3; }
|
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));
|
data.vecPeriods.resize(12, std::vector<int>(24, 3));
|
||||||
ui.parent = parent;
|
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();
|
auto& appdata = Application::data();
|
||||||
std::vector<std::string> vecPeriods = {"尖峰", "高峰", "平段", "低谷"};
|
std::vector<std::string> vecPeriods = {"尖峰", "高峰", "平段", "低谷"};
|
||||||
|
|
||||||
ui.vecComboxs.resize(12, std::vector<int>(24, PV_ID_NUL));
|
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;
|
for (int col = 0; col<=24; ++col)
|
||||||
int x = 10, y = 180, w = 64, h = 30;
|
|
||||||
for (int row = 0; row<=12; row++)
|
|
||||||
{
|
{
|
||||||
for (int col = 0; col<=24; ++col)
|
std::string text;
|
||||||
|
if (row == 0)
|
||||||
{
|
{
|
||||||
std::string text;
|
text = (col == 0) ? "月份" : std::to_string(col-1) + "-" + std::to_string(col) + "时";
|
||||||
if (row == 0)
|
}
|
||||||
{
|
else
|
||||||
text = (col == 0) ? "月份" : std::to_string(col-1) + "-" + std::to_string(col) + "时";
|
{
|
||||||
}
|
text = (col == 0) ? std::to_string(row) : "";
|
||||||
else
|
}
|
||||||
{
|
if (row == 0 || col == 0)
|
||||||
text = (col == 0) ? std::to_string(row) : "";
|
{
|
||||||
}
|
std::string qssLabel = (row==0) ? qss::label(14, "", "rgb(19, 93, 114)") : "";
|
||||||
if (row == 0 || col == 0)
|
int label = PvApp::label(p, pvid, x+w*col, y+h*row, w, h, text, qssLabel);
|
||||||
{
|
pvSetAlignment(p, label, AlignCenter);
|
||||||
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);
|
else
|
||||||
pvSetAlignment(p, label, AlignCenter);
|
{
|
||||||
}
|
int periodVal = data.vecPeriods[row-1][col-1];
|
||||||
else
|
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());
|
||||||
int periodVal = data.vecPeriods[row-1][col-1];
|
ui.vecComboxs[row-1][col-1] = combox;
|
||||||
int combox = PvApp::combox(p, parent, x+w*col, y+h*row+3, w-3, 24, vecPeriods, periodVal);
|
PvApp::bind(p, PvEvent::TEXT_EVENT, combox, [=](std::string text) {
|
||||||
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
|
pvSetStyleSheet(p, combox, GetPeriodQss(text).c_str());
|
||||||
ui.vecComboxs[row-1][col-1] = combox;
|
data.vecPeriods[row-1][col-1] = GetPeriod(text);
|
||||||
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()
|
void PanelPolicyPeak::updateUI()
|
||||||
@@ -284,7 +307,7 @@ void PanelPolicyPeak::parseAttr(std::string str)
|
|||||||
periodVal = tmpVal;
|
periodVal = tmpVal;
|
||||||
// 更新UI (时段下拉列表)
|
// 更新UI (时段下拉列表)
|
||||||
auto combox = ui.vecComboxs[row][col];
|
auto combox = ui.vecComboxs[row][col];
|
||||||
pvSetCurrentItem(p, combox, periodVal);
|
pvSetCurrentItem(p, combox, periodVal-1);
|
||||||
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
|
pvSetStyleSheet(p, combox, GetPeriodQss(periodVal).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,7 +356,6 @@ void PanelPolicyPeak::parseAttr(std::string str)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PanelPolicyPeak::dumpAttr()
|
std::string PanelPolicyPeak::dumpAttr()
|
||||||
{
|
{
|
||||||
NJsonNode jsonroot;
|
NJsonNode jsonroot;
|
||||||
@@ -364,3 +386,116 @@ std::string PanelPolicyPeak::dumpAttr()
|
|||||||
jsonroot["cycle"] = nodeCycle;
|
jsonroot["cycle"] = nodeCycle;
|
||||||
return jsonroot.dump();
|
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();
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
class PanelPolicyPeak : public PvObject
|
class PanelPolicyPeak : public PvObject
|
||||||
{
|
{
|
||||||
public:
|
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();
|
void updateUI();
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ public:
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
int parent {};
|
int parent {};
|
||||||
int widget {PV_ID_NUL};
|
|
||||||
|
|
||||||
int label1 {PV_ID_NUL};
|
int label1 {PV_ID_NUL};
|
||||||
int label2 {PV_ID_NUL};
|
int label2 {PV_ID_NUL};
|
||||||
@@ -73,3 +72,58 @@ public:
|
|||||||
std::vector<std::vector<int>> vecPeriods;
|
std::vector<std::vector<int>> vecPeriods;
|
||||||
} data;
|
} 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;
|
||||||
|
};
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
void pvInitResource(PARAM* p)
|
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/icon1.png");
|
||||||
pvDownloadFile(p, "assets/pv/icon2.png");
|
pvDownloadFile(p, "assets/pv/icon2.png");
|
||||||
pvDownloadFile(p, "assets/pv/icon3.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/map.png");
|
||||||
pvDownloadFile(p, "assets/pv/mapMarker.png");
|
pvDownloadFile(p, "assets/pv/mapMarker.png");
|
||||||
pvDownloadFile(p, "assets/pv/downFill.png");
|
pvDownloadFile(p, "assets/pv/downFill.png");
|
||||||
|
pvDownloadFile(p, "assets/pv/play1.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
int onPvThreadCleanup(void* ptr)
|
int onPvThreadCleanup(void* ptr)
|
||||||
@@ -29,6 +30,7 @@ int pvMain(PARAM* p)
|
|||||||
// 管理客户端的连接信息
|
// 管理客户端的连接信息
|
||||||
PvUser pvuser;
|
PvUser pvuser;
|
||||||
PvApp::setPvUser(p, &pvuser);
|
PvApp::setPvUser(p, &pvuser);
|
||||||
|
XLOGD() << "Browser client connect: s= " << int(p->s) << ", user=" << int(&pvuser);
|
||||||
|
|
||||||
// 客户端断开时回调
|
// 客户端断开时回调
|
||||||
pvSetCleanup(p, onPvThreadCleanup, p);
|
pvSetCleanup(p, onPvThreadCleanup, p);
|
||||||
@@ -38,7 +40,7 @@ int pvMain(PARAM* p)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
// 重置控件的ID值
|
// 重置控件的ID值、回调函数表
|
||||||
PvApp::reset(p);
|
PvApp::reset(p);
|
||||||
|
|
||||||
std::shared_ptr<MaskMain> mask;
|
std::shared_ptr<MaskMain> mask;
|
||||||
@@ -48,14 +50,13 @@ int pvMain(PARAM* p)
|
|||||||
pvStartDefinition(p, 2048);
|
pvStartDefinition(p, 2048);
|
||||||
if (mask)
|
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();
|
mask->initUI();
|
||||||
}
|
}
|
||||||
pvQLayoutVbox(p, 0, -1);
|
pvQLayoutVbox(p, 0, -1);
|
||||||
pvEndDefinition(p);
|
pvEndDefinition(p);
|
||||||
XLOGD() << "===>>> pvidIndex=" << PvApp::pvid(p);
|
XLOGD() << "===>>> pvidIndex=" << PvApp::pvid(p);
|
||||||
|
|
||||||
|
|
||||||
char event[MAX_EVENT_LENGTH];
|
char event[MAX_EVENT_LENGTH];
|
||||||
char text[MAX_EVENT_LENGTH];
|
char text[MAX_EVENT_LENGTH];
|
||||||
int pvid;
|
int pvid;
|
||||||
@@ -68,37 +69,36 @@ int pvMain(PARAM* p)
|
|||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
PvApp::dispatch(p, pvEventId, pvid, text);
|
PvApp::dispatch(p, pvEventId, pvid, text);
|
||||||
|
|
||||||
switch (pvEventId)
|
switch (pvEventId)
|
||||||
{
|
{
|
||||||
case NULL_EVENT: {
|
case NULL_EVENT: {
|
||||||
pvcode = mask->onEventNull(pvid);
|
pvcode = mask->onEventNull(pvid);
|
||||||
} break;
|
} break;
|
||||||
case BUTTON_EVENT: {
|
case BUTTON_EVENT: {
|
||||||
pvcode = mask->onEventButton(pvid); std::cout << "EVENT: (" << pvid << ")BUTTON\n";
|
pvcode = mask->onEventButton(pvid); std::cout << "PvEvent: (" << pvid << ") BUTTON\n";
|
||||||
} break;
|
} break;
|
||||||
case TEXT_EVENT: { std::cout << "EVENT: (" << pvid << ")TEXT_EVENT\n"; } break;
|
case TEXT_EVENT: { std::cout << "PvEvent: (" << pvid << ") TEXT_EVENT\n"; } break;
|
||||||
case SLIDER_EVENT: { std::cout << "EVENT: (" << pvid << ")SLIDER_EVENT\n"; } break;
|
case SLIDER_EVENT: { std::cout << "PvEvent: (" << pvid << ") SLIDER_EVENT\n"; } break;
|
||||||
case CHECKBOX_EVENT: { std::cout << "EVENT: (" << pvid << ")CHECKBOX_EVENT\n"; } break;
|
case CHECKBOX_EVENT: { std::cout << "PvEvent: (" << pvid << ") CHECKBOX_EVENT\n"; } break;
|
||||||
case RADIOBUTTON_EVENT: { std::cout << "EVENT: (" << pvid << ")RADIOBUTTON_EVENT\n"; } break;
|
case RADIOBUTTON_EVENT: { std::cout << "PvEvent: (" << pvid << ") RADIOBUTTON_EVENT\n"; } break;
|
||||||
case GL_IDLE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_IDLE_EVENT\n"; } break;
|
case GL_IDLE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_IDLE_EVENT\n"; } break;
|
||||||
case GL_PAINT_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_PAINT_EVENT\n"; } break;
|
case GL_PAINT_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_PAINT_EVENT\n"; } break;
|
||||||
case GL_INITIALIZE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_INITIALIZE_EVENT\n"; } break;
|
case GL_INITIALIZE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_INITIALIZE_EVENT\n"; } break;
|
||||||
case GL_RESIZE_EVENT: { std::cout << "EVENT: (" << pvid << ")GL_RESIZE_EVENT\n"; } break;
|
case GL_RESIZE_EVENT: { std::cout << "PvEvent: (" << pvid << ") GL_RESIZE_EVENT\n"; } break;
|
||||||
case TAB_EVENT: { std::cout << "EVENT: (" << pvid << ")TAB_EVENT\n"; } break;
|
case TAB_EVENT: { std::cout << "PvEvent: (" << pvid << ") TAB_EVENT\n"; } break;
|
||||||
case TABLE_CLICKED_EVENT: { std::cout << "EVENT: (" << pvid << ")TABLE_CLICKED_EVENT\n"; } break;
|
case TABLE_CLICKED_EVENT: { std::cout << "PvEvent: (" << pvid << ") TABLE_CLICKED_EVENT\n"; } break;
|
||||||
case TABLE_TEXT_EVENT: { std::cout << "EVENT: (" << pvid << ")TABLE_TEXT_EVENT\n"; } break;
|
case TABLE_TEXT_EVENT: { std::cout << "PvEvent: (" << pvid << ") TABLE_TEXT_EVENT\n"; } break;
|
||||||
case SELECTION_EVENT: { std::cout << "EVENT: (" << pvid << ")SELECTION_EVENT\n"; } break;
|
case SELECTION_EVENT: { std::cout << "PvEvent: (" << pvid << ") SELECTION_EVENT\n"; } break;
|
||||||
case CLIPBOARD_EVENT: { std::cout << "EVENT: (" << pvid << ")CLIPBOARD_EVENT\n"; } break;
|
case CLIPBOARD_EVENT: { std::cout << "PvEvent: (" << pvid << ") CLIPBOARD_EVENT\n"; } break;
|
||||||
case BUTTON_PRESSED_EVENT: { std::cout << "EVENT: (" << pvid << ")BUTTON_PRESSED_EVENT\n"; } break;
|
case BUTTON_PRESSED_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") BUTTON_PRESSED_EVENT\n";*/ } break;
|
||||||
case BUTTON_RELEASED_EVENT: { std::cout << "EVENT: (" << pvid << ")BUTTON_RELEASED_EVENT\n"; } break;
|
case BUTTON_RELEASED_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") BUTTON_RELEASED_EVENT\n";*/ } break;
|
||||||
case RIGHT_MOUSE_EVENT: { std::cout << "EVENT: (" << pvid << ")RIGHT_MOUSE_EVENT\n"; } break;
|
case RIGHT_MOUSE_EVENT: { std::cout << "PvEvent: (" << pvid << ") RIGHT_MOUSE_EVENT\n"; } break;
|
||||||
case KEYBOARD_EVENT: { std::cout << "EVENT: (" << pvid << ")KEYBOARD_EVENT\n"; } break;
|
case KEYBOARD_EVENT: { std::cout << "PvEvent: (" << pvid << ") KEYBOARD_EVENT\n"; } break;
|
||||||
case PLOT_MOUSE_MOVED_EVENT: { std::cout << "EVENT: (" << pvid << ")PLOT_MOUSE_MOVED_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 << "EVENT: (" << pvid << ")PLOT_MOUSE_PRESSED_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 << "EVENT: (" << pvid << ")PLOT_MOUSE_RELEASED_EVENT\n"; } break;
|
case PLOT_MOUSE_RELEASED_EVENT: { std::cout << "PvEvent: (" << pvid << ") PLOT_MOUSE_RELEASED_EVENT\n"; } break;
|
||||||
case USER_EVENT: { std::cout << "EVENT: (" << pvid << ")USER_EVENT\n"; } break;
|
case USER_EVENT: { std::cout << "PvEvent: (" << pvid << ") USER_EVENT\n"; } break;
|
||||||
case MOUSE_OVER_EVENT: { /*std::cout << "EVENT: (" << pvid << ")MOUSE_OVER_EVENT\n";*/ } break;
|
case MOUSE_OVER_EVENT: { /*std::cout << "PvEvent: (" << pvid << ") MOUSE_OVER_EVENT\n";*/ } break;
|
||||||
default: {} break;
|
default: {} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,10 +114,10 @@ void QUI::combox(QComboBox& comb, QWidget* parent, int x, int y, int w, int h, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QUI::lineedit(QLineEdit& lineEdit, QWidget* parent, int x, int y, int w, int h)
|
void QUI::lineedit(QLineEdit& edit, QWidget* parent, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
lineEdit.setParent(parent);
|
edit.setParent(parent);
|
||||||
lineEdit.setGeometry(x, y, w, h);
|
edit.setGeometry(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QUI::setBackground(QWidget* w, std::string name, QColor color, std::string border)
|
void QUI::setBackground(QWidget* w, std::string name, QColor color, std::string border)
|
||||||
@@ -742,7 +742,7 @@ void TableBase::setOperate(std::vector<std::string> vecOperate, std::function<vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableBase::setRowData(int row, std::vector<std::string> vd)
|
void TableBase::setRow(int row, std::vector<std::string> vd)
|
||||||
{
|
{
|
||||||
int rowCount = widget_->rowCount();
|
int rowCount = widget_->rowCount();
|
||||||
if (row >= rowCount)
|
if (row >= rowCount)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
static void combox(QComboBox& comb, QWidget* parent, int x, int y, int w, int h, std::vector<std::string> items, std::string v="");
|
static void combox(QComboBox& comb, QWidget* parent, int x, int y, int w, int h, std::vector<std::string> items, std::string v="");
|
||||||
|
|
||||||
static void lineedit(QLineEdit& lineEdit, QWidget* parent, int x, int y, int w, int h);
|
static void lineedit(QLineEdit& edit, QWidget* parent, int x, int y, int w, int h);
|
||||||
|
|
||||||
static void setBackground(QWidget* w, std::string name, QColor color=QColor(29, 54, 102), std::string border="border-radius:5px;");
|
static void setBackground(QWidget* w, std::string name, QColor color=QColor(29, 54, 102), std::string border="border-radius:5px;");
|
||||||
};
|
};
|
||||||
@@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
void setOperate(std::vector<std::string> vecOperate, std::function<void(int, std::string)> cb);
|
void setOperate(std::vector<std::string> vecOperate, std::function<void(int, std::string)> cb);
|
||||||
|
|
||||||
void setRowData(int row, std::vector<std::string> vd);
|
void setRow(int row, std::vector<std::string> vd);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user