添加跨平台设置

main
parent 1725e238ae
commit 9da872d928

9
.gitmodules vendored

@ -0,0 +1,9 @@
[submodule "third_party/QxOrm"]
path = third_party/QxOrm
url = https://github.com/QxOrm/QxOrm.git
[submodule "third_party/librdkafka"]
path = third_party/librdkafka
url = https://github.com/confluentinc/librdkafka.git
[submodule "third_party/boost"]
path = third_party/boost
url = https://github.com/boostorg/boost.git

@ -6,13 +6,20 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_PREFIX_PATH $ENV{QT_5_MINGW64})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_CURRENT_BINARY_DIR}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_CURRENT_BINARY_DIR}")
set(BOOST_INCLUDES third_party/boost-1_83/include)
if(WIN32)
set(CMAKE_PREFIX_PATH $ENV{QT_5_MINGW64})
set(BOOST_INCLUDES third_party/boost-1_83/include)
set(BOOST_LIBRARIES third_party/boost-1_83/lib)
endif ()
# QxOrm
include(third_party/QxOrm/QxOrm.cmake)
if(APPLE)
set(BOOST_ROOT "/usr/local/Cellar/boost/1.83.0")
find_package(Boost 1.83.0 COMPONENTS system)
set(BOOST_INCLUDES ${Boost_INCLUDE_DIRS})
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
endif ()
add_executable(${PROJECT_NAME} main.cpp)
@ -60,14 +67,18 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
rdkafka
rdkafka++
QxOrm
${BOOST_LIBRARIES}
)
include(third_party/QxOrm/QxOrm.cmake)
add_subdirectory(third_party/librdkafka)
#
file(COPY application.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # QxOrm
file(COPY lib/kafka/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # kafka
file(GLOB LIB "lib/*.dll")
file(COPY ${LIB} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # mysql
file(COPY lib/sqldrivers DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # QT mysql
#file(COPY lib/kafka/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # kafka
#file(GLOB LIB "lib/*.dll")
#file(COPY ${LIB} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # mysql
#file(COPY lib/sqldrivers DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # QT mysql
file(COPY third_party/QxOrm/lib/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # QxOrm
if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)

@ -1,9 +1,9 @@
[database]
host=localhost
port=3306
database=csci
username=csci
password=csci@1234
database=sim
username=root
password=root123
driver=QMYSQL
[kafka]

@ -0,0 +1,49 @@
//
//#include "three.h"
//
//vector<State> Tree::run(const State &init_state, double start, double end, double t) {
//// integrate_const(runge_kutta4<State>(), dmove2, init_state, start ,end ,t, write_pendulum);
// return _stateList;
//}
//
//void Tree::dmove2(const State &x_input, State &dxdt, const double t) {
// double velocity = x_input[0];
// double gamma = x_input[1];
// double varphi = x_input[2];
// double nx = _control[0];
// double nz = _control[1];
// varphi = _control[2];
//// if(varphi == 0){
//// varphi = control[2];
//// }
// double g = 9.81; // 重力加速度
// double velocity_ = g * (nx - sin(gamma)); // 米每秒
// double gamma_ = (g / velocity) * (nz * cos(varphi) - cos(gamma)); // 米每秒
// double varphi_ = g * nz * sin(varphi) / (velocity * cos(gamma));
// dxdt[0] = velocity_;
// dxdt[1] = gamma_;
// dxdt[2] = varphi_;
//}
//
//void Tree::setController(const State &control) {
// _k = 1;
// _control = control;
//}
//
//void Tree::write_pendulum(const State &x, const double t) {
// double velocity = x[0];
// double gamma = x[1];
// double varphi = x[2];
// double dx = velocity * cos(gamma) * sin(varphi);
// double dy = velocity * cos(gamma) * cos(varphi);
// double dz = velocity * sin(gamma);
// State new_state(6);
// new_state[0] = _stateList[_k - 1][0] + dx;
// new_state[1] = _stateList[_k - 1][1] + dy;
// new_state[2] = _stateList[_k - 1][2] + dz;
// new_state[3] = velocity;
// new_state[4] = gamma;
// new_state[5] = varphi;
// _k++;
// _stateList.push_back(new_state);
//}

@ -0,0 +1,127 @@
//
//#ifndef CSCI_THREE_H
//#define CSCI_THREE_H
//
///*
//typedef vector<double> State;
//typedef vector<double> Control;
//double Nx = 3.0;
//double Nz = 2.0;
//double mu = M_PI / 12.;
//Control control = { Nx, Nz, mu };
//vector<State> state_list;
//// 飞行器的运动学方程
//void dmove2(const State& x_input, State& dxdt, const double t) {
// double velocity = x_input[0];
// double gamma = x_input[1];
// double varphi = x_input[2];
// double nx = control[0];
// double nz = control[1];
// varphi = control[2];
//// if(varphi == 0){
//// varphi = control[2];
//// }
// double g = 9.81; // 重力加速度
// double velocity_ = g * (nx - sin(gamma)); // 米每秒
// double gamma_ = (g / velocity) * (nz * cos(varphi) - cos(gamma)); // 米每秒
// double varphi_ = g * nz * sin(varphi) / (velocity * cos(gamma));
// dxdt[0] = velocity_;
// dxdt[1] = gamma_;
// dxdt[2] = varphi_;
//}
//int k = 1;
//void write_pendulum(const State &x, const double t)
//{
// double velocity = x[0];
// double gamma = x[1];
// double varphi = x[2];
// double dx = velocity * cos(gamma) * sin(varphi);
// double dy = velocity * cos(gamma) * cos(varphi);
// double dz = velocity * sin(gamma);
// State new_state(6);
// new_state[0] = state_list[k - 1][0] + dx;
// new_state[1] = state_list[k - 1][1] + dy;
// new_state[2] = state_list[k - 1][2] + dz;
// new_state[3] = velocity;
// new_state[4] = gamma;
// new_state[5] = varphi;
// k++;
// state_list.push_back(new_state);
//}
//
//void boost_test(){
// double init_velocity = 260.0;
// double init_gamma = M_PI / 10.0;
// double init_varphi = 0.0;
// double init_x = 0.0;
// double init_y = 0.0;
// double init_z = 1000.0;
// State int_state(6);
// int_state[0] = init_x;
// int_state[1] = init_y;
// int_state[2] = init_z;
// int_state[3] = init_velocity;
// int_state[4] = init_gamma;
// int_state[5] = init_varphi;
// state_list.push_back(int_state);
// State init_state = { init_velocity, init_gamma, init_varphi };
// integrate_const(runge_kutta4<State>(), dmove2, init_state, 0.0 ,10.0 ,0.1, write_pendulum);
// string filename = R"(test.csv)";
// ofstream ofs(filename);
// if(ofs.is_open()){
// ofs << "x,y,z,v,g,f\n";
// for (const auto& state : state_list) {
// int i = 0;
// for (const auto& val : state) {
// cout << val << ",";
// if(i == 5){
// ofs << val;
// i = 0;
// }else{
// ofs << val << ",";
// i++;
// }
// }
// cout << "\n";
// ofs << "\n";
// }
// ofs.close();
// }
//}
//
// */
//
//#include <boost/numeric/odeint.hpp>
//
//using namespace std;
//using namespace boost::numeric::odeint;
//
//typedef vector<double> State;
//typedef vector<double> Control;
//
//class Tree {
//
//private:
// static int _k;
//
// static Control _control;
//
// static vector<State> _stateList;
//
//private:
//
// static void dmove2(const State& x_input, State& dxdt, const double t);
//
// static void write_pendulum(const State &x, const double t);
//
//public:
//
// static void setController(const State &control);
//
// static vector<State> run(const State& init_state, double start, double end, double dt);
//
//
//};
//
//
//#endif //CSCI_THREE_H

@ -2,7 +2,10 @@
#ifndef CSCI_MAP_ENTITY_H
#define CSCI_MAP_ENTITY_H
#include <precompiled.h>
//#ifndef _MSC_VER
//#include <precompiled.h>
//#endif
#include <QxOrm.h>
#include <QxOrm_Impl.h>
class MapEntity{

@ -3,7 +3,8 @@
#define CSCI_DATABASE_HANDLER_H
#include <QObject>
#include <precompiled.h>
//#include <precompiled.h>
#include <QxOrm.h>
#include <QxOrm_Impl.h>
#include "../config/database_config.h"

@ -33,116 +33,26 @@ void loadConfig(const QString& filename){
void init(){
// 初始化日志, 开启会记录日志到文件
LogHandler::init();
// LogHandler::init();
// 初始化数据库
DataBaseHandler::init();
// DataBaseHandler::init();
// 初始化Kafka
KafkaHandler::init();
// 初始化Controller
ControllerHandler::init();
}
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
typedef vector<double> State;
typedef vector<double> Control;
double Nx = 3.0;
double Nz = 2.0;
double mu = M_PI / 12.;
Control control = { Nx, Nz, mu };
vector<State> state_list;
// 飞行器的运动学方程
void dmove2(const State& x_input, State& dxdt, const double t) {
double velocity = x_input[0];
double gamma = x_input[1];
double varphi = x_input[2];
double nx = control[0];
double nz = control[1];
varphi = control[2];
// if(varphi == 0){
// varphi = control[2];
// }
double g = 9.81; // 重力加速度
double velocity_ = g * (nx - sin(gamma)); // 米每秒
double gamma_ = (g / velocity) * (nz * cos(varphi) - cos(gamma)); // 米每秒
double varphi_ = g * nz * sin(varphi) / (velocity * cos(gamma));
dxdt[0] = velocity_;
dxdt[1] = gamma_;
dxdt[2] = varphi_;
}
int k = 1;
void write_pendulum(const State &x, const double t)
{
double velocity = x[0];
double gamma = x[1];
double varphi = x[2];
double dx = velocity * cos(gamma) * sin(varphi);
double dy = velocity * cos(gamma) * cos(varphi);
double dz = velocity * sin(gamma);
State new_state(6);
new_state[0] = state_list[k - 1][0] + dx;
new_state[1] = state_list[k - 1][1] + dy;
new_state[2] = state_list[k - 1][2] + dz;
new_state[3] = velocity;
new_state[4] = gamma;
new_state[5] = varphi;
k++;
state_list.push_back(new_state);
}
void boost_test(){
double init_velocity = 260.0;
double init_gamma = M_PI / 10.0;
double init_varphi = 0.0;
double init_x = 0.0;
double init_y = 0.0;
double init_z = 1000.0;
State int_state(6);
int_state[0] = init_x;
int_state[1] = init_y;
int_state[2] = init_z;
int_state[3] = init_velocity;
int_state[4] = init_gamma;
int_state[5] = init_varphi;
state_list.push_back(int_state);
State init_state = { init_velocity, init_gamma, init_varphi };
integrate_const(runge_kutta4<State>(), dmove2, init_state, 0.0 ,10.0 ,0.1, write_pendulum);
string filename = R"(test.csv)";
ofstream ofs(filename);
if(ofs.is_open()){
ofs << "x,y,z,v,g,f\n";
for (const auto& state : state_list) {
int i = 0;
for (const auto& val : state) {
cout << val << ",";
if(i == 5){
ofs << val;
i = 0;
}else{
ofs << val << ",";
i++;
}
}
cout << "\n";
ofs << "\n";
}
ofs.close();
}
}
#include "./compute/bessel.h"
void bessel_test(){
vector<Point> points = {{0.0,0.0,0.0}, {20.0, 80.0,70.0},{40.0,120.0,68.0},{80.0,240.0,68.0}};
vector<Point> res = Bessel::run(points, 0.02);
// 轨迹关键点
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);
// 计算结果存储到文件
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;
}
@ -166,9 +76,9 @@ int main(int argc, char *argv[]) {
// auto headers = RdKafka::Headers::create();
// headers->add("token", "safdasgdagafgafdsghfsjh");
// KafkaHandler::message("test_topic" , msg, key , headers);
// boost_test();
bessel_test();
qDebug() << "sds";
/// test -end
return QCoreApplication::exec();

Loading…
Cancel
Save