mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现MQTT协议消息订阅和消息解析流程
This commit is contained in:
78
src/main.cpp
78
src/main.cpp
@@ -30,6 +30,9 @@
|
||||
#include <string>
|
||||
#include "DataStruct.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QtWebEngineWidgets/QWebEngineView>
|
||||
|
||||
#define wsa rlwsa
|
||||
void rlSocketTest()
|
||||
{
|
||||
@@ -118,8 +121,9 @@ void memberJsonTest()
|
||||
//std::cout << to << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
{
|
||||
// 设置控制台输出为 UTF-8 编码
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
// 设置控制台输入为 UTF-8 编码(如果需要输入中文)
|
||||
@@ -138,33 +142,42 @@ int main(int argc, char** argv)
|
||||
// 运行后台服务
|
||||
Application::instance().init();
|
||||
|
||||
{
|
||||
//REGInfo reg;
|
||||
//std::string s = "BMS(电池堆)通信状态 R uint16 \"0:正常1:故障\" bit位从低到高分别对应1~16 0x2001";
|
||||
//int pos;
|
||||
//if (std::string::npos != (pos = s.find("\t0x")))
|
||||
//{
|
||||
// reg.name = s.substr(pos+1);
|
||||
// s = s.substr(0, pos);
|
||||
// std::cout << reg.name << std::endl;
|
||||
//}
|
||||
//if (std::string::npos != (pos = s.find("\t")))
|
||||
//{
|
||||
// reg.remark = s.substr(0, pos);
|
||||
// s = s.substr(pos+1);
|
||||
// std::cout << reg.remark << std::endl;
|
||||
//}
|
||||
//if (std::string::npos != (pos = s.find("uint")))
|
||||
//{
|
||||
// std::string bytename = s.substr(pos, 6);
|
||||
// std::cout << bytename << std::endl;
|
||||
// s = s.substr(pos+6);
|
||||
//}
|
||||
//std::cout << s << std::endl;
|
||||
//std::cout << s << std::endl;
|
||||
|
||||
}
|
||||
// 启动 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);
|
||||
|
||||
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);
|
||||
|
||||
mainWin.show();
|
||||
qapp.exec();
|
||||
|
||||
// 运行QT主窗口
|
||||
//QApplication qapp(argc, argv);
|
||||
@@ -173,16 +186,5 @@ int main(int argc, char** argv)
|
||||
//mainWin.resize(1920, 1080);
|
||||
//mainWin.show();
|
||||
//qapp.exec();
|
||||
|
||||
// 运行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);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user