parent
cf09d8b0fe
commit
1fd6d7d418
@ -0,0 +1,81 @@
|
||||
#include "BattlefieldAISystem.h"
|
||||
#include <iostream>
|
||||
#include <csignal>
|
||||
#include <atomic>
|
||||
|
||||
std::atomic<bool> running(true);
|
||||
|
||||
void signalHandler(int signal) {
|
||||
if (signal == SIGINT || signal == SIGTERM) {
|
||||
std::cout << "\n接收到终止信号,正在关闭系统..." << std::endl;
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// 设置信号处理
|
||||
std::signal(SIGINT, signalHandler);
|
||||
std::signal(SIGTERM, signalHandler);
|
||||
|
||||
std::cout << "==========================================" << std::endl;
|
||||
std::cout << " 智能战场态势感知与决策辅助系统 v1.0" << std::endl;
|
||||
std::cout << " 基于C++实现 - 国防军事应用" << std::endl;
|
||||
std::cout << "==========================================" << std::endl;
|
||||
|
||||
try {
|
||||
// 创建系统实例
|
||||
Battlefield::BattlefieldAISystem battlefieldSystem;
|
||||
|
||||
// 初始化系统
|
||||
std::cout << "正在初始化系统..." << std::endl;
|
||||
if (!battlefieldSystem.initialize("config/battlefield_config.json")) {
|
||||
std::cerr << "系统初始化失败!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "系统初始化成功!" << std::endl;
|
||||
|
||||
// 启动系统
|
||||
std::cout << "正在启动系统..." << std::endl;
|
||||
battlefieldSystem.start();
|
||||
|
||||
// 启动模拟数据输入
|
||||
std::cout << "启动模拟数据输入..." << std::endl;
|
||||
battlefieldSystem.simulateDataInput();
|
||||
|
||||
std::cout << "\n系统运行中..." << std::endl;
|
||||
std::cout << "按 Ctrl+C 停止系统" << std::endl;
|
||||
|
||||
// 主循环
|
||||
while (running) {
|
||||
// 此处可以添加用户交互界面
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
// 显示系统状态
|
||||
static int counter = 0;
|
||||
if (++counter % 10 == 0) { // 每10秒显示一次状态
|
||||
auto status = battlefieldSystem.getStatus();
|
||||
std::cout << "\n系统状态: "
|
||||
<< (status.isRunning ? "运行中" : "已停止")
|
||||
<< " | 处理数据包: " << status.packetsProcessed
|
||||
<< " | 跟踪目标: " << status.targetsTracked
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// 停止系统
|
||||
std::cout << "正在停止系统..." << std::endl;
|
||||
battlefieldSystem.stop();
|
||||
|
||||
// 导出最终态势
|
||||
std::cout << "正在导出态势数据..." << std::endl;
|
||||
battlefieldSystem.exportSituation("output/final_situation.json");
|
||||
|
||||
std::cout << "系统已安全关闭。" << std::endl;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "系统发生异常: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue