Skip to content

Commit

Permalink
Merged development repository to public.
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Sobel committed Aug 12, 2020
1 parent 7e006ac commit e8f90e2
Show file tree
Hide file tree
Showing 113 changed files with 71,728 additions and 2,626 deletions.
8 changes: 8 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Checks: '-*,modernize-*,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-branch-clone'
WarningsAsErrors: '*'
HeaderFilterRegex: '/src/.*\.hpp$'
AnalyzeTemporaryDtors: false
FormatStyle: File
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: 1
16 changes: 0 additions & 16 deletions .gitmodules

This file was deleted.

25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# The version number.
set(AGENT_VERSION_MAJOR 1)
set(AGENT_VERSION_MINOR 5)
set(AGENT_VERSION_MINOR 6)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 14)
set(AGENT_VERSION_BUILD 7)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2017 and C++ feature checking
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
# This minimum version is to support Visual Studio 2017 and C++ feature checking and FetchContent
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

option(AGENT_ENABLE_UNITTESTS "Enables the agent's unit tests" ON)
set(INSTALL_GTEST OFF FORCE)

project(cppagent)
project(cppagent LANGUAGES C CXX)

# All of the C++ Agent code, DLib require C++ 14 features to compile.
# We will define these properties by default for each CMake target to be created.
set_property(GLOBAL PROPERTY CXX_STANDARD 14)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# By default only generate 2 configurations (Debug and Release) for simplicity.
# The user can change this option if required for the additional ones such as 'RelWithDebInfo'.
Expand Down Expand Up @@ -53,11 +58,10 @@ if(MSVC)
set(WINVER "0x0600" CACHE STRING "Windows Target Version: 0x0400 - 95 & NT 4.0, 0x0500 - 2000, 0x0501 - XP, 0x0600 - Vista, 0x0601 - 7, 0x0602 - 8")
endif()

include(cmake/msvc_xp_support.cmake)
include(cmake/msvc_use_static_runtime.cmake)
include(cmake/vs_set_working_directory.cmake)
include(cmake/osx_no_app_or_frameworks.cmake)
include(cmake/ClangFormat.cmake)
include(cmake/ClangTidy.cmake)

# Add our dependency projects
include(cmake/LibXML2.cmake)
Expand All @@ -73,6 +77,8 @@ if(AGENT_ENABLE_UNITTESTS)
add_subdirectory(test)
endif()

include(cmake/ide_integration.cmake)

# For Visual Studio generators it is now possible (since V3.6) to set a default startup project.
# We will set this to the agent_test project.
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT agent_test)
Expand All @@ -93,3 +99,4 @@ set(CPACK_PACKAGE_NAME "cppagent")
set(CPACK_PACKAGE_VENDOR "MTConnect.org")

include(CPack)

18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

MTConnect C++ Agent Version 1.5.0.0
MTConnect C++ Agent Version 1.6.0.0
--------
[![Build status](https://ci.appveyor.com/api/projects/status/g4xdyitw7h41rl48/branch/master?svg=true)](https://ci.appveyor.com/project/WilliamSobel/cppagent/branch/master)
[![Build status](https://ci.appveyor.com/api/projects/status/8ijbprd7rtwohv7c?svg=true)](https://ci.appveyor.com/project/WilliamSobel/cppagent-dev)

The C++ Agent provides the a complete implementation of the HTTP
server required by the MTConnect standard. The agent provides the
Expand All @@ -11,6 +11,8 @@ the devices and the location of the adapter.

Pre-built binary releases for Windows are available from [Releases](https://github.com/mtconnect/cppagent/releases) for those who do not want to build the agent themselves. For *NIX users, you will need libxml2, cppunit, and cmake as well as build essentials.

Version 1.6.0.0 added coordinate systems, specifications, and tabular data.

Version 1.5.0.0 added Data Set capabilities and has been updated to use C++ 14.

Version 1.4.0.0 added time period filter constraint, compositions, initial values, and reset triggers.
Expand Down Expand Up @@ -823,6 +825,18 @@ And the streams will only have the one value when a sample is request is made at

When the `discrete` flag is set to `true` in the data item, all change tracking is ignored and each set is treated as if it is new.

One can quote values using the following methods: `"<text>"`, `'<text>'`, and `{<text>}`. Spaces and other characters can be included in the text and the matching character can be escaped with a `\` if it is required as follows: `"hello \"there\""` will yield the value: `hellow "there"`.

### `TABLE` Representation ###

A `TABLE` representation is similar to the `DATA_SET` that has a key value pair as the value. Using the encoding mentioned above, the following representations are allowed for tables:

<timestamp>|wpo|G53.1={X=1.0 Y=2.0 Z=3.0 s='string with space'} G53.2={X=4.0 Y=5.0 Z=6.0} G53.3={X=7.0 Y=8.0 Z=9 U=10.0}

Using the quoting conventions explained in the previous section, the inner content can contain quoted text and exscaped values. The value is interpreted as a key/value pair in the same way as the `DATA_SET`. A table can be thought of as a data set of data sets.

All the reset rules of data set apply to tables and the values are treated as a unit.

Assets
-----

Expand Down
46 changes: 11 additions & 35 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
set(AGENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
set(AGENT_SOURCES cppagent.cpp)

if(WIN32)
# Version info
string(TIMESTAMP AGENT_VERSION_TIME "%Y-%m-%dT%H:%M:%SZ" UTC)
set(RESOURCE_FILE "${PROJECT_BINARY_DIR}/agent/version.rc")
configure_file("${AGENT_SOURCE_DIR}/version.rc.in" "${RESOURCE_FILE}")

set(WINDOWS_LIBRARIES shlwapi)
else()
set(RESOURCE_FILE "")
endif()

if(UNIX AND NOT APPLE)
set(LINUX_LIBRARIES pthread)
configure_file("${CMAKE_CURRENT_LIST_DIR}/../src/version.rc.in" "${RESOURCE_FILE}")
list(APPEND AGENT_SOURCES "${RESOURCE_FILE}")
endif()

file(GLOB AGENT_SRCS *.cpp)

# Allow better viewing and grouping of files in Visual Studio by defining source groups
source_group("Headers Files" FILES ${AGENT_HEADERS})
source_group("Source Files" FILES ${AGENT_SRCS})
source_group("Dlib Source Files" FILES ${DLIB_FIX_SRCS})
source_group("Resource Files" FILES ${RESOURCE_FILE})

add_executable(agent ${AGENT_SRCS} ${DLIB_FIX_SRCS} ${AGENT_HEADERS} ${RESOURCE_FILE})

AddMsvcXPSupport(agent)
AddLibXML2Support(agent)
AddDLibSupport(agent)
AddDateSupport(agent)
AddJsonSupport(agent)

target_include_directories(agent PRIVATE "${AGENT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/agent")
target_link_libraries(agent PRIVATE agent_lib PRIVATE ${LINUX_LIBRARIES} ${WINDOWS_LIBRARIES})

if (MSVC)
add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}" "/DLIBXML_STATIC")
endif()
add_executable(agent ${AGENT_SOURCES})
target_link_libraries(
agent
PRIVATE
agent_lib
$<$<PLATFORM_ID:Windows>:shlwapi>
)
target_clangtidy_setup(agent_lib)

install(TARGETS agent RUNTIME DESTINATION bin)
add_dependencies(agent UPDATE_VERSION)

target_compile_features(agent PRIVATE cxx_std_14)
116 changes: 79 additions & 37 deletions agent_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,85 @@
set(AGENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
set(AGENT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../src/adapter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/adapter.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/agent.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/agent.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/asset.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/asset.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/change_observer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/change_observer.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/checkpoint.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/checkpoint.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/component_configuration.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/component.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/component.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/composition.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/config.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/config.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/connector.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/connector.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/coordinate_systems.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/cutting_tool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/cutting_tool.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/data_item.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/data_item.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/definitions.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/device.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/device.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/globals.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/globals.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/json_printer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/json_printer.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/observation.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/observation.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/options.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/options.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/printer.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/ref_counted.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/relationships.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/rolling_file_logger.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/rolling_file_logger.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/sensor_configuration.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/service.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/service.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/specifications.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/version.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/xml_parser.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/xml_parser.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/xml_printer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/xml_printer.hpp"
)

if(UNIX AND NOT APPLE)
set(LINUX_LIBRARIES pthread)
endif()

file(GLOB AGENT_SRCS "${AGENT_SOURCE_DIR}/*.cpp")
file(GLOB AGENT_HEADERS "${AGENT_SOURCE_DIR}/*.hpp")

# configure a header file to pass some of the CMake settings to the source code
## configure a header file to pass some of the CMake settings to the source code
add_custom_target(UPDATE_VERSION ALL
COMMAND ${CMAKE_COMMAND} -E touch_nocreate "${AGENT_SOURCE_DIR}/version.cpp")

configure_file("${AGENT_SOURCE_DIR}/version.h.in" "${PROJECT_BINARY_DIR}/agent_lib/version.h")

# Allow better viewing and grouping of files in Visual Studio by defining source groups
source_group("Headers Files" FILES ${AGENT_HEADERS})
source_group("Source Files" FILES ${AGENT_SRCS})
source_group("Dlib Source Files" FILES ${DLIB_FIX_SRCS})

add_library(agent_lib ${AGENT_SRCS} ${DLIB_FIX_SRCS} ${AGENT_HEADERS})

AddMsvcXPSupport(agent_lib)
AddLibXML2Support(agent_lib)
AddDLibSupport(agent_lib)
AddDateSupport(agent_lib)
AddJsonSupport(agent_lib)

target_include_directories(agent_lib
PRIVATE "${PROJECT_BINARY_DIR}/agent_lib"
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../src")

target_compile_definitions(agent_lib PRIVATE NOMINMAX)

if (MSVC)
add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}" "/DLIBXML_STATIC")
endif()
COMMAND ${CMAKE_COMMAND} -E touch_nocreate "${CMAKE_CURRENT_SOURCE_DIR}/../src/version.cpp")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../src/version.h.in" "${PROJECT_BINARY_DIR}/agent_lib/version.h")

add_library(agent_lib STATIC ${AGENT_SOURCES})
add_dependencies(agent_lib UPDATE_VERSION)
target_include_directories(
agent_lib
PUBLIC
"${PROJECT_BINARY_DIR}/agent_lib"
"${CMAKE_CURRENT_LIST_DIR}/../src"
)
target_link_libraries(
agent_lib
PUBLIC
dlib::dlib
date
json
LibXml2::LibXml2
$<$<PLATFORM_ID:Linux>:pthread>
)
target_compile_definitions(
agent_lib
PUBLIC
$<$<PLATFORM_ID:Windows>:NOMINMAX>
$<$<PLATFORM_ID:Windows>:WINVER=${WINVER}>
$<$<PLATFORM_ID:Windows>:_WIN32_WINNT=${WINVER}>
)

target_compile_features(agent_lib PRIVATE cxx_std_14)

# set_property(SOURCE ${AGENT_SOURCES} PROPERTY COMPILE_FLAGS_DEBUG "${COVERAGE_FLAGS}")
target_compile_features(agent_lib PUBLIC cxx_std_14)
target_clangformat_setup(agent_lib)
target_clangtidy_setup(agent_lib)
23 changes: 9 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ image:
- Visual Studio 2017

configuration:
- Debug
#- Release
- Release

platform:
- x86
Expand All @@ -31,23 +30,20 @@ init:
echo %APPVEYOR_BUILD_WORKER_IMAGE%
if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017%arch%" )
echo %generator%
- sh: sudo apt-get update
- sh: sudo apt-get --yes install libxml2-dev
echo %MSBUILD_FLAGS%
# - sh: sudo apt-get update
# - sh: sudo apt-get --yes install libxml2-dev

before_build:
- cmd: |-
git submodule init
git submodule update
mkdir build
cd build
cmake --version
cmake .. -DAPPVEYOR=ON -DAGENT_ENABLE_UNITTESTS=ON -G %generator%
- sh: git submodule init
- sh: git submodule update
cmake .. -DAGENT_ENABLE_UNITTESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON -G %generator%
- sh: mkdir build
- sh: cd build
- sh: cmake --version
- sh: cmake ..
- sh: cmake .. -DAGENT_ENABLE_UNITTESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON


build:
Expand All @@ -58,13 +54,13 @@ build:
build_script:
- cmd: |-
cd %APPVEYOR_BUILD_FOLDER%\build
cmake --build . --config Debug --target ALL_BUILD -- %MSBUILD_FLAGS%
cmake --build . --config Release --target ALL_BUILD -- %MSBUILD_FLAGS%
- sh: |-
cd ${APPVEYOR_BUILD_FOLDER}/build
cmake --build . --config Debug --target all -- -j 4
cmake --build . --config Release --target all -- -j4
test_script:
- cmd: ctest -C Debug --output-on-failure
- cmd: ctest -C Release --output-on-failure
- sh: ctest


Expand All @@ -76,6 +72,5 @@ only_commits:
- test/
- cmake/
- dlib_fix/
- cppunit_make/
- libxml2_make/
- agent/
21 changes: 21 additions & 0 deletions cmake/ClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include_guard()

option(AGENT_ENABLE_CLANGTIDY "Runs clang-tidy on all source files" OFF)

find_program(
CLANG_TIDY_EXECUTABLE
NAMES clang-tidy-10 clang-tidy-9 clang-tidy-8 clang-tidy-7 clang-tidy-6.0 clang-tidy-5.0 clang-tidy-4.0 clang-tidy
DOC "Path to clang-tidy executable"
)

function(target_clangtidy_setup _target)
if(AGENT_ENABLE_CLANGTIDY)
if(CLANG_TIDY_EXECUTABLE)
set_target_properties(
${_target} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}"
)
else()
message(FATAL_ERROR "Could not find clang-tidy")
endif()
endif()
endfunction()
Loading

0 comments on commit e8f90e2

Please sign in to comment.