Skip to content

Commit 12cd82d

Browse files
authored
24m11a (#43)
# 功能更新 ## 添加新的测试文件以及更新推荐引擎类以支持隐式反馈和评估功能 - **测试文件**: 新增测试文件以覆盖隐式反馈和评估功能的测试用例。 - **推荐引擎类**: 更新推荐引擎类以支持隐式反馈和评估功能,增强推荐系统的准确性和实用性。 ## 添加网络管理器与进程信息结构,更新字符串处理函数,增强配置管理功能 - **网络管理器**: 新增网络管理器类,用于管理网络连接和资源。 - **进程信息结构**: 添加进程信息结构,用于存储和管理进程相关信息。 - **字符串处理函数**: 更新字符串处理函数,增强字符串操作的效率和功能。 - **配置管理功能**: 增强配置管理功能,支持更灵活的配置选项和动态更新。 ## 代码优化与重构 - **头文件引用**: 更新头文件引用,确保所有依赖项正确包含。 - **类成员类型**: 修复类成员类型,确保类型一致性和正确性。 - **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] 自动修复代码,确保代码质量和一致性。
1 parent 7db6ae4 commit 12cd82d

File tree

362 files changed

+26124
-13238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

362 files changed

+26124
-13238
lines changed

CMakeLists.txt

Lines changed: 17 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,10 @@ cmake_minimum_required(VERSION 3.20)
1010
project(Lithium VERSION 1.0.0 LANGUAGES C CXX)
1111

1212
# Set project options
13-
option(ENABLE_ASYNC "Enable Async Server Mode" ON)
14-
option(ENABLE_NATIVE_SERVER "Enable to use INDI native server" OFF)
15-
option(ENABLE_DEBUG "Enable Debug Mode" OFF)
16-
option(ENABLE_FASHHASH "Enable Using emhash8 as fast hash map" OFF)
17-
option(ENABLE_WEB_SERVER "Enable Web Server" ON)
18-
option(ENABLE_WEB_CLIENT "Enable Web Client" ON)
19-
20-
# Set compile definitions based on options
21-
if(ENABLE_ASYNC)
22-
add_compile_definitions(ENABLE_ASYNC_FLAG=1)
23-
endif()
24-
if(ENABLE_DEBUG)
25-
add_compile_definitions(ENABLE_DEBUG_FLAG=1)
26-
endif()
27-
if(ENABLE_NATIVE_SERVER)
28-
add_compile_definitions(ENABLE_NATIVE_SERVER_FLAG=1)
29-
endif()
30-
if(ENABLE_FASHHASH)
31-
add_compile_definitions(ENABLE_FASHHASH_FLAG=1)
32-
endif()
33-
if(ENABLE_WEB_SERVER)
34-
add_compile_definitions(ENABLE_WEB_SERVER_FLAG=1)
35-
endif()
36-
if(ENABLE_WEB_CLIENT)
37-
add_compile_definitions(ENABLE_WEB_CLIENT_FLAG=1)
38-
endif()
13+
include(cmake/options.cmake)
3914

4015
# Set policies
41-
if(POLICY CMP0003)
42-
cmake_policy(SET CMP0003 NEW)
43-
endif()
44-
if(POLICY CMP0043)
45-
cmake_policy(SET CMP0043 NEW)
46-
endif()
16+
include(cmake/policies.cmake)
4717

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

5626
add_custom_target(CmakeAdditionalFiles
5727
SOURCES
58-
${lithium_src_dir}/../cmake_modules/compiler_options.cmake)
59-
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
60-
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/")
61-
include(cmake_modules/compiler_options.cmake)
28+
${lithium_src_dir}/../cmake/compiler_options.cmake)
29+
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
30+
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/")
31+
include(cmake/compiler_options.cmake)
6232

6333
# ------------------ CPM Begin ------------------
6434

6535
set(CPM_DOWNLOAD_VERSION 0.35.6)
66-
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake_modules/CPM.cmake")
36+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM.cmake")
6737

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

139109
# Find packages
140-
find_package(OpenSSL REQUIRED)
141-
find_package(ZLIB REQUIRED)
142-
find_package(SQLite3 REQUIRED)
143-
find_package(fmt REQUIRED)
144-
find_package(Readline REQUIRED)
145-
146-
find_package(Python COMPONENTS Interpreter REQUIRED)
147-
148-
# Specify the path to requirements.txt
149-
set(REQUIREMENTS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt")
150-
151-
# Define a function to check if a Python package is installed
152-
function(check_python_package package version)
153-
# Replace hyphens with underscores for the import statement
154-
string(REPLACE "-" "_" import_name ${package})
155-
156-
# Check if the package can be imported
157-
execute_process(
158-
COMMAND ${Python_EXECUTABLE} -c "import ${import_name}"
159-
RESULT_VARIABLE result
160-
)
161-
162-
if(NOT result EQUAL 0)
163-
set(result FALSE PARENT_SCOPE)
164-
return()
165-
endif()
166-
167-
# Get the installed package version
168-
execute_process(
169-
COMMAND ${Python_EXECUTABLE} -m pip show ${package}
170-
OUTPUT_VARIABLE package_info
171-
)
172-
173-
# Extract version information from the output
174-
string(FIND "${package_info}" "Version:" version_pos)
175-
176-
if(version_pos EQUAL -1)
177-
set(result FALSE PARENT_SCOPE)
178-
return() # Return false if version not found
179-
endif()
180-
181-
# Extract the version string
182-
string(SUBSTRING "${package_info}" ${version_pos} 1000 version_string)
183-
string(REGEX REPLACE "Version: ([^ ]+).*" "\\1" installed_version "${version_string}")
184-
185-
# Compare versions
186-
if("${installed_version}" VERSION_LESS "${version}")
187-
set(result FALSE PARENT_SCOPE) # Return false if installed version is less than required
188-
return()
189-
endif()
190-
191-
set(result TRUE PARENT_SCOPE)
192-
endfunction()
193-
194-
if (EXISTS "${CMAKE_BINARY_DIR}/check_marker.txt")
195-
message(STATUS "Check marker file found, skipping the checks.")
196-
else()
197-
# Create a virtual environment
198-
set(VENV_DIR "${CMAKE_BINARY_DIR}/venv")
199-
execute_process(
200-
COMMAND ${Python_EXECUTABLE} -m venv ${VENV_DIR}
201-
)
202-
203-
set(PYTHON_EXECUTABLE "${VENV_DIR}/bin/python")
204-
set(PIP_EXECUTABLE "${VENV_DIR}/bin/pip")
205-
206-
# Upgrade pip in the virtual environment
207-
execute_process(
208-
COMMAND ${PIP_EXECUTABLE} install --upgrade pip
209-
)
210-
211-
# Read the requirements.txt file and install missing packages
212-
file(READ ${REQUIREMENTS_FILE} requirements_content)
213-
214-
# Split the requirements file content into lines
215-
string(REPLACE "\n" ";" requirements_list "${requirements_content}")
110+
include(cmake/find_packages.cmake)
216111

217-
# Check and install each package
218-
foreach(requirement ${requirements_list})
219-
# Skip empty lines
220-
string(STRIP ${requirement} trimmed_requirement)
221-
if(trimmed_requirement STREQUAL "")
222-
continue()
223-
endif()
224-
225-
# Get the package name and version (without the version number)
226-
if(${trimmed_requirement} MATCHES "==")
227-
string(REPLACE "==" ";" parts ${trimmed_requirement})
228-
elseif(${trimmed_requirement} MATCHES ">=")
229-
string(REPLACE ">=" ";" parts ${trimmed_requirement})
230-
else()
231-
message(WARNING "Could not parse requirement '${trimmed_requirement}'. Skipping...")
232-
continue()
233-
endif()
234-
235-
list(GET parts 0 package_name)
236-
list(GET parts 1 package_version)
237-
238-
# If the package name or version could not be parsed, output a warning and skip
239-
if(NOT package_name OR NOT package_version)
240-
message(WARNING "Could not parse requirement '${trimmed_requirement}'. Skipping...")
241-
continue()
242-
endif()
243-
244-
# Check if the package is installed
245-
message(STATUS "Checking if Python package '${package_name}' is installed...")
246-
check_python_package(${package_name} ${package_version})
247-
if(NOT result)
248-
message(STATUS "Package '${package_name}' is not installed or needs an upgrade. Installing...")
249-
execute_process(
250-
COMMAND ${PIP_EXECUTABLE} install ${trimmed_requirement}
251-
RESULT_VARIABLE install_result
252-
)
253-
if(NOT install_result EQUAL 0)
254-
message(FATAL_ERROR "Failed to install Python package '${package_name}'.")
255-
endif()
256-
else()
257-
message(STATUS "Package '${package_name}' is already installed with a suitable version.")
258-
endif()
259-
endforeach()
260-
execute_process(
261-
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/check_marker.txt"
262-
RESULT_VARIABLE result
263-
)
264-
endif()
112+
# Configure Python environment
113+
include(cmake/python_environment.cmake)
265114

266115
# Configure config.h
267116
configure_file(${lithium_src_dir}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
@@ -271,13 +120,16 @@ set(BUILD_SHARED_LIBS ON)
271120
# Add subdirectories
272121
add_subdirectory(libs)
273122
add_subdirectory(modules)
123+
274124
add_subdirectory(${lithium_module_dir})
125+
275126
add_subdirectory(${lithium_src_dir}/config)
276127
add_subdirectory(${lithium_src_dir}/task)
277128
add_subdirectory(${lithium_src_dir}/server)
278129
add_subdirectory(${lithium_src_dir}/utils)
279130
add_subdirectory(${lithium_src_dir}/addon)
280131
add_subdirectory(${lithium_src_dir}/client)
132+
add_subdirectory(${lithium_src_dir}/target)
281133
add_subdirectory(${lithium_src_dir}/device)
282134
add_subdirectory(tests)
283135

@@ -308,12 +160,13 @@ set(debug_module
308160

309161
set(device_module
310162
${lithium_src_dir}/device/manager.cpp
311-
312163
${lithium_src_dir}/device/template/device.cpp
313164
)
314165

315166
set(script_module
316167
${lithium_src_dir}/script/manager.cpp
168+
${lithium_src_dir}/script/pycaller.cpp
169+
${lithium_src_dir}/script/pycaller.hpp
317170
${lithium_src_dir}/script/sheller.cpp
318171
)
319172

@@ -364,6 +217,7 @@ target_link_libraries(lithium_server
364217
tinyxml2
365218
pocketpy
366219
${Readline_LIBRARIES}
220+
pybind11::embed
367221
)
368222

369223
if(WIN32)
@@ -395,17 +249,7 @@ target_compile_definitions(lithium_server PRIVATE LOGURU_DEBUG_LOGGING)
395249
set_target_properties(lithium_server PROPERTIES OUTPUT_NAME lithium_server)
396250

397251
# Set install paths
398-
if(UNIX AND NOT APPLE)
399-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
400-
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Lithium install path" FORCE)
401-
endif()
402-
endif()
403-
404-
if(WIN32)
405-
set(CMAKE_INSTALL_PREFIX "C:/Program Files/LithiumServer")
406-
elseif(LINUX)
407-
set(CMAKE_INSTALL_PREFIX "/usr/lithium")
408-
endif()
252+
include(cmake/install_paths.cmake)
409253

410254
# Enable folder grouping in IDEs
411255
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ Alternatively, utilize the provided quick-build scripts to streamline the proces
6969
### Intellectual Inspiration
7070

7171
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.
72+
73+
<figure><embed src="https://wakatime.com/share/@018d39f0-57c9-4a13-aedb-90454b61e6cc/e1b2b694-2ecc-4cfd-9c75-2d01b8581e4d.svg"></embed></figure>
74+
<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.

cmake/FindGlib.cmake

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# - Try to find Glib-2.0 (with gobject)
2+
# Once done, this will define
3+
#
4+
# Glib_FOUND - system has Glib
5+
# Glib_INCLUDE_DIRS - the Glib include directories
6+
# Glib_LIBRARIES - link these to use Glib
7+
8+
include(LibFindMacros)
9+
10+
# Use pkg-config to get hints about paths
11+
libfind_pkg_check_modules(Glib_PKGCONF glib-2.0>=2.16)
12+
13+
# Main include dir
14+
find_path(Glib_INCLUDE_DIR
15+
NAMES glib.h
16+
PATHS ${Glib_PKGCONF_INCLUDE_DIRS}
17+
PATH_SUFFIXES glib-2.0
18+
)
19+
20+
# Glib-related libraries also use a separate config header, which is in lib dir
21+
find_path(GlibConfig_INCLUDE_DIR
22+
NAMES glibconfig.h
23+
PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr
24+
PATH_SUFFIXES lib/glib-2.0/include
25+
)
26+
27+
# Finally the library itself
28+
find_library(Glib_LIBRARY
29+
NAMES glib-2.0
30+
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
31+
)
32+
33+
# Find gobject library
34+
find_library(GObject_LIBRARY
35+
NAMES gobject-2.0
36+
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
37+
)
38+
39+
# Find gthread library
40+
find_library(GThread_LIBRARY
41+
NAMES gthread-2.0
42+
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
43+
)
44+
45+
# Set the include dir variables and the libraries and let libfind_process do the rest.
46+
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
47+
set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
48+
set(Glib_PROCESS_LIBS Glib_LIBRARY GObject_LIBRARY GThread_LIBRARY)
49+
libfind_process(Glib)
50+
51+
# Redefine variables for backward compatibility
52+
set(GLIB_INCLUDE_DIRS ${Glib_INCLUDE_DIRS})
53+
set(GLIB_LIBRARIES ${Glib_LIBRARIES})
54+
set(GLIB_FOUND ${Glib_FOUND})
55+
56+
# Provide a summary of the found libraries
57+
if(Glib_FOUND)
58+
message(STATUS "Found Glib: ${Glib_LIBRARIES}")
59+
message(STATUS "Glib include directories: ${Glib_INCLUDE_DIRS}")
60+
else()
61+
message(WARNING "Glib not found")
62+
endif()
File renamed without changes.
File renamed without changes.

cmake/FindLibSecret.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# - Try to find LIBSECRET-1
2+
# Once done, this will define
3+
#
4+
# LIBSECRET_FOUND - system has LIBSECRET
5+
# LIBSECRET_INCLUDE_DIRS - the LIBSECRET include directories
6+
# LIBSECRET_LIBRARIES - link these to use LIBSECRET
7+
8+
include(LibFindMacros)
9+
10+
# Use pkg-config to get hints about paths
11+
libfind_pkg_check_modules(LIBSECRET_PKGCONF LIBSECRET-1)
12+
13+
# Main include dir
14+
find_path(LIBSECRET_INCLUDE_DIR
15+
NAMES LIBSECRET/secret.h
16+
PATHS ${LIBSECRET_PKGCONF_INCLUDE_DIRS}
17+
)
18+
19+
# Finally the library itself
20+
find_library(LIBSECRET_LIBRARY
21+
NAMES secret-1
22+
PATHS ${LIBSECRET_PKGCONF_LIBRARY_DIRS}
23+
)
24+
25+
# Set the include dir variables and the libraries and let libfind_process do the rest.
26+
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
27+
set(LIBSECRET_PROCESS_INCLUDES LIBSECRET_INCLUDE_DIR)
28+
set(LIBSECRET_PROCESS_LIBS LIBSECRET_LIBRARY)
29+
libfind_process(LIBSECRET)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)