#include #include #include #include #include #include "common/Utils.h" #include "common/Snowflake.h" #include "common/JsonN.h" #include "app/Application.h" #include "app/Config.h" #include "protocol/TcpEntity.h" #include "widgets/MainWindow.h" #include "common/Spdlogger.h" #include "database/DaoEntity.h" #include #include #include #include #include #include #include "DataStruct.h" #include "qt/MainWeb.h" //#define wsa rlwsa //void rlSocketTest() //{ // 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 buf(1024, 0); // while (true) // { // int len = socket.read(&buf[0], 1, 0); // if (len > 0) // { // std::cout << "===>>> " << std::string(buf.begin(), buf.end()); // } // } //} void memberJsonTest() { std::string fromJson = "fromJson(const std::string& str) {\nNJsonNode jsonroot;\nauto ret = NJson::parse(str, jsonroot);\nif (!ret) { return; }\n"; std::string toJson = "toJson() {\nNJsonNode jsonroot;"; std::ifstream ifs("", std::ios::in); std::string line; std::string cpp = "#include \"DataStruct.h\"\n\n"; if (ifs.is_open()) { std::string s1; std::string s2; while (std::getline(ifs, line)) { int pos = line.find("struct"); if (pos != std::string::npos) { std::string className = line.substr(pos+7); s1 = "void " + className + "::" + fromJson; s2 = "}\nstd::string " + className + "::" + toJson; } else { std::string key; pos = line.find("uint"); if (pos != std::string::npos) { key = line.substr(pos+9); } if (!key.empty()) { pos = key.find(";"); if (pos != std::string::npos) { key = key.substr(0, pos); } } if (!key.empty()) { s1 += ("NJson::read(jsonroot, \"" + key + "\", " + key + ");\n"); s2 += ("jsonroot[\"" + key + "\"] = " + key + ";\n"); } } } ifs.close(); } //std::string strTmp = R"()"; //std::vector vecTmp; //Utils::split(strTmp, "\n", vecTmp); //std::string from = "void fromJson(const std::string& str) {\nNJsonNode jsonroot;\nauto ret = NJson::parse(str, jsonroot);\nif (!ret) { return; }\n"; //std::string to = "std::string toJson() {\nNJsonNode jsonroot;"; //for (auto& item: vecTmp) //{ // std::string key; // int pos = item.find_first_of("_"); // if (pos != std::string::npos) { key = item.substr(pos+3); } // pos = key.find_first_of(";"); // if (pos != std::string::npos) { key = key.substr(0, pos); } // if (!key.empty()) // { // from += ("NJson::read(jsonroot, \"" + key + "\", " + key + ");\n"); // to += ("jsonroot[\"" + key + "\"] = " + key + ";\n"); // } //} //from += "}"; //to += "return jsonroot.dump();\n}"; //std::cout << from << std::endl; //std::cout << to << std::endl; } int main(int argc, char** argv) { // 设置控制台输出为 UTF-8 编码 SetConsoleOutputCP(CP_UTF8); // 设置控制台输入为 UTF-8 编码(如果需要输入中文) SetConsoleCP(CP_UTF8); // 初始化日志 Spdlogger::init(spdlog::level::debug, ""); spdlog::info("[main] start ... ======================================================================"); njson json; json = {1, 2, 3, 4}; spdlog::info(json.dump()); // 运行后台服务 Application::instance().init(); // 启动 PV 服务主线程 //std::thread([=]() // { // // 运行pv主流程 // 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); // std::this_thread::sleep_for(std::chrono::milliseconds(10)); // } // }).detach(); QApplication qapp(argc, argv); qapp.setWindowIcon(QIcon("./yhicon.ico")); MainWeb mainWin; qapp.exec(); //QApplication a(argc, argv); //QMainWindow w; //QWebEngineView webView(&w); //webView.load(QUrl("http://127.0.0.1:19600/")); //w.setCentralWidget(&webView); //w.setWindowTitle("Qt 6.7 WebEngine Demo"); //w.resize(1280, 720); //w.show(); //webView.show(); //a.exec(); // 运行QT主窗口 //QApplication qapp(argc, argv); //MainWindow mainWin; //mainWin.setWindowTitle("风光储能站控制管理系统"); //mainWin.resize(1920, 1080); //mainWin.show(); //qapp.exec(); return 0; }