Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acc diagram #558

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
cmake-build-*/
.idea/

build*/
*~
*#
Expand Down
298 changes: 150 additions & 148 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@
# full license information.
#*******************************************************************/

cmake_minimum_required (VERSION 3.14)
cmake_minimum_required(VERSION 3.14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools")
project (PROFINET VERSION 0.2.0)
project(PROFINET VERSION 0.2.0)

# Default settings if this is the main project
if (CMAKE_PROJECT_NAME STREQUAL PROFINET)
include(CTest)

# Make option visible in ccmake, cmake-gui
option (BUILD_SHARED_LIBS "Build shared library" OFF)

# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)

# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${PROFINET_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()

message(STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
endif()
include(CTest)

# Make option visible in ccmake, cmake-gui
option(BUILD_SHARED_LIBS "Build shared library" OFF)

# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)

# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${PROFINET_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif ()

message(STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for ${CMAKE_SYSTEM_NAME}")
endif ()

include(AddOsal)
include(GenerateExportHeader)
Expand All @@ -54,61 +54,61 @@ set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

# Options. See options.h.in for more information.

option (PNET_OPTION_FAST_STARTUP "" ON)
option (PNET_OPTION_PARAMETER_SERVER "" ON)
option (PNET_OPTION_IR "" ON)
option (PNET_OPTION_SR "" ON)
option (PNET_OPTION_REDUNDANCY "" ON)
option (PNET_OPTION_AR_VENDOR_BLOCKS "" ON)
option (PNET_OPTION_RS "" ON)
option (PNET_OPTION_MC_CR "" ON)
option (PNET_OPTION_SRL "" OFF)
option (PNET_OPTION_SNMP "" OFF)
option (PNET_OPTION_DRIVER_ENABLE "Enable drivers. Specific driver must be enabled." OFF )
option(PNET_OPTION_FAST_STARTUP "" ON)
option(PNET_OPTION_PARAMETER_SERVER "" ON)
option(PNET_OPTION_IR "" ON)
option(PNET_OPTION_SR "" ON)
option(PNET_OPTION_REDUNDANCY "" ON)
option(PNET_OPTION_AR_VENDOR_BLOCKS "" ON)
option(PNET_OPTION_RS "" ON)
option(PNET_OPTION_MC_CR "" ON)
option(PNET_OPTION_SRL "" OFF)
option(PNET_OPTION_SNMP "" OFF)
option(PNET_OPTION_DRIVER_ENABLE "Enable drivers. Specific driver must be enabled." OFF)

# TODO: this should be handled in cc.h
option (PNET_USE_ATOMICS "Enable use of atomic operations (stdatomic.h)" OFF)

set(PNET_MAX_AR 2
CACHE STRING "Number of connections. Must be > 0. 'Automated RT Tester' uses 2, but only 1 connection AR is supported.")
set(PNET_MAX_API 1
CACHE STRING "Number of Application Processes. Must be > 0")
set(PNET_MAX_CR 2
CACHE STRING "Per AR. At least 2 (1 input and 1 output). If unsure, use 2.")
set(PNET_MAX_SLOTS 5
CACHE STRING "Per API. Should be > 1 to allow at least one I/O module")
set(PNET_MAX_SUBSLOTS 3
CACHE STRING "Per slot (DAP requires 2 + PNET_MAX_PHYSICAL_PORTS)")
set(PNET_MAX_DFP_IOCR 2
CACHE STRING "Allowed values are 0 (zero) or 2")
set(PNET_MAX_PHYSICAL_PORTS 1
CACHE STRING "Max number of physical ports")
set(PNET_MAX_LOG_BOOK_ENTRIES 16
CACHE STRING "")
set(PNET_MAX_ALARMS 6
CACHE STRING "Per AR and queue. One queue for high and one for low priority alarms. 'Automated RT Tester' uses 6.")
option(PNET_USE_ATOMICS "Enable use of atomic operations (stdatomic.h)" OFF)

set(PNET_MAX_AR 2
CACHE STRING "Number of connections. Must be > 0. 'Automated RT Tester' uses 2, but only 1 connection AR is supported.")
set(PNET_MAX_API 1
CACHE STRING "Number of Application Processes. Must be > 0")
set(PNET_MAX_CR 2
CACHE STRING "Per AR. At least 2 (1 input and 1 output). If unsure, use 2.")
set(PNET_MAX_SLOTS 5
CACHE STRING "Per API. Should be > 1 to allow at least one I/O module")
set(PNET_MAX_SUBSLOTS 3
CACHE STRING "Per slot (DAP requires 2 + PNET_MAX_PHYSICAL_PORTS)")
set(PNET_MAX_DFP_IOCR 2
CACHE STRING "Allowed values are 0 (zero) or 2")
set(PNET_MAX_PHYSICAL_PORTS 1
CACHE STRING "Max number of physical ports")
set(PNET_MAX_LOG_BOOK_ENTRIES 16
CACHE STRING "")
set(PNET_MAX_ALARMS 6
CACHE STRING "Per AR and queue. One queue for high and one for low priority alarms. 'Automated RT Tester' uses 6.")
set(PNET_MAX_ALARM_PAYLOAD_DATA_SIZE 28
CACHE STRING "Min 24 or PNET_MAX_DIAG_MANUF_DATA_SIZE + 12. Max is 1408")
set(PNET_MAX_DIAG_ITEMS 200
CACHE STRING "Total, per device. Max is 65534 items")
CACHE STRING "Min 24 or PNET_MAX_DIAG_MANUF_DATA_SIZE + 12. Max is 1408")
set(PNET_MAX_DIAG_ITEMS 200
CACHE STRING "Total, per device. Max is 65534 items")
set(PNET_MAX_DIAG_MANUF_DATA_SIZE 16
CACHE STRING "Min 5 for tests. Max is 1396")
set(PNET_MAX_MC_CR 1
CACHE STRING "Per AR")
set(PNET_MAX_AR_VENDOR_BLOCKS 1
CACHE STRING "Must be > 0")
CACHE STRING "Min 5 for tests. Max is 1396")
set(PNET_MAX_MC_CR 1
CACHE STRING "Per AR")
set(PNET_MAX_AR_VENDOR_BLOCKS 1
CACHE STRING "Must be > 0")
set(PNET_MAX_AR_VENDOR_BLOCK_DATA_LENGTH 512
CACHE STRING "")
CACHE STRING "")
set(PNET_MAX_MAN_SPECIFIC_FAST_STARTUP_DATA_LENGTH 0
CACHE STRING "or 512 (bytes")
CACHE STRING "or 512 (bytes")
set(PNET_MAX_SESSION_BUFFER_SIZE 4500
CACHE STRING "Max fragmented RPC request/response length. Max value 65535")
CACHE STRING "Max fragmented RPC request/response length. Max value 65535")
set(PNET_MAX_DIRECTORYPATH_SIZE 240
CACHE STRING "Max size of directory path, including termination")
CACHE STRING "Max size of directory path, including termination")
set(PNET_MAX_FILENAME_SIZE 30
CACHE STRING "Max size of filename, including termination")
CACHE STRING "Max size of filename, including termination")
set(PNET_MAX_PORT_DESCRIPTION_SIZE 60
CACHE STRING "Max size of port description, including termination")
CACHE STRING "Max size of port description, including termination")

set(LOG_STATE_VALUES "ON;OFF")
set(LOG_LEVEL_VALUES "DEBUG;INFO;WARNING;ERROR;FATAL")
Expand Down Expand Up @@ -150,116 +150,118 @@ set(PNET_LOG ON CACHE STRING "PNET log")
set_property(CACHE PNET_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})

# Generate version numbers
configure_file (
pnet_version.h.in
${PROFINET_BINARY_DIR}/include/pnet_version.h
)
configure_file(
pnet_version.h.in
${PROFINET_BINARY_DIR}/include/pnet_version.h
)

# Generate config options
configure_file (
options.h.in
${PROFINET_BINARY_DIR}/src/options.h
)
configure_file (
pnet_options.h.in
${PROFINET_BINARY_DIR}/include/pnet_options.h
)
configure_file(
options.h.in
${PROFINET_BINARY_DIR}/src/options.h
)
configure_file(
pnet_options.h.in
${PROFINET_BINARY_DIR}/include/pnet_options.h
)

# Add platform-dependent targets early, so they can be configured by
# platform
add_library(profinet "")
add_executable(pn_dev "")

if (PNET_OPTION_DRIVER_ENABLE)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/drivers.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/drivers.cmake)
endif ()

if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING)
add_executable(pf_test "")
endif()
add_executable(pf_test "")
endif ()

# Platform configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake)

generate_export_header(profinet
BASE_NAME pnet
EXPORT_FILE_NAME ${PROFINET_BINARY_DIR}/include/pnet_export.h
)
BASE_NAME pnet
EXPORT_FILE_NAME ${PROFINET_BINARY_DIR}/include/pnet_export.h
)

set_target_properties (profinet pn_dev
PROPERTIES
C_STANDARD 99
)
set_target_properties(profinet pn_dev
PROPERTIES
C_STANDARD 99
)

target_compile_features(profinet PUBLIC c_std_99)

target_include_directories(profinet
PUBLIC
$<BUILD_INTERFACE:${PROFINET_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROFINET_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${PROFINET_BINARY_DIR}/src
src
src/common
src/device
)
PUBLIC
$<BUILD_INTERFACE:${PROFINET_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROFINET_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${PROFINET_BINARY_DIR}/src
src
src/common
src/device
)

target_link_libraries(profinet PUBLIC osal)

install (
TARGETS profinet
EXPORT ProfinetConfig
DESTINATION lib
)

install(
EXPORT ProfinetConfig
DESTINATION cmake
)

install (FILES
include/pnet_api.h
${PROFINET_BINARY_DIR}/include/pnet_export.h
${PROFINET_BINARY_DIR}/include/pnet_options.h
${PROFINET_BINARY_DIR}/include/pnet_version.h
DESTINATION include
)
TARGETS profinet
EXPORT ProfinetConfig
DESTINATION lib
)

add_subdirectory (src)
add_subdirectory (samples/pn_dev)
install(
EXPORT ProfinetConfig
DESTINATION cmake
)

install(FILES
include/pnet_api.h
${PROFINET_BINARY_DIR}/include/pnet_export.h
${PROFINET_BINARY_DIR}/include/pnet_options.h
${PROFINET_BINARY_DIR}/include/pnet_version.h
DESTINATION include
)

add_subdirectory(src)
add_subdirectory(samples/pn_dev)
add_subdirectory(samples/pn_dev_counter)
add_subdirectory(samples/pn_simple_example)

if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING)
add_subdirectory (test)
include(AddGoogleTest)
add_gtest(pf_test)
endif()
add_subdirectory(test)
include(AddGoogleTest)
add_gtest(pf_test)
endif ()

# Doxygen configuration
cmake_policy(SET CMP0057 NEW)
find_package(Doxygen)
if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND DOXYGEN_FOUND)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set(DOXYGEN_TYPEDEF_HIDES_STRUCT YES)
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(DOXYGEN_PREDEFINED PNET_EXPORT)
set(DOXYGEN_EXPAND_AS_DEFINED PNET_EXPORT)
set(DOXYGEN_COLLABORATION_GRAPH NO)
set(DOXYGEN_INCLUDE_GRAPH NO)
set(DOXYGEN_INCLUDED_BY_GRAPH NO)
set(DOXYGEN_RECURSIVE YES)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
doxygen_add_docs(docs
README.md
include
src
)
endif()

include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${PROFINET_SOURCE_DIR}/LICENSE.md")
set (CPACK_PACKAGE_CONTACT [email protected])
include (CPack)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set(DOXYGEN_TYPEDEF_HIDES_STRUCT YES)
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(DOXYGEN_PREDEFINED PNET_EXPORT)
set(DOXYGEN_EXPAND_AS_DEFINED PNET_EXPORT)
set(DOXYGEN_COLLABORATION_GRAPH NO)
set(DOXYGEN_INCLUDE_GRAPH NO)
set(DOXYGEN_INCLUDED_BY_GRAPH NO)
set(DOXYGEN_RECURSIVE YES)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
doxygen_add_docs(docs
README.md
include
src
)
endif ()

include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${PROFINET_SOURCE_DIR}/LICENSE.md")
set(CPACK_PACKAGE_CONTACT [email protected])
include(CPack)
Loading