You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

11 months ago
#include <QCoreApplication>
#include "config/log_config.h"
#include "config/database_config.h"
#include "config/kafka_config.h"
#include "handler/log_handler.h"
#include "handler/database_handler.h"
#include "handler/kafka_handler.h"
#include "handler/controller_handler.h"
void loadConfig(const QString& filename){
QFile file(filename);
if(!file.exists()){
qFatal("config file %s is not found!" , qPrintable(filename));
}
auto configs = new QSettings(filename, QSettings::IniFormat);
auto logConf = LogConfig::getIns();
configs->beginGroup("log");
logConf->load(configs);
configs->endGroup();
auto kafkaConf = KafkaConfig::getIns();
configs->beginGroup("kafka");
kafkaConf->load(configs);
configs->endGroup();
auto databaseConf = DatabaseConfig::getIns();
configs->beginGroup("database");
databaseConf->load(configs);
configs->endGroup();
}
void init(){
// 初始化日志, 开启会记录日志到文件
// LogHandler::init();
11 months ago
// 初始化数据库
11 months ago
DataBaseHandler::init();
11 months ago
// 初始化Kafka
KafkaHandler::init();
// 初始化Controller
ControllerHandler::init();
}
11 months ago
#include "./compute/bessel.h"
void bessel_test(){
// 轨迹关键点
vector<Point> points = {{0.0,0.0,0.0}, {200.0, 800.0,7000.0},{400.0,0.0,6800.0},{800.0,800.0,8000.0}};
// 计算步长
vector<Point> res = Bessel::run(points, 0.001);
// 计算结果存储到文件
11 months ago
string filename = R"(test_1.csv)";
ofstream ofs(filename);
ofs << "x,y,z" << endl;
for (const auto &item: res){
ofs << item.x << "," << item.y << "," << item.z << endl;
}
ofs.close();
}
11 months ago
/// TODO 当前是将消息广播全部消费者自行判断是否消费,该种机制是否合理后续在进行论证
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
// 加载配置文件
11 months ago
loadConfig(QCoreApplication::applicationDirPath() + "/application.ini");
11 months ago
// 初始化系统
11 months ago
init();
11 months ago
/// test -start
11 months ago
qDebug() << "init";
QString msg = "{\"name\":\"张三\"}";
QString key = "loadMap";
auto headers = RdKafka::Headers::create();
headers->add("token", "safdasgdagafgafdsghfsjh");
KafkaHandler::message("test_topic" , msg, key , headers);
11 months ago
// boost_test();
11 months ago
// bessel_test();
qDebug() << "sds";
11 months ago
/// test -end
return QCoreApplication::exec();
}