Browse Source

支持PC版本编译

storage-in-realtime
zhaohe 12 months ago
parent
commit
abeda71ea6
  1. 10
      CMakeLists.txt
  2. 1
      appdep/libs/libixwebsocket/README.md
  3. 0
      appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-config.cmake
  4. 0
      appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake
  5. 0
      appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets.cmake
  6. 0
      appdep/libs/libixwebsocket/aarch64/libixwebsocket.a
  7. 9
      appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-config.cmake
  8. 19
      appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake
  9. 102
      appdep/libs/libixwebsocket/amd64/cmake/ixwebsocket/ixwebsocket-targets.cmake
  10. BIN
      appdep/libs/libixwebsocket/amd64/libixwebsocket.a
  11. 45
      appsrc/service/iflytop_front_end_service/iflytop_front_end_service.cpp
  12. 20
      appsrc/service/iflytop_front_end_service/iflytop_front_end_service.hpp
  13. 13
      appsrc/service/iflytop_front_end_service/protocol.md
  14. 3
      build.sh
  15. 19
      buildpc.sh

10
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/)

1
appdep/libs/libixwebsocket/README.md

@ -0,0 +1 @@
[](http://192.168.1.3:3000/z3rd_lib/IXWebSocket/src/branch/master/docs/usage.md)

0
appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-config.cmake → appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-config.cmake

0
appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake → appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake

0
appdep/libs/libixwebsocket/lib/cmake/ixwebsocket/ixwebsocket-targets.cmake → appdep/libs/libixwebsocket/aarch64/cmake/ixwebsocket/ixwebsocket-targets.cmake

0
appdep/libs/libixwebsocket/lib/libixwebsocket.a → appdep/libs/libixwebsocket/aarch64/libixwebsocket.a

9
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")

19
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)

102
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 "\$<LINK_ONLY:ZLIB::ZLIB>;\$<LINK_ONLY:Threads::Threads>"
)
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)

BIN
appdep/libs/libixwebsocket/amd64/libixwebsocket.a

45
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> webSocket, shared_ptr<ConnectionState> 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> webSocket, shared_ptr<ConnectionState> connectionState) {
m_reportServer.reset(new WebSocketServer(19002, ip));
m_reportServer->setOnConnectionCallback([this](weak_ptr<WebSocket> webSocket, shared_ptr<ConnectionState> 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<milliseconds>(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> 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> 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> webSocket, string rxmsg) {
// if (msg->binary) {
// logger->warn("receive binary message,ignore");
// return;
// }
string msgtext = rxmsg;
json message;

20
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<IflytopFrontEndSer
public:
// nod::signal<void(weak_ptr<WebSocket> webSocket, const ix::WebSocketMessagePtr& msg)> onMessage;
nod::signal<void(weak_ptr<WebSocket> webSocket)> onConnect;
nod::signal<void(weak_ptr<WebSocket> webSocket)> onDisconnect;
nod::signal<void(weak_ptr<WebSocket> webSocket)> onConnect;
nod::signal<void(weak_ptr<WebSocket> webSocket)> onDisconnect;
nod::signal<void(weak_ptr<WebSocket> webSocket, json& cmd, json& receipt)> onMessage;
nod::signal<void(struct sockaddr_in* from, char* data, size_t len)> onUdpCmdMessage;
unique_ptr<WorkQueue> m_work_queue;
private:
//
// WebSocketServer的使用参考:http://192.168.1.3:3000/z3rd_lib/IXWebSocket/src/branch/master/docs/usage.md
//
shared_ptr<ix::WebSocketServer> m_server;
shared_ptr<ix::WebSocketServer> m_report_server;
shared_ptr<ix::WebSocketServer> m_reportServer;
unique_ptr<WorkQueue> 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> webSocket, shared_ptr<ConnectionState> connectionState, const ix::WebSocketMessagePtr& msg);
void processRxMessage(weak_ptr<WebSocket> webSocket, string rxmsg);

13
appsrc/service/iflytop_front_end_service/protocol.md

@ -0,0 +1,13 @@
```
cmd:
messageId
timeStamp
className:""
fnName:""
param:{
}
```

3
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

19
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
Loading…
Cancel
Save