Skip to content

Commit

Permalink
Merge pull request #25 from ElementAstro/reborn
Browse files Browse the repository at this point in the history
24m04b reborn & fix update
  • Loading branch information
AstroAir authored Apr 30, 2024
2 parents c8601f0 + 2e69715 commit 8343b32
Show file tree
Hide file tree
Showing 374 changed files with 3,211 additions and 16,046 deletions.
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ elseif(LINUX)
endif()

set(component_module
${lithium_src_dir}/device/server/ascom.cpp
${lithium_src_dir}/device/server/hydrogen.cpp
${lithium_src_dir}/device/server/hydrogen_driver.cpp
${lithium_src_dir}/device/server/connector.cpp

${lithium_src_dir}/device/manager.cpp

${lithium_src_dir}/device/utils/utils.cpp

${lithium_component_dir}/addons.cpp
${lithium_component_dir}/compiler.cpp
${lithium_component_dir}/loader.cpp
Expand Down Expand Up @@ -240,7 +231,7 @@ set(Lithium_module

add_library(lithium_server-library STATIC ${component_module} ${config_module} ${debug_module} ${module_module} ${device_module} ${task_module} ${script_module} ${Lithium_module})
target_link_libraries(lithium_server-library loguru)
add_executable(lithium_server ${lithium_src_dir}/app.cpp)
add_executable(lithium_server ${lithium_src_dir}/App.cpp)
target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs)

target_link_libraries(lithium_server lithium_server-library)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ sudo apt-get install gcc-13 g++-13 # GCC13 is the best choice, clang is alse OK

wget https://cmake.org/files/v3.28/cmake-3.28.0-rc5.tar.gz
tar -zxvf cmake-3.28.0-rc5.tar.gz
cd cmake-3.28.0-rc5
./bootstrap && make && sudo make install

#install newest clang-format
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogencamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Description: Hydorgen Camera
HydrogenCamera::HydrogenCamera(const std::string &name) : Camera(name) {
DLOG_F(INFO, "Hydorgen camera {} init successfully", name);
m_number_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
m_switch_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
m_text_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>();

registerFunc("connect", &HydrogenCamera::connect, this);
registerFunc("disconnect", &HydrogenCamera::disconnect, this);
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogencamera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ class HydrogenCamera : public Camera, public HYDROGEN::BaseClient {

std::atomic<double> polling_period;

std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
m_number_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
m_switch_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>
m_text_switch;

private:
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogenfilterwheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ HydrogenFilterwheel::HydrogenFilterwheel(const std::string &name)
DLOG_F(INFO, "Hydrogen filterwheel {} init successfully", name);

m_number_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
m_switch_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
m_text_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>();

m_switch_switch->registerCase(
"CONNECTION", [this](HYDROGEN::PropertyViewSwitch *svp) {
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogenfilterwheel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ class HydrogenFilterwheel : public Filterwheel, public HYDROGEN::BaseClient {
std::string hydrogen_filter_version = "";
std::string hydrogen_filter_interface = "";

std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
m_number_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
m_switch_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>
m_text_switch;
};

Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogenfocuser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ HydrogenFocuser::HydrogenFocuser(const std::string &name) : Focuser(name) {
DLOG_F(INFO, "Hydrogen Focuser {} init successfully", name);

m_number_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
m_switch_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
m_text_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>();

m_switch_switch->registerCase(
"CONNECTION", [this](HYDROGEN::PropertyViewSwitch *svp) {
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogenfocuser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ class HydrogenFocuser : public Focuser, public HYDROGEN::BaseClient {
std::string hydrogen_focuser_version = ""; // Hydrogen 设备固件版本
std::string hydrogen_focuser_interface = ""; // Hydrogen 接口版本

std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
m_number_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
m_switch_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>
m_text_switch;
};

Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogentelescope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ HydrogenTelescope::HydrogenTelescope(const std::string &name)
DLOG_F(INFO, "Hydrogen telescope {} init successfully", name);

m_number_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>();
m_switch_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>();
m_text_switch = std::make_unique<
Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>();
atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>();

m_switch_switch->registerCase(
"CONNECTION", [this](HYDROGEN::PropertyViewSwitch *svp) {
Expand Down
6 changes: 3 additions & 3 deletions driver/client/atom-hydrogen/hydrogentelescope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ class HydrogenTelescope : public Telescope, public HYDROGEN::BaseClient {
std::string hydrogen_telescope_version = ""; // Hydrogen 设备固件版本
std::string hydrogen_telescope_interface = ""; // Hydrogen 接口版本

std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewNumber *>>
m_number_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewSwitch *>>
m_switch_switch;
std::unique_ptr<Atom::Utils::StringSwitch<HYDROGEN::PropertyViewText *>>
std::unique_ptr<atom::utils::StringSwitch<HYDROGEN::PropertyViewText *>>
m_text_switch;
};
2 changes: 1 addition & 1 deletion driver/solver/atom-astap/astap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool AstapSolver::solveImage(const std::string &image, const int &timeout,

auto ret = Atom::Async::asyncRetry(
[](const std::string &cmd) -> std::string {
return Atom::Utils::executeCommand(cmd, false);
return atom::utils::executeCommand(cmd, false);
},
3, std::chrono::seconds(5), cmd);

Expand Down
42 changes: 22 additions & 20 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Description: Main Entry
#define ENABLE_TERMINAL 1
#if ENABLE_TERMINAL
#include "debug/terminal.hpp"
using namespace Lithium::Terminal;
using namespace lithium::Terminal;
#endif

#include "server/App.hpp"
Expand Down Expand Up @@ -116,9 +116,9 @@ int main(int argc, char *argv[]) {

program.parse_args(argc, argv);

Lithium::InitLithiumApp(argc, argv);
lithium::InitLithiumApp(argc, argv);
// Create shared instance
Lithium::MyApp = Lithium::LithiumApp::createShared();
lithium::MyApp = lithium::LithiumApp::createShared();
// Parse arguments
try {
auto cmd_host = program.get<std::string>("--host");
Expand All @@ -128,64 +128,66 @@ int main(int argc, char *argv[]) {
auto cmd_web_panel = program.get<bool>("--web-panel");
auto cmd_debug = program.get<bool>("--debug");

// TODO: We need a new way to handle command line arguments.
// Maybe we will generate a json object or a map and then given to the
// lithiumapp for initialization.
/*
if (!cmd_host.empty()) {
Lithium::MyApp->SetConfig(
lithium::MyApp->SetConfig(
{{"key", "config/server/host"}, {"value", cmd_host}});
DLOG_F(INFO, "Set server host to {}", cmd_host);
}
if (cmd_port != 8000) {
DLOG_F(INFO, "Command line server port : {}", cmd_port);
auto port = Lithium::MyApp->GetConfig("config/server")
auto port = lithium::MyApp->GetConfig("config/server")
.value<int>("port", 8000);
if (port != cmd_port) {
Lithium::MyApp->SetConfig(
lithium::MyApp->SetConfig(
{{"key", "config/server/port"}, {"value", cmd_port}});
DLOG_F(INFO, "Set server port to {}", cmd_port);
}
}
if (!cmd_config_path.empty()) {
Lithium::MyApp->SetConfig({{"key", "config/server/configpath"},
lithium::MyApp->SetConfig({{"key", "config/server/configpath"},
{"value", cmd_config_path}});
DLOG_F(INFO, "Set server config path to {}", cmd_config_path);
}
if (!cmd_module_path.empty()) {
Lithium::MyApp->SetConfig({{"key", "config/server/modulepath"},
lithium::MyApp->SetConfig({{"key", "config/server/modulepath"},
{"value", cmd_module_path}});
DLOG_F(INFO, "Set server module path to {}", cmd_module_path);
}
if (!cmd_web_panel) {
if (Lithium::MyApp->GetConfig("config/server/web").get<bool>()) {
Lithium::MyApp->SetConfig(
if (lithium::MyApp->GetConfig("config/server/web").get<bool>()) {
lithium::MyApp->SetConfig(
{{"key", "config/server/web"}, {"value", false}});
DLOG_F(INFO, "Disable web panel");
}
}
if (cmd_debug) {
if (!Lithium::MyApp->GetConfig("config/server/debug").get<bool>()) {
Lithium::MyApp->SetConfig(
if (!lithium::MyApp->GetConfig("config/server/debug").get<bool>()) {
lithium::MyApp->SetConfig(
{{"key", "config/server/debug"}, {"value", true}});
}
} else {
Lithium::MyApp->SetConfig(
lithium::MyApp->SetConfig(
{{"key", "config/server/debug"}, {"value", false}});
DLOG_F(INFO, "Disable debug mode");
}
*/

} catch (const std::bad_any_cast &e) {
LOG_F(ERROR, "Invalid args format! Error: {}", e.what());
Atom::System::saveCrashLog(e.what());
return 1;
}

// In debug mode run the terminal first and will not run the server
if (Lithium::MyApp->GetConfig("config/server/debug").get<bool>()) {
ConsoleTerminal terminal;
terminal.run();
} else {
runServer();
}
ConsoleTerminal terminal;
terminal.run();
runServer();

return 0;
}
Loading

0 comments on commit 8343b32

Please sign in to comment.