diff --git a/bin/Release/assets/ui/splash.jpg b/bin/Release/assets/ui/splash.jpg new file mode 100644 index 0000000..aebb6c9 Binary files /dev/null and b/bin/Release/assets/ui/splash.jpg differ diff --git a/bin/Release/assets/ui/splash.png b/bin/Release/assets/ui/splash.png new file mode 100644 index 0000000..5e0ede6 Binary files /dev/null and b/bin/Release/assets/ui/splash.png differ diff --git a/bin/Release/yhicon.ico b/bin/Release/yhicon.ico new file mode 100644 index 0000000..c7a07f1 Binary files /dev/null and b/bin/Release/yhicon.ico differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37b8794..b814508 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,9 +83,11 @@ ADD_SOURCE_GROUP(protocol) #ADD_SOURCE_GROUP(widgets/pages) ADD_SOURCE_GROUP(pv) ADD_SOURCE_GROUP(pv/pages) +ADD_SOURCE_GROUP(qt) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../bin) -add_executable(${PROJECT_NAME} ${SOURCE_FILE}) +add_executable(${PROJECT_NAME} ${SOURCE_FILE} "resource.rc") + #set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") target_link_libraries(${PROJECT_NAME} @@ -97,6 +99,7 @@ target_link_libraries(${PROJECT_NAME} Qt5::Charts Qt5::WebEngineWidgets ) + target_link_libraries(${PROJECT_NAME} ws2_32 iphlpapi ${THIRDPARTY_PATH}/mysql/lib/x64/libmysql.lib diff --git a/src/RCa06216 b/src/RCa06216 new file mode 100644 index 0000000..a443f97 Binary files /dev/null and b/src/RCa06216 differ diff --git a/src/app/AppData.cpp b/src/app/AppData.cpp index e8e3bc4..3c6761e 100644 --- a/src/app/AppData.cpp +++ b/src/app/AppData.cpp @@ -113,9 +113,9 @@ void AppData::initFromDB() { auto station = std::make_shared(); station->setFields(fields); - this->mapStation[station->id] = station; - mapping.stationName.push_back({std::to_string(station->id), station->name}); - str += ("场站: {" + std::to_string(station->id) + ":" + station->name + "},"); + this->mapStation[station->stationId] = station; + mapping.stationName.push_back({std::to_string(station->stationId), station->name}); + str += ("场站: {" + std::to_string(station->stationId) + ":" + station->name + "},"); } spdlog::info(str); } @@ -210,6 +210,34 @@ void AppData::initFromDB() } } } + + { // 初始化场站设备的历史监测数据 + + vector result; + DAO::queryRuntimeData(dao, Utils::dateStr(), result); + for (auto& item : result) + { + int stationId = item.get("station_id"); + int deviceId = item.get("device_id"); + auto device = this->getDevice(stationId, deviceId); + if (device) + { + int datatype = item.get("datatype"); + std::string value = item.value("value"); + + njson json; + if (JSON::parse(value, json)) + { + std::vector vecVal(json.size()); + for (int i=0; i(json[i]); + } + device->setCache(datatype, vecVal); + } + } + } + } } void AppData::init() diff --git a/src/app/Application.cpp b/src/app/Application.cpp index db55822..dc8e325 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -49,6 +49,9 @@ void Application::init() // 创建主业务循环线程 std::thread([=]() { runThreadMain(); }).detach(); + + // 统计分析 + std::thread([=]() { runThreadStat(); }).detach(); } @@ -56,7 +59,7 @@ void Application::runThreadDevice() { while (!isQuit) { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } @@ -101,4 +104,32 @@ void Application::runThreadMain() std::this_thread::sleep_for(std::chrono::milliseconds(10)); } +} + + +void Application::runThreadStat() +{ + int nCachePos = 0; + while (!isQuit) + { + int64_t tTime = Utils::time(); + int64_t tDate = Utils::date(); + int64_t delta = tTime-tDate; + int n = delta / 600; + int offset = delta % 600; + if (delta >=0 && delta < 86400 && offset <= 10 && n != nCachePos) + { + nCachePos = n; + std::string dt = Utils::dateStr(tDate); + for (auto item: appdata.mapStation) + { + item.second->writeRuntimeData(dt, nCachePos); + } + } + else + { + spdlog::info("保存历史数据倒计时: {}", 600 - offset); + } + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + } } \ No newline at end of file diff --git a/src/app/Application.h b/src/app/Application.h index c614ce7..3832257 100644 --- a/src/app/Application.h +++ b/src/app/Application.h @@ -29,6 +29,8 @@ public: void runThreadDevice(); + void runThreadStat(); + public: bool isQuit = false; diff --git a/src/app/Device.cpp b/src/app/Device.cpp index 88d2149..f5c0259 100644 --- a/src/app/Device.cpp +++ b/src/app/Device.cpp @@ -5,6 +5,13 @@ #include "protocol/CommEntity.h" #include "common/JsonN.h" +#include + +static std::unordered_set g_setCacheDeviceType = {3, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}; +static bool CheckCacheType(int type) +{ + return g_setCacheDeviceType.find(type) != g_setCacheDeviceType.end(); +} std::shared_ptr Device::create(Fields& fields) { @@ -40,15 +47,15 @@ std::shared_ptr Device::create(Fields& fields) } } - int step = 600; - for (int i = 0; i*600<86400; ++i) - { - double voltage = double(Utils::random(20000, 30000))*0.01; - double current = double(Utils::random(1000, 2000))*0.01; - device->mapCacheVoltage[i*step] = voltage; - device->mapCacheCurrent[i*step] = current; - device->mapCachePower[i*step] = voltage * current; - } + //int step = 600; + //for (int i = 0; i*600<86400; ++i) + //{ + // double voltage = double(Utils::random(20000, 30000))*0.01; + // double current = double(Utils::random(1000, 2000))*0.01; + // device->mapCacheVoltage[i*step] = voltage; + // device->mapCacheCurrent[i*step] = current; + // device->mapCachePower[i*step] = voltage * current; + //} // 启动通讯,该函数中会自动判断isOpen状态,选择是否进行通讯连接 //device->startComm(); @@ -117,6 +124,64 @@ void Device::getCachePower(std::vector& vec) } } +int64_t GetCurrentTimePos(int step) +{ + auto tp = chrono::system_clock::now(); + int64_t tTime = chrono::time_point_cast(tp).time_since_epoch().count(); + std::time_t t = chrono::system_clock::to_time_t(tp); + std::tm* tmlocal = localtime(&t); + tmlocal->tm_hour = 0; + tmlocal->tm_min = 0; + tmlocal->tm_sec = 0; + int64_t tDate = chrono::time_point_cast(chrono::system_clock::from_time_t(mktime(tmlocal))).time_since_epoch().count(); + return (tTime - tDate) / step; +} + +void Device::setCache(int datatype, std::vector& vec) +{ + std::map* mapptr = NULL; + if (datatype == 1) { mapptr = &mapCacheVoltage; } + else if (datatype == 2) { mapptr = &mapCacheCurrent; } + else if (datatype == 3) { mapptr = &mapCachePower; } + + if (mapptr) + { + const int step = 600; + const int N = 86400/step; + + int n = GetCurrentTimePos(step); + for (int i = 0; itype)) + { + return false; + } + if (npos == 0) + { + mapCacheVoltage.clear(); + mapCacheCurrent.clear(); + mapCachePower.clear(); + } + // 根据设备类型从参数(寄存器地址)中读取实时数据进行保存 + mapCacheVoltage[npos] = Utils::random(100, 200); + mapCacheCurrent[npos] = Utils::random(100, 200); + mapCachePower[npos] = Utils::random(100, 200); + + return true; +} + +void Device::storeDB(int npos) +{ +} + void Device::setParam(std::string k, std::string v) { mapParams[k] = v; diff --git a/src/app/Device.h b/src/app/Device.h index cd5ed36..423baa1 100644 --- a/src/app/Device.h +++ b/src/app/Device.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "common/Fields.h" @@ -15,18 +16,24 @@ class Device public: static std::shared_ptr create(Fields& fields); - int startComm(); void getCacheVoltage(std::vector& vec); void getCacheCurrent(std::vector& vec); void getCachePower(std::vector& vec); + // int datatype: 1: 电压,2:电流,3:功率 + void setCache(int datatype, std::vector& vec); + + bool cache(int npos); + void storeDB(int npos); + void setParam(std::string k, std::string v); std::string getParam(std::string k, std::string defaultVal = ""); void getRuntimeParams(std::vector>& params); + public: int deviceId = -1; int type = -1; diff --git a/src/app/Station.cpp b/src/app/Station.cpp index 2121fde..8418f06 100644 --- a/src/app/Station.cpp +++ b/src/app/Station.cpp @@ -6,8 +6,9 @@ #include "common/Spdlogger.h" #include "common/Utils.h" #include "protocol/MqttEntity.h" +#include "common/JsonN.h" -Station::Station() : id(0) +Station::Station() : stationId(0) { mqttCli = std::make_shared(); @@ -32,7 +33,7 @@ Station::Station() : id(0) void Station::setFields(Fields& fields) { - this->id = fields.get(DMStation::STATION_ID); + this->stationId = fields.get(DMStation::STATION_ID); this->name = fields.value(DMStation::NAME); this->energyCapacity = fields.get(DMStation::CAPACITY); this->workModeId = fields.get(DMStation::WORK_MODE); @@ -99,7 +100,7 @@ void Station::setWorkMode(int modeId) this->workModeId = modeId; std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME) .update(DMStation::WORK_MODE, std::to_string(modeId)) - .where(DMStation::STATION_ID + "=" + std::to_string(id)).str(); + .where(DMStation::STATION_ID + "=" + std::to_string(stationId)).str(); Errcode err = DAO::exec(NULL, sql); if (err != Errcode::OK) { @@ -111,10 +112,49 @@ void Station::setPolicy(int policyId) { std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME) .update(DMStation::POLICY_ID, std::to_string(policyId)) - .where(DMStation::STATION_ID + "=" + std::to_string(id)).str(); + .where(DMStation::STATION_ID + "=" + std::to_string(stationId)).str(); Errcode err = DAO::exec(NULL, sql); if (err != Errcode::OK) { spdlog::error("set station policy failed."); } } + +static std::string MapValueToJson(int npos, std::map& mapV) +{ + njson jsonarray = njson::array(); + for (int i = 0; i<=npos; i++) + { + jsonarray.push_back(mapV[i]); + } + return jsonarray.dump(); +} + +void Station::writeRuntimeData(std::string dt, int npos) +{ + auto dao = DaoEntity::create("history_day"); + for (auto iter = mapDevice.begin(); iter!=mapDevice.end(); ++iter) + { + auto device = iter->second; + if (device->cache(npos)) + { + Fields fields; + fields.set("dt", dt); + fields.set("station_id", this->stationId); + fields.set("device_id", device->deviceId); + fields.set("datatype", 1); + fields.set("value", MapValueToJson(npos, device->mapCacheVoltage)); + DAO::insertRuntimeData(dao, fields); + + fields.set("datatype", 2); + fields.set("value", MapValueToJson(npos, device->mapCacheCurrent)); + DAO::insertRuntimeData(dao, fields); + + fields.set("datatype", 3); + fields.set("value", MapValueToJson(npos, device->mapCachePower)); + DAO::insertRuntimeData(dao, fields); + + spdlog::info("[device] write runtime date to database, deviceId={}", device->deviceId); + } + } +} diff --git a/src/app/Station.h b/src/app/Station.h index 7d80c33..56ba423 100644 --- a/src/app/Station.h +++ b/src/app/Station.h @@ -105,10 +105,12 @@ public: void setWorkMode(int modeId); void setPolicy(int policyId); + + void writeRuntimeData(std::string dt, int npos); public: - int id {}; + int stationId {}; std::string name; std::string code; bool isConnected {false}; diff --git a/src/common/Fields.cpp b/src/common/Fields.cpp index 56130dd..edd287e 100644 --- a/src/common/Fields.cpp +++ b/src/common/Fields.cpp @@ -35,7 +35,7 @@ void Fields::append(Fields& datafield) } } -std::unordered_map& Fields::map() +std::map& Fields::map() { return mapFields; } diff --git a/src/common/Fields.h b/src/common/Fields.h index 3c1be32..db3275d 100644 --- a/src/common/Fields.h +++ b/src/common/Fields.h @@ -72,7 +72,7 @@ public: /** * 获取数据项 map */ - std::unordered_map& map(); + std::map& map(); /** * 获取数据项的大小 @@ -140,7 +140,7 @@ public: void parseJson(std::string jsonstr); private: - std::unordered_map mapFields; + std::map mapFields; }; #endif \ No newline at end of file diff --git a/src/common/JsonN.h b/src/common/JsonN.h index b24485d..0065693 100644 --- a/src/common/JsonN.h +++ b/src/common/JsonN.h @@ -4,6 +4,7 @@ #include #include #include +#include using njson = nlohmann::json; @@ -53,26 +54,36 @@ class JSON public: static bool load(std::string jsonfile, njson& json); - static bool parse(std::string jsonstr, njson& json); template static void read(njson& json, std::string k, T& v) { - try - { - if (json.contains(k)) { v = json.at(k).get(); } - } - catch (const nlohmann::detail::exception& e) - { - std::cout << "JSON read error: k=" << k << ", err=" << e.what() << std::endl; - } + try { if (json.contains(k)) { v = json.at(k).get(); } } + catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: k={}, err={}", k, e.what()); } + } + + template + static T read(njson& json, std::string k) + { + T v {}; + try { if (json.contains(k)) { v = json.at(k).get(); } } + catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: k={}, err={}", k, e.what()); } + return v; + } + + template + static T get(njson& json) + { + T v {}; + try { v = json.get(); } + catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: err={}, json={}", e.what(), json.dump()); } + return v; } static std::string readStr(njson& json, std::string k); static void parse(std::string jsonstr, std::vector& vd); - }; diff --git a/src/database/Dao.cpp b/src/database/Dao.cpp index 0e39fbc..1373ba4 100644 --- a/src/database/Dao.cpp +++ b/src/database/Dao.cpp @@ -551,7 +551,25 @@ Errcode DAO::queryPolicyTypeDef(std::shared_ptr dao, vector& Errcode DAO::insertRuntimeData(std::shared_ptr dao, Fields& fields) { - if (!dao) { dao = DaoEntity::create("history1"); } + if (!dao) { dao = DaoEntity::create("history_day"); } int ret = dao->duplicateUpdate(fields, {"value"}); return Errcode(ret); +} + + +Errcode DAO::queryRuntimeData(std::shared_ptr dao, std::string dt, int stationId, int deviceId, vector& result) +{ + if (!dao) { dao = DaoEntity::create("history_day"); } + std::string sql = "SELECT * FROM history_day WHERE dt='" + dt + "' AND station_id='" + std::to_string(stationId) + + "' AND device_id='" + std::to_string(deviceId) + "';"; + int ret = dao->exec(sql, result); + return Errcode(ret); +} + +Errcode DAO::queryRuntimeData(std::shared_ptr dao, std::string dt, vector& result) +{ + if (!dao) { dao = DaoEntity::create("history_day"); } + std::string sql = "SELECT * FROM history_day WHERE dt='" + dt + "';"; + int ret = dao->exec(sql, result); + return Errcode(ret); } \ No newline at end of file diff --git a/src/database/Dao.h b/src/database/Dao.h index 48e24f4..b6e9a4c 100644 --- a/src/database/Dao.h +++ b/src/database/Dao.h @@ -118,5 +118,13 @@ public: static Errcode queryPolicyTypeDef(std::shared_ptr dao, vector& result); + + + + + /////////////////////////////////////////////////////////////////////////////////////////////// + // === 设备历史监测数据管理 === static Errcode insertRuntimeData(std::shared_ptr dao, Fields& fields); + static Errcode queryRuntimeData(std::shared_ptr dao, std::string dt, int stationId, int deviceId, vector& result); + static Errcode queryRuntimeData(std::shared_ptr dao, std::string dt, vector& result); }; \ No newline at end of file diff --git a/src/database/DaoEntity.cpp b/src/database/DaoEntity.cpp index b97959c..6771809 100644 --- a/src/database/DaoEntity.cpp +++ b/src/database/DaoEntity.cpp @@ -105,6 +105,7 @@ int DaoEntity::insertFields(vector& vec_fields) } if (!values.empty()) { values += ","; } values += ("'" + v + "'"); + std::cout << k << std::endl; } if (first) { diff --git a/src/database/DataModelDef.h b/src/database/DataModelDef.h index a4b4ab3..e47cfd6 100644 --- a/src/database/DataModelDef.h +++ b/src/database/DataModelDef.h @@ -184,7 +184,7 @@ namespace DMStatStation namespace DMHistory1 { - const string TABLENAME = "history1"; + const string TABLENAME = "history_day"; const string DT = "dt"; const string STATION_ID = "station_id"; const string DEVICE_ID = "device_id"; diff --git a/src/main.cpp b/src/main.cpp index 03e6fa3..732f962 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,8 +30,7 @@ #include #include "DataStruct.h" -#include -#include +#include "qt/MainWeb.h" #define wsa rlwsa void rlSocketTest() @@ -159,23 +158,8 @@ int main(int argc, char** argv) }).detach(); QApplication qapp(argc, argv); - - QMainWindow mainWin; - mainWin.setWindowTitle("光储充站监控与运营管理平台"); - mainWin.setGeometry(0, 0, 1920, 1080); - QWebEngineView webView; - webView.setGeometry(0, 0, 1920, 1080); - // 默认设置透明, 解决加载时的白屏闪烁 - webView.page()->setBackgroundColor(Qt::transparent); - webView.setContextMenuPolicy(Qt::NoContextMenu); - webView.load(QUrl(Config::option.webSrvUrl.c_str())); - //webView.load(QUrl("file:///assets/html/main.html")); - //connect(wWebView.get(), &QWebEngineView::loadFinished, this, &MyWidget::slotLoadFinished); - //std::string htmlContent = "HelloWorld"; - //webView->setHtml(htmlContent.c_str(), QUrl("file:///assets/html/")); - webView.show(); - mainWin.setCentralWidget(&webView); - + qapp.setWindowIcon(QIcon("./yhicon.ico")); + MainWeb mainWin; mainWin.show(); qapp.exec(); diff --git a/src/protocol/HttpEntity.cpp b/src/protocol/HttpEntity.cpp index 3de980d..ba37826 100644 --- a/src/protocol/HttpEntity.cpp +++ b/src/protocol/HttpEntity.cpp @@ -151,6 +151,7 @@ static std::map g_mapHttpHandlerGet = {"/queryDevicTypeDef", HandlerOptions(&HttpEntity::queryDevicTypeDef, {})}, {"/queryDevicByCategory", HandlerOptions(&HttpEntity::queryDevicByCategory, {DMStation::STATION_ID, "category"})}, {"/queryDevicCharts", HandlerOptions(&HttpEntity::queryDevicCharts, {DMStation::STATION_ID, "device_id"})}, + {"/queryDeviceBCUDetail", HandlerOptions(&HttpEntity::queryDeviceBCUDetail, {DMStation::STATION_ID, "device_id"})}, {"/queryPolicyList", HandlerOptions(&HttpEntity::queryPolicyList, {})}, @@ -305,11 +306,35 @@ Errcode HttpEntity::login(const httplib::Request& req, njson& json, std::string& DAO::queryRolePermission(dao, roleId, vecPermission); njson nodePermission = njson::array(); - for (auto& item : vecPermission) + std::map mapParentPos; + for (int i=0; isecond]["children"].push_back(node); + } + } } json["permission"] = nodePermission; } @@ -406,25 +431,56 @@ Errcode HttpEntity::queryRoleList(const httplib::Request& req, njson& json, std: { return err; } + std::map> mapP; - std::map> mapPermission; - for (auto& fields: vecPermission) + for (int i = 0; i& vecP = mapP[roleId]; + + std::map mapParentPos; + for (int i = 0; isecond]["children"].push_back(node); + } + } + } + item["permission"] = jsonpermission; } } return err; @@ -501,7 +557,7 @@ Errcode HttpEntity::insertStation(const httplib::Request& req, njson& json, std: Errcode HttpEntity::updateStation(const httplib::Request& req, njson& json, std::string& errmsg) { Fields params; - GetRequestParam(req, {"station_id", "name", "address", "lon", "lat", "tel", "capacity", "status"}, params); + GetRequestParam(req, {"station_id", "name", "address", "lon", "lat", "tel", "capacity", "status", "work_mode"}, params); params.check("capacity", "", "0.0"); params.check("lon", "", "0.0"); params.check("lat", "", "0.0"); @@ -739,6 +795,17 @@ Errcode HttpEntity::queryDevicCharts(const httplib::Request& req, njson& json, s return Errcode::OK; } +Errcode HttpEntity::queryDeviceBCUDetail(const httplib::Request& req, njson& json, std::string& errmsg) +{ + njson jsondata = njson::array(); + for (int i = 0; i<=100; ++i) + { + jsondata.push_back({{"SOC", "1"}, {"SOH", "1"}, {"V", "1"}, {"T", "1"}, {"R_i", "1"}}); + } + json["data"] = jsondata; + return Errcode::OK; +} + Errcode HttpEntity::queryPolicyList(const httplib::Request& req, njson& json, std::string& errmsg) { PageInfo pageinfo; diff --git a/src/protocol/HttpEntity.h b/src/protocol/HttpEntity.h index 4eff86b..3a8cd63 100644 --- a/src/protocol/HttpEntity.h +++ b/src/protocol/HttpEntity.h @@ -63,6 +63,7 @@ public: Errcode queryDevicTypeDef(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDevicByCategory(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDevicCharts(const httplib::Request& req, njson& json, std::string& errmsg); + Errcode queryDeviceBCUDetail(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryPolicyList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertPolicy(const httplib::Request& req, njson& json, std::string& errmsg); diff --git a/src/pv/pages/MaskPageRunning.cpp b/src/pv/pages/MaskPageRunning.cpp index 2824bc4..ddd596b 100644 --- a/src/pv/pages/MaskPageRunning.cpp +++ b/src/pv/pages/MaskPageRunning.cpp @@ -125,7 +125,7 @@ int MaskPageRunning::initUI(EPvCode pvcode) } PvApp::label(p, 0, 320, 110, 80, 30, "运行模式", "color:white; font: bold 16px;"); - ui.comboxWorkMode = PvApp::combox(p, 0, 400, 110, 200, 30, appdata.getWorkModes(), activeStation->id - 1); + ui.comboxWorkMode = PvApp::combox(p, 0, 400, 110, 200, 30, appdata.getWorkModes(), activeStation->stationId - 1); PvApp::label(p, 0, 670, 110, 80, 30, "策略名称", "color:white; font: bold 16px;"); PvApp::combox(p, 0, 750, 110, 200, 30, appdata.getPolicyNames()); diff --git a/src/qt/MainWeb.cpp b/src/qt/MainWeb.cpp new file mode 100644 index 0000000..0ef0b7e --- /dev/null +++ b/src/qt/MainWeb.cpp @@ -0,0 +1,57 @@ +#include "MainWeb.h" + +#include "app/Config.h" +#include +#include +#include + + +void MySplash(MainWeb* mainWin) +{ + //===动态程序启动画面=== + QPixmap pixmap("./assets/ui/splash.png"); + QSplashScreen splash(pixmap); + splash.show(); + QCoreApplication::processEvents(); + QLabel label(&splash); + label.setStyleSheet("background-color: gray"); + label.setGeometry(100, 480, 800, 20); + label.show(); + + QLabel labelProgress(&splash); + labelProgress.setStyleSheet("background-color: rgb(29, 54, 102)"); + labelProgress.setGeometry(10, 10, 0, 20); + labelProgress.show(); + + int i = 0; + while ((++i)<500) + { + splash.showMessage(QString("Loading... %1 ms").arg(i), Qt::AlignBottom | Qt::AlignRight, Qt::black); + labelProgress.setGeometry(100, 480, i*2*0.8, 20); + QThread::msleep(10); + } + + splash.finish(mainWin);//程序启动画面结束 +} + + +MainWeb::MainWeb() +{ + this->setWindowTitle("光储充站监控与运营管理平台"); + this->setGeometry(0, 0, 1920, 1080); + + webView.setGeometry(0, 0, 1920, 1080); + // 默认设置透明, 解决加载时的白屏闪烁 + webView.page()->setBackgroundColor(Qt::transparent); + webView.setContextMenuPolicy(Qt::NoContextMenu); + webView.load(QUrl(Config::option.webSrvUrl.c_str())); + //webView.load(QUrl("file:///assets/html/main.html")); + //connect(wWebView.get(), &QWebEngineView::loadFinished, this, &MyWidget::slotLoadFinished); + //std::string htmlContent = "HelloWorld"; + //webView->setHtml(htmlContent.c_str(), QUrl("file:///assets/html/")); + webView.show(); + this->setCentralWidget(&webView); + + MySplash(this); + this->show(); +} \ No newline at end of file diff --git a/src/qt/MainWeb.h b/src/qt/MainWeb.h new file mode 100644 index 0000000..57d92d2 --- /dev/null +++ b/src/qt/MainWeb.h @@ -0,0 +1,14 @@ +#include +#include +#include + + + + +class MainWeb : public QMainWindow +{ +public: + MainWeb(); + + QWebEngineView webView; +}; \ No newline at end of file diff --git a/src/resource.aps b/src/resource.aps new file mode 100644 index 0000000..7fa341e Binary files /dev/null and b/src/resource.aps differ diff --git a/src/resource.h b/src/resource.h new file mode 100644 index 0000000..bbaaa3a --- /dev/null +++ b/src/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ ɵİļ +// ESS.rc ʹ +// +#define IDI_ICON1 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/resource.rc b/src/resource.rc new file mode 100644 index 0000000..4e1b7c8 Binary files /dev/null and b/src/resource.rc differ diff --git a/src/yhicon.ico b/src/yhicon.ico new file mode 100644 index 0000000..c7a07f1 Binary files /dev/null and b/src/yhicon.ico differ