Commit 619b0959 authored by paopao's avatar paopao

添加库

parent 003ba89e
......@@ -5,6 +5,15 @@ set(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS ON)
list (APPEND CMAKE_MODULE_PATH "$ENV{HT_BUILDSYS_CMAKE_MODULES}")
include (HtCMakePub)
# Import git dependencies.
import_git_modules (
REPOSITORIES "3rdparty/libmosquitto"
"3rdparty/libprotobuf"
)
execute_process(COMMAND ${CMAKE_C_COMPILER} -march=native -Q -v
OUTPUT_VARIABLE COMPILER_INFO
ERROR_VARIABLE COMPILER_INFO)
......@@ -30,6 +39,24 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/mqtt SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/modbus SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/uart SRCS)
add_executable(${PROJECT_NAME} ${SRCS})
install (TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
add_git_dependencies (
TARGET ${PROJECT_NAME}
REPOSITORIES "3rdparty/libmosquitto"
)
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
......@@ -37,5 +64,40 @@ PRIVATE
target_link_libraries(${PROJECT_NAME}
${Coin_LIBRARIES}
pthread
mosquitto
)
install (TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
set(MAJOR_VERSION 1)
set(MINOR_VERSION 0)
set(PATCH_VERSION 1)
set (CPACK_PACKAGE_NAME "ht-${PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set (CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set (CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set (CPACK_PACKAGE_CONTACT "Li Songpo <songpo.li@waytous.com>")
if (TARGET_DISTRO_TYPE STREQUAL "debian_based")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION "Hello world. Branch: ${GIT_BRANCH}. Commit: ${GIT_LAST_COMMIT}.")
file (GLOB_RECURSE PACKAGE_EXTRAS
"${CMAKE_CURRENT_SOURCE_DIR}/debian_package/*"
)
add_deb_control_extra (
FILES "${PACKAGE_EXTRAS}")
endif ()
add_deb_dependencies(
PACKAGES "ht-3rdparty-libmosquitto"
"ht-3rdparty-libprotobuf"
)
include(HtCPack)
\ No newline at end of file
{
"files.associations": {
"array": "cpp",
"bitset": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"utility": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"deque": "cpp",
"map": "cpp",
"queue": "cpp",
"stack": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"chrono": "cpp",
"any": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"forward_list": "cpp",
"list": "cpp",
"set": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"fstream": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
}
}
\ No newline at end of file
libmosquitto.so.1
\ No newline at end of file
libmosquitto.so.1
\ No newline at end of file
# traffic_light_control
## 0.deps
```sh
sudo apt install libprotobuf-dev protobuf-compiler
sudo apt install libmosquitto-dev
```
## 1.compile
```sh
mkdir build
cd build
cmake ..
make -j7
```
## 2.exec
```sh
cd build
./traffic_light_control ../test/config.json
```
## 3.config.json
```sh
"mqtt_server_ip": "192.168.9.30", //mqtt 服务器ip地址
"mqtt_server_port": 1883, //mqtt 服务器端口号
"mqtt_server_user": "test", //mqtt 用户名
"mqtt_server_pwd": "test", //mqtt 密码
"hdmap_topic": "/mqtt_msg_data_trans_traffic_light_layer", //订阅高精地图数据的topic
"traffic_control_topic": "/USR-M100/Control/Traffic", //下发给继电器的控制topic
"expand_size": 5, //继电器拓展的板个数
"offset_do_addr": 2, //继电器实际接线的偏移量
"lights":
[
//id: 地图给的值 do_addrs->colors: [对应到继电器的接口编号]
{"name": "light1", "id": 1, "type": "left", "do_addrs":[5, 6, 7], "colors":["red", "yellow", "green"]},
{"name": "light2", "id": 2, "type": "up", "do_addrs":[2, 3, 4], "colors":["red", "yellow", "green"]},
{"name": "light3", "id": 3, "type": "right", "do_addrs":[8, 9, 34], "colors":["red", "yellow", "green"]},
{"name": "light4", "id": 4, "type": "left", "do_addrs":[13, 14, 15], "colors":["red", "yellow", "green"]},
{"name": "light5", "id": 5, "type": "up", "do_addrs":[10, 11, 12], "colors":["red", "yellow", "green"]},
{"name": "light6", "id": 6, "type": "right", "do_addrs":[16, 17, 35], "colors":["red", "yellow", "green"]},
{"name": "light7", "id": 7, "type": "left", "do_addrs":[21, 22, 23], "colors":["red", "yellow", "green"]},
{"name": "light8", "id": 8, "type": "up", "do_addrs":[18, 19, 20], "colors":["red", "yellow", "green"]},
{"name": "light9", "id": 9, "type": "right", "do_addrs":[24, 25, 36], "colors":["red", "yellow", "green"]},
{"name": "light10", "id": 10, "type": "left", "do_addrs":[29, 30, 31], "colors":["red", "yellow", "green"]},
{"name": "light11", "id": 11, "type": "up", "do_addrs":[26, 27, 28], "colors":["red", "yellow", "green"]},
{"name": "light12", "id": 12, "type": "right", "do_addrs":[32, 33, 37], "colors":["red", "yellow", "green"]}
],
"modes":
[
{
"id": 0, //模式id
"lights": //12个灯的状态
[
{"id": 1, "color": "red"},
{"id": 2, "color": "green"},
{"id": 3, "color": "yellow"},
{"id": 4, "color": "black"},
{"id": 5, "color": "unkown"},
{"id": 6, "color": "green"},
{"id": 7, "color": "green"},
{"id": 8, "color": "green"},
{"id": 9, "color": "green"},
{"id": 10, "color": "green"},
{"id": 11, "color": "green"},
{"id": 12, "color": "green"}
]
},
{
"id": 1,
"lights":
[
{"id": 1, "color": "red"},
{"id": 2, "color": "green"},
{"id": 3, "color": "green"},
{"id": 4, "color": "green"},
{"id": 5, "color": "green"},
{"id": 6, "color": "green"},
{"id": 7, "color": "green"},
{"id": 8, "color": "green"},
{"id": 9, "color": "green"},
{"id": 10, "color": "green"},
{"id": 11, "color": "green"},
{"id": 12, "color": "green"}
]
}
]
```
\ No newline at end of file
libmosquitto.so.1
\ No newline at end of file
libmosquitto.so.1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment