2025-05-19 09:54:33 +08:00
|
|
|
|
#include <Windows.h>
|
2025-07-18 09:08:09 +08:00
|
|
|
|
#include <thread>
|
2025-05-19 09:54:33 +08:00
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
#include <QtWebEngineWidgets/QtWebEngineWidgets>
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/Utils.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
#include "common/Snowflake.h"
|
|
|
|
|
|
#include "common/JsonN.h"
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
#include "app/Application.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
#include "app/Config.h"
|
2025-08-20 19:00:22 +08:00
|
|
|
|
#include "protocol/TcpEntity.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "widgets/MainWindow.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "pv/PvApp.h"
|
|
|
|
|
|
#include "pv/PvUser.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
2025-08-26 18:36:25 +08:00
|
|
|
|
|
2025-05-19 09:54:33 +08:00
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
|
{
|
2025-07-18 09:08:09 +08:00
|
|
|
|
// 设置控制台输出为 UTF-8 编码
|
|
|
|
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
|
|
|
|
// 设置控制台输入为 UTF-8 编码(如果需要输入中文)
|
|
|
|
|
|
SetConsoleCP(CP_UTF8);
|
2025-05-19 09:54:33 +08:00
|
|
|
|
|
2025-08-26 18:36:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
NJsonNode jsonroot;
|
|
|
|
|
|
NJson::parse(R"({"name": "Alice", "age": 25, "data":[["1","1","1"],["1","1","1"],["1","1","1"]]})", jsonroot);
|
|
|
|
|
|
std::cout << (jsonroot.is_null() ? "ERROR" : "OK") << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<std::string>> v1;
|
|
|
|
|
|
NJson::read<std::vector<std::vector<std::string>>>(jsonroot, "data", v1);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<std::string>> vec = {
|
|
|
|
|
|
{"1", "1", "1", "1", "1", "1", "1", "1"},
|
|
|
|
|
|
{"1", "1", "1", "1", "1", "1", "1", "1"},
|
|
|
|
|
|
{"1", "1", "1", "1", "1", "1", "1", "1"},
|
|
|
|
|
|
{"1", "1", "1", "1", "1", "1", "1", "1"}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
NJsonNode jsonroot1;
|
|
|
|
|
|
jsonroot1["price_super_peak"] = 0.53;
|
|
|
|
|
|
jsonroot1["price_peak"] = 0.53;
|
|
|
|
|
|
jsonroot1["price_shoulder"] = 0.53;
|
|
|
|
|
|
jsonroot1["price_off_peak"] = 0.53;
|
|
|
|
|
|
jsonroot1["periods"] = vec;
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << jsonroot1.dump();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << "===>>> main start ... " << std::endl;
|
2025-05-19 09:54:33 +08:00
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
////std::cout << Snowflake::instance().getId() << std::endl;
|
|
|
|
|
|
//for (int i = 0; i<=10; ++i) {
|
|
|
|
|
|
// //std::cout << Snowflake::instance().getId() << std::endl;
|
|
|
|
|
|
//}
|
2025-05-19 09:54:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
//DaoEntity dao("");
|
|
|
|
|
|
//
|
|
|
|
|
|
//std::string filename = "assets/html/data中文.txt";
|
|
|
|
|
|
//
|
|
|
|
|
|
//std::filesystem::path filePath = std::filesystem::u8path("assets/html/data中文.txt");
|
|
|
|
|
|
////std::locale::global(locale(""));//将全局区域设为操作系统默认区域
|
|
|
|
|
|
//std::ifstream ifs(filePath, std::ios::binary);
|
|
|
|
|
|
////std::locale::global(locale("C"));//还原全局区域设定
|
2025-05-19 09:54:33 +08:00
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
//if (ifs.is_open())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// // 将文件指针移动到末尾获取文件大小
|
|
|
|
|
|
// ifs.seekg(0, std::ios::end);
|
|
|
|
|
|
// std::streamsize size = ifs.tellg();
|
|
|
|
|
|
// ifs.seekg(0, std::ios::beg);
|
|
|
|
|
|
|
|
|
|
|
|
// std::string buf(size, '\0');
|
|
|
|
|
|
// ifs.read(&buf[0], size);
|
|
|
|
|
|
// std::cout << "文件内容: " << buf << std::endl;
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// std::cout << "error" << std::endl;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//TcpEntity tcpEntity;
|
|
|
|
|
|
//tcpEntity.setHost("127.0.0.1", 9901, true);
|
|
|
|
|
|
//tcpEntity.setReconnect(5000);
|
|
|
|
|
|
//tcpEntity.start();
|
|
|
|
|
|
|
|
|
|
|
|
// 运行后台服务
|
2025-05-19 09:54:33 +08:00
|
|
|
|
Application::instance().init();
|
|
|
|
|
|
|
|
|
|
|
|
// 运行QT主窗口
|
2025-08-20 19:00:22 +08:00
|
|
|
|
//QApplication qapp(argc, argv);
|
|
|
|
|
|
//MainWindow mainWin;
|
|
|
|
|
|
//mainWin.setWindowTitle("风光储能站控制管理系统");
|
|
|
|
|
|
//mainWin.resize(1920, 1080);
|
|
|
|
|
|
//mainWin.show();
|
|
|
|
|
|
//qapp.exec();
|
|
|
|
|
|
|
2025-08-26 18:36:25 +08:00
|
|
|
|
// 运行pv主流程
|
2025-08-20 19:00:22 +08:00
|
|
|
|
PARAM p;
|
|
|
|
|
|
int s;
|
|
|
|
|
|
pvInit(argc, argv, &p);
|
|
|
|
|
|
/* here you may interpret ac,av and set p->user to your data */
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
{
|
|
|
|
|
|
s = pvAccept(&p);
|
|
|
|
|
|
if(s != -1) pvCreateThread(&p,s);
|
|
|
|
|
|
}
|
2025-05-19 09:54:33 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|