删除了不使用的文件

This commit is contained in:
zjk
2025-02-13 15:44:21 +08:00
parent 734226a33a
commit 25b4e0d688
10 changed files with 139 additions and 360 deletions
-19
View File
@@ -1,19 +0,0 @@
#--------------------------------------------------------
# The CMakeLists.txt for: appPowerMangerGui
# Author(s):
#--------------------------------------------------------
SET(SRC
PowerMangerGui.cpp
PowerMangerGui_Info.cpp
main.cpp
)
ADD_EXECUTABLE(appPowerMangerGui ${SRC})
TARGET_LINK_LIBRARIES(appPowerMangerGui
${MOOS_LIBRARIES}
mbutil
m
pthread)
-106
View File
@@ -1,106 +0,0 @@
/************************************************************/
/* NAME: */
/* ORGN: MIT */
/* FILE: PowerMangerGui.cpp */
/* DATE: */
/************************************************************/
#include <iterator>
#include "MBUtils.h"
#include "PowerMangerGui.h"
using namespace std;
//---------------------------------------------------------
// Constructor
PowerMangerGui::PowerMangerGui()
{
}
//---------------------------------------------------------
// Destructor
PowerMangerGui::~PowerMangerGui()
{
}
//---------------------------------------------------------
// Procedure: OnNewMail
bool PowerMangerGui::OnNewMail(MOOSMSG_LIST &NewMail)
{
MOOSMSG_LIST::iterator p;
for(p=NewMail.begin(); p!=NewMail.end(); p++) {
CMOOSMsg &msg = *p;
#if 0 // Keep these around just for template
string key = msg.GetKey();
string comm = msg.GetCommunity();
double dval = msg.GetDouble();
string sval = msg.GetString();
string msrc = msg.GetSource();
double mtime = msg.GetTime();
bool mdbl = msg.IsDouble();
bool mstr = msg.IsString();
#endif
}
return(true);
}
//---------------------------------------------------------
// Procedure: OnConnectToServer
bool PowerMangerGui::OnConnectToServer()
{
RegisterVariables();
return(true);
}
//---------------------------------------------------------
// Procedure: Iterate()
// happens AppTick times per second
bool PowerMangerGui::Iterate()
{
return(true);
}
//---------------------------------------------------------
// Procedure: OnStartUp()
// happens before connection is open
bool PowerMangerGui::OnStartUp()
{
list<string> sParams;
m_MissionReader.EnableVerbatimQuoting(false);
if(m_MissionReader.GetConfiguration(GetAppName(), sParams)) {
list<string>::iterator p;
for(p=sParams.begin(); p!=sParams.end(); p++) {
string line = *p;
string param = tolower(biteStringX(line, '='));
string value = line;
if(param == "foo") {
//handled
}
else if(param == "bar") {
//handled
}
}
}
RegisterVariables();
return(true);
}
//---------------------------------------------------------
// Procedure: RegisterVariables
void PowerMangerGui::RegisterVariables()
{
// Register("FOOBAR", 0);
}
-33
View File
@@ -1,33 +0,0 @@
/************************************************************/
/* NAME: */
/* ORGN: MIT */
/* FILE: PowerMangerGui.h */
/* DATE: */
/************************************************************/
#ifndef PowerMangerGui_HEADER
#define PowerMangerGui_HEADER
#include "FL/Fl.H"
#include "MOOS/libMOOS/MOOSLib.h"
class PowerMangerGui : public CMOOSApp {
public:
PowerMangerGui();
~PowerMangerGui();
bool minWindows();
protected: // Standard MOOSApp functions to overload
bool OnNewMail(MOOSMSG_LIST &NewMail);
bool Iterate();
bool OnConnectToServer();
bool OnStartUp();
protected:
void RegisterVariables();
private: // Configuration variables
private: // State variables
};
#endif
@@ -1,115 +0,0 @@
/****************************************************************/
/* NAME: */
/* ORGN: MIT Cambridge MA */
/* FILE: PowerMangerGui_Info.cpp */
/* DATE: Dec 29th 1963 */
/****************************************************************/
#include <cstdlib>
#include <iostream>
#include "PowerMangerGui_Info.h"
#include "ColorParse.h"
#include "ReleaseInfo.h"
using namespace std;
//----------------------------------------------------------------
// Procedure: showSynopsis
void showSynopsis()
{
blk("SYNOPSIS: ");
blk("------------------------------------ ");
blk(" The appPowerMangerGui application is used for ");
blk(" ");
blk(" ");
blk(" ");
blk(" ");
}
//----------------------------------------------------------------
// Procedure: showHelpAndExit
void showHelpAndExit()
{
blk(" ");
blu("=============================================================== ");
blu("Usage: appPowerMangerGui file.moos [OPTIONS] ");
blu("=============================================================== ");
blk(" ");
showSynopsis();
blk(" ");
blk("Options: ");
mag(" --alias","=<ProcessName> ");
blk(" Launch appPowerMangerGui with the given process name ");
blk(" rather than appPowerMangerGui. ");
mag(" --example, -e ");
blk(" Display example MOOS configuration block. ");
mag(" --help, -h ");
blk(" Display this help message. ");
mag(" --interface, -i ");
blk(" Display MOOS publications and subscriptions. ");
mag(" --version,-v ");
blk(" Display the release version of appPowerMangerGui. ");
blk(" ");
blk("Note: If argv[2] does not otherwise match a known option, ");
blk(" then it will be interpreted as a run alias. This is ");
blk(" to support pAntler launching conventions. ");
blk(" ");
exit(0);
}
//----------------------------------------------------------------
// Procedure: showExampleConfigAndExit
void showExampleConfigAndExit()
{
blk(" ");
blu("=============================================================== ");
blu("appPowerMangerGui Example MOOS Configuration ");
blu("=============================================================== ");
blk(" ");
blk("ProcessConfig = appPowerMangerGui ");
blk("{ ");
blk(" AppTick = 4 ");
blk(" CommsTick = 4 ");
blk(" ");
blk("} ");
blk(" ");
exit(0);
}
//----------------------------------------------------------------
// Procedure: showInterfaceAndExit
void showInterfaceAndExit()
{
blk(" ");
blu("=============================================================== ");
blu("appPowerMangerGui INTERFACE ");
blu("=============================================================== ");
blk(" ");
showSynopsis();
blk(" ");
blk("SUBSCRIPTIONS: ");
blk("------------------------------------ ");
blk(" NODE_MESSAGE = src_node=alpha,dest_node=bravo,var_name=FOO, ");
blk(" string_val=BAR ");
blk(" ");
blk("PUBLICATIONS: ");
blk("------------------------------------ ");
blk(" Publications are determined by the node message content. ");
blk(" ");
exit(0);
}
//----------------------------------------------------------------
// Procedure: showReleaseInfoAndExit
void showReleaseInfoAndExit()
{
showReleaseInfo("appPowerMangerGui", "gpl");
exit(0);
}
@@ -1,18 +0,0 @@
/****************************************************************/
/* NAME: */
/* ORGN: MIT Cambridge MA */
/* FILE: PowerMangerGui_Info.h */
/* DATE: Dec 29th 1963 */
/****************************************************************/
#ifndef PowerMangerGui_INFO_HEADER
#define PowerMangerGui_INFO_HEADER
void showSynopsis();
void showHelpAndExit();
void showExampleConfigAndExit();
void showInterfaceAndExit();
void showReleaseInfoAndExit();
#endif
@@ -1,9 +0,0 @@
//------------------------------------------------
// appPowerMangerGui config block
ProcessConfig = appPowerMangerGui
{
AppTick = 4
CommsTick = 4
}
-52
View File
@@ -1,52 +0,0 @@
/************************************************************/
/* NAME: */
/* ORGN: MIT */
/* FILE: main.cpp */
/* DATE: */
/************************************************************/
#include <string>
#include "MBUtils.h"
#include "ColorParse.h"
#include "PowerMangerGui.h"
#include "PowerMangerGui_Info.h"
using namespace std;
int main(int argc, char *argv[])
{
string mission_file;
string run_command = argv[0];
for(int i=1; i<argc; i++) {
string argi = argv[i];
if((argi=="-v") || (argi=="--version") || (argi=="-version"))
showReleaseInfoAndExit();
else if((argi=="-e") || (argi=="--example") || (argi=="-example"))
showExampleConfigAndExit();
else if((argi == "-h") || (argi == "--help") || (argi=="-help"))
showHelpAndExit();
else if((argi == "-i") || (argi == "--interface"))
showInterfaceAndExit();
else if(strEnds(argi, ".moos") || strEnds(argi, ".moos++"))
mission_file = argv[i];
else if(strBegins(argi, "--alias="))
run_command = argi.substr(8);
else if(i==2)
run_command = argi;
}
if(mission_file == "")
showHelpAndExit();
cout << termColor("green");
cout << "appPowerMangerGui launching as " << run_command << endl;
cout << termColor() << endl;
PowerMangerGui PowerMangerGui;
PowerMangerGui.Run(run_command.c_str(), mission_file.c_str());
return(0);
}
+104
View File
@@ -161,6 +161,60 @@
cursor: pointer;
margin-left: 10px;
}
/* MOOS通知面板样式 */
.moos-notify-panel {
margin-top: 20px;
padding: 15px;
background-color: #3a3f4b;
border: 1px solid #61dafb;
border-radius: 6px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.moos-notify-panel .input-group {
margin-bottom: 15px;
}
.moos-notify-panel label {
display: block;
margin-bottom: 5px;
color: #61dafb;
font-size: 14px;
}
.moos-notify-panel input {
width: 80%;
padding: 8px 8px;
background-color: #282c34;
border: 1px solid #61dafb;
border-radius: 4px;
color: #ffffff;
font-size: 14px;
}
.moos-notify-panel input:focus {
outline: none;
border-color: #4fa8c7;
box-shadow: 0 0 0 2px rgba(97, 218, 251, 0.2);
}
.moos-notify-panel button {
width: 80%;
padding: 8px;
background: linear-gradient(145deg, #61dafb, #4fa8c7);
border: none;
border-radius: 4px;
color: #282c34;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
}
.moos-notify-panel button:hover {
transform: translateY(-1px);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
</style>
</head>
@@ -174,6 +228,17 @@
<i class="fas fa-database"></i>
<span>正在连接MOOSDB...</span>
</div>
<div class="moos-notify-panel">
<div class="input-group">
<label for="moos-var">Var:</label>
<input type="text" id="moos-var" placeholder="输入Var值">
</div>
<div class="input-group">
<label for="moos-key">Key:</label>
<input type="text" id="moos-key" placeholder="输入Key值">
</div>
<button id="moos-send-btn">发送</button>
</div>
</div>
<div class="status-column">
<h3>本地数据库</h3>
@@ -315,6 +380,45 @@
});
}
// MOOS通知功能
function sendMoosNotify() {
const varValue = document.getElementById('moos-var').value.trim();
const keyValue = document.getElementById('moos-key').value.trim();
if (!varValue || !keyValue) {
alert('请填写Var和Key值');
return;
}
const payload = {
var: varValue,
// key: isNaN(keyValue) ? keyValue : Number(keyValue)
key: keyValue
};
fetch('/api/moos-notify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('发送成功');
} else {
alert('发送失败: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('发送请求失败');
});
}
document.getElementById('moos-send-btn').addEventListener('click', sendMoosNotify);
// 每1秒更新一次数据
setInterval(updateData, 1000);
updateData(); // 初始加载
+34 -7
View File
@@ -49,7 +49,7 @@ int main() {
// 定义路由,处理 /api/power-data 的请求
CROW_ROUTE(app, "/api/download-db")
([&db]() {
std::ifstream file("/home/zjk/project/H100/H100PowerManger/data/power_data.db", std::ios::binary);
std::ifstream file("/home/zjk/project/H100/H100PowerManger/src/appPowerMangerWebUI/static/index.html", std::ios::binary);
if (!file) {
return crow::response(404, "Database file not found");
}
@@ -86,12 +86,39 @@ int main() {
}
return response;
});
// 定义路由,处理 /api/moos-notify 的请求(POST)
CROW_ROUTE(app, "/api/moos-notify")
([&moosClient]() {
crow::json::wvalue response;
response["message"] = "Received MOOS notification";
return response;
// 定义路由,处理 /api/moos-notify 的请求(POST)
CROW_ROUTE(app, "/api/moos-notify").methods("POST"_method)
([&moosClient](const crow::request& req) {
auto json = crow::json::load(req.body);
if (!json) {
return crow::response(400, "Invalid JSON");
}
std::string var = json["var"].s();
std::string key = json["key"].s();
// 发送MOOS消息
bool notifyResult = moosClient.Notify(var, key);
std::cout << "MOOS Notify: var=" << var << ", key=" << key
<< ", result=" << (notifyResult ? "success" : "failed") << std::endl;
crow::response res;
if (notifyResult)
{
res.body = crow::json::wvalue({
{"success", true},
{"message", key + ":" + var}
}).dump();
}
else
{
res.body = crow::json::wvalue({
{"success", false},
{"message", key + ":" + var},
}).dump();
}
res.set_header("Content-Type", "application/json");
return res;
});
// 启动服务器,监听端口 18080
+1 -1
View File
@@ -123,7 +123,7 @@ bool PowerManger::Iterate()
else
m_FsmThread.Stop();
// 数据库测试
//3. 输出报告
buildPowerSysReport();
//4. 打印错误信息