From d65ec5627c0be474aae669e3c9edbad99707a5f9 Mon Sep 17 00:00:00 2001 From: Max Qian Date: Sat, 11 Nov 2023 21:20:13 +0800 Subject: [PATCH] update --- CMakeLists.txt | 5 +- locale/lithium.pot | 287 +++++++++++++++++++ locale/po/en_US.UTF-8/lithium.po | 96 +++---- src/LithiumApp.cpp | 16 +- src/LithiumApp.hpp | 9 +- src/atom/io/compress.cpp | 6 +- src/atom/server/deserialize.cpp | 2 +- src/client/hydrogen/hydrogenclient.hpp | 2 +- src/client/hydrogen/hydrogendevice.hpp | 2 +- src/controller/AsyncWebSocketController.hpp | 1 + src/core/base/CMakeLists.txt | 3 + src/device/device_manager.cpp | 6 +- src/device/device_manager.hpp | 11 +- src/script/script_manager.cpp | 15 - src/task/task_generator.hpp | 4 +- src/websocket/device/WsCameraInstance.cpp | 88 ++++++ src/websocket/device/WsCameraInstance.hpp | 69 +++++ src/websocket/device/WsDeviceHub.cpp | 2 +- src/websocket/device/WsDeviceHub.hpp | 2 +- src/websocket/device/WsDeviceInstance.cpp | 20 +- src/websocket/device/WsDeviceInstance.hpp | 47 +-- src/websocket/device/WsDeviceServer.cpp | 25 +- src/websocket/device/WsDeviceServer.hpp | 47 ++- src/websocket/device/WsTelescopeInstance.cpp | 0 src/websocket/device/WsTelescopeInstance.hpp | 0 tools/CMakeLists.txt | 4 +- 26 files changed, 618 insertions(+), 151 deletions(-) create mode 100644 locale/lithium.pot create mode 100644 src/websocket/device/WsCameraInstance.cpp create mode 100644 src/websocket/device/WsCameraInstance.hpp create mode 100644 src/websocket/device/WsTelescopeInstance.cpp create mode 100644 src/websocket/device/WsTelescopeInstance.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b3468696..47cb6638 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,8 @@ set(server_module ${lithium_src_dir}/websocket/device/WsDeviceInstance.cpp ${lithium_src_dir}/websocket/device/WsDeviceServer.cpp + ${lithium_src_dir}/websocket/device/WsCameraInstance.cpp + ${lithium_src_dir}/websocket/plugin/WsPluginHub.cpp ${lithium_src_dir}/websocket/plugin/WsPluginInstance.cpp ${lithium_src_dir}/websocket/plugin/WsPluginServer.cpp @@ -276,9 +278,6 @@ add_subdirectory(modules/hydrogen_client) # 构建Lithium内核 add_subdirectory(${lithium_src_dir}/core) -if(NOT WIN32) -add_subdirectory(${lithium_module_dir}/deviceloader) -endif() add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${web_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${utils_module} ${Lithium_module}) diff --git a/locale/lithium.pot b/locale/lithium.pot new file mode 100644 index 00000000..c2dd79e3 --- /dev/null +++ b/locale/lithium.pot @@ -0,0 +1,287 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Max Qian +# This file is distributed under the same license as the package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: astro_air@126.com\n" +"POT-Creation-Date: 2023-11-11 19:58+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: E:/msys64/home/Qrm/Lithium/src/device/device_manager.cpp:161 +#, c++-format +msgid "A device with name {} already exists, please choose a different name" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/device/indidevice_manager.cpp:278 +#, c++-format +msgid "Failed to run command: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:63 +#, c++-format +msgid "Failed to destroy ThreadManager: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:82 +msgid "Thread manager has stopped, cannot add new thread" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:100 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:122 +#, c++-format +msgid "Unhandled exception in thread: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:128 +#, c++-format +msgid "Added thread: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:133 +#, c++-format +msgid "Failed to add thread {}: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:149 +msgid "All threads joined" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:153 +#, c++-format +msgid "Failed to join all threads: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:163 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:180 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:194 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:205 +#, c++-format +msgid "Thread {} not found" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:172 +#, c++-format +msgid "Thread {} joined" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:184 +#, c++-format +msgid "Failed to join thread {}: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:210 +#, c++-format +msgid "Failed to check if thread {} is running: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:76 +msgid "Failed to create PowerShell process" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:86 +#, c++-format +msgid "Running command: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:103 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:127 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:148 +msgid "Failed to create process" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:113 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:158 +#, c++-format +msgid "Process created: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:137 +#, c++-format +msgid "Running script: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:175 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:187 +#, c++-format +msgid "Process terminated: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:179 +msgid "Failed to terminate process" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:195 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:240 +msgid "Process not found" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:210 +#, c++-format +msgid "Process not found by name: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:255 +#, c++-format +msgid "Process completed: {} (PID: {})" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:259 +msgid "Failed to wait for process completion" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:265 +#, c-format +msgid "Process completed: %s (PID: %d)" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:270 +msgid "All processes completed." +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:281 +msgid "Failed to create process snapshot" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:322 +msgid "Failed to open /proc directory" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:351 +msgid "Failed to get process path" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:372 +msgid "Failed to get process info length" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:379 +msgid "Failed to allocate memory" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:385 +msgid "Failed to get process info" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:94 +msgid "CreateToolhelp32Snapshot failed." +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:113 +#, c++-format +msgid "Watching process with PID: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:124 +#, c++-format +msgid "Process exited with code: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:133 +msgid "GetExitCodeProcess failed." +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:143 +msgid "OpenProcess failed." +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:170 +#, c++-format +msgid "Process exited with status: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:179 +#, c++-format +msgid "Process terminated by signal: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:226 +msgid "port the server running on" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:227 +msgid "host the server running on" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:228 +msgid "path to the config file" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:229 +msgid "path to the modules directory" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:230 +msgid "web panel" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:231 +msgid "path to log file" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:233 +msgid "Lithium Command Line Interface:" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:234 +msgid "End." +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:242 +#, c-format +msgid "Failed to parser command line : %s" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:263 +#, c-format +msgid "Command line server port : %d" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/App.cpp:269 +#, c-format +msgid "Set server port to %d" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:81 +#, c++-format +msgid "Failed to load Lithium App , error : {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:93 +#, c++-format +msgid "Get config value: {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:99 +#, c++-format +msgid "Set {} to {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:297 +#, c++-format +msgid "Failed to run chai command : {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:315 +#, c++-format +msgid "Failed to run chai multi command {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:328 +#, c++-format +msgid "Failed to load chaiscript file {}" +msgstr "" + +#: E:/msys64/home/Qrm/Lithium/src/LithiumApp.cpp:341 +#, c++-format +msgid "Failed to run chai script {}" +msgstr "" diff --git a/locale/po/en_US.UTF-8/lithium.po b/locale/po/en_US.UTF-8/lithium.po index bda44bad..bd5b3fc3 100644 --- a/locale/po/en_US.UTF-8/lithium.po +++ b/locale/po/en_US.UTF-8/lithium.po @@ -1,186 +1,186 @@ -#: E:/msys64/home/Qrm/Lithium/src/modules/device/device_manager.cpp:161 +#: E:/msys64/home/Qrm/Lithium/src/device/device_manager.cpp:161 #, c++-format msgid "A device with name {} already exists, please choose a different name" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/device/indidevice_manager.cpp:278 +#: E:/msys64/home/Qrm/Lithium/src/device/indidevice_manager.cpp:278 #, c++-format msgid "Failed to run command: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:63 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:63 #, c++-format msgid "Failed to destroy ThreadManager: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:82 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:82 msgid "Thread manager has stopped, cannot add new thread" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:100 -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:122 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:100 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:122 #, c++-format msgid "Unhandled exception in thread: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:128 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:128 #, c++-format msgid "Added thread: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:133 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:133 #, c++-format msgid "Failed to add thread {}: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:149 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:149 msgid "All threads joined" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:153 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:153 #, c++-format msgid "Failed to join all threads: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:163 -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:180 -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:194 -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:205 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:163 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:180 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:194 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:205 #, c++-format msgid "Thread {} not found" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:172 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:172 #, c++-format msgid "Thread {} joined" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:184 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:184 #, c++-format msgid "Failed to join thread {}: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/thread/thread.cpp:210 +#: E:/msys64/home/Qrm/Lithium/src/atom/thread/thread.cpp:210 #, c++-format msgid "Failed to check if thread {} is running: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:76 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:76 msgid "Failed to create PowerShell process" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:86 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:86 #, c++-format msgid "Running command: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:103 -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:127 -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:148 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:103 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:127 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:148 msgid "Failed to create process" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:113 -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:158 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:113 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:158 #, c++-format msgid "Process created: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:137 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:137 #, c++-format msgid "Running script: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:175 -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:187 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:175 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:187 #, c++-format msgid "Process terminated: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:179 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:179 msgid "Failed to terminate process" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:195 -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:240 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:195 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:240 msgid "Process not found" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:210 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:210 #, c++-format msgid "Process not found by name: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:255 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:255 #, c++-format msgid "Process completed: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:259 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:259 msgid "Failed to wait for process completion" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:265 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:265 #, c-format msgid "Process completed: %s (PID: %d)" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:270 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:270 msgid "All processes completed." msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:281 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:281 msgid "Failed to create process snapshot" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:322 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:322 msgid "Failed to open /proc directory" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:351 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:351 msgid "Failed to get process path" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:372 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:372 msgid "Failed to get process info length" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:379 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:379 msgid "Failed to allocate memory" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/process.cpp:385 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/process.cpp:385 msgid "Failed to get process info" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:94 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:94 msgid "CreateToolhelp32Snapshot failed." msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:113 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:113 #, c++-format msgid "Watching process with PID: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:124 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:124 #, c++-format msgid "Process exited with code: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:133 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:133 msgid "GetExitCodeProcess failed." msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:143 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:143 msgid "OpenProcess failed." msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:170 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:170 #, c++-format msgid "Process exited with status: {}" msgstr "" -#: E:/msys64/home/Qrm/Lithium/src/modules/system/pid.cpp:179 +#: E:/msys64/home/Qrm/Lithium/src/atom/system/pid.cpp:179 #, c++-format msgid "Process terminated by signal: {}" msgstr "" diff --git a/src/LithiumApp.cpp b/src/LithiumApp.cpp index 24c9b504..ba6a8f82 100644 --- a/src/LithiumApp.cpp +++ b/src/LithiumApp.cpp @@ -33,15 +33,15 @@ Description: Lithium App Enter #include "config.h" #include "atom/thread/thread.hpp" -#include "atom/config/configor.hpp" -#include "atom/device/device_manager.hpp" +#include "config/configor.hpp" +#include "device/device_manager.hpp" #include "atom/system/process.hpp" -#include "atom/task/task_manager.hpp" -#include "atom/task/task_generator.hpp" -#include "atom/task/task_stack.hpp" +#include "task/task_manager.hpp" +#include "task/task_generator.hpp" +#include "task/task_stack.hpp" #include "core/property/iproperty.hpp" -#include "atom/plugin/plugin_loader.hpp" -#include "atom/script/script_manager.hpp" +#include "plugin/plugin_loader.hpp" +#include "script/script_manager.hpp" #include "loguru/loguru.hpp" #include "nlohmann/json.hpp" @@ -55,7 +55,7 @@ namespace Lithium { try { - m_ConfigManager = Config::ConfigManager::createShared(); + m_ConfigManager = ConfigManager::createShared(); m_MessageBus = std::make_shared(); m_DeviceManager = DeviceManager::createShared(m_MessageBus, m_ConfigManager); diff --git a/src/LithiumApp.hpp b/src/LithiumApp.hpp index 41be430a..861cc7e3 100644 --- a/src/LithiumApp.hpp +++ b/src/LithiumApp.hpp @@ -36,7 +36,7 @@ Description: Lithium App Enter #include #include "atom/server/message_bus.hpp" -#include "atom/device/device_manager.hpp" +#include "device/device_manager.hpp" #include "atom/system/process.hpp" #include "nlohmann/json.hpp" @@ -49,10 +49,7 @@ namespace Lithium class ThreadManager; } - namespace Config - { - class ConfigManager; - } + class ConfigManager; class ScriptManager; class PluginManager; @@ -144,7 +141,7 @@ namespace Lithium private: std::shared_ptr m_ThreadManager; - std::shared_ptr m_ConfigManager; + std::shared_ptr m_ConfigManager; std::shared_ptr m_DeviceManager; std::shared_ptr m_ProcessManager; std::shared_ptr m_TaskManager; diff --git a/src/atom/io/compress.cpp b/src/atom/io/compress.cpp index 8e96236c..ffcdc595 100644 --- a/src/atom/io/compress.cpp +++ b/src/atom/io/compress.cpp @@ -132,7 +132,7 @@ namespace Lithium::File std::ifstream in(file, std::ios::binary); if (!in) { - LOG_F(ERROR, "Failed to open file {}", file); + LOG_F(ERROR, "Failed to open file {}", file.string()); return false; } @@ -222,7 +222,7 @@ namespace Lithium::File std::ifstream in(sub_entry.path(), std::ios::binary); if (!in) { - LOG_F(ERROR, "Failed to open file {}", sub_entry.path()); + LOG_F(ERROR, "Failed to open file {}", sub_entry.path().string()); continue; } @@ -233,7 +233,7 @@ namespace Lithium::File { in.close(); gzclose(out); - LOG_F(ERROR, "Failed to compress file {}", sub_entry.path()); + LOG_F(ERROR, "Failed to compress file {}", sub_entry.path().string()); return false; } } diff --git a/src/atom/server/deserialize.cpp b/src/atom/server/deserialize.cpp index 9ae6c9f9..6416a31a 100644 --- a/src/atom/server/deserialize.cpp +++ b/src/atom/server/deserialize.cpp @@ -34,7 +34,7 @@ Description: This file contains the declaration of the DeserializationEngine cla #include "nlohmann/json.hpp" using json = nlohmann::json; -std::optional JsonDeserializer::deserialize(const std::string &data) const override +std::optional JsonDeserializer::deserialize(const std::string &data) const { try { diff --git a/src/client/hydrogen/hydrogenclient.hpp b/src/client/hydrogen/hydrogenclient.hpp index f66e5461..f81e5b25 100644 --- a/src/client/hydrogen/hydrogenclient.hpp +++ b/src/client/hydrogen/hydrogenclient.hpp @@ -58,7 +58,7 @@ class LithiumIndiClient : public HYDROGEN::BaseClient virtual void IndiServerConnected() = 0; virtual void IndiServerDisconnected(int exit_code) = 0; - // must use this in LGuider2 rather than BaseClient::disconnectServer() + // must use this in PHD2 rather than BaseClient::disconnectServer() bool DisconnectIndiServer(); protected: // old deprecated interface INDI Version < 2.0.0 diff --git a/src/client/hydrogen/hydrogendevice.hpp b/src/client/hydrogen/hydrogendevice.hpp index f3b9b639..36d9333e 100644 --- a/src/client/hydrogen/hydrogendevice.hpp +++ b/src/client/hydrogen/hydrogendevice.hpp @@ -1,6 +1,6 @@ #pragma once -#include "atom/client/hydrogenclient.hpp" +#include "hydrogenclient.hpp" #include "core/property/task/device_task.hpp" #include "core/property/task/conditional_task.hpp" #include "core/property/task/loop_task.hpp" diff --git a/src/controller/AsyncWebSocketController.hpp b/src/controller/AsyncWebSocketController.hpp index c8a45106..01a1f95f 100644 --- a/src/controller/AsyncWebSocketController.hpp +++ b/src/controller/AsyncWebSocketController.hpp @@ -97,6 +97,7 @@ class WebSocketController : public oatpp::web::server::api::ApiController auto parameters = std::make_shared(); (*parameters)["deviceName"] = hubName; (*parameters)["deviceHub"] = instanceName; + (*parameters)["deviceType"] = hubType; response->setConnectionUpgradeParameters(parameters); return _return(response); } diff --git a/src/core/base/CMakeLists.txt b/src/core/base/CMakeLists.txt index d5f90287..40df1ff8 100644 --- a/src/core/base/CMakeLists.txt +++ b/src/core/base/CMakeLists.txt @@ -62,6 +62,9 @@ list(APPEND ${PROJECT_NAME}_SOURCES hydrogenstandardproperty.cpp ) +find_package(Intl REQUIRED) +target_link_libraries(hydrogencore ${Libintl_LIBRARY}) + if(UNIX OR WIN32 OR LINUX) list(APPEND ${PROJECT_NAME}_PRIVATE_HEADERS sharedblob_parse.hpp diff --git a/src/device/device_manager.cpp b/src/device/device_manager.cpp index f3222687..9620d9bb 100644 --- a/src/device/device_manager.cpp +++ b/src/device/device_manager.cpp @@ -31,7 +31,7 @@ Description: Device Manager #include "device_manager.hpp" #include "config/configor.hpp" -#include "module/module_loader.hpp" +#include "atom/plugin/module_loader.hpp" #include "server/message_bus.hpp" #include "thread/thread.hpp" @@ -103,7 +103,7 @@ namespace Lithium { // Constructor - DeviceManager::DeviceManager(std::shared_ptr messageBus, std::shared_ptr configManager) + DeviceManager::DeviceManager(std::shared_ptr messageBus, std::shared_ptr configManager) { m_ModuleLoader = ModuleLoader::createShared("drivers"); m_ConfigManager = configManager; @@ -130,7 +130,7 @@ namespace Lithium } } - std::shared_ptr DeviceManager::createShared(std::shared_ptr messageBus, std::shared_ptr configManager) + std::shared_ptr DeviceManager::createShared(std::shared_ptr messageBus, std::shared_ptr configManager) { return std::make_shared(messageBus, configManager); } diff --git a/src/device/device_manager.hpp b/src/device/device_manager.hpp index 9bd08948..fb218a50 100644 --- a/src/device/device_manager.hpp +++ b/src/device/device_manager.hpp @@ -79,10 +79,7 @@ namespace Lithium class ThreadManager; } - namespace Config - { - class ConfigManager; - } + class ConfigManager; /** * @class DeviceManager @@ -96,7 +93,7 @@ namespace Lithium * @param messageBus 消息总线对象的共享指针。 * @param configManager 配置管理器对象的共享指针。 */ - DeviceManager(std::shared_ptr messageBus, std::shared_ptr configManager); + DeviceManager(std::shared_ptr messageBus, std::shared_ptr configManager); /** * @brief 析构函数,销毁设备管理器对象。 @@ -109,7 +106,7 @@ namespace Lithium * @param configManager 配置管理器对象的共享指针。 * @return 返回一个指向设备管理器对象的共享指针。 */ - static std::shared_ptr createShared(std::shared_ptr messageBus, std::shared_ptr configManager); + static std::shared_ptr createShared(std::shared_ptr messageBus, std::shared_ptr configManager); /** * @brief 获取指定类型设备的设备列表。 @@ -318,7 +315,7 @@ namespace Lithium std::shared_ptr m_ModuleLoader; ///< 模块加载器对象的共享指针。 std::shared_ptr m_MessageBus; ///< 消息总线对象的共享指针。 - std::shared_ptr m_ConfigManager; ///< 配置管理器对象的共享指针。 + std::shared_ptr m_ConfigManager; ///< 配置管理器对象的共享指针。 std::shared_ptr m_ThreadManager; // Device for quick performance diff --git a/src/script/script_manager.cpp b/src/script/script_manager.cpp index 4f921f74..51bacf66 100644 --- a/src/script/script_manager.cpp +++ b/src/script/script_manager.cpp @@ -143,21 +143,6 @@ namespace Lithium chai_->add(chaiscript::user_type(), "LiError"); chai_->add(chaiscript::user_type(), "DeviceType"); - chai_->add(chaiscript::constructor(),"DeviceManager"); - chai_->add(chaiscript::fun(&DeviceManager::getDeviceList),"get_device_list"); - chai_->add(chaiscript::fun(&DeviceManager::addDevice),"add_device"); - chai_->add(chaiscript::fun(&DeviceManager::addDeviceLibrary),"add_device_library"); - chai_->add(chaiscript::fun(&DeviceManager::addDeviceObserver),"add_device_observer"); - chai_->add(chaiscript::fun(&DeviceManager::removeDevice),"remove_device"); - chai_->add(chaiscript::fun(&DeviceManager::removeDeviceByName),"remove_device_by_name"); - chai_->add(chaiscript::fun(&DeviceManager::removeDeviceLibrary),"remove_device_library"); - chai_->add(chaiscript::fun(&DeviceManager::getDevice),"get_device"); - chai_->add(chaiscript::fun(&DeviceManager::findDevice),"find_device"); - chai_->add(chaiscript::fun(&DeviceManager::findDeviceByName),"find_device_by_name"); - chai_->add(chaiscript::fun(&DeviceManager::getTask),"get_task"); - chai_->add(chaiscript::fun(&DeviceManager::setDeviceProperty),"set_device_property"); - chai_->add(chaiscript::fun(&DeviceManager::setDevicePropertyByName),"set_device_property_by_name"); - chai_->add(chaiscript::type_conversion()); } diff --git a/src/task/task_generator.hpp b/src/task/task_generator.hpp index 98ef5bb0..f8571be8 100644 --- a/src/task/task_generator.hpp +++ b/src/task/task_generator.hpp @@ -40,8 +40,8 @@ Description: Task Generator #endif #include -#include "atom/device/device_manager.hpp" -#include "atom/plugin/plugin_loader.hpp" +#include "device/device_manager.hpp" +#include "plugin/plugin_loader.hpp" #include "core/property/task/task.hpp" namespace Lithium::Task diff --git a/src/websocket/device/WsCameraInstance.cpp b/src/websocket/device/WsCameraInstance.cpp new file mode 100644 index 00000000..395dcc4e --- /dev/null +++ b/src/websocket/device/WsCameraInstance.cpp @@ -0,0 +1,88 @@ +/* + * WsCameraInstance.cpp + * + * Copyright (C) 2023 Max Qian + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/************************************************* + +Copyright: 2023 Max Qian. All rights reserved + +Author: Max Qian + +E-mail: astro_air@126.com + +Date: 2023-10-20 + +Description: WebSocket Device Instance (each device each instance) + +**************************************************/ + +#include "WsCameraInstance.hpp" +#include "WsDeviceHub.hpp" + +#include "device/device_manager.hpp" +#include "atom/server/serialize.hpp" +#include "atom/server/deserialize.hpp" + +#include "atom/utils/time.hpp" +#include "websocket/template/error_message.hpp" +#include "atom/error/error_code.hpp" + +#include "loguru/loguru.hpp" +#include "nlohmann/json.hpp" +#include "magic_enum/magic_enum.hpp" + +WsCameraInstance::WsCameraInstance(const std::shared_ptr &socket, + const std::shared_ptr &hub, + const oatpp::String &device_name, + v_int32 userId) + : WsDeviceInstance(socket, hub, device_name, userId) +{ + LiRegisterFunc("startExopsure", &WsCameraInstance::startExposure, this); +} + +WsCameraInstance::~WsCameraInstance() +{ +} + +void WsCameraInstance::startExposure(const json &m_params) +{ + // 实现参数检查 + if (m_params.contains("exposure_time") && m_params["exposure_time"].is_number_integer()) + { + int exposure_time = m_params["exposure_time"]; + if (exposure_time < 1) + { + json error_message = {{"error_code", ServerError::InvalidParameters}, + {"error_message", "exposure_time must be greater than 0"}}; + sendMessage(error_message.dump()); + return; + } + if (exposure_time > 1000000) + { + json error_message = {{"error_code", ServerError::InvalidParameters}, + {"error_message", "exposure_time must be less than 1000000"}}; + sendMessage(error_message.dump()); + return; + } + } + else + { + json error_message = {{"error_code", ServerError::InvalidParameters}, + {"error_message", "exposure_time must be an integer"}}; + sendMessage(error_message.dump()); + return; + } +} \ No newline at end of file diff --git a/src/websocket/device/WsCameraInstance.hpp b/src/websocket/device/WsCameraInstance.hpp new file mode 100644 index 00000000..ac69656a --- /dev/null +++ b/src/websocket/device/WsCameraInstance.hpp @@ -0,0 +1,69 @@ +/* + * WsCameraInstance.hpp + * + * Copyright (C) 2023 Max Qian + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/************************************************* + +Copyright: 2023 Max Qian. All rights reserved + +Author: Max Qian + +E-mail: astro_air@126.com + +Date: 2023-10-20 + +Description: WebSocket Device Instance (each device each instance) + +**************************************************/ + +#ifndef WSCAMERAINSTANCE_HPP +#define WSCAMERAINSTANCE_HPP + +#include "WsDeviceInstance.hpp" + +/** + * @brief Class representing an instance of a WebSocket Camera + * + */ +class WsCameraInstance : public WsDeviceInstance +{ + +public: + /** + * @brief Construct a new WsCameraInstance object. + * + * @param socket Shared pointer to the AsyncWebSocket object. + * @param hub Shared pointer to the WsDeviceHub object. + * @param device_name Name of the device. + * @param userId Id of the user. + */ + WsCameraInstance(const std::shared_ptr &socket, + const std::shared_ptr &hub, + const oatpp::String &device_name, + v_int32 userId); + + /** + * @brief Destroy the WsCameraInstance object. + * + */ + ~WsCameraInstance(); + +public: + + void startExposure(const json &m_params); +}; + +#endif // WSCAMERAINSTANCE_HPP diff --git a/src/websocket/device/WsDeviceHub.cpp b/src/websocket/device/WsDeviceHub.cpp index 7515d594..3ea7be5e 100644 --- a/src/websocket/device/WsDeviceHub.cpp +++ b/src/websocket/device/WsDeviceHub.cpp @@ -31,7 +31,7 @@ Description: WebSocket Device Hub (all devices of one type in one hub) #include "WsDeviceHub.hpp" -void WsDeviceHub::adddevice(const std::shared_ptr &device) +void WsDeviceHub::addDevice(const std::shared_ptr &device) { std::lock_guard guard(m_deviceByIdLock); m_deviceById[device->getUserId()] = device; diff --git a/src/websocket/device/WsDeviceHub.hpp b/src/websocket/device/WsDeviceHub.hpp index 0ae2b1a2..1cb8c6f8 100644 --- a/src/websocket/device/WsDeviceHub.hpp +++ b/src/websocket/device/WsDeviceHub.hpp @@ -57,7 +57,7 @@ class WsDeviceHub * Add device to the WsDeviceHub. * @param device */ - void adddevice(const std::shared_ptr &device); + void addDevice(const std::shared_ptr &device); /** * Remove device from the WsDeviceHub. diff --git a/src/websocket/device/WsDeviceInstance.cpp b/src/websocket/device/WsDeviceInstance.cpp index b231c8c5..2c6a45c7 100644 --- a/src/websocket/device/WsDeviceInstance.cpp +++ b/src/websocket/device/WsDeviceInstance.cpp @@ -32,8 +32,9 @@ Description: WebSocket Device Instance (each device each instance) #include "WsDeviceInstance.hpp" #include "WsDeviceHub.hpp" -#include "atom/device/device_manager.hpp" +#include "device/device_manager.hpp" #include "atom/server/serialize.hpp" +#include "atom/server/deserialize.hpp" #include "atom/utils/time.hpp" #include "websocket/template/error_message.hpp" @@ -53,16 +54,17 @@ WsDeviceInstance::WsDeviceInstance(const std::shared_ptr &socket m_CommandDispatcher = std::make_unique>(); - LiRegisterFunc("getProperty", &WsDeviceInstance::getProperty); - LiRegisterFunc("setProperty", &WsDeviceInstance::setProperty); - LiRegisterFunc("runTask", &WsDeviceInstance::runTask); - LiRegisterFunc("runFunc", &WsDeviceInstance::runFunc); - LiRegisterFunc("loadDriverLibrary", &WsDeviceInstance::loadDriverLibrary); - LiRegisterFunc("unloadDriverLibrary", &WsDeviceInstance::unloadDriverLibrary); - LiRegisterFunc("addDriver", &WsDeviceInstance::addDriver); - LiRegisterFunc("removeDriver", &WsDeviceInstance::removeDriver); + LiRegisterFunc("getProperty", &WsDeviceInstance::getProperty, this); + LiRegisterFunc("setProperty", &WsDeviceInstance::setProperty, this); + LiRegisterFunc("runTask", &WsDeviceInstance::runTask, this); + LiRegisterFunc("runFunc", &WsDeviceInstance::runFunc, this); + LiRegisterFunc("loadDriverLibrary", &WsDeviceInstance::loadDriverLibrary, this); + LiRegisterFunc("unloadDriverLibrary", &WsDeviceInstance::unloadDriverLibrary, this); + LiRegisterFunc("addDriver", &WsDeviceInstance::addDriver, this); + LiRegisterFunc("removeDriver", &WsDeviceInstance::removeDriver, this); m_SerializationEngine = std::make_unique(); + m_DeserializationEngine = std::make_unique(); } WsDeviceInstance::~WsDeviceInstance() diff --git a/src/websocket/device/WsDeviceInstance.hpp b/src/websocket/device/WsDeviceInstance.hpp index 27e81f98..47c28dc9 100644 --- a/src/websocket/device/WsDeviceInstance.hpp +++ b/src/websocket/device/WsDeviceInstance.hpp @@ -59,6 +59,7 @@ using json = nlohmann::json; class WsDeviceHub; // FWD class SerializationEngine; +class DeserializationEngine; /** * @brief Class representing an instance of a WebSocket device. @@ -206,24 +207,8 @@ class WsDeviceInstance : public oatpp::websocket::AsyncWebSocket::Listener */ CoroutineStarter readMessage(const std::shared_ptr &socket, v_uint8 opcode, p_char8 data, oatpp::v_io_size size) override; -private: - /** - * @brief Buffer for messages. Needed for multi-frame messages. - * - */ - oatpp::data::stream::BufferOutputStream m_messageBuffer; - - /** - * @brief Lock for synchronization of writes to the WebSocket. - * - */ - oatpp::async::Lock m_writeLock; - - std::unique_ptr> m_CommandDispatcher; - - std::unique_ptr m_SerializationEngine; - - /** +public: +/** * @brief Register a function handler for the VCommandDispatcher. * * @tparam ClassType The class type of the handler. @@ -231,11 +216,11 @@ class WsDeviceInstance : public oatpp::websocket::AsyncWebSocket::Listener * @param handler The function handler. */ template - void LiRegisterFunc(const std::string &name, void (T::*memberFunc)(const json &)) + void LiRegisterFunc(const std::string &name, void (T::*memberFunc)(const json &), T *object) { - m_CommandDispatcher->RegisterMemberHandler(name, this, memberFunc); + m_CommandDispatcher->RegisterMemberHandler(name, object, memberFunc); } - + /** * @brief Run a function on the VCommandDispatcher. * @@ -245,6 +230,26 @@ class WsDeviceInstance : public oatpp::websocket::AsyncWebSocket::Listener */ bool LiRunFunc(const std::string &name, const json ¶ms); +private: + + /** + * @brief Buffer for messages. Needed for multi-frame messages. + * + */ + oatpp::data::stream::BufferOutputStream m_messageBuffer; + + /** + * @brief Lock for synchronization of writes to the WebSocket. + * + */ + oatpp::async::Lock m_writeLock; + + std::unique_ptr> m_CommandDispatcher; + + std::unique_ptr m_SerializationEngine; + + std::unique_ptr m_DeserializationEngine; + std::unordered_map DeviceTypeMap = { {"Camera", Lithium::DeviceType::Camera}, {"Telescope", Lithium::DeviceType::Telescope}, diff --git a/src/websocket/device/WsDeviceServer.cpp b/src/websocket/device/WsDeviceServer.cpp index 9ca6bb3f..baf68eac 100644 --- a/src/websocket/device/WsDeviceServer.cpp +++ b/src/websocket/device/WsDeviceServer.cpp @@ -31,6 +31,22 @@ Description: WebSocket Device Server #include "WsDeviceServer.hpp" +WsDeviceServer::WsDeviceServer() : m_userIdCounter(0) +{ + m_device_switch = std::make_unique &, const oatpp::String &, const oatpp::String &>>(); + m_device_switch->registerCase("camera", [this](const std::shared_ptr &socket, const oatpp::String &deviceName, const oatpp::String &deviceHub) + { + auto hub = getOrCreateHub(deviceHub); + auto device = std::make_shared(socket, hub, deviceName, obtainNewUserId()); + socket->setListener(device); + hub->addDevice(device); }); + m_device_switch->registerCase("telescope", [this](const std::shared_ptr &socket, const oatpp::String &deviceName, const oatpp::String &deviceHub) + { + auto hub = getOrCreateHub(deviceHub); + auto device = std::make_shared(socket, hub, deviceName, obtainNewUserId()); + socket->setListener(device); + hub->addDevice(device); }); +} v_int32 WsDeviceServer::obtainNewUserId() { return m_userIdCounter++; @@ -51,13 +67,8 @@ void WsDeviceServer::onAfterCreate_NonBlocking(const std::shared_ptrfind("deviceName")->second; auto deviceHub = params->find("deviceHub")->second; - auto hub = getOrCreateHub(deviceHub); - - auto device = std::make_shared(socket, hub, deviceName, obtainNewUserId()); - socket->setListener(device); - - hub->adddevice(device); - hub->sendMessage(deviceName + " joined " + deviceHub); + auto deviceType = params->find("deviceType")->second; + m_device_switch->match(deviceType, socket, deviceName, deviceHub); } void WsDeviceServer::onBeforeDestroy_NonBlocking(const std::shared_ptr &socket) diff --git a/src/websocket/device/WsDeviceServer.hpp b/src/websocket/device/WsDeviceServer.hpp index d2b125ee..2df96ee7 100644 --- a/src/websocket/device/WsDeviceServer.hpp +++ b/src/websocket/device/WsDeviceServer.hpp @@ -36,6 +36,8 @@ Description: WebSocket Device Server #include "config.h" +#include + #if ENABLE_ASYNC #include "oatpp-websocket/AsyncConnectionHandler.hpp" #else @@ -47,20 +49,17 @@ Description: WebSocket Device Server #else #include #endif -#include +#include "atom/utils/switch.hpp" + +#if ENABLE_ASYNC class WsDeviceServer : public oatpp::websocket::AsyncConnectionHandler::SocketInstanceListener +#else +class WsDeviceServer : public oatpp::websocket::ConnectionHandler::SocketInstanceListener +#endif { public: - std::atomic m_userIdCounter; - std::unordered_map> m_hubs; - std::mutex m_hubsMutex; - -public: - WsDeviceServer() - : m_userIdCounter(0) - { - } + WsDeviceServer(); /** * Generate id for new user @@ -76,15 +75,39 @@ class WsDeviceServer : public oatpp::websocket::AsyncConnectionHandler::SocketIn std::shared_ptr getOrCreateHub(const oatpp::String &hubName); public: +#if ENABLE_ASYNC /** - * Called when socket is created + * @brief Callback function called after creating a new WebSocket connection in non-blocking mode. + * @param socket The newly created WebSocket connection. + * @param params The parameters associated with the connection. */ void onAfterCreate_NonBlocking(const std::shared_ptr &socket, const std::shared_ptr ¶ms) override; /** - * Called before socket instance is destroyed. + * @brief Callback function called before destroying a WebSocket connection in non-blocking mode. + * @param socket The WebSocket connection to be destroyed. */ void onBeforeDestroy_NonBlocking(const std::shared_ptr &socket) override; +#else + /** + * @brief Callback function called after creating a new WebSocket connection. + * @param socket The newly created WebSocket connection. + * @param params The parameters associated with the connection. + */ + void onAfterCreate(const oatpp::websocket::WebSocket &socket, const std::shared_ptr ¶ms) override; + + /** + * @brief Callback function called before destroying a WebSocket connection. + * @param socket The WebSocket connection to be destroyed. + */ + void onBeforeDestroy(const oatpp::websocket::WebSocket &socket) override; +#endif + +public: + std::atomic m_userIdCounter; + std::unordered_map> m_hubs; + std::mutex m_hubsMutex; + std::unique_ptr &, const oatpp::String &, const oatpp::String &>> m_device_switch; }; #endif // WSDEVICESERVER_HPP diff --git a/src/websocket/device/WsTelescopeInstance.cpp b/src/websocket/device/WsTelescopeInstance.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/websocket/device/WsTelescopeInstance.hpp b/src/websocket/device/WsTelescopeInstance.hpp new file mode 100644 index 00000000..e69de29b diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index eb1e8cf6..b97b0737 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -13,11 +13,11 @@ target_link_libraries(json2ini loguru) add_executable(json2xml json2xml.cpp) target_link_libraries(json2xml loguru) -target_link_libraries(json2xml pugixml-static) +target_link_libraries(json2xml pugixml-shared) add_executable(xml2json xml2json.cpp) target_link_libraries(xml2json loguru) -target_link_libraries(xml2json pugixml-static) +target_link_libraries(xml2json pugixml-shared) add_executable(csv2json csv2json.cpp) target_link_libraries(csv2json loguru)