Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 5 additions & 17 deletions AdsLib/AdsException.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,13 @@
#include <stdexcept>
#include <string>

struct AdsException : std::exception {
AdsException(const long adsErrorCode)
: errorCode(adsErrorCode)
, m_Message("Ads operation failed with error code " +
std::to_string(adsErrorCode) + ".")
struct AdsException : std::runtime_error {
explicit AdsException(const long adsErrorCode)
: std::runtime_error("Ads operation failed with error code " +
std::to_string(adsErrorCode) + "."),
errorCode(adsErrorCode)
{
}

virtual ~AdsException() throw()
{
}

virtual const char *what() const throw()
{
return m_Message.c_str();
}

const long errorCode;

protected:
const std::string m_Message;
};
2 changes: 1 addition & 1 deletion AdsLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif ()

if (BUILD_SHARED_LIBS)
target_compile_definitions(TcAdsLib
target_compile_definitions(AdsLib
PUBLIC
BHF_ADS_EXPORT_C
BHF_ADS_USE_TWINCAT_ORDER
Expand Down
2 changes: 1 addition & 1 deletion AdsLib/MasterDcStatAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ long MasterDcStatAccess::Print(std::ostream &os) const
sizeof(stat.posArr) / sizeof(stat.posArr[0])>
rowNames{ {
"1", "2", "5", "10", "20", "50", "100", "200", "500",
"\u221E" // infinity symbol
u8"\u221E" // infinity symbol
} };

os << "Deviation <" << " | " << "Count (neg)" << " | " << "Count (pos)"
Expand Down
2 changes: 1 addition & 1 deletion AdsLib/standalone/AmsRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ long AmsRouter::AddRoute(AmsNetId ams, const std::string &host)
}

return -1;
} catch (std::exception &e) {
} catch (...) {
lock.lock();
connection_attempts.erase(ams);
connection_attempt_events.notify_all();
Expand Down
4 changes: 4 additions & 0 deletions AdsLibTestRef/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
if (NOT TcAdsDll_FOUND)
return()
endif ()
# Skip this test if we are not on Windows or FreeBSD system
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
return()
endif ()

set(SOURCES
main.cpp
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ include(GNUInstallDirs)

option(WITH_EXAMPLES "Build the examples (for the variant)" ON)
option(WITH_TESTS "Build the test (for the variant)" ON)
option(STANDALONE_ONLY "Build only the AdsLib as stand alone (no TwinCat TcAdsDll targets)" OFF)
option(STANDALONE_ONLY "Build only the AdsLib as stand alone (no TwinCAT TcAdsDll targets)" OFF)

#Find the needed dependencies
find_package(Threads REQUIRED)
if (NOT STANDALONE_ONLY)
find_package(TcAdsDll)
if (NOT TcAdsDll_FOUND)
message(WARNING "Could NOT find TcAdsDll. TwinCat project targets will not be added.")
message(WARNING "Could NOT find TcAdsDll. TwinCAT router project targets will not be added.")
endif ()
endif ()
# This list variable will contain all the targets that are created and need to be install.
Expand Down
8 changes: 1 addition & 7 deletions cmake/FindTcAdsDll.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ if (NOT TcAdsDll_FIND_QUIETLY)
message(STATUS "Looking for TcAdsDll (TwinCAT ADS-DLL)...")
endif ()

if (NOT WIN32)
message(WARNING "FindTcAdsDll.cmake only tested on WINDOWS")
endif ()

if (WIN32)
# Typical install locations on Windows
set(_TcAdsDll_PATH "$ENV{SystemDrive}/TwinCAT/AdsApi/TcAdsDll")
else ()
# TODO: Linux not tested. Set additional known default locations to search.
set(_TcAdsDll_PATH)
endif ()
# Find the include headers
Expand All @@ -34,7 +29,7 @@ find_path(TcAdsDll_INCLUDE_DIR
PATH_SUFFIXES "Include" "include"
)
# Find all related files base on the include files location. This is done
# assuming that the files are ordered as install by TwinCat. If they are
# assuming that the files are ordered as install by TwinCAT. If they are
# in some other configuration this will not work.
if (WIN32)
cmake_path(GET TcAdsDll_INCLUDE_DIR PARENT_PATH TcAdsDll_ROOT_DIR)
Expand Down Expand Up @@ -62,7 +57,6 @@ if (WIN32)
NO_DEFAULT_PATH
)
else ()
# TODO: Linux not tested. We just try to look for the library by name.
find_library(TcAdsDll_LIBRARY
NAMES TcAdsDll
)
Expand Down