Skip to content

Commit d6344dc

Browse files
author
anlijiu
committed
demo
Signed-off-by: anlijiu <[email protected]>
1 parent 956817d commit d6344dc

File tree

173 files changed

+71557
-20
lines changed

Some content is hidden

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

173 files changed

+71557
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ install_manifest.txt
1010
compile_commands.json
1111
CTestTestfile.cmake
1212
_deps
13+
*.log

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# dds-samples
22
cyclonedds samples
3+
4+
# build cyclonedds
5+
sudo apt install libcunit1-dev libcunit1 libssh-dev
6+
0.8版本编译可能出错, 原因是用到编译过程中生成的idlc ,但是此时的libidl.so 还没到/usr/local/lib , 所以执行会出错, 把build/lib下面的cpy到 /usr/local/lib就可以了

dashboard-demo/.ycm_extra_conf.py

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
from distutils.sysconfig import get_python_inc
2+
import platform
3+
import os.path as p
4+
import subprocess
5+
6+
DIR_OF_THIS_SCRIPT = p.abspath( p.dirname( __file__ ) )
7+
DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
8+
DIR_OF_WATCHDOG_DEPS = p.join( DIR_OF_THIRD_PARTY, 'watchdog_deps' )
9+
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
10+
11+
database = None
12+
13+
# These are the compilation flags that will be used in case there's no
14+
# compilation database set (by default, one is not set).
15+
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
16+
flags = [
17+
'-Wall',
18+
'-Wextra',
19+
'-Werror',
20+
'-Wno-long-long',
21+
'-Wno-variadic-macros',
22+
'-fexceptions',
23+
'-DNDEBUG',
24+
# You 100% do NOT need -DUSE_CLANG_COMPLETER and/or -DYCM_EXPORT in your flags;
25+
# only the YCM source code needs it.
26+
'-DUSE_CLANG_COMPLETER',
27+
'-DYCM_EXPORT=',
28+
'-DYCM_ABSEIL_SUPPORTED',
29+
# THIS IS IMPORTANT! Without the '-x' flag, Clang won't know which language to
30+
# use when compiling headers. So it will guess. Badly. So C++ headers will be
31+
# compiled as C headers. You don't want that so ALWAYS specify the '-x' flag.
32+
# For a C project, you would set this to 'c' instead of 'c++'.
33+
'-x',
34+
'c++',
35+
'-isystem',
36+
'cpp/absl',
37+
'-isystem',
38+
'cpp/pybind11',
39+
'-isystem',
40+
'cpp/whereami',
41+
'-isystem',
42+
'cpp/BoostParts',
43+
'-isystem',
44+
get_python_inc(),
45+
'-isystem',
46+
'cpp/llvm/include',
47+
'-isystem',
48+
'cpp/llvm/tools/clang/include',
49+
'-I',
50+
'cpp/ycm',
51+
'-I',
52+
'cpp/ycm/ClangCompleter',
53+
'-isystem',
54+
'cpp/ycm/tests/gmock/googlemock/include',
55+
'-isystem',
56+
'cpp/ycm/tests/gmock/googletest/include',
57+
'-isystem',
58+
'cpp/ycm/benchmarks/benchmark/include',
59+
'-isystem','/usr/include',
60+
'-isystem','/usr/local/include',
61+
'-isystem','/home/anlijiu/rti_connext_dds-6.1.0/include/ndds/hpp/dds/',
62+
'-isystem','/home/anlijiu/rti_connext_dds-6.1.0/include/ndds/hpp/rti/request/',
63+
'-isystem','/home/anlijiu/rti_connext_dds-6.1.0/include/ndds/hpp/rti/',
64+
'-isystem','/home/anlijiu/rti_connext_dds-6.1.0/include/ndds/hpp',
65+
'-std=c++11',
66+
]
67+
68+
# Set this to the absolute path to the folder (NOT the file!) containing the
69+
# compile_commands.json file to use that instead of 'flags'. See here for
70+
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
71+
#
72+
# You can get CMake to generate this file for you by adding:
73+
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
74+
# to your CMakeLists.txt file.
75+
#
76+
# Most projects will NOT need to set this to anything; you can just change the
77+
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
78+
compilation_database_folder = ''
79+
80+
81+
def IsHeaderFile( filename ):
82+
extension = p.splitext( filename )[ 1 ]
83+
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
84+
85+
86+
def FindCorrespondingSourceFile( filename ):
87+
if IsHeaderFile( filename ):
88+
basename = p.splitext( filename )[ 0 ]
89+
for extension in SOURCE_EXTENSIONS:
90+
replacement_file = basename + extension
91+
if p.exists( replacement_file ):
92+
return replacement_file
93+
return filename
94+
95+
96+
def PathToPythonUsedDuringBuild():
97+
try:
98+
filepath = p.join( DIR_OF_THIS_SCRIPT, 'PYTHON_USED_DURING_BUILDING' )
99+
with open( filepath ) as f:
100+
return f.read().strip()
101+
except OSError:
102+
return None
103+
104+
105+
def Settings( **kwargs ):
106+
# Do NOT import ycm_core at module scope.
107+
import ycm_core
108+
109+
global database
110+
if database is None and p.exists( compilation_database_folder ):
111+
database = ycm_core.CompilationDatabase( compilation_database_folder )
112+
113+
language = kwargs[ 'language' ]
114+
115+
if language == 'cfamily':
116+
# If the file is a header, try to find the corresponding source file and
117+
# retrieve its flags from the compilation database if using one. This is
118+
# necessary since compilation databases don't have entries for header files.
119+
# In addition, use this source file as the translation unit. This makes it
120+
# possible to jump from a declaration in the header file to its definition
121+
# in the corresponding source file.
122+
filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] )
123+
124+
if not database:
125+
return {
126+
'flags': flags,
127+
'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
128+
'override_filename': filename
129+
}
130+
131+
compilation_info = database.GetCompilationInfoForFile( filename )
132+
if not compilation_info.compiler_flags_:
133+
return {}
134+
135+
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
136+
# python list, but a "list-like" StringVec object.
137+
final_flags = list( compilation_info.compiler_flags_ )
138+
139+
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
140+
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
141+
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
142+
try:
143+
final_flags.remove( '-stdlib=libc++' )
144+
except ValueError:
145+
pass
146+
147+
return {
148+
'flags': final_flags,
149+
'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
150+
'override_filename': filename
151+
}
152+
153+
if language == 'python':
154+
return {
155+
'interpreter_path': PathToPythonUsedDuringBuild()
156+
}
157+
158+
return {}
159+
160+
161+
def PythonSysPath( **kwargs ):
162+
sys_path = kwargs[ 'sys_path' ]
163+
164+
interpreter_path = kwargs[ 'interpreter_path' ]
165+
major_version = subprocess.check_output( [
166+
interpreter_path, '-c', 'import sys; print( sys.version_info[ 0 ] )' ]
167+
).rstrip().decode( 'utf8' )
168+
169+
sys_path[ 0:0 ] = [ p.join( DIR_OF_THIS_SCRIPT ),
170+
p.join( DIR_OF_THIRD_PARTY, 'bottle' ),
171+
p.join( DIR_OF_THIRD_PARTY, 'regex-build' ),
172+
p.join( DIR_OF_THIRD_PARTY, 'frozendict' ),
173+
p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'jedi' ),
174+
p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'parso' ),
175+
p.join( DIR_OF_WATCHDOG_DEPS, 'watchdog', 'build', 'lib3' ),
176+
p.join( DIR_OF_WATCHDOG_DEPS, 'pathtools' ),
177+
p.join( DIR_OF_THIRD_PARTY, 'waitress' ) ]
178+
179+
sys_path.append( p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'numpydoc' ) )
180+
return sys_path

dashboard-demo/CMakeLists.txt

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
2+
3+
project(dashboard-demo VERSION 1.0.0)
4+
5+
set(CMAKE_MODULE_PATH
6+
${CMAKE_MODULE_PATH}
7+
"${CMAKE_CURRENT_SOURCE_DIR}/resources/cmake")
8+
9+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -pg")
10+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -pg")
11+
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -O3 -pg")
12+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O3 -pg")
13+
14+
set(api "cpp2")
15+
set(cxx_standard CXX_STANDARD 11)
16+
17+
18+
if(NOT RTIConnextDDS_FOUND)
19+
find_package(RTIConnextDDS
20+
"6.1.0"
21+
REQUIRED
22+
COMPONENTS
23+
core
24+
messaging_api
25+
)
26+
endif()
27+
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")
29+
30+
find_package(soa-types)
31+
# find_library(soa-types NAMES SoaDataTypes)
32+
33+
include_directories(
34+
"src/"
35+
"src/hvac"
36+
${CONNEXTDDS_INCLUDE_DIRS}
37+
)
38+
39+
add_executable(${CMAKE_PROJECT_NAME}
40+
src/libwecan.c
41+
src/main.cpp
42+
src/DataHub.cpp
43+
src/CanMessageDistributor.cpp
44+
src/AbsModule.cpp
45+
src/hvac/HvacModule.cpp
46+
)
47+
48+
target_link_libraries(${CMAKE_PROJECT_NAME}
49+
PRIVATE
50+
soa-types::SoaDataTypes
51+
${_CONNEXT_DEPENDENCIES}
52+
RTIConnextDDS::${api}_api
53+
RTIConnextDDS::messaging_${api}_api
54+
)
55+
56+
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
57+
${CONNEXTDDS_INCLUDE_DIRS}
58+
$<TARGET_PROPERTY:RTIConnextDDS::${api}_api,INTERFACE_INCLUDE_DIRECTORIES>
59+
$<TARGET_PROPERTY:RTIConnextDDS::messaging_${api}_api,INTERFACE_INCLUDE_DIRECTORIES>
60+
)
61+
# $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>
62+
63+
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
64+
$<TARGET_PROPERTY:RTIConnextDDS::${api}_api,INTERFACE_COMPILE_DEFINITIONS>
65+
$<TARGET_PROPERTY:RTIConnextDDS::messaging_${api}_api,INTERFACE_COMPILE_DEFINITIONS>
66+
)
67+
# ${CONNEXTDDS_COMPILE_DEFINITIONS}
68+
69+
70+
# Install target
71+
install(TARGETS ${CMAKE_PROJECT_NAME}
72+
EXPORT "${TARGETS_EXPORT_NAME}"
73+
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
74+
)

0 commit comments

Comments
 (0)