From 6b46c0a1b8693f49f15314e2c110478fd254d073 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Aug 2024 15:35:04 +1000 Subject: [PATCH 01/13] starting to fix linting on this branch --- .vscode/c_cpp_properties.json | 6 +++--- .vscode/settings.json | 2 +- src/projects/StarterKit/plcnext.proj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 2621370..a83533a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,14 +5,14 @@ "includePath": [ "${workspaceFolder}/**", "/usr/include/**", - "/opt/plcnext_axcf2152_sdk_2023/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**", + "/opt/plcnext_axcf2152-linux_sdk_2024/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**", "${workspaceFolder}/src/projects/StarterKit/**" ], "defines": [], - "compilerPath": "/opt/plcnext_axcf2152_sdk_2023/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++", + "compilerPath": "/usr/bin/x86_64-linux-gnu-g++", "cStandard": "c99", "cppStandard": "c++14", - "intelliSenseMode": "gcc-arm", + "intelliSenseMode": "linux-gcc-x86", "configurationProvider": "ms-vscode.cpptools" } ], diff --git a/.vscode/settings.json b/.vscode/settings.json index 173fea9..ecf22b7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -170,5 +170,5 @@ } ], "cmake.ignoreCMakeListsMissing": true, - "C_Cpp.default.compilerPath": "/opt/plcnext_axcf2152_sdk_2023/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++" + "C_Cpp.default.compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++" } \ No newline at end of file diff --git a/src/projects/StarterKit/plcnext.proj b/src/projects/StarterKit/plcnext.proj index 0490244..ed7e8af 100644 --- a/src/projects/StarterKit/plcnext.proj +++ b/src/projects/StarterKit/plcnext.proj @@ -5,5 +5,5 @@ StarterKit true true - AXCF2152,2023.0.0 LTS (23.0.0.65) + AXCF2152,2024.0.0 LTS (24.0.0.102) \ No newline at end of file From 327eb78e6b15a03d2323176f3a6a9b9afc375955 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Aug 2024 15:54:33 +1000 Subject: [PATCH 02/13] fixing to build the code --- .vscode/c_cpp_properties.json | 6 +++--- src/projects/StarterKit/plcnext.proj | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 2621370..a83533a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,14 +5,14 @@ "includePath": [ "${workspaceFolder}/**", "/usr/include/**", - "/opt/plcnext_axcf2152_sdk_2023/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**", + "/opt/plcnext_axcf2152-linux_sdk_2024/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**", "${workspaceFolder}/src/projects/StarterKit/**" ], "defines": [], - "compilerPath": "/opt/plcnext_axcf2152_sdk_2023/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++", + "compilerPath": "/usr/bin/x86_64-linux-gnu-g++", "cStandard": "c99", "cppStandard": "c++14", - "intelliSenseMode": "gcc-arm", + "intelliSenseMode": "linux-gcc-x86", "configurationProvider": "ms-vscode.cpptools" } ], diff --git a/src/projects/StarterKit/plcnext.proj b/src/projects/StarterKit/plcnext.proj index 0490244..8e20a6f 100644 --- a/src/projects/StarterKit/plcnext.proj +++ b/src/projects/StarterKit/plcnext.proj @@ -5,5 +5,6 @@ StarterKit true true - AXCF2152,2023.0.0 LTS (23.0.0.65) + + AXCF2152,2024.0.0 LTS (24.0.0.102) \ No newline at end of file From 4d73d8a0efa05b8af04ef8e4e738ff69f3623a87 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Aug 2024 16:47:19 +1000 Subject: [PATCH 03/13] Added folder for utils --- .vscode/settings.json | 174 ------------------ CPPLINT.cfg | 2 +- src/libs/Utils/.gitignore | 2 + src/libs/Utils/CmakeLists.txt | 132 +++++++++++++ src/libs/Utils/Config.cmake.in | 7 + src/libs/Utils/How_to_use.txt | 9 + .../external/ADD_DEPENDENT_LIBRARIES_HERE.txt | 19 ++ ...ARIES_HERE.txt\357\200\272Zone.Identifier" | 0 .../Utils/include/ADD_PUBLIC_HEADERS_HERE.txt | 3 + ...ADERS_HERE.txt\357\200\272Zone.Identifier" | 0 src/libs/Utils/plcnext.proj | 9 + .../StarterKit/src/StarterKitProgram.cpp | 6 +- .../StarterKit/src/StarterKitProgram.hpp | 2 +- 13 files changed, 185 insertions(+), 180 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 src/libs/Utils/.gitignore create mode 100644 src/libs/Utils/CmakeLists.txt create mode 100644 src/libs/Utils/Config.cmake.in create mode 100644 src/libs/Utils/How_to_use.txt create mode 100644 src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt create mode 100644 "src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt\357\200\272Zone.Identifier" create mode 100644 src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt create mode 100644 "src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt\357\200\272Zone.Identifier" create mode 100644 src/libs/Utils/plcnext.proj diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 173fea9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll": "explicit" - }, - "editor.fontFamily": "'MesloLGS NF',Consolas, 'Courier New', monospace", - "editor.tabSize": 4, - "editor.insertSpaces": true, - "editor.rulers": [ - 100 - ], - "clang-format.executable": "/usr/bin/clang-format-14", - "clang-format.style": "file", - "clang-format.language.c.enable": true, - "C_Cpp.files.exclude": { - "**/build/**": true, - }, - "terminal.integrated.defaultProfile.linux": "zsh", - "files.associations": { - "array": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "atomic": "cpp", - "strstream": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "chrono": "cpp", - "compare": "cpp", - "complex": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "cstdint": "cpp", - "deque": "cpp", - "forward_list": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "semaphore": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "stop_token": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cfenv": "cpp", - "cinttypes": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "variant": "cpp", - "future": "cpp", - "charconv": "cpp", - "span": "cpp", - "any": "cpp", - "*.ipp": "cpp", - "codecvt": "cpp", - "coroutine": "cpp", - "source_location": "cpp", - "slist": "cpp", - "valarray": "cpp", - "shared_mutex": "cpp", - "barrier": "cpp", - "latch": "cpp", - "ranges": "cpp", - "syncstream": "cpp", - "hash_map": "cpp", - "hash_set": "cpp", - "alignedvector3": "cpp", - "scoped_allocator": "cpp", - "*.inc": "cpp", - "*.in": "cpp", - "pqxx": "cpp", - "cursor": "cpp", - "binarystring": "cpp" - }, - "better-comments.tags": [ - { - "tag": "!", - "color": "#FF2D00", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "?", - "color": "#3498DB", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "todo", - "color": "#FF8C00", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "*", - "color": "#f730fb", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "#", - "color": "#299AA2", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": true, - "italic": false - }, - { - "tag": "[", - "color": "#FF7F50", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - } - ], - "cmake.ignoreCMakeListsMissing": true, - "C_Cpp.default.compilerPath": "/opt/plcnext_axcf2152_sdk_2023/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++" -} \ No newline at end of file diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 6b320fc..e2cc532 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,3 +1,3 @@ # Remove annoying cpplint tests if they are too much/annoying filter=-legal/copyright,-whitespace/blank_line,-whitespace/end_of_line,-build/header_guard,-whitespace/comments,-readability/todo,-whitespace/newline,-whitespace/empty_loop_body -linelength=120 \ No newline at end of file +linelength=100 \ No newline at end of file diff --git a/src/libs/Utils/.gitignore b/src/libs/Utils/.gitignore new file mode 100644 index 0000000..9e6c307 --- /dev/null +++ b/src/libs/Utils/.gitignore @@ -0,0 +1,2 @@ +bin/* +intermediate/* \ No newline at end of file diff --git a/src/libs/Utils/CmakeLists.txt b/src/libs/Utils/CmakeLists.txt new file mode 100644 index 0000000..1fd4729 --- /dev/null +++ b/src/libs/Utils/CmakeLists.txt @@ -0,0 +1,132 @@ +cmake_minimum_required(VERSION 3.13) + +project(Utils) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +set (ArpProgramming_ARP_IO_PROFIBUS_LIBRARY FALSE) + +################# create target ####################################################### + +file(GLOB_RECURSE Headers CONFIGURE_DEPENDS src/*.h src/*.hpp src/*.hxx) +file(GLOB_RECURSE PublicHeaders CONFIGURE_DEPENDS include/*.h include/*.hpp include/*.hxx) +file(GLOB_RECURSE Sources CONFIGURE_DEPENDS src/*.cpp) +add_library(${CMAKE_PROJECT_NAME} SHARED ${Headers} ${PublicHeaders} ${Sources}) + +####################################################################################### + +################# set install directories ############################################# + +string(REGEX REPLACE "^.*\\(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*$" "\\1" _ARP_SHORT_DEVICE_VERSION ${ARP_DEVICE_VERSION}) +set(INCLUDE_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/include) +set(LIB_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/lib/${CMAKE_PROJECT_NAME}) + +####################################################################################### + +################# project include-paths ############################################### + +target_include_directories(${CMAKE_PROJECT_NAME} + PRIVATE + $ + PUBLIC + $ + $) + +####################################################################################### + +################# include arp cmake module path ####################################### + +list(INSERT CMAKE_MODULE_PATH 0 "${ARP_TOOLCHAIN_CMAKE_MODULE_PATH}") + +####################################################################################### + +################# set RPATH to ORIGIN for thrid party libraries ####################### +# Only by setting this is it possible to use libraries which are not already # +# installed in the default install locations on the target. # +####################################################################################### + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT "$ENV{SHELL}" MATCHES ".*[\/\\]bash($|.exe$)") + # With Windows there is a known issue with CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/21291 + # This is currently the only way to set the RPATH to $ORIGIN in Windows + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "-Wl,-rpath,\$$ORIGIN") +else() + set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES INSTALL_RPATH $ORIGIN) +endif() + +####################################################################################### + +################# set link options #################################################### +# WARNING: Without --no-undefined the linker will not check, whether all necessary # +# libraries are linked. When a library which is necessary is not linked, # +# the firmware will crash and there will be NO indication why it crashed. # +####################################################################################### + +target_link_options(${CMAKE_PROJECT_NAME} PRIVATE LINKER:--no-undefined) + +####################################################################################### + +################# add link targets #################################################### + +find_package(ArpDevice REQUIRED) +find_package(ArpProgramming REQUIRED) + +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming log4cplus) + +####################################################################################### + +################# configure cmake package config files ################################ +# IMPORTANT: The library version is set here. # +####################################################################################### + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "Config.cmake.in" + "${CMAKE_PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake + PATH_VARS + INCLUDE_INSTALL_DIR + LIB_INSTALL_DIR + ) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake + VERSION 1.0.0 + COMPATIBILITY SameMajorVersion + ) + +####################################################################################### + +########## install public headers while retaining the directory structure ############# + +file(GLOB _DEPLOY_HEADERS_AND_DIRS include/*) +set(_DIRS_TO_DEPLOY "") +set(_FILES_TO_DEPLOY "") +foreach(ITEM ${_DEPLOY_HEADERS_AND_DIRS}) + if( IS_DIRECTORY "${ITEM}" ) + list( APPEND _DIRS_TO_DEPLOY "${ITEM}" ) + elseif(NOT ITEM MATCHES ".*ADD_PUBLIC_HEADERS_HERE") + list( APPEND _FILES_TO_DEPLOY "${ITEM}" ) + endif() +endforeach() +install( FILES ${_FILES_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) +install( DIRECTORY ${_DIRS_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) +unset(_FILES_TO_DEPLOY) +unset(_DIRS_TO_DEPLOY) +unset(_DEPLOY_HEADERS_AND_DIRS) + +####################################################################################### + +################# install CMake package and library ################################### + +install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) +install(EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake" + ) +unset(_ARP_SHORT_DEVICE_VERSION) + +####################################################################################### \ No newline at end of file diff --git a/src/libs/Utils/Config.cmake.in b/src/libs/Utils/Config.cmake.in new file mode 100644 index 0000000..f9da09f --- /dev/null +++ b/src/libs/Utils/Config.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT @ + + include("@PACKAGE_LIB_INSTALL_DIR@/Utils-targets.cmake") + + set_and_check(Utils_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") + + check_required_components(Utils) \ No newline at end of file diff --git a/src/libs/Utils/How_to_use.txt b/src/libs/Utils/How_to_use.txt new file mode 100644 index 0000000..9768841 --- /dev/null +++ b/src/libs/Utils/How_to_use.txt @@ -0,0 +1,9 @@ ++ Copy eyerthing under the 'bin' directory of this project to the 'external' + directory of the consuming project ++ In the CMakeLists.txt of the consuming project add the following line before + the 'target_link_libraries' call + find_package(Utils REQUIRED) ++ Add in the CMakeLists.txt of the consuming project to the + 'target_link_libraries' call the previousely found package 'Utils' ++ Use public headers of this project by including them in the consuming project + e.g. '#include "Utils/UtilsClass.hpp"' \ No newline at end of file diff --git a/src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt b/src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt new file mode 100644 index 0000000..6a8363f --- /dev/null +++ b/src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt @@ -0,0 +1,19 @@ +The CLI will automatically set the CMAKE_PREFIX_PATH to find CMake packages to +this directory or a sub-directory of this directory. To decide which directory +to use for the CMAKE_PREFIX_PATH the CLI looks for a directory with the name +_. + +To choose such a directory the target_name must match the current build target +name and the version must be lower or equal to the current build target +version. If such a directory is found the CLI looks whether the directory +contains the current build type (Release, Debug, ...). If no such directory is +found it looks for a directory named "Release". + +If the CLI finds the build type directory or the "Release" directory it uses +this directory as CMAKE_PREFIX_PATH. If not it uses as fallback the found +target specific directory. If that is not found it uses the external directory. +If the CMAKE_PREFIX_PATH is already set by a command line option it will not +override the set value. + +Please make sure that if the libraries which are used by this project use other +libraries themself, that the library must have the RPATH set to $ORIGIN. \ No newline at end of file diff --git "a/src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt\357\200\272Zone.Identifier" "b/src/libs/Utils/external/ADD_DEPENDENT_LIBRARIES_HERE.txt\357\200\272Zone.Identifier" new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt b/src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt new file mode 100644 index 0000000..c927b01 --- /dev/null +++ b/src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt @@ -0,0 +1,3 @@ +This directory will automatically be deployed to the CMake package. Therefore +all headers that need to be visible to the user of the library need to be +placed here. \ No newline at end of file diff --git "a/src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt\357\200\272Zone.Identifier" "b/src/libs/Utils/include/ADD_PUBLIC_HEADERS_HERE.txt\357\200\272Zone.Identifier" new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/Utils/plcnext.proj b/src/libs/Utils/plcnext.proj new file mode 100644 index 0000000..fcdb17e --- /dev/null +++ b/src/libs/Utils/plcnext.proj @@ -0,0 +1,9 @@ + + + 4.0 + consumablelibrary + Utils + true + true + AXCF2152,2023.0.0 LTS (23.0.0.65) + \ No newline at end of file diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index 1fbd431..6ed5936 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -23,7 +23,7 @@ StarterKitProgram::Execute() { // implement program - if (config_.allowOutputs && command_.setOutput) + if (config_.allowOutputs && command_.setOutput || dIN01_) { // control two fans for cooling dOUT01_ = true; @@ -37,9 +37,7 @@ StarterKitProgram::Execute() if (command_.readAnalog1) { - uint32 analogReading = aiN1_; - - log.Info("Analog one reading: {0}", analogReading); + log.Info("Analog one reading: {0}", aiN1_); const double scaledReading = convertMillivoltsToRange( analogReading, config_.analogInOne.minRange, config_.analogInOne.maxRange); diff --git a/src/projects/StarterKit/src/StarterKitProgram.hpp b/src/projects/StarterKit/src/StarterKitProgram.hpp index f8d66b5..273d974 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.hpp +++ b/src/projects/StarterKit/src/StarterKitProgram.hpp @@ -85,7 +85,7 @@ class StarterKitProgram : public ProgramBase, private Loggable Date: Sat, 31 Aug 2024 14:39:16 +1000 Subject: [PATCH 04/13] working on building libs --- .../Utils/{CmakeLists.txt => CMakeLists.txt} | 2 +- src/libs/Utils/include/Utils/Config.cmake.in | 0 src/libs/Utils/include/Utils/util.hpp | 23 ++++++++++++++++++ src/libs/Utils/plcnext.proj | 6 ++--- src/libs/Utils/src/util.cpp | 24 +++++++++++++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) rename src/libs/Utils/{CmakeLists.txt => CMakeLists.txt} (99%) create mode 100644 src/libs/Utils/include/Utils/Config.cmake.in create mode 100644 src/libs/Utils/include/Utils/util.hpp create mode 100644 src/libs/Utils/src/util.cpp diff --git a/src/libs/Utils/CmakeLists.txt b/src/libs/Utils/CMakeLists.txt similarity index 99% rename from src/libs/Utils/CmakeLists.txt rename to src/libs/Utils/CMakeLists.txt index 1fd4729..6ea2dec 100644 --- a/src/libs/Utils/CmakeLists.txt +++ b/src/libs/Utils/CMakeLists.txt @@ -72,7 +72,7 @@ target_link_options(${CMAKE_PROJECT_NAME} PRIVATE LINKER:--no-undefined) find_package(ArpDevice REQUIRED) find_package(ArpProgramming REQUIRED) -target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming log4cplus) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming) ####################################################################################### diff --git a/src/libs/Utils/include/Utils/Config.cmake.in b/src/libs/Utils/include/Utils/Config.cmake.in new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/Utils/include/Utils/util.hpp b/src/libs/Utils/include/Utils/util.hpp new file mode 100644 index 0000000..79b8ced --- /dev/null +++ b/src/libs/Utils/include/Utils/util.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "Arp/System/Core/Arp.h" + +namespace Utils +{ + +class AnalogInputs +{ + enum class DiagnosticType : Arp::uint8 + { + UNKNOWN = 0x00, + Status = 0x01, + Alert = 0x02, + Error = 0x03 + }; + + struct RelayStatus + { + DiagnosticType diagnosticType = DiagnosticType::UNKNOWN; + }; +}; + +} // namespace Utils \ No newline at end of file diff --git a/src/libs/Utils/plcnext.proj b/src/libs/Utils/plcnext.proj index fcdb17e..039298d 100644 --- a/src/libs/Utils/plcnext.proj +++ b/src/libs/Utils/plcnext.proj @@ -1,9 +1,7 @@ - 4.0 + AXCF2152,2024.0.0 LTS (24.0.0.102) consumablelibrary + 4.0 Utils - true - true - AXCF2152,2023.0.0 LTS (23.0.0.65) \ No newline at end of file diff --git a/src/libs/Utils/src/util.cpp b/src/libs/Utils/src/util.cpp new file mode 100644 index 0000000..df280cb --- /dev/null +++ b/src/libs/Utils/src/util.cpp @@ -0,0 +1,24 @@ +#include "Utils/util.hpp" +#include "Arp/System/Commons/Logging.h" + +namespace Utils +{ + +std::string +toString(const SafetyRelayHandler::DiagnosticType diagnosticType) +{ + switch (diagnosticType) + { + case SafetyRelayHandler::DiagnosticType::UNKNOWN: + return "UNKNOWN"; + case SafetyRelayHandler::DiagnosticType::Status: + return "Status"; + case SafetyRelayHandler::DiagnosticType::Alert: + return "Alert"; + case SafetyRelayHandler::DiagnosticType::Error: + return "Error"; + default: + return "UNKNOWN"; + } +} +} // namespace Utils \ No newline at end of file From bf8e508900a934e8bc7cc26f47ddb7f7c0805527 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Aug 2024 15:37:00 +1000 Subject: [PATCH 05/13] first utils function building --- .vscode/settings.json | 74 +++++ .vscode/tasks.json | 4 +- src/libs/Utils/CMakeLists.txt | 262 +++++++++--------- src/libs/Utils/Config.cmake.in | 13 +- src/libs/Utils/docs/Timer.md | 82 ++++++ src/libs/Utils/include/Utils/Config.cmake.in | 0 src/libs/Utils/include/Utils/util.hpp | 108 +++++++- src/libs/Utils/plcnext.proj | 12 +- src/libs/Utils/src/util.cpp | 25 +- .../code/StarterKitLibrary.meta.cpp | 2 +- .../StarterKit/src/StarterKitProgram.cpp | 4 +- 11 files changed, 401 insertions(+), 185 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/libs/Utils/docs/Timer.md delete mode 100644 src/libs/Utils/include/Utils/Config.cmake.in diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0abcf43 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,74 @@ +{ + "files.associations": { + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "strstream": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cfenv": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c43d537..2007fb0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -36,7 +36,7 @@ "label": "plcnext_gen_build", "detail": "Build a PLCNext PLM project", "type": "shell", - "command": "export BUILD_TYPE=Release && echo Build PLCNext release project for project ${input:project_name} && cd src/projects/${input:project_name} && plcncli generate code --verbose && plcncli generate config --verbose && plcncli build --verbose && plcncli deploy && cp bin/${input:project_name}.pcwlx /home/plc/Windows_PLCNextEngineer_Libraries && echo 'File copied successfully'", + "command": "export BUILD_TYPE=Release && echo Build PLCNext release project for project ${input:project_name} && echo Build PLCNext libs && cd src/libs/Utils && plcncli build && cd ../../projects/${input:project_name} && plcncli generate code --verbose && plcncli generate config --verbose && plcncli build --verbose && plcncli deploy && cp bin/${input:project_name}.pcwlx /home/plc/Windows_PLCNextEngineer_Libraries && echo 'File copied successfully'", "group": { "kind": "build" }, @@ -80,7 +80,7 @@ "id": "project_name", "description": "Name of project for plcnext", "default": "Hello", - "type": "promptString", + "type": "promptString" } ] } \ No newline at end of file diff --git a/src/libs/Utils/CMakeLists.txt b/src/libs/Utils/CMakeLists.txt index 6ea2dec..f9eae6f 100644 --- a/src/libs/Utils/CMakeLists.txt +++ b/src/libs/Utils/CMakeLists.txt @@ -1,132 +1,132 @@ -cmake_minimum_required(VERSION 3.13) - -project(Utils) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() - -set (ArpProgramming_ARP_IO_PROFIBUS_LIBRARY FALSE) - -################# create target ####################################################### - -file(GLOB_RECURSE Headers CONFIGURE_DEPENDS src/*.h src/*.hpp src/*.hxx) -file(GLOB_RECURSE PublicHeaders CONFIGURE_DEPENDS include/*.h include/*.hpp include/*.hxx) -file(GLOB_RECURSE Sources CONFIGURE_DEPENDS src/*.cpp) -add_library(${CMAKE_PROJECT_NAME} SHARED ${Headers} ${PublicHeaders} ${Sources}) - -####################################################################################### - -################# set install directories ############################################# - -string(REGEX REPLACE "^.*\\(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*$" "\\1" _ARP_SHORT_DEVICE_VERSION ${ARP_DEVICE_VERSION}) -set(INCLUDE_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/include) -set(LIB_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/lib/${CMAKE_PROJECT_NAME}) - -####################################################################################### - -################# project include-paths ############################################### - -target_include_directories(${CMAKE_PROJECT_NAME} - PRIVATE - $ - PUBLIC - $ - $) - -####################################################################################### - -################# include arp cmake module path ####################################### - -list(INSERT CMAKE_MODULE_PATH 0 "${ARP_TOOLCHAIN_CMAKE_MODULE_PATH}") - -####################################################################################### - -################# set RPATH to ORIGIN for thrid party libraries ####################### -# Only by setting this is it possible to use libraries which are not already # -# installed in the default install locations on the target. # -####################################################################################### - -if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT "$ENV{SHELL}" MATCHES ".*[\/\\]bash($|.exe$)") - # With Windows there is a known issue with CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/21291 - # This is currently the only way to set the RPATH to $ORIGIN in Windows - target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "-Wl,-rpath,\$$ORIGIN") -else() - set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES INSTALL_RPATH $ORIGIN) -endif() - -####################################################################################### - -################# set link options #################################################### -# WARNING: Without --no-undefined the linker will not check, whether all necessary # -# libraries are linked. When a library which is necessary is not linked, # -# the firmware will crash and there will be NO indication why it crashed. # -####################################################################################### - -target_link_options(${CMAKE_PROJECT_NAME} PRIVATE LINKER:--no-undefined) - -####################################################################################### - -################# add link targets #################################################### - -find_package(ArpDevice REQUIRED) -find_package(ArpProgramming REQUIRED) - -target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming) - -####################################################################################### - -################# configure cmake package config files ################################ -# IMPORTANT: The library version is set here. # -####################################################################################### - -include(CMakePackageConfigHelpers) -configure_package_config_file( - "Config.cmake.in" - "${CMAKE_PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake - PATH_VARS - INCLUDE_INSTALL_DIR - LIB_INSTALL_DIR - ) - -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake - VERSION 1.0.0 - COMPATIBILITY SameMajorVersion - ) - -####################################################################################### - -########## install public headers while retaining the directory structure ############# - -file(GLOB _DEPLOY_HEADERS_AND_DIRS include/*) -set(_DIRS_TO_DEPLOY "") -set(_FILES_TO_DEPLOY "") -foreach(ITEM ${_DEPLOY_HEADERS_AND_DIRS}) - if( IS_DIRECTORY "${ITEM}" ) - list( APPEND _DIRS_TO_DEPLOY "${ITEM}" ) - elseif(NOT ITEM MATCHES ".*ADD_PUBLIC_HEADERS_HERE") - list( APPEND _FILES_TO_DEPLOY "${ITEM}" ) - endif() -endforeach() -install( FILES ${_FILES_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) -install( DIRECTORY ${_DIRS_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) -unset(_FILES_TO_DEPLOY) -unset(_DIRS_TO_DEPLOY) -unset(_DEPLOY_HEADERS_AND_DIRS) - -####################################################################################### - -################# install CMake package and library ################################### - -install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) -install(EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) -install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" - DESTINATION "${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake" - ) -unset(_ARP_SHORT_DEVICE_VERSION) - +cmake_minimum_required(VERSION 3.13) + +project(Utils) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +set (ArpProgramming_ARP_IO_PROFIBUS_LIBRARY FALSE) + +################# create target ####################################################### + +file(GLOB_RECURSE Headers CONFIGURE_DEPENDS src/*.h src/*.hpp src/*.hxx) +file(GLOB_RECURSE PublicHeaders CONFIGURE_DEPENDS include/*.h include/*.hpp include/*.hxx) +file(GLOB_RECURSE Sources CONFIGURE_DEPENDS src/*.cpp) +add_library(${CMAKE_PROJECT_NAME} SHARED ${Headers} ${PublicHeaders} ${Sources}) + +####################################################################################### + +################# set install directories ############################################# + +string(REGEX REPLACE "^.*\\(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*$" "\\1" _ARP_SHORT_DEVICE_VERSION ${ARP_DEVICE_VERSION}) +set(INCLUDE_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/include) +set(LIB_INSTALL_DIR ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/lib/${CMAKE_PROJECT_NAME}) + +####################################################################################### + +################# project include-paths ############################################### + +target_include_directories(${CMAKE_PROJECT_NAME} + PRIVATE + $ + PUBLIC + $ + $) + +####################################################################################### + +################# include arp cmake module path ####################################### + +list(INSERT CMAKE_MODULE_PATH 0 "${ARP_TOOLCHAIN_CMAKE_MODULE_PATH}") + +####################################################################################### + +################# set RPATH to ORIGIN for thrid party libraries ####################### +# Only by setting this is it possible to use libraries which are not already # +# installed in the default install locations on the target. # +####################################################################################### + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT "$ENV{SHELL}" MATCHES ".*[\/\\]bash($|.exe$)") + # With Windows there is a known issue with CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/21291 + # This is currently the only way to set the RPATH to $ORIGIN in Windows + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "-Wl,-rpath,\$$ORIGIN") +else() + set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES INSTALL_RPATH $ORIGIN) +endif() + +####################################################################################### + +################# set link options #################################################### +# WARNING: Without --no-undefined the linker will not check, whether all necessary # +# libraries are linked. When a library which is necessary is not linked, # +# the firmware will crash and there will be NO indication why it crashed. # +####################################################################################### + +target_link_options(${CMAKE_PROJECT_NAME} PRIVATE LINKER:--no-undefined) + +####################################################################################### + +################# add link targets #################################################### + +find_package(ArpDevice REQUIRED) +find_package(ArpProgramming REQUIRED) + +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming) + +####################################################################################### + +################# configure cmake package config files ################################ +# IMPORTANT: The library version is set here. # +####################################################################################### + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "Config.cmake.in" + "${CMAKE_PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake + PATH_VARS + INCLUDE_INSTALL_DIR + LIB_INSTALL_DIR + ) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake + VERSION 1.0.0 + COMPATIBILITY SameMajorVersion + ) + +####################################################################################### + +########## install public headers while retaining the directory structure ############# + +file(GLOB _DEPLOY_HEADERS_AND_DIRS include/*) +set(_DIRS_TO_DEPLOY "") +set(_FILES_TO_DEPLOY "") +foreach(ITEM ${_DEPLOY_HEADERS_AND_DIRS}) + if( IS_DIRECTORY "${ITEM}" ) + list( APPEND _DIRS_TO_DEPLOY "${ITEM}" ) + elseif(NOT ITEM MATCHES ".*ADD_PUBLIC_HEADERS_HERE") + list( APPEND _FILES_TO_DEPLOY "${ITEM}" ) + endif() +endforeach() +install( FILES ${_FILES_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) +install( DIRECTORY ${_DIRS_TO_DEPLOY} DESTINATION ${INCLUDE_INSTALL_DIR} ) +unset(_FILES_TO_DEPLOY) +unset(_DIRS_TO_DEPLOY) +unset(_DEPLOY_HEADERS_AND_DIRS) + +####################################################################################### + +################# install CMake package and library ################################### + +install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) +install(EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION ${LIB_INSTALL_DIR}) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${ARP_DEVICE}_${_ARP_SHORT_DEVICE_VERSION}/${CMAKE_BUILD_TYPE}/cmake" + ) +unset(_ARP_SHORT_DEVICE_VERSION) + ####################################################################################### \ No newline at end of file diff --git a/src/libs/Utils/Config.cmake.in b/src/libs/Utils/Config.cmake.in index f9da09f..ecff60f 100644 --- a/src/libs/Utils/Config.cmake.in +++ b/src/libs/Utils/Config.cmake.in @@ -1,7 +1,6 @@ -@PACKAGE_INIT @ - - include("@PACKAGE_LIB_INSTALL_DIR@/Utils-targets.cmake") - - set_and_check(Utils_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") - - check_required_components(Utils) \ No newline at end of file +@PACKAGE_INIT@ +include( "@PACKAGE_LIB_INSTALL_DIR@/Utils-targets.cmake" ) + +set_and_check(Utils_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") + +check_required_components(Utils) \ No newline at end of file diff --git a/src/libs/Utils/docs/Timer.md b/src/libs/Utils/docs/Timer.md new file mode 100644 index 0000000..0fd4141 --- /dev/null +++ b/src/libs/Utils/docs/Timer.md @@ -0,0 +1,82 @@ +Timer Class Documentation +Overview +The Timer class provides a flexible way to implement timer-based functionalities similar to TON (Timer On Delay) and TOF (Timer Off Delay) used in ladder logic. This class allows you to configure and use the timer for different purposes based on the selected mode. + +Features +TON (Timer On Delay): Delays the output turning on after the input condition becomes true. +TOF (Timer Off Delay): Delays the output turning off after the input condition becomes false. +Get Elapsed Time: Allows you to retrieve the current elapsed time since the timer started. +Restart Timer: Resets the timer, clearing the internal state. +Usage +1. Include the Timer Header +Ensure that you include the Timer class header in your source file: + +cpp +Copy code +#include "PlatingTimer.hpp" +2. Create a Timer Instance +To create a timer, you need to specify the mode (TON or TOF) and the timeout duration. + +cpp +Copy code +// Create a TON timer with a 1-second delay +Plating::Timer tonTimer(Plating::TimerMode::TON, std::chrono::milliseconds(1000)); + +// Create a TOF timer with a 1-second delay +Plating::Timer tofTimer(Plating::TimerMode::TOF, std::chrono::milliseconds(1000)); +3. Update the Timer +Call the update() method in your loop or control logic to process the input signal and get the timer's output. + +cpp +Copy code +bool input = /* your input condition */; + +bool tonOutput = tonTimer.update(input); // Update and get output for TON +bool tofOutput = tofTimer.update(input); // Update and get output for TOF +For TON mode: The output will be true only after the input has been true for the specified timeout duration. +For TOF mode: The output will stay true as long as the input remains true and will turn false after the timeout duration once the input becomes false. +4. Get Elapsed Time +You can retrieve the current elapsed time since the timer started in milliseconds using the getCurrentTime() method. + +cpp +Copy code +double tonTime = tonTimer.getCurrentTime(); // Get elapsed time for TON +double tofTime = tofTimer.getCurrentTime(); // Get elapsed time for TOF +5. Restart the Timer +If needed, you can reset the timer and clear its internal state using the restart() method. + +cpp +Copy code +tonTimer.restart(); // Restart the TON timer +tofTimer.restart(); // Restart the TOF timer +Example +Here’s a complete example demonstrating how to use the Timer class: + +cpp +Copy code +#include "PlatingTimer.hpp" + +int main() +{ + // Create timers + Plating::Timer tonTimer(Plating::TimerMode::TON, std::chrono::milliseconds(1000)); + Plating::Timer tofTimer(Plating::TimerMode::TOF, std::chrono::milliseconds(1000)); + + bool input = /* your input condition */; + + // Update timers + bool tonOutput = tonTimer.update(input); + bool tofOutput = tofTimer.update(input); + + // Get elapsed time + double tonTime = tonTimer.getCurrentTime(); + double tofTime = tofTimer.getCurrentTime(); + + // Optionally restart timers + tonTimer.restart(); + tofTimer.restart(); + + return 0; +} +Conclusion +The Timer class is a versatile tool for implementing timer-based logic in your application. With support for both TON and TOF modes, it offers a flexible solution for timing tasks. By following this guide, you can quickly integrate the Timer class into your project and start utilizing its features. \ No newline at end of file diff --git a/src/libs/Utils/include/Utils/Config.cmake.in b/src/libs/Utils/include/Utils/Config.cmake.in deleted file mode 100644 index e69de29..0000000 diff --git a/src/libs/Utils/include/Utils/util.hpp b/src/libs/Utils/include/Utils/util.hpp index 79b8ced..895299b 100644 --- a/src/libs/Utils/include/Utils/util.hpp +++ b/src/libs/Utils/include/Utils/util.hpp @@ -1,23 +1,107 @@ #pragma once -#include "Arp/System/Core/Arp.h" +#include "Arp/System/Commons/Chrono/SystemTick.hpp" +#include namespace Utils { -class AnalogInputs +using namespace Arp::System::Commons::Chrono; + +enum class TimerMode +{ + TON, // Timer On Delay + TOF // Timer Off Delay +}; + +class Timer { - enum class DiagnosticType : Arp::uint8 + public: + Timer(TimerMode mode, std::chrono::milliseconds timeout) + : mode_(mode), tTimeoutMicros_(timeout.count() * 1000), isTiming_(false), output_(false), + tStartMicros_(0) + { + } + + // Update function to process the input and return the timer's output + bool update(bool input) + { + const int64_t now = SystemTick::GetMicroTick().count(); + + if (mode_ == TimerMode::TON) + { + return updateTON(input, now); + } + else // TimerMode::TOF + { + return updateTOF(input, now); + } + } + + // Method to get the current elapsed time in milliseconds + double getElapsedTime() const + { + const int64_t now = SystemTick::GetMicroTick().count(); + return static_cast(now - tStartMicros_) / 1000.0; + } + + // Method to restart the timer + void restart() + { + tStartMicros_ = SystemTick::GetMicroTick().count(); + isTiming_ = false; + output_ = false; + } + + private: + TimerMode mode_; + int64_t tTimeoutMicros_; + bool isTiming_; + bool output_; + int64_t tStartMicros_; + + bool updateTON(bool input, int64_t now) { - UNKNOWN = 0x00, - Status = 0x01, - Alert = 0x02, - Error = 0x03 - }; + if (input) + { + if (!isTiming_) + { + tStartMicros_ = now; + isTiming_ = true; + } + if (now - tStartMicros_ >= tTimeoutMicros_) + { + return true; + } + } + else + { + isTiming_ = false; + } + return false; + } - struct RelayStatus + bool updateTOF(bool input, int64_t now) { - DiagnosticType diagnosticType = DiagnosticType::UNKNOWN; - }; + if (!input) + { + if (!isTiming_) + { + tStartMicros_ = now; + isTiming_ = true; + output_ = true; + } + if (now - tStartMicros_ >= tTimeoutMicros_) + { + output_ = false; + } + } + else + { + isTiming_ = false; + output_ = true; + } + return output_; + } }; -} // namespace Utils \ No newline at end of file +} // namespace Utils diff --git a/src/libs/Utils/plcnext.proj b/src/libs/Utils/plcnext.proj index 039298d..c83536b 100644 --- a/src/libs/Utils/plcnext.proj +++ b/src/libs/Utils/plcnext.proj @@ -1,7 +1,7 @@ - - - AXCF2152,2024.0.0 LTS (24.0.0.102) - consumablelibrary - 4.0 - Utils + + + AXCF2152,2024.0.0 LTS (24.0.0.102) + consumablelibrary + 4.0 + Utils \ No newline at end of file diff --git a/src/libs/Utils/src/util.cpp b/src/libs/Utils/src/util.cpp index df280cb..29dca82 100644 --- a/src/libs/Utils/src/util.cpp +++ b/src/libs/Utils/src/util.cpp @@ -1,24 +1 @@ -#include "Utils/util.hpp" -#include "Arp/System/Commons/Logging.h" - -namespace Utils -{ - -std::string -toString(const SafetyRelayHandler::DiagnosticType diagnosticType) -{ - switch (diagnosticType) - { - case SafetyRelayHandler::DiagnosticType::UNKNOWN: - return "UNKNOWN"; - case SafetyRelayHandler::DiagnosticType::Status: - return "Status"; - case SafetyRelayHandler::DiagnosticType::Alert: - return "Alert"; - case SafetyRelayHandler::DiagnosticType::Error: - return "Error"; - default: - return "UNKNOWN"; - } -} -} // namespace Utils \ No newline at end of file +#include "Utils/util.hpp" \ No newline at end of file diff --git a/src/projects/StarterKit/intermediate/code/StarterKitLibrary.meta.cpp b/src/projects/StarterKit/intermediate/code/StarterKitLibrary.meta.cpp index 2f04153..7ed4176 100644 --- a/src/projects/StarterKit/intermediate/code/StarterKitLibrary.meta.cpp +++ b/src/projects/StarterKit/intermediate/code/StarterKitLibrary.meta.cpp @@ -53,7 +53,7 @@ using namespace Arp::Plc::Commons::Meta; { "Command", offsetof(::StarterKit::StarterKitProgram, command_), DataType::Struct, CTN(), sizeof(StarterKit::StarterKitProgram::StarterKitCommand), alignof(StarterKit::StarterKitProgram::StarterKitCommand), { }, StandardAttribute::Input | StandardAttribute::Opc }, { "Config", offsetof(::StarterKit::StarterKitProgram, config_), DataType::Struct, CTN(), sizeof(StarterKit::StarterKitProgram::StarterKitConfig), alignof(StarterKit::StarterKitProgram::StarterKitConfig), { }, StandardAttribute::Input | StandardAttribute::Opc }, { "Data", offsetof(::StarterKit::StarterKitProgram, data_), DataType::Struct, CTN(), sizeof(StarterKit::StarterKitProgram::StarterKitData), alignof(StarterKit::StarterKitProgram::StarterKitData), { }, StandardAttribute::Output | StandardAttribute::Opc }, - { "DIN01", offsetof(::StarterKit::StarterKitProgram, digitalIn1_), DataType::Boolean, String::Empty, sizeof(Arp::boolean), alignof(Arp::boolean), { }, StandardAttribute::Input | StandardAttribute::Opc }, + { "DIN01", offsetof(::StarterKit::StarterKitProgram, dIN01_), DataType::Boolean, String::Empty, sizeof(Arp::boolean), alignof(Arp::boolean), { }, StandardAttribute::Input | StandardAttribute::Opc }, { "DIN02", offsetof(::StarterKit::StarterKitProgram, dIN02_), DataType::Boolean, String::Empty, sizeof(Arp::boolean), alignof(Arp::boolean), { }, StandardAttribute::Input | StandardAttribute::Opc }, { "DIN03", offsetof(::StarterKit::StarterKitProgram, dIN03_), DataType::Boolean, String::Empty, sizeof(Arp::boolean), alignof(Arp::boolean), { }, StandardAttribute::Input | StandardAttribute::Opc }, { "DIN04", offsetof(::StarterKit::StarterKitProgram, dIN04_), DataType::Boolean, String::Empty, sizeof(Arp::boolean), alignof(Arp::boolean), { }, StandardAttribute::Input | StandardAttribute::Opc }, diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index 6ed5936..87bfb0a 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -39,8 +39,8 @@ StarterKitProgram::Execute() { log.Info("Analog one reading: {0}", aiN1_); - const double scaledReading = convertMillivoltsToRange( - analogReading, config_.analogInOne.minRange, config_.analogInOne.maxRange); + const double scaledReading = convertMillivoltsToRange(aiN1_, config_.analogInOne.minRange, + config_.analogInOne.maxRange); log.Info("Scaled analog reading {0}", scaledReading); } From 1dfb5152b057655b1dfdfaed159f7e0bc4fec28d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Aug 2024 15:50:25 +1000 Subject: [PATCH 06/13] can build libs speratly --- .vscode/tasks.json | 14 ++++++++++++-- src/libs/Utils/docs/Timer.md | 13 +++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2007fb0..f023533 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -26,7 +26,7 @@ "label": "plcnext_build", "detail": "Build a PLCNext PLM project. Note: do not use this method if the port definitions have changed since it does not generate the required code for this.", "type": "shell", - "command": "export BUILD_TYPE=Release && echo Build PLCNext project for project ${input:project_name} && cd src/projects/${input:project_name} && plcncli build --verbose && plcncli deploy && cp bin/${input:project_name}.pcwlx /home/plc/Windows_PLCNextEngineer_Libraries", + "command": "export BUILD_TYPE=Release && echo Build PLCNext project for project ${input:project_name} && echo Build PLCNext libs && cd src/libs/Utils && plcncli build && cd ../../projects/${input:project_name} && plcncli build --verbose && plcncli deploy", "group": { "kind": "build" }, @@ -36,7 +36,17 @@ "label": "plcnext_gen_build", "detail": "Build a PLCNext PLM project", "type": "shell", - "command": "export BUILD_TYPE=Release && echo Build PLCNext release project for project ${input:project_name} && echo Build PLCNext libs && cd src/libs/Utils && plcncli build && cd ../../projects/${input:project_name} && plcncli generate code --verbose && plcncli generate config --verbose && plcncli build --verbose && plcncli deploy && cp bin/${input:project_name}.pcwlx /home/plc/Windows_PLCNextEngineer_Libraries && echo 'File copied successfully'", + "command": "export BUILD_TYPE=Release && echo Build PLCNext release project for project ${input:project_name} && echo Build PLCNext libs && cd src/libs/Utils && plcncli build && cd ../../projects/${input:project_name} && plcncli generate code --verbose && plcncli generate config --verbose && plcncli build --verbose && plcncli deploy", + "group": { + "kind": "build" + }, + "problemMatcher": "$gcc" + }, + { + "label": "plcnext_libs_build", + "detail": "Build Libs", + "type": "shell", + "command": "export BUILD_TYPE=Release && echo Build PLCNext libs && cd src/libs/Utils && plcncli build ", "group": { "kind": "build" }, diff --git a/src/libs/Utils/docs/Timer.md b/src/libs/Utils/docs/Timer.md index 0fd4141..e8610c8 100644 --- a/src/libs/Utils/docs/Timer.md +++ b/src/libs/Utils/docs/Timer.md @@ -11,19 +11,16 @@ Usage 1. Include the Timer Header Ensure that you include the Timer class header in your source file: -cpp -Copy code -#include "PlatingTimer.hpp" 2. Create a Timer Instance To create a timer, you need to specify the mode (TON or TOF) and the timeout duration. cpp Copy code // Create a TON timer with a 1-second delay -Plating::Timer tonTimer(Plating::TimerMode::TON, std::chrono::milliseconds(1000)); +Utils::Timer tonTimer(Utils::TimerMode::TON, std::chrono::milliseconds(1000)); // Create a TOF timer with a 1-second delay -Plating::Timer tofTimer(Plating::TimerMode::TOF, std::chrono::milliseconds(1000)); +Utils::Timer tofTimer(Utils::TimerMode::TOF, std::chrono::milliseconds(1000)); 3. Update the Timer Call the update() method in your loop or control logic to process the input signal and get the timer's output. @@ -54,13 +51,13 @@ Here’s a complete example demonstrating how to use the Timer class: cpp Copy code -#include "PlatingTimer.hpp" +#include "UtilsTimer.hpp" int main() { // Create timers - Plating::Timer tonTimer(Plating::TimerMode::TON, std::chrono::milliseconds(1000)); - Plating::Timer tofTimer(Plating::TimerMode::TOF, std::chrono::milliseconds(1000)); + Utils::Timer tonTimer(Utils::TimerMode::TON, std::chrono::milliseconds(1000)); + Utils::Timer tofTimer(Utils::TimerMode::TOF, std::chrono::milliseconds(1000)); bool input = /* your input condition */; From 93e9ea22beb38d6c121f56984c76a848f7f02277 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Aug 2024 16:38:39 +1000 Subject: [PATCH 07/13] might have just fixed it --- .vscode/c_cpp_properties.json | 24 ++++++++++++------- .../StarterKit/src/StarterKitProgram.cpp | 10 ++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a83533a..02138e3 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,19 +1,25 @@ { "configurations": [ { - "name": "Linux", + "name": "linux", + "compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux/arm-pxc-linux-g++", + "cStandard": "c99", + "cppStandard": "c++14", + "intelliSenseMode": "linux-gcc-arm", "includePath": [ "${workspaceFolder}/**", "/usr/include/**", - "/opt/plcnext_axcf2152-linux_sdk_2024/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**", - "${workspaceFolder}/src/projects/StarterKit/**" + "${workspaceFolder}/src/projects/StarterKit/**", + "/opt/axcf2152-linux_sdk_2024/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/**" ], - "defines": [], - "compilerPath": "/usr/bin/x86_64-linux-gnu-g++", - "cStandard": "c99", - "cppStandard": "c++14", - "intelliSenseMode": "linux-gcc-x86", - "configurationProvider": "ms-vscode.cpptools" + "compilerArgs": [ + "--sysroot=/opt/axcf2152-linux_sdk_2024/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi", + "-march=armv7-a", + "-mthumb", + "-mfpu=neon", + "-mfloat-abi=hard", + "-mcpu=cortex-a9" + ] } ], "version": 4 diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index 1fbd431..a80a7c2 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -4,7 +4,7 @@ namespace StarterKit { -uint32 +uint32_t StarterKitProgram::convertMillivoltsToRange(uint32 millivolts, uint32 minRange, uint32 maxRange) { // Convert millivolts to volts as a floating-point number @@ -16,7 +16,7 @@ StarterKitProgram::convertMillivoltsToRange(uint32 millivolts, uint32 minRange, // Cast the result to uint32 for return return scaled; -} +}; void StarterKitProgram::Execute() @@ -39,13 +39,13 @@ StarterKitProgram::Execute() { uint32 analogReading = aiN1_; - log.Info("Analog one reading: {0}", analogReading); + // log.Info("Analog one reading: {0}", analogReading); const double scaledReading = convertMillivoltsToRange( analogReading, config_.analogInOne.minRange, config_.analogInOne.maxRange); - log.Info("Scaled analog reading {0}", scaledReading); + // log.Info("Scaled analog reading {0}", scaledReading); } -} +}; } // end of namespace StarterKit From ed308560d5b0cecc9201213f58a66fd3e4880181 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Aug 2024 17:01:33 +1000 Subject: [PATCH 08/13] don't get sqiggle error but liting is broke still --- .vscode/c_cpp_properties.json | 2 +- .vscode/settings.json | 2 +- src/projects/StarterKit/src/StarterKitProgram.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 02138e3..5c86830 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -2,7 +2,7 @@ "configurations": [ { "name": "linux", - "compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux/arm-pxc-linux-g++", + "compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++", "cStandard": "c99", "cppStandard": "c++14", "intelliSenseMode": "linux-gcc-arm", diff --git a/.vscode/settings.json b/.vscode/settings.json index ecf22b7..f38d7e6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -170,5 +170,5 @@ } ], "cmake.ignoreCMakeListsMissing": true, - "C_Cpp.default.compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++" + "C_Cpp.default.compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux/arm-pxc-linux-g++" } \ No newline at end of file diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index a80a7c2..9039585 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -5,7 +5,8 @@ namespace StarterKit { uint32_t -StarterKitProgram::convertMillivoltsToRange(uint32 millivolts, uint32 minRange, uint32 maxRange) +StarterKitProgram::convertMillivoltsToRange(uint32_t millivolts, uint32_t minRange, + uint32_t maxRange) { // Convert millivolts to volts as a floating-point number double voltage = static_cast(millivolts) / 1000.0; @@ -37,14 +38,14 @@ StarterKitProgram::Execute() if (command_.readAnalog1) { - uint32 analogReading = aiN1_; + uint32_t analogReading = aiN1_; - // log.Info("Analog one reading: {0}", analogReading); + log.Info("Analog one reading: {0}", analogReading); const double scaledReading = convertMillivoltsToRange( analogReading, config_.analogInOne.minRange, config_.analogInOne.maxRange); - // log.Info("Scaled analog reading {0}", scaledReading); + log.Info("Scaled analog reading {0}", scaledReading); } }; From 5066246fbec5707f2ab32fd1bb179ff3c92ddc2f Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 Aug 2024 18:44:24 +1000 Subject: [PATCH 09/13] linting works, maybe it had to be c++ 11 --- .vscode/c_cpp_properties.json | 2 +- .vscode/settings.json | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 5c86830..0c6a887 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,7 +4,7 @@ "name": "linux", "compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux-gnueabi/arm-pxc-linux-gnueabi-g++", "cStandard": "c99", - "cppStandard": "c++14", + "cppStandard": "c++11", "intelliSenseMode": "linux-gcc-arm", "includePath": [ "${workspaceFolder}/**", diff --git a/.vscode/settings.json b/.vscode/settings.json index baed87e..853d217 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,24 @@ { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + }, + "editor.fontFamily": "'MesloLGS NF',Consolas, 'Courier New', monospace", + "editor.tabSize": 4, + "editor.insertSpaces": true, + "editor.rulers": [ + 100 + ], + "clang-format.executable": "/usr/bin/clang-format-14", + "clang-format.style": "file", + "clang-format.language.c.enable": true, + "[cpp]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "C_Cpp.files.exclude": { + "**/build/**": true, + }, + "terminal.integrated.defaultProfile.linux": "zsh", "files.associations": { "cctype": "cpp", "clocale": "cpp", @@ -150,6 +170,5 @@ "italic": false } ], - "cmake.ignoreCMakeListsMissing": true, - "C_Cpp.default.compilerPath": "/opt/axcf2152-linux_sdk_2024/sysroots/x86_64-pokysdk-linux/usr/bin/arm-pxc-linux/arm-pxc-linux-g++" + "cmake.ignoreCMakeListsMissing": true } \ No newline at end of file From 54cf098d427e43b1b386fe922c8d64cd4eddac2f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 3 Sep 2024 11:52:35 +1000 Subject: [PATCH 10/13] added error util --- src/libs/Utils/include/Utils/error.hpp | 17 +++++++++++++++++ .../StarterKit/src/StarterKitProgram.cpp | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/libs/Utils/include/Utils/error.hpp diff --git a/src/libs/Utils/include/Utils/error.hpp b/src/libs/Utils/include/Utils/error.hpp new file mode 100644 index 0000000..4fbc71c --- /dev/null +++ b/src/libs/Utils/include/Utils/error.hpp @@ -0,0 +1,17 @@ +#pragma once + +/* Class that will allow error catching*/ + +namespace Utils +{ + +class Error +{ + public: + virtual bool hasWarning() = 0; + virtual bool hasError() = 0; + virtual void clearWarnings() = 0; + virtual void clear() = 0; +}; + +} // namespace Utils \ No newline at end of file diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index c80723c..bfbd4b3 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -1,6 +1,7 @@ #include "StarterKitProgram.hpp" #include "Arp/System/Commons/Logging.h" #include "Arp/System/Core/ByteConverter.hpp" +#include "Utils/include/Utils/util.hpp" namespace StarterKit { @@ -43,7 +44,7 @@ StarterKitProgram::Execute() const double scaledReading = convertMillivoltsToRange(aiN1_, config_.analogInOne.minRange, config_.analogInOne.maxRange); - // log.Info("Scaled analog reading {0}", scaledReading); + log.Info("Scaled analog reading {0}", scaledReading); } }; From b9e69eebcda57f54b43dd58709da02b7eee9ba6d Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 13 Sep 2024 19:07:36 +1000 Subject: [PATCH 11/13] trying to fix the lib connection to projects --- src/libs/Utils/Config.cmake.in | 1 + src/projects/StarterKit/CMakeLists.txt | 6 +++++- src/projects/StarterKit/src/StarterKitProgram.cpp | 6 +++++- src/projects/StarterKit/src/StarterKitProgram.hpp | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libs/Utils/Config.cmake.in b/src/libs/Utils/Config.cmake.in index ecff60f..c8281cc 100644 --- a/src/libs/Utils/Config.cmake.in +++ b/src/libs/Utils/Config.cmake.in @@ -1,4 +1,5 @@ @PACKAGE_INIT@ + include( "@PACKAGE_LIB_INSTALL_DIR@/Utils-targets.cmake" ) set_and_check(Utils_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") diff --git a/src/projects/StarterKit/CMakeLists.txt b/src/projects/StarterKit/CMakeLists.txt index b944d0c..f621373 100644 --- a/src/projects/StarterKit/CMakeLists.txt +++ b/src/projects/StarterKit/CMakeLists.txt @@ -27,8 +27,11 @@ target_include_directories(${CMAKE_PROJECT_NAME} list(INSERT CMAKE_MODULE_PATH 0 "${ARP_TOOLCHAIN_CMAKE_MODULE_PATH}") +set (Utils_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/Utils/bin/AXCF2152_2024.0.0.102/${CMAKE_BUILD_TYPE}/cmake) + ####################################################################################### + ################# set RPATH to ORIGIN for third party libraries ####################### # Only by setting this is it possible to use libraries which are not already # # installed in the default install locations on the target. # @@ -58,8 +61,9 @@ target_link_options(${CMAKE_PROJECT_NAME} PRIVATE LINKER:--no-undefined) find_package(ArpDevice REQUIRED) find_package(ArpProgramming REQUIRED) +find_package(Utils CONFIG REQUIRED) -target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArpDevice ArpProgramming Utils) ####################################################################################### diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index bfbd4b3..8780e3e 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -1,7 +1,6 @@ #include "StarterKitProgram.hpp" #include "Arp/System/Commons/Logging.h" #include "Arp/System/Core/ByteConverter.hpp" -#include "Utils/include/Utils/util.hpp" namespace StarterKit { @@ -25,6 +24,11 @@ StarterKitProgram::Execute() { // implement program + bool tonOutput = tonTimer.update(dIN02_); + + + + if (config_.allowOutputs && command_.setOutput || dIN01_) { // control two fans for cooling diff --git a/src/projects/StarterKit/src/StarterKitProgram.hpp b/src/projects/StarterKit/src/StarterKitProgram.hpp index 273d974..7943292 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.hpp +++ b/src/projects/StarterKit/src/StarterKitProgram.hpp @@ -3,6 +3,7 @@ #include "Arp/System/Commons/Logging.h" #include "Arp/System/Core/Arp.h" #include "StarterKitComponent.hpp" +#include "Utils/util.hpp" namespace StarterKit { @@ -267,6 +268,7 @@ class StarterKitProgram : public ProgramBase, private Loggable Date: Sat, 12 Oct 2024 12:08:05 +1100 Subject: [PATCH 12/13] FIX - Cmake lib buidling with project --- src/projects/StarterKit/CMakeLists.txt | 2 +- src/projects/StarterKit/src/StarterKitProgram.cpp | 5 +---- src/projects/StarterKit/src/StarterKitProgram.hpp | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/projects/StarterKit/CMakeLists.txt b/src/projects/StarterKit/CMakeLists.txt index f621373..67a628d 100644 --- a/src/projects/StarterKit/CMakeLists.txt +++ b/src/projects/StarterKit/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(${CMAKE_PROJECT_NAME} list(INSERT CMAKE_MODULE_PATH 0 "${ARP_TOOLCHAIN_CMAKE_MODULE_PATH}") -set (Utils_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/Utils/bin/AXCF2152_2024.0.0.102/${CMAKE_BUILD_TYPE}/cmake) +set (Utils_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/Utils/bin/AXCF2152_24.0.0.102/${CMAKE_BUILD_TYPE}/cmake) ####################################################################################### diff --git a/src/projects/StarterKit/src/StarterKitProgram.cpp b/src/projects/StarterKit/src/StarterKitProgram.cpp index 8780e3e..51f3163 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.cpp +++ b/src/projects/StarterKit/src/StarterKitProgram.cpp @@ -24,10 +24,7 @@ StarterKitProgram::Execute() { // implement program - bool tonOutput = tonTimer.update(dIN02_); - - - + // bool tonOutput = tonTimer.update(dIN02_); if (config_.allowOutputs && command_.setOutput || dIN01_) { diff --git a/src/projects/StarterKit/src/StarterKitProgram.hpp b/src/projects/StarterKit/src/StarterKitProgram.hpp index 7943292..d7374ac 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.hpp +++ b/src/projects/StarterKit/src/StarterKitProgram.hpp @@ -268,7 +268,7 @@ class StarterKitProgram : public ProgramBase, private Loggable Date: Wed, 12 Feb 2025 19:30:12 +1100 Subject: [PATCH 13/13] Adding error heading --- src/projects/StarterKit/src/StarterKitProgram.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/projects/StarterKit/src/StarterKitProgram.hpp b/src/projects/StarterKit/src/StarterKitProgram.hpp index d7374ac..278401a 100644 --- a/src/projects/StarterKit/src/StarterKitProgram.hpp +++ b/src/projects/StarterKit/src/StarterKitProgram.hpp @@ -3,8 +3,10 @@ #include "Arp/System/Commons/Logging.h" #include "Arp/System/Core/Arp.h" #include "StarterKitComponent.hpp" +#include "Utils/error.hpp" #include "Utils/util.hpp" + namespace StarterKit {