diff --git a/CMakeLists.txt b/CMakeLists.txt index 7132f62..5964392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") message("PROJECT_NAME: ${PROJECT_NAME}") +message("ARCH: ${ARCH}") + + file( GLOB_RECURSE @@ -79,20 +82,17 @@ zadd_executable( appdep/ app_protocols/ ./ - appdep/libs/libixwebsocket/include - # # LINK_LIBRARIES # LINK_LIBRARIES pthread ixwebsocket - + z # # LINK_DIRECTORIES # LINK_DIRECTORIES # - appdep/libs/libixwebsocket/lib/ -) + appdep/libs/libixwebsocket/amd64/) diff --git a/appdep/libs/libixwebsocket/README.md b/appdep/libs/libixwebsocket/README.md new file mode 100644 index 0000000..fce9057 --- /dev/null +++ b/appdep/libs/libixwebsocket/README.md @@ -0,0 +1 @@ +[](http://192.168.1.3:3000/z3rd_lib/IXWebSocket/src/branch/master/docs/usage.md) \ No newline at end of file diff --git a/appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-config.cmake b/appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-config.cmake similarity index 100% rename from appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-config.cmake rename to appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-config.cmake diff --git a/appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake b/appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake similarity index 100% rename from appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake rename to appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake diff --git a/appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets.cmake b/appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets.cmake similarity index 100% rename from appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets.cmake rename to appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets.cmake diff --git a/appdep/libs/libixwebsocket/lib/libixwebsocket.a b/appdep/libs/libixwebsocket/aarch64/libixwebsocket.a similarity index 100% rename from appdep/libs/libixwebsocket/lib/libixwebsocket.a rename to appdep/libs/libixwebsocket/aarch64/libixwebsocket.a diff --git a/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-config.cmake b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-config.cmake new file mode 100644 index 0000000..43cba58 --- /dev/null +++ b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-config.cmake @@ -0,0 +1,9 @@ + + +include(CMakeFindDependencyMacro) + +if (ON) + find_dependency(ZLIB) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/ixwebsocket-targets.cmake") diff --git a/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake new file mode 100644 index 0000000..81c46a7 --- /dev/null +++ b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "ixwebsocket::ixwebsocket" for configuration "" +set_property(TARGET ixwebsocket::ixwebsocket APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(ixwebsocket::ixwebsocket PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/./ixwebsocket/lib/libixwebsocket.a" + ) + +list(APPEND _IMPORT_CHECK_TARGETS ixwebsocket::ixwebsocket ) +list(APPEND _IMPORT_CHECK_FILES_FOR_ixwebsocket::ixwebsocket "${_IMPORT_PREFIX}/./ixwebsocket/lib/libixwebsocket.a" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets.cmake b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets.cmake new file mode 100644 index 0000000..c7d2816 --- /dev/null +++ b/appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets.cmake @@ -0,0 +1,102 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget ixwebsocket::ixwebsocket) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target ixwebsocket::ixwebsocket +add_library(ixwebsocket::ixwebsocket STATIC IMPORTED) + +set_target_properties(ixwebsocket::ixwebsocket PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "IXWEBSOCKET_USE_ZLIB" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/./ixwebsocket/include/ixwebsocket" + INTERFACE_LINK_LIBRARIES "\$;\$" +) + +if(CMAKE_VERSION VERSION_LESS 2.8.12) + message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") +endif() + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/ixwebsocket-targets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/appdep/libs/libixwebsocket/amd64/libixwebsocket.a b/appdep/libs/libixwebsocket/amd64/libixwebsocket.a new file mode 100644 index 0000000..3de850c Binary files /dev/null and b/appdep/libs/libixwebsocket/amd64/libixwebsocket.a differ diff --git a/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.cpp b/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.cpp index 081fe91..e0b182a 100644 --- a/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.cpp +++ b/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.cpp @@ -9,8 +9,8 @@ void IflytopFrontEndService::initialize(string ip) { logger->info("IflytopFrontEndService initialize {}:{}", ip, 19001); logger->info("IflytopFrontEndService initialize {}:{}", ip, 19002); - m_work_queue.reset(new WorkQueue("IflytopFrontEndService-WQ")); - m_work_queue->startWork(); + m_workQueue.reset(new WorkQueue("IflytopFrontEndService-WQ")); + m_workQueue->startWork(); m_server.reset(new WebSocketServer(19001, ip)); m_server->setOnConnectionCallback([this](weak_ptr webSocket, shared_ptr connectionState) { @@ -27,8 +27,8 @@ void IflytopFrontEndService::initialize(string ip) { }); }); - m_report_server.reset(new WebSocketServer(19002, ip)); - m_report_server->setOnConnectionCallback([this](weak_ptr webSocket, shared_ptr connectionState) { + m_reportServer.reset(new WebSocketServer(19002, ip)); + m_reportServer->setOnConnectionCallback([this](weak_ptr webSocket, shared_ptr connectionState) { logger->info("Remote ip: {}", connectionState->getRemoteIp()); auto ws = webSocket.lock(); if (!ws) return; @@ -44,38 +44,20 @@ void IflytopFrontEndService::startListen() { return; } - if (!m_report_server->listen().first) { + if (!m_reportServer->listen().first) { logger->error("listen error!!!!"); return; } m_server->disablePerMessageDeflate(); m_server->start(); - // m_server->wait(); - m_report_server->disablePerMessageDeflate(); - m_report_server->start(); + m_reportServer->disablePerMessageDeflate(); + m_reportServer->start(); logger->info("IflytopFrontEndService startListen"); } -// void IflytopFrontEndService::sendMessage(const string& message) { -// if (!m_initialized) { -// logger->error("IflytopFrontEndService not initialized"); -// return; -// } -// /** -// * @brief 广播消息给所有连接的客户端 -// */ -// logger->debug("uplink msg: {}", message); -// auto clients = m_server->getClients(); -// for (auto& each : clients) { -// if (each) { -// each->sendText(message); -// } -// } -// } - void IflytopFrontEndService::sendReport(json& report) { if (!m_initialized) { logger->error("IflytopFrontEndService not initialized"); @@ -88,7 +70,7 @@ void IflytopFrontEndService::sendReport(json& report) { report["timeStamp"] = duration_cast(system_clock::now().time_since_epoch()).count(); logger->debug("uplink msg: {}", report.dump()); - auto clients = m_report_server->getClients(); + auto clients = m_reportServer->getClients(); for (auto& each : clients) { if (each) { each->sendText(report.dump()); @@ -106,12 +88,12 @@ void IflytopFrontEndService::onMessageCallback(weak_ptr webSocket, sh logger->info(" {}: {}", it.first, it.second); } - m_work_queue->enQueue([this, webSocket]() { onConnect(webSocket); }); + m_workQueue->enQueue([this, webSocket]() { onConnect(webSocket); }); } else if (msg->type == ix::WebSocketMessageType::Message) { logger->debug("downlink msg: {}", msg->str); string msgtext = msg->str; - m_work_queue->enQueue([this, webSocket, msgtext]() { + m_workQueue->enQueue([this, webSocket, msgtext]() { try { processRxMessage(webSocket, msgtext); } catch (const std::exception& e) { @@ -121,15 +103,10 @@ void IflytopFrontEndService::onMessageCallback(weak_ptr webSocket, sh } else if (msg->type == ix::WebSocketMessageType::Close) { logger->info("{} Closed connection", msg->closeInfo.remote); - m_work_queue->enQueue([this, webSocket]() { onDisconnect(webSocket); }); + m_workQueue->enQueue([this, webSocket]() { onDisconnect(webSocket); }); } } void IflytopFrontEndService::processRxMessage(weak_ptr webSocket, string rxmsg) { - // if (msg->binary) { - // logger->warn("receive binary message,ignore"); - // return; - // } - string msgtext = rxmsg; json message; diff --git a/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.hpp b/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.hpp index e2e92da..2dd311d 100644 --- a/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.hpp +++ b/appsrc/service/iflytop_front_end_service/iflytop_front_end_service.hpp @@ -21,11 +21,6 @@ * * service: IflytopHardwareWSService * - * 协议文档 - * https://iflytop1.feishu.cn/docx/XCeWddMyzoktUdx6EeMcOV5HnAb - * 端口号 - * 19001 - * 参考https://iflytop1.feishu.cn/wiki/wikcnukbr3vOdBfrNdnVXX8YkLg */ namespace iflytop { @@ -40,31 +35,24 @@ class IflytopFrontEndService : public enable_shared_from_this webSocket, const ix::WebSocketMessagePtr& msg)> onMessage; - nod::signal webSocket)> onConnect; - nod::signal webSocket)> onDisconnect; - + nod::signal webSocket)> onConnect; + nod::signal webSocket)> onDisconnect; nod::signal webSocket, json& cmd, json& receipt)> onMessage; - nod::signal onUdpCmdMessage; - - unique_ptr m_work_queue; - private: // // WebSocketServer的使用参考:http://192.168.1.3:3000/z3rd_lib/IXWebSocket/src/branch/master/docs/usage.md // shared_ptr m_server; - shared_ptr m_report_server; + shared_ptr m_reportServer; + unique_ptr m_workQueue; bool m_initialized = false; public: void initialize(string ip = "0.0.0.0"); void startListen(); - - // void sendMessage(const string& message); void sendReport(json& report); - private: void onMessageCallback(weak_ptr webSocket, shared_ptr connectionState, const ix::WebSocketMessagePtr& msg); void processRxMessage(weak_ptr webSocket, string rxmsg); diff --git a/appsrc/service/iflytop_front_end_service/protocol.md b/appsrc/service/iflytop_front_end_service/protocol.md new file mode 100644 index 0000000..072360c --- /dev/null +++ b/appsrc/service/iflytop_front_end_service/protocol.md @@ -0,0 +1,13 @@ +``` +cmd: + +messageId +timeStamp + +className:"" +fnName:"" +param:{ +} + + +``` \ No newline at end of file diff --git a/build.sh b/build.sh index 9b4c90a..2626bfe 100755 --- a/build.sh +++ b/build.sh @@ -8,12 +8,13 @@ # PROJECT_TYPE_PIPE_DISINFECTION # PROJECT_TYPE_DRAW_BAR_BOX # - +rm -rf build mkdir -p build cd build cmake .. \ -DCMAKE_C_COMPILER='aarch64-linux-gnu-gcc' \ -DCMAKE_CXX_COMPILER='aarch64-linux-gnu-g++' \ + -DARCH=aarch64 \ make -j8 make install \ No newline at end of file diff --git a/buildpc.sh b/buildpc.sh new file mode 100755 index 0000000..910c854 --- /dev/null +++ b/buildpc.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# +# ./build.sh +# +# PROJECT_TYPE_LARGE_SPACE_DISINFECTION +# PROJECT_TYPE_SMALL_SPACE_DISINFECTION +# PROJECT_TYPE_PIPE_DISINFECTION +# PROJECT_TYPE_DRAW_BAR_BOX +# + +rm -rf build +mkdir -p build +cd build +cmake .. \ + -DARCH=amd64 \ + +make -j8 +make install \ No newline at end of file