Skip to content

Commit

Permalink
24m11a (#43)
Browse files Browse the repository at this point in the history
# 功能更新

## 添加新的测试文件以及更新推荐引擎类以支持隐式反馈和评估功能

- **测试文件**: 新增测试文件以覆盖隐式反馈和评估功能的测试用例。
- **推荐引擎类**: 更新推荐引擎类以支持隐式反馈和评估功能,增强推荐系统的准确性和实用性。

## 添加网络管理器与进程信息结构,更新字符串处理函数,增强配置管理功能

- **网络管理器**: 新增网络管理器类,用于管理网络连接和资源。
- **进程信息结构**: 添加进程信息结构,用于存储和管理进程相关信息。
- **字符串处理函数**: 更新字符串处理函数,增强字符串操作的效率和功能。
- **配置管理功能**: 增强配置管理功能,支持更灵活的配置选项和动态更新。

## 代码优化与重构

- **头文件引用**: 更新头文件引用,确保所有依赖项正确包含。
- **类成员类型**: 修复类成员类型,确保类型一致性和正确性。
- **TCP 代理功能**: 添加新的 TCP 代理功能,优化网络通信效率。
- **组件管理器**: 优化组件管理器,提高组件加载和管理的效率。
- **命名空间重构**: 重构命名空间,优化代码结构,提高代码可读性和维护性。
- **SHA1 算法实现**: 新增 SHA1 算法实现,增强数据安全性和完整性。
- **CMake 配置**: 更新 CMake 配置以支持 Python 模块,扩展项目功能。

## 安全与错误修复

- **代码扫描警报 no. 242**: 修复代码扫描警报 no. 242,清除明文日志记录敏感信息,增强数据安全性。
- **pre-commit.ci 自动修复**: 使用 pre-commit.ci 自动修复来自 pre-commit.com 的钩子,确保代码质量和一致性。

## 新类与功能添加

- **MimeTypes 类**: 添加 MimeTypes 类以支持 MIME 类型处理,增强文件类型识别和处理能力。
- **LCG 类重构**: 重构 LCG 类以实现内联最小和最大值函数,优化随机数生成效率。
- **XML 头文件包含**: 优化 XML 头文件包含,提高 XML 处理的效率和稳定性。
- **插件管理器异常处理**: 增强插件管理器中的异常处理,提高插件加载和管理的可靠性。
- **差异比较库**: 新增差异比较库及其单元测试,增强数据比较和分析能力。
- **Preloader 类**: 新增 Preloader 类及其功能,优化资源加载和预处理效率。
- **存储监控类**: 更新存储监控类,增强存储资源管理和监控能力。
- **JSON 处理能力**: 增强 JSON 处理能力,提高 JSON 数据解析和生成的效率。
- **GPIO 类**: 新增 GPIO 类,支持硬件 GPIO 接口的管理和控制。
- **任务等待功能**: 添加任务等待功能,优化任务调度和执行效率。
- **波特率枚举重命名**: 重命名波特率枚举,提高代码可读性和一致性。
- **相机和配置管理器接口**: 更新相机和配置管理器接口,增强设备管理和配置能力。
- **打印格式优化**: 优化打印格式,提高日志和输出信息的可读性。
- **INDI 服务器中间件功能**: 增加 INDI 服务器中间件功能,增强天文设备控制和管理能力。

## CMake 配置与模块更新

- **CMakeLists.txt 文件**: 新增多个模块的 CMakeLists.txt 文件,确保模块构建和管理的正确性。
- **项目重命名**: 重命名项目以统一命名规范,提高项目管理的规范性和一致性。
- **包描述文件**: 添加 atom.async、atom.algorithm、atom.connection 和 atom.extra 模块的包描述文件,增强模块管理和文档化。
- **UUID 比较运算符实现**: 更新 UUID 比较运算符实现,增强 UUID 数据处理的效率和准确性。
- **atom.sysinfo 模块库类型**: 调整 atom.sysinfo 模块的库类型为共享库,提高模块加载和使用的灵活性。
- **CMake 配置文件**: 新增 CMake 配置文件以支持多个依赖项,增强项目构建和管理的灵活性。
- **模块扫描功能**: 重构模块扫描功能,提高模块加载和管理的效率。
- **安装路径设置**: 更新安装路径设置,确保项目安装和部署的正确性。
- **过时 CMake 模块删除**: 删除过时的 CMake 模块,提高项目构建和管理的效率。

## 跨团队协作

- **Co-authored-by: Copilot Autofix powered by AI**: 使用 AI 自动修复代码,提高代码质量和一致性。
- **Co-authored-by: pre-commit-ci[bot]**: 使用 pre-commit-ci[bot] 自动修复代码,确保代码质量和一致性。
  • Loading branch information
AstroAir authored Nov 9, 2024
1 parent 7db6ae4 commit 12cd82d
Show file tree
Hide file tree
Showing 362 changed files with 26,124 additions and 13,238 deletions.
190 changes: 17 additions & 173 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,10 @@ cmake_minimum_required(VERSION 3.20)
project(Lithium VERSION 1.0.0 LANGUAGES C CXX)

# Set project options
option(ENABLE_ASYNC "Enable Async Server Mode" ON)
option(ENABLE_NATIVE_SERVER "Enable to use INDI native server" OFF)
option(ENABLE_DEBUG "Enable Debug Mode" OFF)
option(ENABLE_FASHHASH "Enable Using emhash8 as fast hash map" OFF)
option(ENABLE_WEB_SERVER "Enable Web Server" ON)
option(ENABLE_WEB_CLIENT "Enable Web Client" ON)

# Set compile definitions based on options
if(ENABLE_ASYNC)
add_compile_definitions(ENABLE_ASYNC_FLAG=1)
endif()
if(ENABLE_DEBUG)
add_compile_definitions(ENABLE_DEBUG_FLAG=1)
endif()
if(ENABLE_NATIVE_SERVER)
add_compile_definitions(ENABLE_NATIVE_SERVER_FLAG=1)
endif()
if(ENABLE_FASHHASH)
add_compile_definitions(ENABLE_FASHHASH_FLAG=1)
endif()
if(ENABLE_WEB_SERVER)
add_compile_definitions(ENABLE_WEB_SERVER_FLAG=1)
endif()
if(ENABLE_WEB_CLIENT)
add_compile_definitions(ENABLE_WEB_CLIENT_FLAG=1)
endif()
include(cmake/options.cmake)

# Set policies
if(POLICY CMP0003)
cmake_policy(SET CMP0003 NEW)
endif()
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()
include(cmake/policies.cmake)

# Set project directories
set(Lithium_PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR})
Expand All @@ -55,15 +25,15 @@ set(lithium_task_dir ${lithium_src_dir}/task)

add_custom_target(CmakeAdditionalFiles
SOURCES
${lithium_src_dir}/../cmake_modules/compiler_options.cmake)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/")
include(cmake_modules/compiler_options.cmake)
${lithium_src_dir}/../cmake/compiler_options.cmake)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/")
include(cmake/compiler_options.cmake)

# ------------------ CPM Begin ------------------

set(CPM_DOWNLOAD_VERSION 0.35.6)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake_modules/CPM.cmake")
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM.cmake")

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake")
Expand Down Expand Up @@ -137,131 +107,10 @@ include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-websocket/oatpp-websocket)
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-openssl/oatpp-openssl)

# Find packages
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(fmt REQUIRED)
find_package(Readline REQUIRED)

find_package(Python COMPONENTS Interpreter REQUIRED)

# Specify the path to requirements.txt
set(REQUIREMENTS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt")

# Define a function to check if a Python package is installed
function(check_python_package package version)
# Replace hyphens with underscores for the import statement
string(REPLACE "-" "_" import_name ${package})

# Check if the package can be imported
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import ${import_name}"
RESULT_VARIABLE result
)

if(NOT result EQUAL 0)
set(result FALSE PARENT_SCOPE)
return()
endif()

# Get the installed package version
execute_process(
COMMAND ${Python_EXECUTABLE} -m pip show ${package}
OUTPUT_VARIABLE package_info
)

# Extract version information from the output
string(FIND "${package_info}" "Version:" version_pos)

if(version_pos EQUAL -1)
set(result FALSE PARENT_SCOPE)
return() # Return false if version not found
endif()

# Extract the version string
string(SUBSTRING "${package_info}" ${version_pos} 1000 version_string)
string(REGEX REPLACE "Version: ([^ ]+).*" "\\1" installed_version "${version_string}")

# Compare versions
if("${installed_version}" VERSION_LESS "${version}")
set(result FALSE PARENT_SCOPE) # Return false if installed version is less than required
return()
endif()

set(result TRUE PARENT_SCOPE)
endfunction()

if (EXISTS "${CMAKE_BINARY_DIR}/check_marker.txt")
message(STATUS "Check marker file found, skipping the checks.")
else()
# Create a virtual environment
set(VENV_DIR "${CMAKE_BINARY_DIR}/venv")
execute_process(
COMMAND ${Python_EXECUTABLE} -m venv ${VENV_DIR}
)

set(PYTHON_EXECUTABLE "${VENV_DIR}/bin/python")
set(PIP_EXECUTABLE "${VENV_DIR}/bin/pip")

# Upgrade pip in the virtual environment
execute_process(
COMMAND ${PIP_EXECUTABLE} install --upgrade pip
)

# Read the requirements.txt file and install missing packages
file(READ ${REQUIREMENTS_FILE} requirements_content)

# Split the requirements file content into lines
string(REPLACE "\n" ";" requirements_list "${requirements_content}")
include(cmake/find_packages.cmake)

# Check and install each package
foreach(requirement ${requirements_list})
# Skip empty lines
string(STRIP ${requirement} trimmed_requirement)
if(trimmed_requirement STREQUAL "")
continue()
endif()

# Get the package name and version (without the version number)
if(${trimmed_requirement} MATCHES "==")
string(REPLACE "==" ";" parts ${trimmed_requirement})
elseif(${trimmed_requirement} MATCHES ">=")
string(REPLACE ">=" ";" parts ${trimmed_requirement})
else()
message(WARNING "Could not parse requirement '${trimmed_requirement}'. Skipping...")
continue()
endif()

list(GET parts 0 package_name)
list(GET parts 1 package_version)

# If the package name or version could not be parsed, output a warning and skip
if(NOT package_name OR NOT package_version)
message(WARNING "Could not parse requirement '${trimmed_requirement}'. Skipping...")
continue()
endif()

# Check if the package is installed
message(STATUS "Checking if Python package '${package_name}' is installed...")
check_python_package(${package_name} ${package_version})
if(NOT result)
message(STATUS "Package '${package_name}' is not installed or needs an upgrade. Installing...")
execute_process(
COMMAND ${PIP_EXECUTABLE} install ${trimmed_requirement}
RESULT_VARIABLE install_result
)
if(NOT install_result EQUAL 0)
message(FATAL_ERROR "Failed to install Python package '${package_name}'.")
endif()
else()
message(STATUS "Package '${package_name}' is already installed with a suitable version.")
endif()
endforeach()
execute_process(
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/check_marker.txt"
RESULT_VARIABLE result
)
endif()
# Configure Python environment
include(cmake/python_environment.cmake)

# Configure config.h
configure_file(${lithium_src_dir}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
Expand All @@ -271,13 +120,16 @@ set(BUILD_SHARED_LIBS ON)
# Add subdirectories
add_subdirectory(libs)
add_subdirectory(modules)

add_subdirectory(${lithium_module_dir})

add_subdirectory(${lithium_src_dir}/config)
add_subdirectory(${lithium_src_dir}/task)
add_subdirectory(${lithium_src_dir}/server)
add_subdirectory(${lithium_src_dir}/utils)
add_subdirectory(${lithium_src_dir}/addon)
add_subdirectory(${lithium_src_dir}/client)
add_subdirectory(${lithium_src_dir}/target)
add_subdirectory(${lithium_src_dir}/device)
add_subdirectory(tests)

Expand Down Expand Up @@ -308,12 +160,13 @@ set(debug_module

set(device_module
${lithium_src_dir}/device/manager.cpp

${lithium_src_dir}/device/template/device.cpp
)

set(script_module
${lithium_src_dir}/script/manager.cpp
${lithium_src_dir}/script/pycaller.cpp
${lithium_src_dir}/script/pycaller.hpp
${lithium_src_dir}/script/sheller.cpp
)

Expand Down Expand Up @@ -364,6 +217,7 @@ target_link_libraries(lithium_server
tinyxml2
pocketpy
${Readline_LIBRARIES}
pybind11::embed
)

if(WIN32)
Expand Down Expand Up @@ -395,17 +249,7 @@ target_compile_definitions(lithium_server PRIVATE LOGURU_DEBUG_LOGGING)
set_target_properties(lithium_server PROPERTIES OUTPUT_NAME lithium_server)

# Set install paths
if(UNIX AND NOT APPLE)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Lithium install path" FORCE)
endif()
endif()

if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Program Files/LithiumServer")
elseif(LINUX)
set(CMAKE_INSTALL_PREFIX "/usr/lithium")
endif()
include(cmake/install_paths.cmake)

# Enable folder grouping in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ Alternatively, utilize the provided quick-build scripts to streamline the proces
### Intellectual Inspiration

Embarking on the journey with Lithium, we embrace curiosity and an unwavering pursuit of knowledge, echoing the adapted verse which reminds us that every attempt, though fraught with challenges and setbacks, is a necessary step toward wisdom and understanding. Together, let us navigate the vast cosmos of astronomical imaging, our technology the vessel, innovation our sail, advancing relentlessly forward.

<figure><embed src="https://wakatime.com/share/@018d39f0-57c9-4a13-aedb-90454b61e6cc/e1b2b694-2ecc-4cfd-9c75-2d01b8581e4d.svg"></embed></figure>
<figure><embed src="https://wakatime.com/share/@018d39f0-57c9-4a13-aedb-90454b61e6cc/d6c29fb7-c5b3-4ffc-8e17-16634c7b669a.svg"></embed></figure>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions cmake/FindGlib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# - Try to find Glib-2.0 (with gobject)
# Once done, this will define
#
# Glib_FOUND - system has Glib
# Glib_INCLUDE_DIRS - the Glib include directories
# Glib_LIBRARIES - link these to use Glib

include(LibFindMacros)

# Use pkg-config to get hints about paths
libfind_pkg_check_modules(Glib_PKGCONF glib-2.0>=2.16)

# Main include dir
find_path(Glib_INCLUDE_DIR
NAMES glib.h
PATHS ${Glib_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0
)

# Glib-related libraries also use a separate config header, which is in lib dir
find_path(GlibConfig_INCLUDE_DIR
NAMES glibconfig.h
PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr
PATH_SUFFIXES lib/glib-2.0/include
)

# Finally the library itself
find_library(Glib_LIBRARY
NAMES glib-2.0
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
)

# Find gobject library
find_library(GObject_LIBRARY
NAMES gobject-2.0
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
)

# Find gthread library
find_library(GThread_LIBRARY
NAMES gthread-2.0
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
)

# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
set(Glib_PROCESS_LIBS Glib_LIBRARY GObject_LIBRARY GThread_LIBRARY)
libfind_process(Glib)

# Redefine variables for backward compatibility
set(GLIB_INCLUDE_DIRS ${Glib_INCLUDE_DIRS})
set(GLIB_LIBRARIES ${Glib_LIBRARIES})
set(GLIB_FOUND ${Glib_FOUND})

# Provide a summary of the found libraries
if(Glib_FOUND)
message(STATUS "Found Glib: ${Glib_LIBRARIES}")
message(STATUS "Glib include directories: ${Glib_INCLUDE_DIRS}")
else()
message(WARNING "Glib not found")
endif()
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions cmake/FindLibSecret.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# - Try to find LIBSECRET-1
# Once done, this will define
#
# LIBSECRET_FOUND - system has LIBSECRET
# LIBSECRET_INCLUDE_DIRS - the LIBSECRET include directories
# LIBSECRET_LIBRARIES - link these to use LIBSECRET

include(LibFindMacros)

# Use pkg-config to get hints about paths
libfind_pkg_check_modules(LIBSECRET_PKGCONF LIBSECRET-1)

# Main include dir
find_path(LIBSECRET_INCLUDE_DIR
NAMES LIBSECRET/secret.h
PATHS ${LIBSECRET_PKGCONF_INCLUDE_DIRS}
)

# Finally the library itself
find_library(LIBSECRET_LIBRARY
NAMES secret-1
PATHS ${LIBSECRET_PKGCONF_LIBRARY_DIRS}
)

# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(LIBSECRET_PROCESS_INCLUDES LIBSECRET_INCLUDE_DIR)
set(LIBSECRET_PROCESS_LIBS LIBSECRET_LIBRARY)
libfind_process(LIBSECRET)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 12cd82d

Please sign in to comment.