Merge branch '1.13.x' into develop
Change-Id: I15dad787598a84c05a04074666b784132d288e5f
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11c8f02..dad976d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,11 @@
mark_as_advanced(FORTE_ADDITIONAL_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FORTE_ADDITIONAL_CXX_FLAGS}")
endif(MSVC)
+
+ option(FORTE_WINDOWS_XP_COMPAT OFF "Enable some workarounds for Windows XP compatibility")
+ if (FORTE_WINDOWS_XP_COMPAT)
+ add_definitions(-DWINDOWS_XP_COMPAT=1)
+ endif()
endif(WIN32)
#######################################################################################
@@ -148,6 +153,12 @@
unset(LUAJIT_MATH_LIBRARY CACHE)
endif(NOT ("${FORTE_USE_LUATYPES}" STREQUAL "None"))
+#######################################################################################
+# Early definition of option how to generate stringlist for every source file
+#######################################################################################
+SET(FORTE_LINKED_STRINGDICT ON CACHE BOOL "FORTE will resolve references to the stringdict at link-stage and not compile-stage. This will reduce compiletime if the stringdict changes.")
+mark_as_advanced(FORTE_LINKED_STRINGDICT)
+
#######################################################################################
# Add subdirectories
#######################################################################################
@@ -189,9 +200,9 @@
mark_as_advanced(FORTE_CommunicationInterruptQueueSize)
if(FORTE_DYNAMIC_TYPE_LOAD)
-SET(FORTE_IPLayerRecvBufferSize "20000" CACHE STRING "FORTE ip layer recv buffer size" FORCE)
+SET(FORTE_IPLayerRecvBufferSize "20000" CACHE STRING "FORTE ip layer recv buffer size")
else()
-SET(FORTE_IPLayerRecvBufferSize "1500" CACHE STRING "FORTE ip layer recv buffer size" FORCE)
+SET(FORTE_IPLayerRecvBufferSize "1500" CACHE STRING "FORTE ip layer recv buffer size")
endif(FORTE_DYNAMIC_TYPE_LOAD)
mark_as_advanced(FORTE_IPLayerRecvBufferSize)
@@ -269,12 +280,9 @@
ENDFOREACH(FBLIB_FILE)
LIST(REMOVE_DUPLICATES SOURCE_FILES)
-#######################################################################################
-# Generate stringlist for every source file
-#######################################################################################
-SET(FORTE_LINKED_STRINGDICT ON CACHE BOOL "FORTE will resolve references to the stringdict at link-stage and not compile-stage. This will reduce compiletime if the stringdict changes.")
-mark_as_advanced(FORTE_LINKED_STRINGDICT)
-
+#######################################################################################
+# Generate stringlist for every source file
+#######################################################################################
SET(FORTE_MODIFY_SOURCES_ON_MISSING_GENERATED_INCLUDES ON CACHE BOOL "FORTE change the source-files if includes for the generated includes are missing.")
mark_as_advanced(FORTE_MODIFY_SOURCES_ON_MISSING_GENERATED_INCLUDES)
diff --git a/buildsupport/check_compiler_features.cmake b/buildsupport/check_compiler_features.cmake
index bd166c7..8a0d6cf 100644
--- a/buildsupport/check_compiler_features.cmake
+++ b/buildsupport/check_compiler_features.cmake
@@ -1,5 +1,5 @@
#********************************************************************************
-# Copyright (c) 2020 TU Wien/ACIN
+# Copyright (c) 2020 TU Wien/ACIN, OFFIS e.V.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
@@ -9,15 +9,21 @@
# Contributors:
# Martin Melik Merkumians
# - initial API and implementation and/or initial documentation
+# Jörg Walter - fix detection to honor C++ standard settings
# *******************************************************************************/
+cmake_policy(PUSH)
+cmake_policy(SET CMP0067 NEW)
+
include(CheckCXXSourceCompiles)
-MACRO(TEST_NEEDED_FORTE_COMPILER_FEATURES)
-CHECK_CXX_SOURCE_COMPILES("int main() { void* p = nullptr; }"
+function(TEST_NEEDED_FORTE_COMPILER_FEATURES)
+ check_cxx_source_compiles("int main() { void* p = nullptr; }"
NULLPTR_SUPPORTED
FAIL_REGEX "use of undeclared identifier 'nullptr'")
-if(NOT NULLPTR_SUPPORTED)
+ if(NOT NULLPTR_SUPPORTED)
message(WARNING "`nullptr` not supported, replacing it with 0 via precprocessor")
forte_add_definition("-Dnullptr=0")
-endif()
-ENDMACRO(TEST_NEEDED_FORTE_COMPILER_FEATURES)
\ No newline at end of file
+ endif()
+endfunction()
+
+cmake_policy(POP)
diff --git a/buildsupport/forte.cmake b/buildsupport/forte.cmake
index d3b129d..48af9d8 100644
--- a/buildsupport/forte.cmake
+++ b/buildsupport/forte.cmake
@@ -1,13 +1,15 @@
#*******************************************************************************
# Copyright (c) 2010 -2014 Profactor GmbH, ACIN, fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
+# 2020 Johannes Kepler University Linz
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
+#
+# Contributors:
# Michael Hofmann, Alois Zoitl, Gerhard Ebenhofer, Matthias Plash, Patrick Smejkal - initial API and implementation and/or initial documentation
+# Ernst Blecha - add directory-based module creation
# *******************************************************************************/
MACRO(forte_add_subdirectory DIRECTORY)
@@ -205,9 +207,9 @@
ENDFOREACH(ARG)
ENDFUNCTION(forte_add_architecture)
-MACRO(forte_add_network_layer NAME ONOFF CONFIGNAME CLASSNAME FILENAME DISCRIPTION)
+MACRO(forte_add_network_layer NAME ONOFF CONFIGNAME CLASSNAME FILENAME DESCRIPTION)
# TODO: parse filename from filename
- set(FORTE_COM_${NAME} ${ONOFF} CACHE BOOL "${DISCRIPTION}")
+ set(FORTE_COM_${NAME} ${ONOFF} CACHE BOOL "${DESCRIPTION}")
IF(FORTE_COM_${NAME})
FORTE_ADD_SOURCEFILE_HCPP(${FILENAME})
set_property(GLOBAL APPEND PROPERTY FORTE_LAYER_CLASS ${CLASSNAME})
@@ -222,20 +224,35 @@
set_property(GLOBAL APPEND PROPERTY FORTE_HANDLER_FILENAME "${FILENAME}.h")
ENDMACRO(forte_add_handler)
-#MACRO(forte_add_module NAME DIRECTORY DISCRIPTION)
+#MACRO(forte_add_module NAME DIRECTORY DESCRIPTION)
# Additional parameters are interpreted as dependencies
-MACRO(forte_add_module NAME DISCRIPTION)
- set(FORTE_MODULE_${NAME} OFF CACHE BOOL "${DISCRIPTION}")
+MACRO(forte_add_module NAME DESCRIPTION)
+ # create module with value from cache (does not set the description if the entry exists)
+ SET(FORTE_MODULE_${NAME} OFF CACHE BOOL "${DESCRIPTION}")
+ # update the module description stored in cache
+ SET(FORTE_MODULE_${NAME} ${FORTE_MODULE_${NAME}} CACHE BOOL "${DESCRIPTION}" FORCE)
+
FOREACH(dependencies ${ARGN})
- if(NOT ${dependencies})
- return()
- endif(NOT ${dependencies})
+ IF(NOT ${dependencies})
+ RETURN()
+ ENDIF(NOT ${dependencies})
ENDFOREACH(dependencies)
- if(NOT FORTE_MODULE_${NAME})
- return()
- endif(NOT FORTE_MODULE_${NAME})
+ IF(NOT FORTE_MODULE_${NAME})
+ RETURN()
+ ENDIF(NOT FORTE_MODULE_${NAME})
ENDMACRO(forte_add_module)
+MACRO(forte_add_directory_module)
+ # use the current directory name as basis for naming the module
+ GET_FILENAME_COMPONENT(MODULENAME ${CMAKE_CURRENT_LIST_DIR} NAME)
+ SET(MODULENAME "EXTERNAL_${MODULENAME}")
+
+ forte_directory_listing(DESCRIPTION "*.cpp" "*.c" "*.h")
+
+ # add the module (stops execution if module is disabled!)
+ forte_add_module(${MODULENAME} ${DESCRIPTION})
+ENDMACRO(forte_add_directory_module)
+
#MACRO(forte_add_io NAME DIRECTORY DESCRIPTION)
MACRO(forte_add_io NAME DESCRIPTION)
set(FORTE_IO_${NAME} OFF CACHE BOOL "${DESCRIPTION}")
@@ -269,6 +286,40 @@
ENDFOREACH(ARG)
ENDFUNCTION(forte_add_post_build_command)
+FUNCTION(forte_directory_listing VARIABLE EXTENSION)
+ # retrieve all files matching the given extension(s)
+ file(GLOB FILES LIST_DIRECTORIES false CONFIGURE_DEPENDS ${EXTENSION} ${ARGN})
+ # loop over the files, extract the name
+ FOREACH(FILE ${FILES})
+ get_filename_component(FILENAME ${FILE} NAME)
+ list(APPEND FILENAMES ${FILENAME})
+ ENDFOREACH()
+ # create a newline-seperated list of files
+ list(JOIN FILENAMES "\n" FILENAMESTRING)
+ set(${VARIABLE} "${CMAKE_CURRENT_LIST_DIR}\n${FILENAMESTRING}" PARENT_SCOPE)
+ENDFUNCTION(forte_directory_listing)
+
+FUNCTION(forte_add_all_sourcefiles)
+ forte_add_all_sourcefiles_h()
+ forte_add_all_sourcefiles_c()
+ forte_add_all_sourcefiles_cpp()
+ENDFUNCTION(forte_add_all_sourcefiles)
+
+FUNCTION(forte_add_all_sourcefiles_h)
+ file(GLOB FILES LIST_DIRECTORIES false CONFIGURE_DEPENDS "*.h")
+ forte_add_sourcefile_with_path_h(${FILES})
+ENDFUNCTION(forte_add_all_sourcefiles_h)
+
+FUNCTION(forte_add_all_sourcefiles_c)
+ file(GLOB FILES LIST_DIRECTORIES false CONFIGURE_DEPENDS "*.c")
+ forte_add_sourcefile_with_path_c(${FILES})
+ENDFUNCTION(forte_add_all_sourcefiles_c)
+
+FUNCTION(forte_add_all_sourcefiles_cpp)
+ file(GLOB FILES LIST_DIRECTORIES false CONFIGURE_DEPENDS "*.cpp")
+ forte_add_sourcefile_with_path_cpp(${FILES})
+ENDFUNCTION(forte_add_all_sourcefiles_cpp)
+
## forte_add_systemtest_hard (test_name bootfile_name timeout)
## Fails if any error has been logged
FUNCTION(forte_add_systemtest_hard arg1 arg2 arg3)
diff --git a/forte_config.h.in b/forte_config.h.in
index 7436e9f..944187d 100644
--- a/forte_config.h.in
+++ b/forte_config.h.in
@@ -31,7 +31,7 @@
* For Smaller devices which do not use 64 bit datatypes a time base of 1000 (i.e., 1ms)
* or 1000000 (i.e., 1micro s) may be suitable.
*/
-const uint_fast32_t cgForteTimeBaseUnitsPerSecond = ${FORTE_TimeBaseUnitsPerSecond};
+const uint_fast64_t cgForteTimeBaseUnitsPerSecond = ${FORTE_TimeBaseUnitsPerSecond};
/*! Define the initial size of the event chain list used in the event chain execution thread.
diff --git a/setup_lmsEv3.sh b/setup_lmsEv3.sh
index 59f454c..181fb5d 100755
--- a/setup_lmsEv3.sh
+++ b/setup_lmsEv3.sh
@@ -31,7 +31,7 @@
cd "./$forte_bin_dir"
- cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/cabral/work/arm-linux-gnueabi.cmake" -DFORTE_MODULE_LMS_EV3=ON -DFORTE_ARCHITECTURE=Posix -DFORTE_COM_ETH=ON -DFORTE_COM_FBDK=ON -DFORTE_COM_LOCAL=ON -DFORTE_TESTS=OFF -DFORTE_TESTS_INC_DIRS=${forte_boost_test_inc_dirs} -DFORTE_TESTS_LINK_DIRS=${forte_boost_test_inc_dirs} -DFORTE_MODULE_CONVERT=ON -DFORTE_MODULE_MATH=ON -DFORTE_MODULE_IEC61131=ON -DFORTE_MODULE_OSCAT=ON -DFORTE_MODULE_Test=ON -DFORTE_MODULE_UTILS=ON ../../
+ cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/compiler/toolchain-armel.cmake" -DFORTE_MODULE_LMS_EV3=ON -DFORTE_ARCHITECTURE=Posix -DFORTE_COM_ETH=ON -DFORTE_COM_FBDK=ON -DFORTE_COM_LOCAL=ON -DFORTE_TESTS=OFF -DFORTE_TESTS_INC_DIRS=${forte_boost_test_inc_dirs} -DFORTE_TESTS_LINK_DIRS=${forte_boost_test_inc_dirs} -DFORTE_MODULE_CONVERT=ON -DFORTE_MODULE_MATH=ON -DFORTE_MODULE_IEC61131=ON -DFORTE_MODULE_OSCAT=ON -DFORTE_MODULE_Test=ON -DFORTE_MODULE_UTILS=ON ../../
else
echo "unable to create ${forte_bin_dir}"
exit 1
diff --git a/src/arch/posix/forte_sem.cpp b/src/arch/posix/forte_sem.cpp
index ef7cefb..9cf2ca8 100644
--- a/src/arch/posix/forte_sem.cpp
+++ b/src/arch/posix/forte_sem.cpp
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2018 fortiss GmbH, TU Vienna/ACIN
+ * Copyright (c) 2016, 2020 fortiss GmbH, TU Vienna/ACIN, OFFIS e.V.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -10,58 +10,106 @@
* Alois Zoitl - initial API and implementation and/or initial documentation
* Peter Gsellmann, Martin Melik-Merkumians - adds timed wait and try and no wait
* and documentation
+ * Jörg Walter - make timed wait work withoout busy-loop, switch to binary
+ * semaphore
+ *
*******************************************************************************/
-#include <errno.h>
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
+#include <cerrno>
+#include <cstring>
+#include <ctime>
+#include <cassert>
#include "forte_sem.h"
#include "../devlog.h"
#include "../utils/timespec_utils.h"
+#include <criticalregion.h>
namespace forte {
namespace arch {
- CPThreadSemaphore::CPThreadSemaphore(unsigned int paInitialValue){
- if(-1 == sem_init(&mSemaphore, 0, paInitialValue)){
- DEVLOG_ERROR("Could not initialize suspend sempaphore: %s\n", strerror(errno));
+ CPThreadSemaphore::CPThreadSemaphore(bool paInitialValue) : mPosted(paInitialValue){
+ pthread_condattr_t condAttr;
+
+ if (pthread_condattr_init(&condAttr) != 0) {
+ DEVLOG_ERROR("Could not initialize cv attributes\n");
}
+ if (pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC) != 0) {
+ DEVLOG_ERROR("Could not set cv clock\n");
+ }
+ if (pthread_cond_init(&mCond, &condAttr) != 0) {
+ DEVLOG_ERROR("Could not initialize condition variable\n");
+ }
+ pthread_condattr_destroy(&condAttr);
}
+
CPThreadSemaphore::~CPThreadSemaphore(){
- sem_destroy(&mSemaphore);
+ pthread_cond_destroy(&mCond);
}
+
void CPThreadSemaphore::inc(){
- sem_post(&mSemaphore);
+ CCriticalRegion cr(mMutex);
+ mPosted = true;
+ pthread_cond_signal(&mCond);
}
+
void CPThreadSemaphore::waitIndefinitely(){
- while((-1 == sem_wait(&mSemaphore)) && (errno == EINTR)); //handle interrupts from signals
+ CCriticalRegion cr(mMutex);
+ while (!mPosted) {
+ pthread_cond_wait(&mCond, mMutex.getPosixMutex());
+ }
+ mPosted = false;
}
+
bool CPThreadSemaphore::timedWait(const TForteUInt64 paRelativeTimeout){
- timespec timeoutSpec = { static_cast<time_t>(paRelativeTimeout / scmSecondInNanoSeconds), static_cast<time_t>(paRelativeTimeout % scmSecondInNanoSeconds) };
+ CCriticalRegion cr(mMutex);
+
+ if (mPosted) {
+ mPosted = false;
+ return true;
+ }
+
+ timespec timeoutSpec = {
+ static_cast<time_t>(paRelativeTimeout / 1000000000ULL),
+ static_cast<time_t>(paRelativeTimeout % 1000000000ULL)
+ };
+
timespec currentTime = { 0, 0 };
clock_gettime(CLOCK_MONOTONIC, ¤tTime);
- timespec expectedAbsoluteTimeoutTime = {0, 0};
+ timespec expectedAbsoluteTimeoutTime = { 0, 0 };
timespecAdd(¤tTime, &timeoutSpec, &expectedAbsoluteTimeoutTime);
- do{
- if(0 == sem_trywait(&mSemaphore)){
- return true;
- }
- clock_gettime(CLOCK_MONOTONIC, ¤tTime);
+ int rc = 0;
+ while (!mPosted && rc == 0) {
+ rc = pthread_cond_timedwait(&mCond, mMutex.getPosixMutex(), &expectedAbsoluteTimeoutTime);
+ }
- } while(timespecLessThan(¤tTime, &expectedAbsoluteTimeoutTime));
- return false;
+ if (rc != 0 && rc != ETIMEDOUT) {
+ DEVLOG_ERROR("Unexpected error during condition variable wait: %i\n", rc);
+ }
+
+ assert(!(rc == 0 && !mPosted)
+ && (bool)"should have been posted when waiting successfully");
+
+ bool success = (mPosted && rc == 0);
+ if (success) {
+ mPosted = false;
+ }
+
+ return success;
}
+
bool CPThreadSemaphore::tryNoWait(){
- return (0 == sem_trywait(&mSemaphore));
+ CCriticalRegion cr(mMutex);
+ bool success = mPosted;
+ mPosted = false;
+ return success;
}
} /* namespace arch */
} /* namespace forte */
diff --git a/src/arch/posix/forte_sem.h b/src/arch/posix/forte_sem.h
index 2ce6be9..f99ec98 100644
--- a/src/arch/posix/forte_sem.h
+++ b/src/arch/posix/forte_sem.h
@@ -1,5 +1,6 @@
/*******************************************************************************
- * Copyright (c) 2016, 2018 fortiss GmbH, TU Vienna/ACIN
+ * Copyright (c) 2016 fortiss GmbH, TU Vienna/ACIN,
+ * 2020 OFFIS e.V., Johannes Kepler University Linz
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -10,25 +11,29 @@
* Alois Zoitl - initial API and implementation and/or initial documentation
* Peter Gsellmann, Martin Melik-Merkumians - adds timed wait and try and no wait
* and documentation
+ * Jörg Walter - make timed wait work without busy-loop, switch to binary
+ * semaphore
+ * Alois Zoitl - changed from pthread mutex to CPThreadSyncObject
*******************************************************************************/
#ifndef SRC_ARCH_POSIX_SEMAPHORE_H_
#define SRC_ARCH_POSIX_SEMAPHORE_H_
-#include <semaphore.h>
+#include <pthread.h>
#include "datatype.h"
+#include "forte_sync.h"
namespace forte {
namespace arch {
- /*!\brief counting semaphore for syncing operation in FORTE
+ /*!\brief binary semaphore for syncing operation in FORTE
*
* The semaphore is initialized with the value given.
*/
class CPThreadSemaphore{
public:
- explicit CPThreadSemaphore(unsigned int paInitialValue = 0);
+ explicit CPThreadSemaphore(bool paInitialValue = false);
~CPThreadSemaphore();
/** @brief Unlocks (increments) the semaphore
@@ -55,8 +60,24 @@
bool tryNoWait();
private:
- sem_t mSemaphore;
- static const TForteUInt64 scmSecondInNanoSeconds = (TForteUInt64)1E9;
+ /* TODO: in C++11, this class should be properly made non-copyable since
+ * mutexes cannot be copied after initialisation
+
+ CPThreadSemaphore(const CPThreadSemaphore &) = delete;
+ CPThreadSemaphore &operator=(const CPThreadSemaphore &) = delete;
+ */
+ CPThreadSemaphore(const CPThreadSemaphore &);
+ CPThreadSemaphore &operator=(const CPThreadSemaphore &);
+
+ /* Implementation is based on POSIX condition variables instead of POSIX
+ * semaphores, because POSIX semaphores cannot safely wait without busy
+ * looping. Derived from https://stackoverflow.com/a/57496953 */
+
+ CPThreadSyncObject mMutex;
+ pthread_cond_t mCond;
+
+ bool mPosted;
+
};
typedef CPThreadSemaphore CSemaphore;
diff --git a/src/arch/posix/forte_sync.cpp b/src/arch/posix/forte_sync.cpp
index 8a76eef..0cdf440 100644
--- a/src/arch/posix/forte_sync.cpp
+++ b/src/arch/posix/forte_sync.cpp
@@ -11,11 +11,11 @@
*******************************************************************************/
#include "forte_sync.h"
-CPCSyncObject::CPCSyncObject(){
- pthread_mutex_init(&m_oMutexHandle, 0);
+CPThreadSyncObject::CPThreadSyncObject(){
+ pthread_mutex_init(&mMutex, 0);
}
-CPCSyncObject::~CPCSyncObject(){
- pthread_mutex_destroy(&m_oMutexHandle);
+CPThreadSyncObject::~CPThreadSyncObject(){
+ pthread_mutex_destroy(&mMutex);
//TODO handle return value
}
diff --git a/src/arch/posix/forte_sync.h b/src/arch/posix/forte_sync.h
index 5dfa7d2..6d5927e 100644
--- a/src/arch/posix/forte_sync.h
+++ b/src/arch/posix/forte_sync.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 - 2011 ACIN
+ * Copyright (c) 2005, 2020 ACIN, OFFIS e.V.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -8,12 +8,20 @@
*
* Contributors:
* Alois Zoitl - initial API and implementation and/or initial documentation
+ * Jörg Walter - make objects non-copyable
*******************************************************************************/
#ifndef _FORTE_SYNC_H_
#define _FORTE_SYNC_H_
#include <pthread.h>
+namespace forte {
+ namespace arch {
+ //forward declaration of CPThreadSemaphore so that we can use it in friend
+ class CPThreadSemaphore;
+ }
+}
+
/*! \ingroup posix_hal
* \brief The sync object implementation for the posix thread interface.
@@ -22,31 +30,43 @@
*
*/
-class CPCSyncObject{
+class CPThreadSyncObject{
public:
- CPCSyncObject();
- ~CPCSyncObject();
+ CPThreadSyncObject();
+ ~CPThreadSyncObject();
/*!\brief Lock the resource coming after the lock command
*
* This function blocks until it will get the lock for the coming critical section.
*/
void lock(void){
- pthread_mutex_lock(&m_oMutexHandle);
+ pthread_mutex_lock(&mMutex);
//TODO handle return value
}
- //!Freee the resource coming after the lock command
+ //!Free the resource coming after the lock command
void unlock(void){
- pthread_mutex_unlock(&m_oMutexHandle);
+ pthread_mutex_unlock(&mMutex);
//TODO handle return value
}
+
private:
+ //! Accessor method to the mutex allowing platform specific code to use this sync object class.
+ pthread_mutex_t *getPosixMutex(){
+ return &mMutex;
+ }
+
+ // prevent copies, since pthread_mutex_t may not be copied
+ CPThreadSyncObject(const CPThreadSyncObject &); /* = delete; */
+ CPThreadSyncObject &operator=(const CPThreadSyncObject &); /* = delete; */
+
//! The posix thread mutex handle of the operating system.
- pthread_mutex_t m_oMutexHandle;
+ pthread_mutex_t mMutex;
+
+ friend class forte::arch::CPThreadSemaphore;
};
-typedef CPCSyncObject CSyncObject; //allows that doxygen can generate better documenation
+typedef CPThreadSyncObject CSyncObject; //allows that doxygen can generate better documenation
#endif /*FORTE_SYNC_H_*/
diff --git a/src/arch/timerha.cpp b/src/arch/timerha.cpp
index 78b4749..0e2d790 100644
--- a/src/arch/timerha.cpp
+++ b/src/arch/timerha.cpp
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright (c) 2005 - 2015 ACIN, Profactor GmbH, fortiss GmbH
+ * 2020 Johannes Kepler University Linz
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -8,18 +9,22 @@
*
* Contributors:
* Alois Zoitl, Rene Smodic, Thomas Strasser, Ingo Hegny
- * - initial API and implementation and/or initial documentation
+ * - initial API and implementation and/or initial documentation
+ * Alois Zoitl - worked on reducing the jitter and overhead of timer handler
+ * Bug #568902
*******************************************************************************/
#include "timerha.h"
#include "../core/datatypes/forte_time.h"
#include "../core/devexec.h"
#include "../core/esfb.h"
#include "../core/utils/criticalregion.h"
+#include <algorithm>
+#include <functional>
DEFINE_HANDLER(CTimerHandler)
CTimerHandler::CTimerHandler(CDeviceExecution& paDeviceExecution) : CExternalEventHandler(paDeviceExecution),
- mForteTime(0), mTimedFBList(0){
+ mForteTime(0), mTimedFBList(nullptr), mAddFBList(nullptr){
}
CTimerHandler::~CTimerHandler(){
@@ -28,20 +33,21 @@
void CTimerHandler::registerTimedFB(STimedFBListEntry *paTimerListEntry, const CIEC_TIME &paTimeInterval) {
//calculate the correct interval based on time-base and timer ticks per seconds
paTimerListEntry->mInterval = static_cast<TForteUInt32>((paTimeInterval * getTicksPerSecond()) / cgForteTimeBaseUnitsPerSecond);
+ // Correct null intervals that can lead to event queue overflow to at least 1 timer tick
+ if(0 == paTimerListEntry->mInterval) {
+ paTimerListEntry->mInterval = 1;
+ }
+ // set the first next activation time right here to reduce jitter, see Bug #568902 for details
+ paTimerListEntry->mTimeOut = mForteTime + paTimerListEntry->mInterval;
{
- CCriticalRegion criticalRegion(mSync);
- addTimedFBEntry(paTimerListEntry);
+ CCriticalRegion criticalRegion(mAddListSync);
+ paTimerListEntry->mNext = mAddFBList;
+ mAddFBList = paTimerListEntry;
}
}
void CTimerHandler::addTimedFBEntry(STimedFBListEntry *paTimerListEntry) {
- paTimerListEntry->mTimeOut = mForteTime + paTimerListEntry->mInterval; // the next activation time of this FB
paTimerListEntry->mNext = 0;
-
- // Correct null intervals that can lead to event queue overflow to 10 ms
- if(paTimerListEntry->mInterval == 0) {
- paTimerListEntry->mTimeOut += (getTicksPerSecond() > 100) ? getTicksPerSecond() / 100 : 1;
- }
if (0 == mTimedFBList) {
mTimedFBList = paTimerListEntry;
} else {
@@ -64,7 +70,11 @@
}
void CTimerHandler::unregisterTimedFB(CEventSourceFB *paTimedFB) {
- CCriticalRegion criticalRegion(mSync);
+ CCriticalRegion criticalRegion(mRemoveListSync);
+ mRemoveFBList.push_back(paTimedFB);
+}
+
+void CTimerHandler::removeTimedFB(CEventSourceFB *paTimedFB) {
if (0 != mTimedFBList) {
STimedFBListEntry *buffer = 0;
if (mTimedFBList->mTimedFB == paTimedFB) {
@@ -91,29 +101,65 @@
void CTimerHandler::nextTick(void) {
++mForteTime;
mDeviceExecution.notifyTime(mForteTime); //notify the device execution that one tick passed by.
- if(0 != mTimedFBList){
- //only check the list if there are entries in the list
- CCriticalRegion criticalRegion(mSync);
- while (0 != mTimedFBList) {
- if (mTimedFBList->mTimeOut > mForteTime) {
- break;
- }
- mDeviceExecution.startNewEventChain(mTimedFBList->mTimedFB);
- STimedFBListEntry *buffer = mTimedFBList;
- mTimedFBList = mTimedFBList->mNext;
- switch (buffer->mType) {
- case e_Periodic:
- addTimedFBEntry(buffer); //re-register the timed FB
- break;
- case e_SingleShot:
- // nothing special is to do up to now
- default:
- buffer->mNext = 0;
- buffer->mTimeOut = 0;
- break;
- }
+ if(!mRemoveFBList.empty()){
+ processRemoveList();
+ }
+
+ processTimedFBList();
+
+ if(0 != mAddFBList){
+ processAddList();
+ }
+}
+
+void CTimerHandler::processTimedFBList(){
+ while (0 != mTimedFBList) {
+ if (mTimedFBList->mTimeOut > mForteTime) {
+ break;
+ }
+ STimedFBListEntry *buffer = mTimedFBList;
+ mTimedFBList = buffer->mNext; //remove buffer from the list
+ triggerTimedFB(buffer);
+ }
+}
+
+void CTimerHandler::triggerTimedFB(STimedFBListEntry *paTimerListEntry){
+ mDeviceExecution.startNewEventChain(paTimerListEntry->mTimedFB);
+
+ switch (paTimerListEntry->mType) {
+ case e_Periodic:
+ paTimerListEntry->mTimeOut = mForteTime + paTimerListEntry->mInterval; // the next activation time of this FB
+ addTimedFBEntry(paTimerListEntry); //re-register the timed FB
+ break;
+ case e_SingleShot:
+ // nothing special is to do up to now, therefore go to default
+ default:
+ paTimerListEntry->mNext = 0;
+ paTimerListEntry->mTimeOut = 0;
+ break;
+ }
+}
+
+void CTimerHandler::processAddList(){
+ CCriticalRegion criticalRegion(mAddListSync);
+ while(0 != mAddFBList){
+ STimedFBListEntry *buffer = mAddFBList;
+ mAddFBList = buffer->mNext; //remove buffer from the list
+ if(buffer->mTimeOut < mForteTime){
+ // the time already passed trigger the fb
+ triggerTimedFB(buffer);
+ }
+ else{
+ addTimedFBEntry(buffer);
}
}
}
+void CTimerHandler::processRemoveList(){
+ CCriticalRegion criticalRegion(mRemoveListSync);
+ std::for_each(mRemoveFBList.begin(), mRemoveFBList.end(), std::bind1st(std::mem_fun(&CTimerHandler::removeTimedFB), this));
+ mRemoveFBList.clear();
+}
+
+
diff --git a/src/arch/timerha.h b/src/arch/timerha.h
index 2f471d5..6b380c1 100644
--- a/src/arch/timerha.h
+++ b/src/arch/timerha.h
@@ -1,14 +1,18 @@
/*******************************************************************************
* Copyright (c) 2005 - 2015 ACIN, Profactor GmbH, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
+ * 2020 Johannes Kepler University Linz
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alois Zoitl, Thomas Strasser, Rene Smodic, Monika Wenger, Ingo Hegny
* - initial API and implementation and/or initial documentation
+ * Alois Zoitl - worked on reducing the jitter and overhead of timer handler
+ * Bug #568902
*******************************************************************************/
#ifndef _TIMERHA_H_
#define _TIMERHA_H_
@@ -16,6 +20,7 @@
#include <forte_config.h>
#include "../core/extevhan.h"
#include <forte_sync.h>
+#include <vector>
class CEventSourceFB;
class CIEC_TIME;
@@ -37,7 +42,8 @@
* \ingroup EXTEVHAND
*/
class CTimerHandler : public CExternalEventHandler{
- DECLARE_HANDLER(CTimerHandler);
+ DECLARE_HANDLER(CTimerHandler)
+ ;
public:
/*!\brief create the timer handler and set the parameter pointer with the the new timer handler.
@@ -45,7 +51,7 @@
* This function is not implemented in the standardtimerhandler and has to be implemented in the specific implementation.
* implementations should check that not two timerhanlders can be created.
*/
- static CTimerHandler* createTimerHandler(CDeviceExecution& paDeviceExecution);
+ static CTimerHandler* createTimerHandler(CDeviceExecution &paDeviceExecution);
/*!\brief Sets the priority of the event source
*
@@ -87,18 +93,34 @@
return mForteTime;
}
- protected:
- CSyncObject mSync;
-
private:
//!Add an entry to the timed list.
void addTimedFBEntry(STimedFBListEntry *paTimerListEntry);
+ void processTimedFBList();
+ void processAddList();
+ void processRemoveList();
+
+ //!Remove an entry from the timed list.
+ void removeTimedFB(CEventSourceFB *paTimedFB);
+
+ //! process one timed FB entry, trigger the external event and if needed readd into the list.
+ void triggerTimedFB(STimedFBListEntry *paTimerListEntry);
+
//!The runtime time in ticks till the start of FORTE.
uint_fast64_t mForteTime;
//! List of function blocks currently registered to the timer handler
STimedFBListEntry *mTimedFBList;
+
+ //! List of function blocks to be added to the timer handler
+ STimedFBListEntry *mAddFBList;
+ CSyncObject mAddListSync;
+
+ //! List of function blocks to be removed from the timer handler
+ std::vector<CEventSourceFB *> mRemoveFBList;
+ CSyncObject mRemoveListSync;
+
};
#endif /*TIMERHA_H_*/
diff --git a/src/arch/win32/CMakeLists.txt b/src/arch/win32/CMakeLists.txt
index 53f625f..be144a7 100644
--- a/src/arch/win32/CMakeLists.txt
+++ b/src/arch/win32/CMakeLists.txt
@@ -20,7 +20,13 @@
forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
forte_add_sourcefile_h(fortealloc.h ../forte_architecture_time.h)
- forte_add_sourcefile_hcpp(forte_thread forte_sync forte_sem)
+ forte_add_sourcefile_hcpp(forte_thread forte_sem)
+ forte_add_sourcefile_h(forte_sync.h)
+ if(FORTE_WINDOWS_XP_COMPAT)
+ forte_add_sourcefile_cpp(forte_sync_xp.cpp)
+ else()
+ forte_add_sourcefile_cpp(forte_sync.cpp)
+ endif()
forte_add_sourcefile_cpp(forte_architecture.cpp forte_architecture_time.cpp winforte_printer.cpp)
forte_add_sourcefile_cpp(../genforte_realFunctions.cpp)
diff --git a/src/arch/win32/forte_sync.h b/src/arch/win32/forte_sync.h
index bde0fa6..9694231 100644
--- a/src/arch/win32/forte_sync.h
+++ b/src/arch/win32/forte_sync.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 - 2013, 2017 ACIN, Profactor GmbH, fortiss GmbH
+ * Copyright (c) 2010, 2020 ACIN, Profactor GmbH, fortiss GmbH, OFFIS e.V.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -8,6 +8,7 @@
*
* Contributors:
* Alois Zoitl, Gerhard Ebenhofer, Martin Melik-Merkumians - initial API and implementation and/or initial documentation
+ * Jörg Walter - Windows XP compatibility
*******************************************************************************/
#ifndef _FORTE_SYNC_H_
#define _FORTE_SYNC_H_
@@ -41,7 +42,14 @@
void unlock(void);
private:
+ CPCSyncObject(const CPCSyncObject &); /* = delete; */
+ CPCSyncObject &operator=(const CPCSyncObject &); /* = delete; */
+
+#ifdef WINDOWS_XP_COMPAT
+ CRITICAL_SECTION mLock;
+#else
SRWLOCK mLock;
+#endif
};
#endif /*FORTE_SYNC_H_*/
diff --git a/src/arch/win32/forte_sync_xp.cpp b/src/arch/win32/forte_sync_xp.cpp
new file mode 100644
index 0000000..5c69df1
--- /dev/null
+++ b/src/arch/win32/forte_sync_xp.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2020 ACIN, Profactor GmbH, fortiss GmbH, OFFIS e.V.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alois Zoitl, Gerhard Ebenhofer - initial API and implementation and/or initial documentation
+ * Jörg Walter - Windows XP compatibility
+ *******************************************************************************/
+
+#include "forte_sync.h"
+
+
+CPCSyncObject::CPCSyncObject(){
+ InitializeCriticalSection(&mLock);
+}
+
+CPCSyncObject::~CPCSyncObject(){
+ DeleteCriticalSection(&mLock);
+}
+
+void CPCSyncObject::lock(void){
+ EnterCriticalSection(&mLock);
+}
+
+//!Free the resource coming after the lock command
+void CPCSyncObject::unlock(void){
+ LeaveCriticalSection(&mLock);
+}
diff --git a/src/arch/win32/serlayer/cwin32sercomlayer.cpp b/src/arch/win32/serlayer/cwin32sercomlayer.cpp
index 5f72a2e..38286ea 100644
--- a/src/arch/win32/serlayer/cwin32sercomlayer.cpp
+++ b/src/arch/win32/serlayer/cwin32sercomlayer.cpp
@@ -41,7 +41,7 @@
forte::com_infra::EComResponse CWin32SerComLayer::sendData(void *paData, unsigned int paSize)
{
- DWORD dwBytesWritten= 0, dwWaitResult = 0;
+ DWORD dwBytesWritten= 0;
char *pcData = static_cast<char*> (paData);
unsigned int nToBeSent = paSize;
//Send payload
@@ -82,7 +82,7 @@
return forte::com_infra::e_ProcessDataInvalidObject;
}
- DCB dcbSerialParams = { 0 };
+ DCB dcbSerialParams = DCB();
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
@@ -111,7 +111,7 @@
default: return forte::com_infra::e_InitInvalidId; break;
}
- dcbSerialParams.ByteSize = static_cast<DWORD>(paSerialParameters.byteSize);
+ dcbSerialParams.ByteSize = paSerialParameters.byteSize;
switch (paSerialParameters.stopBits){
case EForteSerialStopBits::eOneBit:
@@ -148,7 +148,7 @@
}
//Timeouts for non-blocking behaviour
- COMMTIMEOUTS timeouts = { 0 };
+ COMMTIMEOUTS timeouts = COMMTIMEOUTS();
//Read timeouts
timeouts.ReadIntervalTimeout = 50;
timeouts.ReadTotalTimeoutConstant = 50;
diff --git a/src/arch/win32/win32socketinterf.cpp b/src/arch/win32/win32socketinterf.cpp
index 05218bf..9b7dd0c 100644
--- a/src/arch/win32/win32socketinterf.cpp
+++ b/src/arch/win32/win32socketinterf.cpp
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 - 2015 ACIN, Profactor GmbH, AIT, fortiss GmbH
+ * Copyright (c) 2010, 2020 ACIN, Profactor GmbH, AIT, fortiss GmbH, OFFIS e.V.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -9,19 +9,9 @@
* Contributors:
* Alois Zoitl, Ingo Hegny, Gerhard Ebenhofer, Thomas Strasser
* - initial API and implementation and/or initial documentation
+ * Jörg Walter - Windows XP compatibility
*******************************************************************************/
-#ifdef __GNUC__
-#ifdef __MINGW32__
-
-#ifdef _WIN32_WINNT
-#undef _WIN32_WINNT
-#endif
-#define _WIN32_WINNT 0x0600 //windows vista version, which included InepPton
-
-#endif //__MINGW32__
-#endif //__GNUC__
-
#include <sockhand.h> //needs to be first pulls in the platform specific includes
#include "win32socketinterf.h"
#include "devlog.h"
@@ -85,12 +75,13 @@
DEVLOG_INFO("CWin32SocketInterface: Opening TCP-Client connection at: %s:%d\n", pa_acIPAddr, pa_nPort);
if(INVALID_SOCKET != nSocket) {
- struct sockaddr_in stSockAddr = { };
+ sockaddr_in stSockAddr = {};
+ int stSockAddrSz = sizeof(stSockAddr);
+ if(WSAStringToAddressA(pa_acIPAddr, AF_INET, NULL, (LPSOCKADDR)&stSockAddr, &stSockAddrSz)) {
+ DEVLOG_ERROR("CWin32SocketInterface: WSAStringToAddressA() failed: %d - %s\n", stSockAddr.sin_addr.s_addr, pa_acIPAddr);
+ }
stSockAddr.sin_family = AF_INET;
stSockAddr.sin_port = htons(pa_nPort);
- if(1 != InetPton(stSockAddr.sin_family, pa_acIPAddr, &(stSockAddr.sin_addr))) {
- DEVLOG_ERROR("CWin32SocketInterface: InetPton() failed: %d - %s\n", stSockAddr.sin_addr.s_addr, pa_acIPAddr);
- }
if(SOCKET_ERROR == connect(nSocket, (struct sockaddr*) &stSockAddr, sizeof(struct sockaddr))) {
int nLastError = WSAGetLastError();
@@ -167,11 +158,14 @@
TSocketDescriptor nRetVal = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(INVALID_SOCKET != nRetVal) {
+ *m_ptDestAddr = TUDPDestAddr();
+ int m_ptDestAddrSz = sizeof(*m_ptDestAddr);
+ if(WSAStringToAddressA(pa_acIPAddr, AF_INET, NULL, (LPSOCKADDR)m_ptDestAddr, &m_ptDestAddrSz)) {
+ DEVLOG_ERROR("CWin32SocketInterface: WSAStringToAddressA() failed: %d - %s\n", m_ptDestAddr->sin_addr.s_addr, pa_acIPAddr);
+ }
m_ptDestAddr->sin_family = AF_INET;
m_ptDestAddr->sin_port = htons(pa_nPort);
- InetPton(m_ptDestAddr->sin_family, pa_acIPAddr, &(m_ptDestAddr->sin_addr));
- memset(&(m_ptDestAddr->sin_zero), '\0', sizeof(m_ptDestAddr->sin_zero));
- }
+ }
else{
int nLastError = WSAGetLastError();
LPSTR pacErrorMessage = getErrorMessage(nLastError);
@@ -189,15 +183,20 @@
if(INVALID_SOCKET != nSocket) {
int nReuseAddrVal = 1;
if(0 <= setsockopt(nSocket, SOL_SOCKET, SO_REUSEADDR, (char *) &nReuseAddrVal, sizeof(nReuseAddrVal))){
- struct sockaddr_in stSockAddr;
+ struct sockaddr_in stSockAddr = {};
stSockAddr.sin_family = AF_INET;
stSockAddr.sin_port = htons(pa_nPort);
stSockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
- memset(&(stSockAddr.sin_zero), '\0', sizeof(stSockAddr.sin_zero));
if(0 == bind(nSocket, (struct sockaddr *) &stSockAddr, sizeof(struct sockaddr))){
// setting up multicast group
- struct ip_mreq stMReq;
- InetPton(stSockAddr.sin_family, pa_acIPAddr, &(stMReq.imr_multiaddr));
+ sockaddr_in stMCastAddr = {};
+ int stMCastAddrSz = sizeof(stMCastAddr);
+ if(WSAStringToAddressA(pa_acIPAddr, AF_INET, NULL, (LPSOCKADDR)&stMCastAddr, &stMCastAddrSz)) {
+ DEVLOG_ERROR("CWin32SocketInterface: WSAStringToAddressA() failed: %d - %s\n", stMCastAddr.sin_addr.s_addr, pa_acIPAddr);
+ }
+
+ struct ip_mreq stMReq = {};
+ stMReq.imr_multiaddr = stMCastAddr.sin_addr;
stMReq.imr_interface.s_addr = htonl(INADDR_ANY);
setsockopt(nSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &stMReq, sizeof(stMReq));
//if this fails we may have given a non multicasting addr. For now we accept this. May need to be changed in the future.
diff --git a/src/com/modbus/modbuslayer.cpp b/src/com/modbus/modbuslayer.cpp
index c31e6e1..3cc0cbe 100644
--- a/src/com/modbus/modbuslayer.cpp
+++ b/src/com/modbus/modbuslayer.cpp
@@ -312,25 +312,18 @@
// we need to swap order of each 16 bit data package
unsigned int nrUint16s = currentDataSize / 2;
- TForteUInt16 *destAr = new TForteUInt16[nrUint16s];
+ TForteUInt16 *destAr = (TForteUInt16*)(&retVal);
TForteUInt16 *sourceAr = (TForteUInt16*) pa_acDataArray;
for(unsigned int i = 0; i < nrUint16s; i++) {
destAr[i] = sourceAr[nrUint16s - 1 - i];
}
-
- retVal = *((T*) destAr);
-
- delete[] destAr;
}
else{
- TForteByte *tempAr = new TForteByte[currentDataSize];
+ TForteByte *tempAr = (TForteByte*)(&retVal);
for(unsigned int j = 0; j < currentDataSize; j++) {
tempAr[j] = pa_acDataArray[j];
}
-
- retVal = *((T*) tempAr);
- delete[] tempAr;
}
}
else {
@@ -360,7 +353,7 @@
DEVLOG_ERROR("CModbusComLayer:: Invalid input parameters\n");
}
else{
- m_pModbusConnection = new CModbusClientConnection(getExtEvHandler<CModbusHandler>());
+ m_pModbusConnection = new CModbusClientConnection((CModbusHandler*)&getExtEvHandler<CModbusHandler>());
if(strlen(tcpParams.m_acIp) > 0){
m_pModbusConnection->setIPAddress(tcpParams.m_acIp);
m_pModbusConnection->setPort(tcpParams.m_nPort);
diff --git a/src/com/modbus/modbustimedevent.cpp b/src/com/modbus/modbustimedevent.cpp
index 96afdc5..d76899b 100644
--- a/src/com/modbus/modbustimedevent.cpp
+++ b/src/com/modbus/modbustimedevent.cpp
@@ -10,11 +10,11 @@
* Filip Andren - initial API and implementation and/or initial documentation
*******************************************************************************/
#include "modbustimedevent.h"
+#include "../../core/iec61131_functions.h"
CModbusTimedEvent::CModbusTimedEvent(TForteUInt32 pa_nUpdateInterval)
: m_bIsStarted(false){
m_nUpdateInterval = pa_nUpdateInterval;
- m_oUpdateInterval += (m_nUpdateInterval * cg_nForteTicksPerSecond) / 1000;
if(pa_nUpdateInterval == 0){
m_bSingleShotEvent = true;
@@ -27,13 +27,10 @@
void CModbusTimedEvent::setUpdateInterval(TForteUInt32 pa_nUpdateInterval){
m_nUpdateInterval = pa_nUpdateInterval;
- SForteTime newTime;
- newTime += (m_nUpdateInterval * cg_nForteTicksPerSecond) / 1000;
- m_oUpdateInterval = newTime;
}
void CModbusTimedEvent::activate(){
- m_oStartTime = CTimerHandler::sm_poFORTETimer->getForteTime();
+ m_nStartTime = NOW_MONOTONIC().getInMilliSeconds();
m_bIsStarted = true;
}
@@ -42,13 +39,13 @@
}
bool CModbusTimedEvent::readyToExecute() const{
- SForteTime currentTime = CTimerHandler::sm_poFORTETimer->getForteTime();
- if (m_oUpdateInterval > currentTime) {
+ uint_fast64_t currentTime = NOW_MONOTONIC().getInMilliSeconds();
+ if (m_nUpdateInterval > currentTime) {
return false;
}
- currentTime -= m_oUpdateInterval;
+ currentTime -= m_nUpdateInterval;
- if(isStarted() && (currentTime > m_oStartTime || currentTime == m_oStartTime)){
+ if(isStarted() && (currentTime > m_nStartTime || currentTime == m_nStartTime)){
return true;
}
diff --git a/src/com/modbus/modbustimedevent.h b/src/com/modbus/modbustimedevent.h
index fe3bfed..4c0153c 100644
--- a/src/com/modbus/modbustimedevent.h
+++ b/src/com/modbus/modbustimedevent.h
@@ -42,8 +42,7 @@
void restartTimer();
private:
- SForteTime m_oStartTime;
- SForteTime m_oUpdateInterval;
+ uint_fast64_t m_nStartTime;
TForteUInt32 m_nUpdateInterval; // Polling interval in milliseconds (0 => single shot event)
diff --git a/src/com/mqtt_paho/MQTTClientConfigParser.cpp b/src/com/mqtt_paho/MQTTClientConfigParser.cpp
index c7eb28b..36c74ba 100644
--- a/src/com/mqtt_paho/MQTTClientConfigParser.cpp
+++ b/src/com/mqtt_paho/MQTTClientConfigParser.cpp
@@ -25,7 +25,7 @@
CConfigFileParser configFileParser(paFileLocation);
bool endpointFound = false;
- std::string endpointKey = mConfigKeysNames[MQTTConfigKeys::eEndoint];
+ std::string endpointKey = mConfigKeysNames[eEndoint];
if(CConfigFileParser::lookForKeyValueInFile(configFileParser, endpointKey, paEndpoint, endpointFound)) {
if(endpointFound) {
@@ -36,11 +36,11 @@
switch(configFileParser.parseNextLine(resultPair)){
case CConfigFileParser::eOk:
- if(0 == resultPair.first.compare(mConfigKeysNames[MQTTConfigKeys::eEndoint])) {
+ if(0 == resultPair.first.compare(mConfigKeysNames[eEndoint])) {
moreLinesToRead = false;
- } else if(0 == resultPair.first.compare(mConfigKeysNames[MQTTConfigKeys::eUsername])) {
+ } else if(0 == resultPair.first.compare(mConfigKeysNames[eUsername])) {
paResult.mUsername = resultPair.second;
- } else if(0 == resultPair.first.compare(mConfigKeysNames[MQTTConfigKeys::ePassword])) {
+ } else if(0 == resultPair.first.compare(mConfigKeysNames[ePassword])) {
paResult.mPassword = resultPair.second;
}
else {
diff --git a/src/com/mqtt_paho/MQTTClientConfigParser.h b/src/com/mqtt_paho/MQTTClientConfigParser.h
index 39900f7..4ed3f99 100644
--- a/src/com/mqtt_paho/MQTTClientConfigParser.h
+++ b/src/com/mqtt_paho/MQTTClientConfigParser.h
@@ -68,7 +68,7 @@
/**
* Strings for the allowed keys in the configuration file for the mqtt clients
*/
- static const char *const mConfigKeysNames[MQTTConfigKeys::eUnknown];
+ static const char *const mConfigKeysNames[eUnknown];
};
diff --git a/src/com/mqtt_paho/MQTTHandler.cpp b/src/com/mqtt_paho/MQTTHandler.cpp
index 6041eac..9aff856 100644
--- a/src/com/mqtt_paho/MQTTHandler.cpp
+++ b/src/com/mqtt_paho/MQTTHandler.cpp
@@ -25,7 +25,7 @@
MQTTAsync_connectOptions MQTTHandler::smClientConnectionOptions =
MQTTAsync_connectOptions_initializer;
-CSyncObject MQTTHandler::smMQTTMutex = CSyncObject();
+CSyncObject MQTTHandler::smMQTTMutex;
MQTTAsync MQTTHandler::smClient = 0;
CIEC_STRING MQTTHandler::smClientId;
@@ -35,7 +35,7 @@
MQTTStates MQTTHandler::smMQTTS_STATE = NOT_CONNECTED;
-forte::arch::CSemaphore MQTTHandler::mStateSemaphore = forte::arch::CSemaphore();
+forte::arch::CSemaphore MQTTHandler::mStateSemaphore;
bool MQTTHandler::mIsSemaphoreEmpty = true;
MQTTHandler::MQTTHandler(CDeviceExecution& paDeviceExecution) : CExternalEventHandler(paDeviceExecution) {
diff --git a/src/com/opc/opccomlayer.cpp b/src/com/opc/opccomlayer.cpp
index abd634d..8dca31b 100644
--- a/src/com/opc/opccomlayer.cpp
+++ b/src/com/opc/opccomlayer.cpp
@@ -399,7 +399,7 @@
CIEC_ANY *dataIn = &apoSDs[sdIndex];
Variant newVariant;
- getInputValueSize(dataIn, &newVariant);;
+ getInputValueSize(dataIn, &newVariant);
it_var->setNewValue(newVariant);
diff --git a/src/modules/modbus/CMakeLists.txt b/src/modules/modbus/CMakeLists.txt
deleted file mode 100644
index 86aa0e3..0000000
--- a/src/modules/modbus/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-#*******************************************************************************
-# Copyright (c) 2012 -2014 AIT, fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
-# Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
-# *******************************************************************************/
-#############################################################################
-# Modbus Com Layer
-#############################################################################
-forte_add_network_layer(MODBUS OFF "modbus" CModbusComLayer modbuslayer "Enable Modbus Com Layer")
-SET(FORTE_COM_MODBUS_LIB_DIR "" CACHE PATH "Path to Modbus library directory (leave empty for installed source code)")
-
-if(FORTE_COM_MODBUS)
- forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
- forte_add_sourcefile_hcpp( modbushandler
- modbusconnection
- modbusclientconnection
- modbuspoll
- modbustimedevent )
-
- forte_add_handler(CModbusHandler modbushandler)
- forte_add_include_directories( ${FORTE_COM_MODBUS_LIB_DIR}/include )
- if("${FORTE_ARCHITECTURE}" STREQUAL "Posix")
- if(EXISTS ${FORTE_COM_MODBUS_LIB_DIR})
- forte_add_include_directories( ${FORTE_COM_MODBUS_LIB_DIR}/include/modbus )
- forte_add_link_directories( ${FORTE_COM_MODBUS_LIB_DIR}/lib )
- else(EXISTS ${FORTE_COM_MODBUS_LIB_DIR})
- forte_add_include_directories( /usr/include/modbus )
- endif(EXISTS ${FORTE_COM_MODBUS_LIB_DIR})
- forte_add_link_library( libmodbus.so )
- elseif("${FORTE_ARCHITECTURE}" STREQUAL "Win32")
- forte_add_include_directories( ${FORTE_COM_MODBUS_LIB_DIR}/include )
- forte_add_link_directories( ${FORTE_COM_MODBUS_LIB_DIR}/lib )
- forte_add_link_library( libmodbus.lib )
- endif()
-
-
-endif(FORTE_COM_MODBUS)
diff --git a/src/modules/modbus/modbusclientconnection.cpp b/src/modules/modbus/modbusclientconnection.cpp
deleted file mode 100644
index 8e6cffd..0000000
--- a/src/modules/modbus/modbusclientconnection.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbusclientconnection.h"
-#include "devlog.h"
-#include "modbuspoll.h"
-#include <forte_thread.h>
-
-using namespace modbus_connection_event;
-
-/*************************************
- * CModbusClientConnection class
- *************************************/
-
-CModbusClientConnection::CModbusClientConnection(CModbusHandler* pa_modbusHandler) :
- CModbusConnection(pa_modbusHandler), m_pModbusConnEvent(NULL), m_nNrOfPolls(0), m_nSlaveId(0xFF), m_unBufFillSize(0){
- memset(m_anRecvBuffPosition, 0, sizeof(m_anRecvBuffPosition)); //TODO change this to m_anRecvBuffPosition{0} in the extended list when fully switching to C++11
- memset(m_acRecvBuffer, 0, sizeof(m_acRecvBuffer)); //TODO change this to m_acRecvBuffer{0} in the extended list when fully switching to C++11
-}
-
-CModbusClientConnection::~CModbusClientConnection(){
- if (m_bConnected){
- disconnect();
- }
- TModbusPollList::Iterator itEnd(m_lstPollList.end());
- for(TModbusPollList::Iterator itRunner = m_lstPollList.begin(); itRunner != itEnd; ++itRunner){
- delete *itRunner;
- }
- if (m_pModbusConnEvent != NULL){
- delete m_pModbusConnEvent;
- }
-}
-
-int CModbusClientConnection::readData(uint8_t *pa_pData){
- for(unsigned int i = 0; i < m_unBufFillSize; i++){
- pa_pData[i] = m_acRecvBuffer[i];
- }
-
- return (int) m_unBufFillSize;
-}
-
-int CModbusClientConnection::writeData(uint16_t *pa_pData, unsigned int pa_nDataSize){
- unsigned int dataIndex = 0;
-
- TModbusSendList::Iterator itEnd = m_lstSendList.end();
- for (TModbusSendList::Iterator it = m_lstSendList.begin(); it!=itEnd; ++it) {
- if (dataIndex + it->m_nNrAddresses > pa_nDataSize) {
- break;
- }
- modbus_write_registers(m_pModbusConn, it->m_nStartAddress, it->m_nNrAddresses, &pa_pData[dataIndex]);
- dataIndex += it->m_nNrAddresses;
- }
-
- return (int)dataIndex;
-}
-
-int CModbusClientConnection::connect(){
- CModbusConnection::connect();
-
- if(m_nSlaveId != 0xFF){
- modbus_set_slave(m_pModbusConn, m_nSlaveId);
- }
-
- m_pModbusConnEvent = new CModbusConnectionEvent(1000);
- m_pModbusConnEvent->activate();
-
- this->start();
-
- return 0;
-}
-
-void CModbusClientConnection::disconnect(){
- this->end();
- if (m_bConnected){
- modbus_close(m_pModbusConn);
- m_bConnected = false;
- }
- CModbusConnection::disconnect();
-}
-
-void CModbusClientConnection::addNewPoll(TForteUInt32 pa_nPollInterval, unsigned int pa_nFunctionCode, unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses){
- CModbusPoll *newPoll = NULL;
-
- TModbusPollList::Iterator itEnd = m_lstPollList.end();
- for(TModbusPollList::Iterator it = m_lstPollList.begin(); it != itEnd; ++it){
- if(it->getUpdateInterval() == pa_nPollInterval && it->getFunctionCode() == pa_nFunctionCode){
- it->addPollAddresses(pa_nStartAddress, pa_nNrAddresses);
- newPoll = *it;
- break;
- }
- }
- if(newPoll == NULL){
- m_lstPollList.pushBack(new CModbusPoll(pa_nPollInterval, pa_nFunctionCode, pa_nStartAddress, pa_nNrAddresses));
- m_nNrOfPolls++;
- m_anRecvBuffPosition[m_nNrOfPolls - 1] = m_unBufFillSize;
- }
-
- // Count bytes
- unsigned int nrBytes = 0;
- switch (pa_nFunctionCode){
- case 1:
- case 2:
- nrBytes = pa_nNrAddresses;
- break;
- case 3:
- case 4:
- nrBytes = pa_nNrAddresses * 2;
- break;
- }
- for(unsigned int i = m_unBufFillSize; i < m_unBufFillSize + nrBytes; i++){
- m_acRecvBuffer[i] = 0;
- }
- m_unBufFillSize += nrBytes;
-}
-
-void CModbusClientConnection::addNewSend(unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses) {
- SSendInformation sendInfo = {pa_nStartAddress, pa_nNrAddresses};
-
- m_lstSendList.pushBack(sendInfo);
-}
-
-void CModbusClientConnection::setSlaveId(unsigned int pa_nSlaveId){
- m_nSlaveId = pa_nSlaveId;
-}
-
-void CModbusClientConnection::run(){
-
- while(isAlive()){
- if(m_bConnected){
- tryPolling();
- }
- else{
- tryConnect();
- }
-
- CThread::sleepThread(1);
- }
-}
-
-void CModbusClientConnection::tryPolling(){
- unsigned int nrErrors = 0;
- bool dataReturned = false;
-
- unsigned int index = 0;
- TModbusPollList::Iterator itEnd(m_lstPollList.end());
- for(TModbusPollList::Iterator itPoll = m_lstPollList.begin(); itPoll != itEnd; ++itPoll, ++index){
- if(itPoll->readyToExecute()){
- int nrVals = itPoll->executeEvent(m_pModbusConn, (void*) &m_acRecvBuffer[m_anRecvBuffPosition[index]]); // retVal);
-
- if(nrVals < 0){
- DEVLOG_ERROR("Error reading input status :: %s\n", modbus_strerror(errno));
- itPoll->deactivate();
-
- nrErrors++;
- }
- else if(nrVals > 0){
- dataReturned = true;
- }
- }
- }
-
- if(dataReturned) {
- m_pModbusHandler->executeComCallback(m_nComCallbackId);
- }
-
- if((nrErrors == m_nNrOfPolls) && (0 != m_nNrOfPolls)){
- modbus_close(m_pModbusConn); // in any case it is worth trying to close the socket
- m_bConnected = false;
- m_pModbusConnEvent = new CModbusConnectionEvent(1000);
- m_pModbusConnEvent->activate();
- }
-}
-
-void CModbusClientConnection::tryConnect(){
- if(m_pModbusConnEvent != NULL){
- if(m_pModbusConnEvent->readyToExecute()){
- if(m_pModbusConnEvent->executeEvent(m_pModbusConn, NULL) < 0) {
- DEVLOG_ERROR("Connection to Modbus server failed: %s\n", modbus_strerror(errno));
- } else {
- DEVLOG_INFO("Connection to Modbus server succeded\n");
-
- delete m_pModbusConnEvent;
- m_pModbusConnEvent = NULL;
-
- m_bConnected = true;
-
- // Start polling
- TModbusPollList::Iterator itEnd(m_lstPollList.end());
- for(TModbusPollList::Iterator itPoll = m_lstPollList.begin(); itPoll != itEnd; ++itPoll){
- itPoll->activate();
- }
- }
- }
- }
-}
-
-/*************************************
- * CModbusConnectionEvent class
- *************************************/
-CModbusConnectionEvent::CModbusConnectionEvent(long pa_nReconnectInterval) :
- CModbusTimedEvent(pa_nReconnectInterval){
-}
-
-int CModbusConnectionEvent::executeEvent(modbus_t *pa_pModbusConn, void *pa_pRetVal){
- (void)pa_pRetVal; // avoid warning
-
- restartTimer();
-
- return modbus_connect(pa_pModbusConn);
-}
-
diff --git a/src/modules/modbus/modbusclientconnection.h b/src/modules/modbus/modbusclientconnection.h
deleted file mode 100644
index cb2bea8..0000000
--- a/src/modules/modbus/modbusclientconnection.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _MODBUSCLIENTCONNECTION_H_
-#define _MODBUSCLIENTCONNECTION_H_
-
-#include "modbusconnection.h"
-#include "modbustimedevent.h"
-#include "fortelist.h"
-
-class CModbusPoll;
-
-namespace modbus_connection_event {
- class CModbusConnectionEvent : public CModbusTimedEvent{
- public:
- explicit CModbusConnectionEvent(long pa_nReconnectInterval); //ReconnectInterval = 0 => only one connection try
- ~CModbusConnectionEvent(){
- }
- ;
-
- int executeEvent(modbus_t *pa_pModbusConn, void *pa_pRetVal);
- };
-}
-
-class CModbusClientConnection : public CModbusConnection{
- public:
- explicit CModbusClientConnection(CModbusHandler* pa_modbusHandler);
- ~CModbusClientConnection();
-
- int readData(uint8_t *pa_pData);
- int writeData(uint16_t *pa_pData, unsigned int pa_nDataSize);
- int connect();
- void disconnect();
-
- void addNewPoll(TForteUInt32 pa_nPollInterval, unsigned int pa_nFunctionCode, unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses);
- void addNewSend(unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses);
-
- void setSlaveId(unsigned int pa_nSlaveId);
-
- protected:
- virtual void run();
-
- private:
- void tryConnect();
- void tryPolling();
-
- struct SSendInformation {
- unsigned int m_nStartAddress;
- unsigned int m_nNrAddresses;
- };
-
- modbus_connection_event::CModbusConnectionEvent *m_pModbusConnEvent;
-
- typedef CSinglyLinkedList<CModbusPoll*> TModbusPollList;
- TModbusPollList m_lstPollList;
-
- typedef CSinglyLinkedList<SSendInformation> TModbusSendList;
- TModbusSendList m_lstSendList;
-
- unsigned int m_nNrOfPolls;
- unsigned int m_anRecvBuffPosition[100];
-
- unsigned int m_nSlaveId;
-
- uint8_t m_acRecvBuffer[cg_unIPLayerRecvBufferSize];
- unsigned int m_unBufFillSize;
-
-};
-
-#endif
diff --git a/src/modules/modbus/modbusconnection.cpp b/src/modules/modbus/modbusconnection.cpp
deleted file mode 100644
index 9337d58..0000000
--- a/src/modules/modbus/modbusconnection.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbusconnection.h"
-#include "modbuslayer.h"
-#include "../../core/cominfra/basecommfb.h"
-
-CModbusConnection::CModbusConnection(CModbusHandler* pa_modbusHandler) : m_pModbusConn(NULL), m_pModbusHandler(pa_modbusHandler), m_nComCallbackId(0),
- m_bConnected(false), m_paIPAddress(NULL), m_nPort(0),
- m_chDevice(NULL), m_nBaud(0), m_cParity(0), m_nDataBit(0),
- m_nStopBit(0), m_nResponseTimeout(0), m_nByteTimeout(0){
-}
-
-CModbusConnection::~CModbusConnection(){
- modbus_free(m_pModbusConn);
-}
-
-int CModbusConnection::connect(){
- if (m_paIPAddress != NULL) {
- m_pModbusConn = modbus_new_tcp(m_paIPAddress, m_nPort);
- } else if (m_chDevice != NULL) {
- m_pModbusConn = modbus_new_rtu(m_chDevice, m_nBaud, m_cParity, m_nDataBit, m_nStopBit);
- } else {
- return -1;
- }
-
- if(m_nResponseTimeout > 0){
- timeval responseTimeout;
- responseTimeout.tv_sec = m_nResponseTimeout / 1000;
- responseTimeout.tv_usec = (m_nResponseTimeout % 1000)*1000;
- //modbus_set_response_timeout(m_pModbusConn, &responseTimeout);
- }
- if(m_nByteTimeout > 0){
- timeval byteTimeout;
- byteTimeout.tv_sec = m_nByteTimeout / 1000;
- byteTimeout.tv_usec = (m_nByteTimeout % 1000)*1000;
- //modbus_set_byte_timeout(m_pModbusConn, &byteTimeout);
- }
-
- return 0;
-}
-
-void CModbusConnection::disconnect(){
-
-}
-
-void CModbusConnection::setIPAddress(const char* pa_poIPAddress){
- m_paIPAddress = pa_poIPAddress;
-}
-
-void CModbusConnection::setPort(unsigned int pa_nPort){
- m_nPort = pa_nPort;
-}
-
-void CModbusConnection::setDevice(const char* pa_chDevice) {
- m_chDevice = pa_chDevice;
-}
-
-void CModbusConnection::setBaud(int pa_nBaud) {
- m_nBaud = pa_nBaud;
-}
-
-void CModbusConnection::setParity(char pa_cParity) {
- m_cParity = pa_cParity;
-}
-
-void CModbusConnection::setDataBit(int pa_nDataBit) {
- m_nDataBit = pa_nDataBit;
-}
-
-void CModbusConnection::setStopBit(int pa_nStopBit) {
- m_nStopBit = pa_nStopBit;
-}
-
-void CModbusConnection::setResponseTimeout(unsigned int pa_nResponseTimeout){
- m_nResponseTimeout = pa_nResponseTimeout;
-}
-
-void CModbusConnection::setByteTimeout(unsigned int pa_nByteTimeout){
- m_nByteTimeout = pa_nByteTimeout;
-}
-
-void CModbusConnection::setComCallback(forte::com_infra::CModbusComLayer* pa_poModbusLayer){
- m_nComCallbackId = m_pModbusHandler->addComCallback(pa_poModbusLayer);
-}
diff --git a/src/modules/modbus/modbusconnection.h b/src/modules/modbus/modbusconnection.h
deleted file mode 100644
index 583fefd..0000000
--- a/src/modules/modbus/modbusconnection.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _MODBUSCONNECTION_H_
-#define _MODBUSCONNECTION_H_
-
-#include <modbus.h>
-#include <forte_thread.h>
-#include "modbushandler.h"
-#include <errno.h>
-
-namespace forte{
- namespace com_infra{
- class CModbusComLayer;
- }
-}
-
-class CModbusConnection : public CThread{
- public:
- explicit CModbusConnection(CModbusHandler* pa_modbusHandler);
- ~CModbusConnection();
-
- virtual int readData(uint8_t *pa_pData) = 0;
- virtual int writeData(uint16_t *pa_pData, unsigned int pa_nDataSize) = 0;
- virtual void run() = 0;
-
- /*! \brief Initializes Modbus connection
- *
- * Any classes derived from this class must call CModbusConnection::connect() in the beginning
- * of their connect() function
- */
- virtual int connect();
- /*! \brief De-initializes Modbus connection
- *
- * Any classes derived from this class should call CModbusConnection::connect() at the end
- * of their disconnect() function
- */
- virtual void disconnect();
-
- void setIPAddress(const char* pa_poIPAddress);
- void setPort(unsigned int pa_nPort);
-
- void setDevice(const char* pa_chDevice);
- void setBaud(int pa_nBaud);
- void setParity(char pa_cParity);
- void setDataBit(int pa_nDataBit);
- void setStopBit(int pa_nStopBit);
- void setResponseTimeout(unsigned int pa_nResponseTimeout);
- void setByteTimeout(unsigned int pa_nByteTimeout);
-
- void setComCallback(forte::com_infra::CModbusComLayer* pa_poModbusLayer);
-
- protected:
- modbus_t* m_pModbusConn;
- CModbusHandler* m_pModbusHandler;
-
- CModbusHandler::TCallbackDescriptor m_nComCallbackId;
-
- bool m_bConnected;
-
- private:
- const char* m_paIPAddress;
- unsigned int m_nPort;
-
- const char* m_chDevice;
- int m_nBaud;
- char m_cParity;
- int m_nDataBit;
- int m_nStopBit;
-
- unsigned int m_nResponseTimeout;
- unsigned int m_nByteTimeout;
-};
-
-#endif // _MODBUSCONNECTION_H_
diff --git a/src/modules/modbus/modbushandler.cpp b/src/modules/modbus/modbushandler.cpp
deleted file mode 100644
index faf0ece..0000000
--- a/src/modules/modbus/modbushandler.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbushandler.h"
-#include "devlog.h"
-#include "../core/devexec.h"
-#include <criticalregion.h>
-#include <commfb.h>
-
-DEFINE_HANDLER(CModbusHandler);
-
-CModbusHandler::TCallbackDescriptor CModbusHandler::m_nCallbackDescCount = 0;
-
-CModbusHandler::CModbusHandler(CDeviceExecution& pa_poDeviceExecution) : CExternalEventHandler(pa_poDeviceExecution) {
-}
-
-CModbusHandler::~CModbusHandler(){
-
-}
-
-CModbusHandler::TCallbackDescriptor CModbusHandler::addComCallback(forte::com_infra::CComLayer* pa_pComCallback){
- CCriticalRegion criticalRegion(m_oSync);
- m_nCallbackDescCount++;
- TComContainer stNewNode = { m_nCallbackDescCount, pa_pComCallback };
- m_lstComCallbacks.pushBack(stNewNode);
-
- return m_nCallbackDescCount;
-}
-
-void CModbusHandler::removeComCallback(CModbusHandler::TCallbackDescriptor pa_nCallbackDesc){
- CCriticalRegion criticalRegion(m_oSync);
-
- TCallbackList::Iterator itRunner(m_lstComCallbacks.begin());
-
- if(itRunner->m_nCallbackDesc == pa_nCallbackDesc){
- m_lstComCallbacks.popFront();
- }
- else{
- TCallbackList::Iterator itLastPos(itRunner);
- TCallbackList::Iterator itEnd(m_lstComCallbacks.end());
- ++itRunner;
- while(itRunner != itEnd){
- if(itRunner->m_nCallbackDesc == pa_nCallbackDesc){
- m_lstComCallbacks.eraseAfter(itLastPos);
- break;
- }
- itLastPos = itRunner;
- ++itRunner;
- }
- }
-}
-
-void CModbusHandler::executeComCallback(CModbusHandler::TCallbackDescriptor pa_nCallbackDesc){
- m_oSync.lock();
- TCallbackList::Iterator itEnd(m_lstComCallbacks.end());
- TCallbackList::Iterator itCurrent(m_lstComCallbacks.begin());
- for(TCallbackList::Iterator itCallback = m_lstComCallbacks.begin(); itCallback != itEnd; ++itCallback){
- itCurrent = itCallback;
-
- if(itCurrent->m_nCallbackDesc == pa_nCallbackDesc){
- forte::com_infra::CComLayer *comLayer = itCurrent->m_pCallback;
- m_oSync.unlock();
- if(forte::com_infra::e_Nothing != comLayer->recvData(0,0)){
- startNewEventChain(comLayer->getCommFB());
- }
- m_oSync.lock();
- break;
- }
- }
- m_oSync.unlock();
-}
diff --git a/src/modules/modbus/modbushandler.h b/src/modules/modbus/modbushandler.h
deleted file mode 100644
index 8735434..0000000
--- a/src/modules/modbus/modbushandler.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2015 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _MODBUSHANDLER_H_
-#define _MODBUSHANDLER_H_
-
-#include <forte_config.h>
-#include "extevhan.h"
-#include <forte_sync.h>
-#include <comlayer.h>
-#include <fortelist.h>
-
-class CModbusHandler : public CExternalEventHandler{
- DECLARE_HANDLER(CModbusHandler)
- public:
- typedef int TCallbackDescriptor;
-
- void enableHandler(void){
- }
- ;
- void disableHandler(void){
- }
- ;
-
- void setPriority(int){
- //currently we are doing nothing here.
- //TODO We should adjust the thread priority.
- }
-
- int getPriority(void) const{
- //the same as for setPriority
- return 0;
- }
-
- TCallbackDescriptor addComCallback(forte::com_infra::CComLayer* pa_pComCallback);
- void removeComCallback(TCallbackDescriptor pa_nCallbackDesc);
-
- void executeComCallback(TCallbackDescriptor pa_nCallbackDesc);
-
- private:
- struct TComContainer{
- TCallbackDescriptor m_nCallbackDesc;
- forte::com_infra::CComLayer* m_pCallback;
- };
-
- typedef CSinglyLinkedList<TComContainer> TCallbackList;
- TCallbackList m_lstComCallbacks;
-
- CSyncObject m_oSync;
-
- static TCallbackDescriptor m_nCallbackDescCount;
-};
-
-#endif // _MODBUSHANDLER_H_
diff --git a/src/modules/modbus/modbuslayer.cpp b/src/modules/modbus/modbuslayer.cpp
deleted file mode 100644
index c31e6e1..0000000
--- a/src/modules/modbus/modbuslayer.cpp
+++ /dev/null
@@ -1,707 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, ACIN, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Patrick Smejkal, Alois Zoitl, Martin Melik-Merkumians - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbuslayer.h"
-#include "commfb.h"
-#include "modbusclientconnection.h"
-
-using namespace forte::com_infra;
-
-CModbusComLayer::CModbusComLayer(CComLayer* pa_poUpperLayer, CBaseCommFB* pa_poComFB) :
- CComLayer(pa_poUpperLayer, pa_poComFB), m_pModbusConnection(0), m_unBufFillSize(0){
- m_eConnectionState = e_Disconnected;
-}
-
-CModbusComLayer::~CModbusComLayer(){
-}
-
-EComResponse CModbusComLayer::sendData(void *pa_pvData, unsigned int pa_unSize){
- EComResponse eRetVal = e_ProcessDataOk;
-
- if(m_eConnectionState == e_Connected){
- switch (m_poFb->getComServiceType()){
- case e_Server:
- // todo
- break;
- case e_Client: {
- TForteUInt16 *convertedData = new TForteUInt16[pa_unSize * 4];
- unsigned int sendLength = convertDataInput(pa_pvData, pa_unSize, convertedData);
- if(sendLength > 0){
- m_pModbusConnection->writeData(convertedData, sendLength);
- }
- delete[] convertedData;
- break;
- }
- case e_Publisher:
- // todo
- break;
- case e_Subscriber:
- //do nothing as subscribers do not send data
- break;
- }
- }
- return eRetVal;
-}
-
-unsigned int CModbusComLayer::convertDataInput(void *pa_poInData, unsigned int pa_nDataSize, TForteUInt16 *pa_poConvertedData){
- unsigned int outLength = 0;
-
- CIEC_ANY *apoSDs = static_cast<CIEC_ANY*>(pa_poInData);
- unsigned int nrSDs = pa_nDataSize;
-
- for(unsigned int i = 0; i < nrSDs; i++){
- CIEC_ANY *anyVal = &apoSDs[i];
- switch (apoSDs[i].getDataTypeID()){
- case CIEC_ANY::e_BOOL: // 8bit data types
- {
- TForteUInt16 out = (bool) *(CIEC_BOOL*) anyVal;
- *(TForteUInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteUInt16) / 2;
- break;
- }
- case CIEC_ANY::e_SINT: {
- TForteInt16 out = (TForteInt8) *(CIEC_SINT*) anyVal;
- *(TForteInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteInt16) / 2;
- break;
- }
- case CIEC_ANY::e_USINT: {
- TForteUInt16 out = (TForteUInt8) *(CIEC_USINT*) anyVal;
- *(TForteUInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteUInt16) / 2;
- break;
- }
- case CIEC_ANY::e_BYTE: {
- TForteUInt16 out = (TForteByte) *(CIEC_BYTE*) anyVal;
- *(TForteUInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteUInt16) / 2;
- break;
- }
- case CIEC_ANY::e_INT: // 16bit data types
- {
- TForteInt16 out = (TForteInt16) *(CIEC_INT*) anyVal;
- *(TForteInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteInt16) / 2;
- break;
- }
- case CIEC_ANY::e_UINT: {
- TForteUInt16 out = (TForteUInt16) *(CIEC_UINT*) anyVal;
- *(TForteUInt16*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteUInt16) / 2;
- break;
- }
- case CIEC_ANY::e_WORD: {
- TForteWord out = (TForteWord) *(CIEC_WORD*) anyVal;
- *(TForteWord*) (&pa_poConvertedData[outLength]) = out;
- outLength += sizeof(TForteWord) / 2;
- break;
- }
- case CIEC_ANY::e_DINT: // 32bit data types
- {
- TForteInt32 out = (TForteInt32) *static_cast<CIEC_DINT*>(anyVal);
- *(TForteInt32*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteInt32>((TForteByte*) &out, sizeof(TForteInt32));
- outLength += sizeof(TForteInt32) / 2;
- break;
- }
- case CIEC_ANY::e_UDINT: {
- TForteUInt32 out = (TForteUInt32) *(CIEC_UDINT*) anyVal;
- *(TForteUInt32*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteUInt32>((TForteByte*) &out, sizeof(TForteUInt32));
- outLength += sizeof(TForteUInt32) / 2;
- break;
- }
- case CIEC_ANY::e_DWORD: {
- TForteDWord out = (TForteDWord) *(CIEC_DWORD*) anyVal;
- *(TForteDWord*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteDWord>((TForteByte*) &out, sizeof(TForteDWord));
- outLength += sizeof(TForteDWord) / 2;
- break;
- }
- case CIEC_ANY::e_REAL: {
- TForteFloat out = (TForteFloat) *(CIEC_REAL*) anyVal;
- *(TForteFloat*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteFloat>((TForteByte*) &out, sizeof(TForteFloat));
- outLength += sizeof(TForteFloat) / 2;
- break;
- }
- case CIEC_ANY::e_LINT: // 64bit data types
- {
- TForteInt64 out = (TForteInt64) *(CIEC_LINT*) anyVal;
- *(TForteInt64*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteInt64>((TForteByte*) &out, sizeof(TForteInt64));
- outLength += sizeof(TForteInt64) / 2;
- break;
- }
- case CIEC_ANY::e_ULINT: {
- TForteUInt64 out = (TForteUInt64) *(CIEC_ULINT*) anyVal;
- *(TForteUInt64*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteUInt64>((TForteByte*) &out, sizeof(TForteUInt64));
- outLength += sizeof(TForteUInt64) / 2;
- break;
- }
- case CIEC_ANY::e_LWORD: {
- TForteLWord out = (TForteLWord) *(CIEC_LWORD*) anyVal;
- *(TForteLWord*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteLWord>((TForteByte*) &out, sizeof(TForteLWord));
- outLength += sizeof(TForteLWord) / 2;
- break;
- }
- case CIEC_ANY::e_LREAL: {
- TForteDFloat out = (TForteDFloat) *(CIEC_LREAL*) anyVal;
- *(TForteDFloat*) (&pa_poConvertedData[outLength]) = convertFBOutput<TForteDFloat>((TForteByte*) &out, sizeof(TForteDFloat));
- outLength += sizeof(TForteDFloat) / 2;
- break;
- }
- default:
- break;
- }
- }
- return outLength;
-}
-
-EComResponse CModbusComLayer::processInterrupt(){
- if(e_ProcessDataOk == m_eInterruptResp){
- switch (m_eConnectionState){
- case e_Connected: {
- CIEC_ANY *apoRDs = m_poFb->getRDs();
- unsigned int nrRDs = m_poFb->getNumRD();
-
- unsigned int dataIndex = 0;
-
- for(unsigned int i = 0; i < nrRDs; i++){
- switch (apoRDs[i].getDataTypeID()){
- case CIEC_ANY::e_BOOL:
- apoRDs[i].setValue(CIEC_BOOL(convertFBOutput<bool>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(bool);
- break;
- case CIEC_ANY::e_SINT:
- apoRDs[i].setValue(CIEC_SINT(convertFBOutput<TForteInt8>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteInt8);
- break;
- case CIEC_ANY::e_INT:
- apoRDs[i].setValue(CIEC_INT(convertFBOutput<TForteInt16>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteInt16);
- break;
- case CIEC_ANY::e_DINT:
- apoRDs[i].setValue(CIEC_DINT(convertFBOutput<TForteInt32>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteInt32);
- break;
- case CIEC_ANY::e_LINT:
- apoRDs[i].setValue(CIEC_LINT(convertFBOutput<TForteInt64>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteInt64);
- break;
- case CIEC_ANY::e_USINT:
- apoRDs[i].setValue(CIEC_USINT(convertFBOutput<TForteUInt8>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteUInt8);
- break;
- case CIEC_ANY::e_UINT:
- apoRDs[i].setValue(CIEC_UINT(convertFBOutput<TForteUInt16>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteUInt16);
- break;
- case CIEC_ANY::e_UDINT:
- apoRDs[i].setValue(CIEC_UDINT(convertFBOutput<TForteUInt32>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteUInt32);
- break;
- case CIEC_ANY::e_ULINT:
- apoRDs[i].setValue(CIEC_ULINT(convertFBOutput<TForteUInt64>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteUInt64);
- break;
- case CIEC_ANY::e_BYTE:
- apoRDs[i].setValue(CIEC_BYTE(convertFBOutput<TForteByte>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteByte);
- break;
- case CIEC_ANY::e_WORD:
- apoRDs[i].setValue(CIEC_WORD(convertFBOutput<TForteWord>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteWord);
- break;
- case CIEC_ANY::e_DWORD:
- apoRDs[i].setValue(CIEC_DWORD(convertFBOutput<TForteDWord>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteDWord);
- break;
- case CIEC_ANY::e_LWORD:
- apoRDs[i].setValue(CIEC_LWORD(convertFBOutput<TForteLWord>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteLWord);
- break;
- case CIEC_ANY::e_REAL:
- apoRDs[i].setValue(CIEC_REAL(convertFBOutput<TForteFloat>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteFloat);
- break;
- case CIEC_ANY::e_LREAL:
- apoRDs[i].setValue(CIEC_LREAL(convertFBOutput<TForteDFloat>(&m_acRecvBuffer[dataIndex], m_unBufFillSize - dataIndex)));
- dataIndex += sizeof(TForteDFloat);
- break;
- default:
- // TODO
- break;
- }
- }
- break;
- }
- case e_Disconnected:
- case e_Listening:
- case e_ConnectedAndListening:
- default:
- break;
- }
- }
- else{
- if(e_InitTerminated == m_eInterruptResp){
- // todo: Move server into listening mode again, etc.
- }
- }
- return m_eInterruptResp;
-}
-
-EComResponse CModbusComLayer::recvData(const void *, unsigned int){
- m_eInterruptResp = e_Nothing;
-
- switch (m_eConnectionState){
- case e_Listening:
-
- //TODO accept incoming connection
-
- break;
- case e_Connected: {
- int nRetVal = 0;
- switch (m_poFb->getComServiceType()){
- case e_Server:
- //TODO
- break;
- case e_Client:
- //TODO check if errors occured during polling in ModbusConnection
- nRetVal = m_pModbusConnection->readData(&m_acRecvBuffer[0]);
- break;
- case e_Publisher:
- //do nothing as publisher cannot receive data
- break;
- case e_Subscriber:
- //do nothing since Modbus protocol cannot act as subscriber
- break;
- }
- switch (nRetVal){
- case 0:
- //TODO
- break;
- default:
- //we successfully received data
- m_unBufFillSize = nRetVal;
- m_eInterruptResp = e_ProcessDataOk;
- break;
- }
- m_poFb->interruptCommFB(this);
- }
- break;
- case e_ConnectedAndListening:
- case e_Disconnected:
- default:
- break;
- }
- return m_eInterruptResp;
-}
-
-template<typename T>
-T CModbusComLayer::convertFBOutput(TForteByte *pa_acDataArray, unsigned int pa_nDataSize){
- T retVal;
- unsigned int currentDataSize = sizeof(T);
-
- if(currentDataSize <= pa_nDataSize){
- if(currentDataSize > 2){
- // A data type with size greater than 16 bits is requested =>
- // we need to swap order of each 16 bit data package
-
- unsigned int nrUint16s = currentDataSize / 2;
- TForteUInt16 *destAr = new TForteUInt16[nrUint16s];
- TForteUInt16 *sourceAr = (TForteUInt16*) pa_acDataArray;
-
- for(unsigned int i = 0; i < nrUint16s; i++) {
- destAr[i] = sourceAr[nrUint16s - 1 - i];
- }
-
- retVal = *((T*) destAr);
-
- delete[] destAr;
- }
- else{
- TForteByte *tempAr = new TForteByte[currentDataSize];
- for(unsigned int j = 0; j < currentDataSize; j++) {
- tempAr[j] = pa_acDataArray[j];
- }
-
- retVal = *((T*) tempAr);
- delete[] tempAr;
- }
- }
- else {
- retVal = 0;
- }
-
- return retVal;
-}
-
-EComResponse CModbusComLayer::openConnection(char *pa_acLayerParameter){
- EComResponse eRetVal = e_InitInvalidId;
- switch (m_poFb->getComServiceType()){
- case e_Server:
- //TODO open server connection
- m_eConnectionState = e_Listening;
- break;
- case e_Client: {
- STcpParams tcpParams;
- SRtuParams rtuParams;
- SCommonParams commonParams;
- memset(&tcpParams, 0, sizeof(tcpParams));
- memset(&rtuParams, 0, sizeof(rtuParams));
- memset(&commonParams, 0, sizeof(commonParams));
-
- int errCode = processClientParams(pa_acLayerParameter, &tcpParams, &rtuParams, &commonParams);
- if(errCode != 0){
- DEVLOG_ERROR("CModbusComLayer:: Invalid input parameters\n");
- }
- else{
- m_pModbusConnection = new CModbusClientConnection(getExtEvHandler<CModbusHandler>());
- if(strlen(tcpParams.m_acIp) > 0){
- m_pModbusConnection->setIPAddress(tcpParams.m_acIp);
- m_pModbusConnection->setPort(tcpParams.m_nPort);
- }
- else if(strlen(rtuParams.m_acDevice) > 0){
- m_pModbusConnection->setDevice(rtuParams.m_acDevice);
- m_pModbusConnection->setBaud(rtuParams.m_nBaud);
- m_pModbusConnection->setParity(rtuParams.m_cParity);
- m_pModbusConnection->setDataBit(rtuParams.m_nDataBit);
- m_pModbusConnection->setStopBit(rtuParams.m_nStopBit);
- }
- m_pModbusConnection->setComCallback(this);
- m_pModbusConnection->setResponseTimeout(commonParams.m_nResponseTimeout);
- m_pModbusConnection->setByteTimeout(commonParams.m_nByteTimeout);
-
- static_cast<CModbusClientConnection*>(m_pModbusConnection)->setSlaveId(commonParams.m_nSlaveId);
-
- for(unsigned int i = 0; i < commonParams.m_nNrPolls; i++){
- static_cast<CModbusClientConnection*>(m_pModbusConnection)->addNewPoll(commonParams.m_nPollFrequency, commonParams.m_nFuncCode, commonParams.m_nReadStartAddress[i], commonParams.m_nReadNrAddresses[i]);
- }
- for(unsigned int i = 0; i < commonParams.m_nNrSends; i++){
- static_cast<CModbusClientConnection*>(m_pModbusConnection)->addNewSend(commonParams.m_nSendStartAddress[i], commonParams.m_nSendNrAddresses[i]);
- }
-
- if(m_pModbusConnection->connect() < 0){
- return eRetVal;
- }
- m_eConnectionState = e_Connected;
- eRetVal = e_InitOk;
- }
- }
- break;
- case e_Publisher:
- //do nothing as modbus cannot be publisher
- break;
- case e_Subscriber:
- //do nothing as modbus cannot be subscriber
- break;
- }
-
- return eRetVal;
-}
-
-void CModbusComLayer::closeConnection(){
- //TODO
- DEVLOG_INFO("CModbusLayer::closeConnection()\n");
-
- if(m_pModbusConnection != NULL){
- m_pModbusConnection->disconnect();
- delete m_pModbusConnection;
- }
-}
-
-int CModbusComLayer::processClientParams(char* pa_acLayerParams, STcpParams* pa_pTcpParams, SRtuParams* pa_pRtuParams, SCommonParams* pa_pCommonParams){
- char *params = new char[strlen(pa_acLayerParams) + 1];
- char *paramsAddress = params;
- strcpy(params, pa_acLayerParams);
- char *chrStorage;
-
- pa_pTcpParams->m_acIp[0] = '\0';
- pa_pRtuParams->m_acDevice[0] = '\0';
-
- chrStorage = strchr(params, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- if(strcmp(params, "rtu") == 0 || strcmp(params, "RTU") == 0){
- // get rtu params
- params = chrStorage;
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- strcpy(pa_pRtuParams->m_acDevice, params);
- pa_pRtuParams->m_nBaud = (int) forte::core::util::strtol(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- pa_pRtuParams->m_cParity = chrStorage[0];
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- pa_pRtuParams->m_nDataBit = (int) forte::core::util::strtol(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- pa_pRtuParams->m_nStopBit = (int) forte::core::util::strtol(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
- }
- else{
- if(strcmp(params, "tcp") == 0 || strcmp(params, "TCP") == 0){
- params = chrStorage;
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
- }
- if(isIp(params)){
- // TCP connection
- strcpy(pa_pTcpParams->m_acIp, params);
- pa_pTcpParams->m_nPort = (unsigned int) forte::core::util::strtoul(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
- }
- else{
- delete[] paramsAddress;
- return -1;
- }
- }
- // Get common parameters
-
- pa_pCommonParams->m_nPollFrequency = atol(chrStorage);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- pa_pCommonParams->m_nFuncCode = (unsigned int) forte::core::util::strtoul(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- // Search for optional parameter slave id
- char *chrSlave = strchr(chrStorage, ':');
- if(chrSlave != NULL){
- chrSlave++;
- if(strchr(chrSlave, ':') != NULL){
- pa_pCommonParams->m_nSlaveId = (unsigned int) forte::core::util::strtoul(chrStorage, 0, 10);
-
- chrStorage = chrSlave;
- }
- else{
- pa_pCommonParams->m_nSlaveId = 0xFF;
- }
- }
- else{
- delete[] paramsAddress;
- return -1;
- }
-
- char *readAddresses = chrStorage;
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- delete[] paramsAddress;
- return -1;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- // Find read addresses
- int paramLen = strlen(readAddresses);
- int nrPolls = 0;
- int strIndex = -1;
- while(strIndex < paramLen - 1){
- strIndex = findNextStartAddress(readAddresses, ++strIndex);
- if(strIndex < 0){
- break;
- }
- pa_pCommonParams->m_nReadStartAddress[nrPolls] = (unsigned int) forte::core::util::strtoul(const_cast<char*>(&readAddresses[strIndex]), 0, 10);
- strIndex = findNextStopAddress(readAddresses, strIndex);
- pa_pCommonParams->m_nReadNrAddresses[nrPolls] = (unsigned int) forte::core::util::strtoul(const_cast<char*>(&readAddresses[strIndex]), 0, 10) - pa_pCommonParams->m_nReadStartAddress[nrPolls] + 1;
- nrPolls++;
- }
- pa_pCommonParams->m_nNrPolls = nrPolls;
-
- char *writeAddresses = chrStorage;
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage != 0){
- *chrStorage = '\0';
- ++chrStorage;
- }
-
- // Find send addresses
- paramLen = strlen(writeAddresses);
- int nrSends = 0;
- strIndex = -1;
- while(strIndex < paramLen - 1){
- strIndex = findNextStartAddress(writeAddresses, ++strIndex);
- if(strIndex < 0){
- break;
- }
- pa_pCommonParams->m_nSendStartAddress[nrSends] = (unsigned int) forte::core::util::strtoul(const_cast<char*>(&writeAddresses[strIndex]), 0, 10);
- strIndex = findNextStopAddress(writeAddresses, strIndex);
- pa_pCommonParams->m_nSendNrAddresses[nrSends] = (unsigned int) forte::core::util::strtoul(const_cast<char*>(&writeAddresses[strIndex]), 0, 10) - pa_pCommonParams->m_nSendStartAddress[nrSends] + 1;
- nrSends++;
- }
- pa_pCommonParams->m_nNrSends = nrSends;
-
- // Find responseTimeout and byteTimeout
- do{
- if(chrStorage == 0){
- break;
- }
- pa_pCommonParams->m_nResponseTimeout = (unsigned int) forte::core::util::strtoul(chrStorage, 0, 10);
-
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- break;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- pa_pCommonParams->m_nByteTimeout = (unsigned int) forte::core::util::strtoul(chrStorage, 0, 10);
- } while(0);
-
- if(nrPolls == 0 && nrSends == 0){
- delete[] paramsAddress;
- return -1;
- }
-
- delete[] paramsAddress;
- return 0;
-}
-
-int CModbusComLayer::findNextStartAddress(const char* pa_acParam, int pa_nStartIndex){
- if(pa_nStartIndex == 0){
- switch (pa_acParam[pa_nStartIndex]){
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return pa_nStartIndex;
- }
- }
-
- int strLength = strlen(&pa_acParam[pa_nStartIndex]);
- const char *pch = strchr(&pa_acParam[pa_nStartIndex], ',');
-
- if(pch != NULL){
- if(pch - &pa_acParam[pa_nStartIndex] < strLength - 1) {
- return pch - &pa_acParam[0] + 1;
- }
-
- }
-
- return -1;
-}
-
-int CModbusComLayer::findNextStopAddress(const char* pa_acParam, int pa_nStartIndex){
- int strLength = strlen(&pa_acParam[pa_nStartIndex]);
- const char *pchComma = strchr(&pa_acParam[pa_nStartIndex], ',');
- const char *pchDot = strchr(&pa_acParam[pa_nStartIndex], '.');
-
- if(pchComma != NULL && pchDot != NULL) {
- if(pchDot < pchComma && (pchDot - &pa_acParam[pa_nStartIndex] < strLength - 2)) {
- return pchDot - &pa_acParam[0] + 2;
- }
- } else if(pchDot != NULL) {
- if(pchDot - &pa_acParam[pa_nStartIndex] < strLength - 2) {
- return pchDot - &pa_acParam[0] + 2;
- }
- }
-
- return pa_nStartIndex;
-}
-
-bool CModbusComLayer::isIp(const char* pa_acIp){
- char* str = new char[strlen(pa_acIp) + 1];
- strcpy(str, pa_acIp);
- char* pch;
- int nrPeriods = 0;
-
- pch = strtok(str, ".");
- while(pch != NULL){
- nrPeriods++;
- if(strlen(pch) > 3){
- delete[] str;
- return false;
- }
- for(unsigned int i = 0; i < strlen(pch); i++){
- if(!forte::core::util::isDigit(pch[i])){
- delete[] str;
- return false;
- }
- }
-
- pch = strtok(NULL, ".");
- }
- if(nrPeriods != 4){
- delete[] str;
- return false;
- }
-
- delete[] str;
- return true;
-}
diff --git a/src/modules/modbus/modbuslayer.h b/src/modules/modbus/modbuslayer.h
deleted file mode 100644
index b634545..0000000
--- a/src/modules/modbus/modbuslayer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2015 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef MODBUSCOMLAYER_H_
-#define MODBUSCOMLAYER_H_
-
-#include <forte_config.h>
-#include "comlayer.h"
-#include <stdint.h>
-
-class CModbusConnection;
-class CIEC_ANY;
-
-namespace forte {
-
- namespace com_infra {
-
- class CModbusComLayer : public CComLayer{
- public:
- CModbusComLayer(CComLayer* pa_poUpperLayer, CBaseCommFB* pa_poComFB);
- virtual ~CModbusComLayer();
-
- EComResponse sendData(void *pa_pvData, unsigned int pa_unSize); // top interface, called from top
- EComResponse recvData(const void *pa_pvData, unsigned int pa_unSize);
-
- EComResponse processInterrupt();
-
- private:
- struct STcpParams {
- char m_acIp[15];
- unsigned int m_nPort;
- };
- struct SRtuParams {
- char m_acDevice[256];
- int m_nBaud;
- char m_cParity;
- int m_nDataBit;
- int m_nStopBit;
- };
- struct SCommonParams {
- unsigned int m_nNrPolls;
- unsigned int m_nNrSends;
- long m_nPollFrequency;
- unsigned int m_nFuncCode;
- unsigned int m_nSlaveId;
- unsigned int m_nReadStartAddress[100];
- unsigned int m_nReadNrAddresses[100];
- unsigned int m_nSendStartAddress[100];
- unsigned int m_nSendNrAddresses[100];
- unsigned int m_nResponseTimeout;
- unsigned int m_nByteTimeout;
- };
-
- template<typename T>
- T convertFBOutput(TForteByte *pa_acDataArray, unsigned int pa_nDataSize);
-
- unsigned int convertDataInput(void *pa_poInData, unsigned int pa_nDataSize, TForteUInt16 *pa_poConvertedData);
-
- EComResponse openConnection(char *pa_acLayerParameter);
- void closeConnection();
-
- //int processClientParams(char* pa_acLayerParams, char* pa_acIp, unsigned int &pa_nPort, long &pa_nPollFrequency, unsigned int &pa_nFuncCode, unsigned int &pa_nSlaveId, unsigned int *pa_nStartAddress, unsigned int *pa_nNrAddresses);
- int processClientParams(char* pa_acLayerParams, STcpParams* pa_pTcpParams, SRtuParams* pa_pRtuParams, SCommonParams* pa_pCommonParams);
- int findNextStartAddress(const char* pa_acString, int pa_nStartIndex);
- int findNextStopAddress(const char* pa_acString, int pa_nStartIndex);
- bool isIp(const char* pa_acIp);
-
- EComResponse m_eInterruptResp;
-
- CModbusConnection *m_pModbusConnection;
-
- TForteByte m_acRecvBuffer[cg_unIPLayerRecvBufferSize];
- unsigned int m_unBufFillSize;
- };
-
- }
-
-}
-
-#endif /* MODBUSCOMLAYER_H_ */
diff --git a/src/modules/modbus/modbuspoll.cpp b/src/modules/modbus/modbuspoll.cpp
deleted file mode 100644
index d4a4044..0000000
--- a/src/modules/modbus/modbuspoll.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbuspoll.h"
-
-#include <devlog.h>
-
-#include <modbus.h>
-
-CModbusPoll::CModbusPoll(TForteUInt32 pa_nPollInterval, unsigned int pa_nFunctionCode, unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses) :
- CModbusTimedEvent(pa_nPollInterval){
- setFunctionCode(pa_nFunctionCode);
- addPollAddresses(pa_nStartAddress, pa_nNrAddresses);
-}
-
-CModbusPoll::~CModbusPoll(){
- CSinglyLinkedList<SModbusPollData*>::Iterator itEnd = m_lPolls.end();
- for(CSinglyLinkedList<SModbusPollData*>::Iterator it = m_lPolls.begin(); it != itEnd; ++it){
- delete *it;
- }
- m_lPolls.clearAll();
-}
-
-void CModbusPoll::addPollAddresses(unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses){
- m_lPolls.pushBack(new SModbusPollData(pa_nStartAddress, pa_nNrAddresses));
-}
-
-int CModbusPoll::executeEvent(modbus_t *pa_pModbusConn, void *pa_pRetVal){
- restartTimer();
-
- int nrVals = 0;
- CSinglyLinkedList<SModbusPollData*>::Iterator itEnd = m_lPolls.end();
- for(CSinglyLinkedList<SModbusPollData*>::Iterator it = m_lPolls.begin(); it != itEnd; ++it){
- switch (m_nFunctionCode){
- case 1:
- nrVals += modbus_read_bits(pa_pModbusConn, it->m_nStartAddress, it->m_nNrAddresses, &((uint8_t*) pa_pRetVal)[nrVals]);
- break;
- case 2:
- nrVals += modbus_read_input_bits(pa_pModbusConn, it->m_nStartAddress, it->m_nNrAddresses, &((uint8_t*) pa_pRetVal)[nrVals]);
- break;
- case 3:
- nrVals += modbus_read_registers(pa_pModbusConn, it->m_nStartAddress, it->m_nNrAddresses, &((uint16_t*) pa_pRetVal)[nrVals]);
- break;
- case 4:
- nrVals += modbus_read_input_registers(pa_pModbusConn, it->m_nStartAddress, it->m_nNrAddresses, &((uint16_t*) pa_pRetVal)[nrVals]);
- break;
- default:
- //TODO Error
- break;
- }
- }
- return nrVals;
-}
diff --git a/src/modules/modbus/modbuspoll.h b/src/modules/modbus/modbuspoll.h
deleted file mode 100644
index 7df7831..0000000
--- a/src/modules/modbus/modbuspoll.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef MODBUSPOLL_H_
-#define MODBUSPOLL_H_
-
-#include "modbustimedevent.h"
-#include <fortelist.h>
-
-class CModbusPoll : public CModbusTimedEvent{
- public:
- CModbusPoll(TForteUInt32 pa_nPollInterval, unsigned int pa_nFunctionCode, unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses);
- ~CModbusPoll();
-
- int executeEvent(modbus_t *pa_pModbusConn, void *pa_pRetVal);
-
- void setFunctionCode(unsigned int pa_nFunctionCode){
- m_nFunctionCode = pa_nFunctionCode;
- }
- unsigned int getFunctionCode(){
- return m_nFunctionCode;
- }
-
- void addPollAddresses(unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses);
-
- private:
-
- struct SModbusPollData{
- unsigned int m_nStartAddress;
- unsigned int m_nNrAddresses;
-
- SModbusPollData(unsigned int pa_nStartAddress, unsigned int pa_nNrAddresses) :
- m_nStartAddress(pa_nStartAddress), m_nNrAddresses(pa_nNrAddresses){
- }
- ;
- };
-
- unsigned int m_nFunctionCode;
-
- CSinglyLinkedList<SModbusPollData*> m_lPolls;
-};
-
-#endif /* MODBUSPOLL_H_ */
diff --git a/src/modules/modbus/modbustimedevent.cpp b/src/modules/modbus/modbustimedevent.cpp
deleted file mode 100644
index 96afdc5..0000000
--- a/src/modules/modbus/modbustimedevent.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "modbustimedevent.h"
-
-CModbusTimedEvent::CModbusTimedEvent(TForteUInt32 pa_nUpdateInterval)
- : m_bIsStarted(false){
- m_nUpdateInterval = pa_nUpdateInterval;
- m_oUpdateInterval += (m_nUpdateInterval * cg_nForteTicksPerSecond) / 1000;
-
- if(pa_nUpdateInterval == 0){
- m_bSingleShotEvent = true;
-
- activate();
- }
- else
- m_bSingleShotEvent = false;
-}
-
-void CModbusTimedEvent::setUpdateInterval(TForteUInt32 pa_nUpdateInterval){
- m_nUpdateInterval = pa_nUpdateInterval;
- SForteTime newTime;
- newTime += (m_nUpdateInterval * cg_nForteTicksPerSecond) / 1000;
- m_oUpdateInterval = newTime;
-}
-
-void CModbusTimedEvent::activate(){
- m_oStartTime = CTimerHandler::sm_poFORTETimer->getForteTime();
- m_bIsStarted = true;
-}
-
-void CModbusTimedEvent::deactivate(){
- m_bIsStarted = false;
-}
-
-bool CModbusTimedEvent::readyToExecute() const{
- SForteTime currentTime = CTimerHandler::sm_poFORTETimer->getForteTime();
- if (m_oUpdateInterval > currentTime) {
- return false;
- }
- currentTime -= m_oUpdateInterval;
-
- if(isStarted() && (currentTime > m_oStartTime || currentTime == m_oStartTime)){
- return true;
- }
-
- return false;
-}
-
-void CModbusTimedEvent::restartTimer(){
-
- activate();
-}
diff --git a/src/modules/modbus/modbustimedevent.h b/src/modules/modbus/modbustimedevent.h
deleted file mode 100644
index fe3bfed..0000000
--- a/src/modules/modbus/modbustimedevent.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _MODBUSTIMEDEVENT_H_
-#define _MODBUSTIMEDEVENT_H_
-
-#include "timerha.h"
-#include <modbus.h>
-
-class CModbusTimedEvent{
- public:
- explicit CModbusTimedEvent(TForteUInt32 pa_nUpdateInterval); // UpdateInterval = 0 => single shot event
- virtual ~CModbusTimedEvent(){
- }
-
- void setUpdateInterval(TForteUInt32 pa_nUpdateInterval);
- TForteUInt32 getUpdateInterval() const{
- return m_nUpdateInterval;
- }
-
- void activate();
- void deactivate();
-
- bool isStarted() const {
- return m_bIsStarted;
- }
-
- bool readyToExecute() const;
-
- // Classes impementing this should call restartTimer in executeEvent
- virtual int executeEvent(modbus_t* pa_pModbusConn, void* pa_pRetVal) = 0;
-
- protected:
- void restartTimer();
-
- private:
- SForteTime m_oStartTime;
- SForteTime m_oUpdateInterval;
-
- TForteUInt32 m_nUpdateInterval; // Polling interval in milliseconds (0 => single shot event)
-
- bool m_bSingleShotEvent;
- bool m_bIsStarted;
-};
-
-#endif // _MODBUSTIMEDEVENT_H_
diff --git a/src/modules/modbus/readme.txt b/src/modules/modbus/readme.txt
deleted file mode 100644
index c633cac..0000000
--- a/src/modules/modbus/readme.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-Installation Instructions
-The Modbus com interface need the libmodbus (http://libmodbus.org/) library to work.
-Follow the steps below to set up your environment before compiling forte
-1. libmodbus files should be placed in the following folder structure:
- <libmodbushome>/include/modbus: include files
- <libmodbushome>/lib: libmodbus.lib (windows) or libmodbus.so (posix)
-2. When configuring forte project with CMake choose <libmodbushome> as FORTE_COM_MODBUS_LIB_DIR
-3. forte.exe must be able to find the dynamic libmodbus library after build
- - copy libmodbus.dll/so to folder with forte.exe or
- - add libmodbus.dll/so to library include path
-
-Parameter Documentation
-Modbus Client (TCP)
-At the moment the Modbus client can only be used for reading values from a Modbus server.
-modbus[(protocol:)ip:port:pollFreqency:functionCode:(slaveId):readAddresses:sendAddresses(:responseTimeout:byteTimeout)]
- - protocol: tcp (tcp is default)
- - ip: 127.0.0.1 etc
- - port: default is 502
- - pollFrequency: polling frequency in milliseconds
- - functionCode: 1 - Read Coils
- 2 - Read Discrete Inputs
- 3 - Read Holding Registers
- 4 - Read Input Register
- - slaveId (optional): the slave id used by the modbus server (0xFF is standard)
- - readAddresses: addresses can be specified between 0-65535
- more than one address (max 100) can be specified using
- + comma for separate addresses 0,2,65500
- + dots for interval 5..10
- + combination 0,5..10,2,65500
- - sendAddresses: addresses can be specified between 0-65535
- if data is only read sendAddresses should be left empty
- more than one address (max 100) can be specified using
- + comma for separate addresses 0,2,65500
- + dots for interval 5..10
- + combination 0,5..10,2,65500
- - responseTimeout (optional): timeout in milliseconds to wait for a response (500ms is default)
- - byteTimeout (optional): timeout in milliseconds between two consecutive bytes (500ms is default)
-
-example: modbus[127.0.0.1:502:1000:3:1:0..3:]
diff --git a/src/modules/opc/CMakeLists.txt b/src/modules/opc/CMakeLists.txt
deleted file mode 100644
index a9df038..0000000
--- a/src/modules/opc/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-#*******************************************************************************
-# Copyright (c) 2012, 2015 AIT, ACIN, fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
-# Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
-# *******************************************************************************/
-#############################################################################
-# OPC Com Layer
-#############################################################################
-
-forte_add_network_layer(OPC OFF "opc" COpcComLayer opccomlayer "Enable OPC communication")
-SET(FORTE_COM_OPC_LIB_ROOT "" CACHE PATH "Path to OPC library root directory")
-SET(FORTE_COM_OPC_BOOST_ROOT "" CACHE PATH "Path to Boost library root directory")
-
-if(FORTE_COM_OPC)
- forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-
- forte_add_handler(COpcEventHandler opceventhandler)
-
- if("${FORTE_ARCHITECTURE}" STREQUAL "Win32")
- forte_add_sourcefile_hcpp( opcconnection opcconnectionhandler opceventhandler
- opcconnectionimpl opcprocessvar Cmd_AddConnection
- Cmd_AddOPCProcessVar Cmd_SetProcessVarValue )
-
- forte_add_include_directories( ${FORTE_COM_OPC_BOOST_ROOT} )
-
- forte_add_include_directories( ${FORTE_COM_OPC_LIB_ROOT}/include )
- forte_add_link_directories( ${FORTE_COM_OPC_LIB_ROOT}/lib )
- forte_add_link_library( OPCClientToolKit.lib )
- else()
- # Generate error since OPC only works with Windows
- MESSAGE(SEND_ERROR "Win32 has to be slected for FORTE_ARCHITECTURE for the OPC Com Layer")
- endif()
-endif(FORTE_COM_OPC)
diff --git a/src/modules/opc/Cmd_AddConnection.cpp b/src/modules/opc/Cmd_AddConnection.cpp
deleted file mode 100644
index 65d0953..0000000
--- a/src/modules/opc/Cmd_AddConnection.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "Cmd_AddConnection.h"
-#include "opcconnectionimpl.h"
-
-CCmd_AddConnection::CCmd_AddConnection(COpcConnectionImpl *pa_pConnection) :
- m_pConnection(pa_pConnection){
-}
-
-CCmd_AddConnection::~CCmd_AddConnection(void){
-}
-
-void CCmd_AddConnection::runCommand(){
- m_pConnection->connect();
-}
-const char* CCmd_AddConnection::getCommandName() const{
- return "Cmd_AddConnection";
-}
diff --git a/src/modules/opc/Cmd_AddConnection.h b/src/modules/opc/Cmd_AddConnection.h
deleted file mode 100644
index 028ea75..0000000
--- a/src/modules/opc/Cmd_AddConnection.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef CMDADDCONNECTION_H_
-#define CMDADDCONNECTION_H_
-#include "ICmd.h"
-
-class COpcConnectionImpl;
-
-class CCmd_AddConnection : public ICmd{
- public:
- explicit CCmd_AddConnection(COpcConnectionImpl *pa_pConnection);
- virtual ~CCmd_AddConnection();
-
- virtual void runCommand();
- virtual const char* getCommandName() const;
- private:
- COpcConnectionImpl* m_pConnection;
-};
-
-#endif // CMDADDCONNECTION_H_
diff --git a/src/modules/opc/Cmd_AddOPCProcessVar.cpp b/src/modules/opc/Cmd_AddOPCProcessVar.cpp
deleted file mode 100644
index 9951f8f..0000000
--- a/src/modules/opc/Cmd_AddOPCProcessVar.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "Cmd_AddOPCProcessVar.h"
-#include "opcconnectionimpl.h"
-
-CCmd_AddOPCProcessVar::CCmd_AddOPCProcessVar(COpcConnectionImpl *pa_pConnection, COpcProcessVar* pa_pNewItem) :
- m_pOpcConn(pa_pConnection), m_pNewProcessVar(pa_pNewItem){
-}
-
-CCmd_AddOPCProcessVar::~CCmd_AddOPCProcessVar(void){
-}
-
-void CCmd_AddOPCProcessVar::runCommand(){
- m_pOpcConn->addItem(m_pNewProcessVar);
-}
-
-const char* CCmd_AddOPCProcessVar::getCommandName() const{
- return "Cmd_AddOPCProcessVar";
-}
diff --git a/src/modules/opc/Cmd_AddOPCProcessVar.h b/src/modules/opc/Cmd_AddOPCProcessVar.h
deleted file mode 100644
index fda6e4b..0000000
--- a/src/modules/opc/Cmd_AddOPCProcessVar.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef CMDADDPROCESSVAR_H_
-#define CMDADDPROCESSVAR_H_
-#include "ICmd.h"
-
-class COpcConnectionImpl;
-class COpcProcessVar;
-
-class CCmd_AddOPCProcessVar : public ICmd{
- public:
- CCmd_AddOPCProcessVar(COpcConnectionImpl *pa_pConnection, COpcProcessVar* pa_pNewItem);
- virtual ~CCmd_AddOPCProcessVar(void);
-
- virtual void runCommand();
- virtual const char* getCommandName() const;
-
- private:
- COpcConnectionImpl *m_pOpcConn;
- COpcProcessVar* m_pNewProcessVar;
-};
-
-#endif //CMDADDPROCESSVAR_H_
diff --git a/src/modules/opc/Cmd_SetProcessVarValue.cpp b/src/modules/opc/Cmd_SetProcessVarValue.cpp
deleted file mode 100644
index 84111f6..0000000
--- a/src/modules/opc/Cmd_SetProcessVarValue.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "Cmd_SetProcessVarValue.h"
-
-#include "opcprocessvar.h"
-#include "opcconnectionimpl.h"
-
-CCmd_SetProcessVarValue::CCmd_SetProcessVarValue(COpcProcessVar * pa_pOpcVar) :
- m_pOpcVar(pa_pOpcVar){
-}
-
-CCmd_SetProcessVarValue::~CCmd_SetProcessVarValue(void){
-}
-
-void CCmd_SetProcessVarValue::runCommand(){
- m_pOpcVar->sendItemData();
-}
-const char* CCmd_SetProcessVarValue::getCommandName() const{
- return "Cmd_SetProcessVarValue";
-}
diff --git a/src/modules/opc/Cmd_SetProcessVarValue.h b/src/modules/opc/Cmd_SetProcessVarValue.h
deleted file mode 100644
index 3d89e2c..0000000
--- a/src/modules/opc/Cmd_SetProcessVarValue.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef CMDSETPROCESSVARVALUE_H_
-#define CMDSETPROCESSVARVALUE_H_
-
-#include "ICmd.h"
-
-#include <Windows.h>
-#include "Variant.h"
-
-class COpcProcessVar;
-class COpcConnectionImpl;
-
-class CCmd_SetProcessVarValue : public ICmd{
- public:
- explicit CCmd_SetProcessVarValue(COpcProcessVar * pa_pOpcVar);
- virtual ~CCmd_SetProcessVarValue(void);
-
- virtual void runCommand();
- virtual const char* getCommandName() const;
-
- private:
- COpcProcessVar* m_pOpcVar;
-};
-
-#endif //CMDSETPROCESSVARVALUE_H_
diff --git a/src/modules/opc/ICmd.h b/src/modules/opc/ICmd.h
deleted file mode 100644
index 33881a4..0000000
--- a/src/modules/opc/ICmd.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef ICMD_H_
-#define ICMD_H_
-
-class ICmd{
- public:
- ICmd(){
- }
- ;
- virtual ~ICmd(){
- }
- ;
-
- virtual void runCommand() = 0;
- virtual const char* getCommandName() const = 0;
-};
-
-#endif //ICMD_H_
diff --git a/src/modules/opc/Variant.h b/src/modules/opc/Variant.h
deleted file mode 100644
index 382df9c..0000000
--- a/src/modules/opc/Variant.h
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Werner Tremmel - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef VARIANTNEW_H_
-#define VARIANTNEW_H_
-
-#include <boost/lexical_cast.hpp>
-
-/*! \brief structure for simplified handling of the VARIANT
- *
- * The structure simplifies the handling of the VARIANT with numeric types.
- */
-
-#include <OleAuto.h>
-#include <comutil.h>
-
-struct Variant : public VARIANT{
- public:
- class VariantException : public std::exception{
- public:
- VariantException(){
- }
- virtual const char* what() throw (){
- return "VariantException: unknown variant type";
- }
- };
-
- ~Variant(){
- }
- Variant(){
- }
-
- explicit Variant(const _variant_t &value) :
- VARIANT(value){
- }
- explicit Variant(const VARIANT &value) :
- VARIANT(value){
- }
- explicit Variant(bool value){
- setbool(value);
- }
- explicit Variant(BOOL value){
- setbool(value != 0);
- }
- explicit Variant(VARIANT_BOOL value){
- setbool(value != 0);
- }
-
- template<typename T> explicit Variant(T value){
- set<T>(value);
- }
-
- template<typename T> T get() const{
- switch (vt){
- case VT_I8:
- return static_cast < T > (llVal);
- case VT_I4:
- return static_cast < T > (lVal);
- case VT_I2:
- return static_cast < T > (iVal);
- case VT_I1:
- return static_cast < T > (cVal);
- case VT_UI8:
- return static_cast < T > (ullVal);
- case VT_UI4:
- return static_cast < T > (ulVal);
- case VT_UI2:
- return static_cast < T > (uiVal);
- case VT_UI1:
- return static_cast < T > (bVal);
- case VT_R8:
- return static_cast < T > (dblVal);
- case VT_R4:
- return static_cast < T > (fltVal);
- case VT_INT:
- return static_cast < T > (intVal);
- case VT_UINT:
- return static_cast < T > (uintVal);
- case VT_BOOL:
- return boolVal != 0 ? static_cast < T > (1) : static_cast < T > (0);
-
- default:
- throw VariantException();
- }
- }
- template<> std::string get<std::string>() const{
- switch (vt){
- case VT_I8:
- return boost::lexical_cast < std::string > (llVal);
- case VT_I4:
- return boost::lexical_cast < std::string > (lVal);
- case VT_I2:
- return boost::lexical_cast < std::string > (iVal);
- case VT_I1:
- return boost::lexical_cast < std::string > (cVal);
- case VT_UI8:
- return boost::lexical_cast < std::string > (ullVal);
- case VT_UI4:
- return boost::lexical_cast < std::string > (ulVal);
- case VT_UI2:
- return boost::lexical_cast < std::string > (uiVal);
- case VT_UI1:
- return boost::lexical_cast < std::string > (bVal);
- case VT_R8:
- return boost::lexical_cast < std::string > (dblVal);
- case VT_R4:
- return boost::lexical_cast < std::string > (fltVal);
- case VT_INT:
- return boost::lexical_cast < std::string > (intVal);
- case VT_UINT:
- return boost::lexical_cast < std::string > (uintVal);
- case VT_BOOL:
- return boolVal != 0 ? boost::lexical_cast < std::string > (true) : boost::lexical_cast < std::string > (false);
-
- default:
- throw VariantException();
- }
- }
- template<> bool get<bool>() const{
- switch (vt){
- case VT_I8:
- return llVal != 0 ? true : false;
- case VT_I4:
- return lVal != 0 ? true : false;
- case VT_I2:
- return iVal != 0 ? true : false;
- case VT_I1:
- return cVal != 0 ? true : false;
- case VT_UI8:
- return ullVal != 0 ? true : false;
- case VT_UI4:
- return ulVal != 0 ? true : false;
- case VT_UI2:
- return uiVal != 0 ? true : false;
- case VT_UI1:
- return bVal != 0 ? true : false;
- case VT_R8:
- return dblVal != 0 ? true : false;
- case VT_R4:
- return fltVal != 0 ? true : false;
- case VT_INT:
- return intVal != 0 ? true : false;
- case VT_UINT:
- return uintVal != 0 ? true : false;
- case VT_BOOL:
- return boolVal != 0 ? true : false;
-
- default:
- throw VariantException();
- }
- }
- void setbool(bool value){
- boolVal = value ? 0xffff : 0;
- vt = VT_BOOL;
- }
- template<typename T> void set(T value){
- getField<T>() = value;
- vt = getType<T>();
- }
- template<> void set<bool>(bool value){
- setbool(value);
- }
- void setBOOL(BOOL value){
- setbool(value != 0);
- }
- void setVARIANT_BOOL(VARIANT_BOOL value){
- setbool(value != 0);
- }
-
- template<typename T> bool isType() const{
- return vt == getType<T>();
- }
-
- bool isInteger() const{
- switch (vt){
- case VT_I8:
- case VT_I4:
- case VT_I2:
- case VT_I1:
- case VT_INT:
- return true;
- default:
- return false;
- }
- }
- bool isUnsignedInteger() const{
- switch (vt){
- case VT_UI8:
- case VT_UI4:
- case VT_UI2:
- case VT_UI1:
- case VT_UINT:
- return true;
- default:
- return false;
- }
- }
- bool isFloatingPoint() const{
- switch (vt){
- case VT_R8:
- case VT_R4:
- return true;
- default:
- return false;
- }
- }
-
- template<typename T> VARTYPE getType() const{
- constraint<T>();
- }
- template<> VARTYPE getType<LONGLONG>() const{
- return VT_I8;
- }
- template<> VARTYPE getType<LONG>() const{
- return VT_I4;
- }
- template<> VARTYPE getType<SHORT>() const{
- return VT_I2;
- }
- template<> VARTYPE getType<CHAR>() const{
- return VT_I1;
- }
- template<> VARTYPE getType<signed char>() const{
- return VT_I1;
- }
- template<> VARTYPE getType<ULONGLONG>() const{
- return VT_UI8;
- }
- template<> VARTYPE getType<ULONG>() const{
- return VT_UI4;
- }
- template<> VARTYPE getType<USHORT>() const{
- return VT_UI2;
- }
- template<> VARTYPE getType<BYTE>() const{
- return VT_UI1;
- }
- template<> VARTYPE getType<float>() const{
- return VT_R4;
- }
- template<> VARTYPE getType<double>() const{
- return VT_R8;
- }
- //template<> VARTYPE getType<BOOL>() const{
- // return VT_BOOL;
- //}
- template<> VARTYPE getType<INT>() const{
- return VT_INT;
- }
- template<> VARTYPE getType<UINT>() const{
- return VT_UINT;
- }
-
- template<typename T> T &getField(){
- constraint<T>();
- }
- template<> LONGLONG &getField<LONGLONG>(){
- return llVal;
- }
- template<> LONG &getField<LONG>(){
- return lVal;
- }
- template<> SHORT &getField<SHORT>(){
- return iVal;
- }
- template<> CHAR &getField<CHAR>(){
- return cVal;
- }
- template<> signed char &getField<signed char>(){
- return (signed char&)cVal;
- }
- template<> ULONGLONG &getField<ULONGLONG>(){
- return ullVal;
- }
- template<> ULONG &getField<ULONG>(){
- return ulVal;
- }
- template<> USHORT &getField<USHORT>(){
- return uiVal;
- }
- template<> BYTE &getField<BYTE>(){
- return bVal;
- }
- template<> float &getField<float>(){
- return fltVal;
- }
- template<> double &getField<double>(){
- return dblVal;
- }
- template<> INT &getField<INT>(){
- return intVal;
- }
- template<> UINT &getField<UINT>(){
- return uintVal;
- }
-
- bool operator==(const Variant &other) const{
- if(vt != other.vt) {
- return false;
- }
- ULONGLONG mask = ~0ul;
- switch (vt){
- case VT_I4:
- case VT_UI4:
- case VT_INT:
- case VT_UINT:
- case VT_R4:
- mask = 0xffffffffull;
- break;
- case VT_I2:
- case VT_UI2:
- case VT_BOOL:
- mask = 0xffffull;
- break;
- case VT_I1:
- case VT_UI1:
- mask = 0xffull;
- break;
- }
- return ((ullVal ^ other.ullVal) & mask) == 0;
- }
-
- /*! \brief Compiler error, when used
- *
- * This is only here to throw a compiler error when used. So the unsupported types are caught by the compiler
- * and not by the runtime system
- */
- template<typename T> static void constraint(){
- char a[2];
- a[1.2] = 0;
- }
-};
-
-#endif //VARIANTNEW_H_
diff --git a/src/modules/opc/opccomlayer.cpp b/src/modules/opc/opccomlayer.cpp
deleted file mode 100644
index 4bf43d9..0000000
--- a/src/modules/opc/opccomlayer.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, ACIN, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Patrick Smejkal, Alois Zoitl, Martin Melik-Merkumians - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opccomlayer.h"
-#include "../../arch/devlog.h"
-#include "commfb.h"
-
-#include "opcconnection.h"
-#include "opcconnectionhandler.h"
-#include "Variant.h"
-#include <criticalregion.h>
-
-using namespace forte::com_infra;
-
-COpcComLayer::COpcComLayer(CComLayer* pa_poUpperLayer, CBaseCommFB* pa_poComFB) :
-CComLayer(pa_poUpperLayer, pa_poComFB), m_acHost(0), m_acServerName(0), m_nUpdateRate(0), m_nDeadBand(0), m_bLayerParamsOK(false), m_pOpcConnection(0), m_eInterruptResp(e_Nothing){
- m_acOpcGroupName = m_poFb->getInstanceName();
-}
-
-COpcComLayer::~COpcComLayer(){
-}
-
-EComResponse COpcComLayer::sendData(void *pa_pvData, unsigned int pa_unSize){
- EComResponse eRetVal = e_ProcessDataOk;
-
- if((0 != m_poFb)){
- if(m_pOpcConnection->isConnected()){
- switch (m_poFb->getComServiceType()){
- case e_Server:
- //TODO
- break;
- case e_Client: {
- convertInputData(pa_pvData, pa_unSize);
-
- TOpcProcessVarList::Iterator itEnd = m_lFBInputVars.end();
- for(TOpcProcessVarList::Iterator it = m_lFBInputVars.begin(); it != itEnd; ++it){
- if(it->getIsActive()) {
- m_pOpcConnection->send_sendItemData((*it));
- }
- }
- break;
- }
- case e_Publisher:
- //do nothing as OPC cannot be publisher
- break;
- case e_Subscriber:
- //do nothing as subscribers do not send data
- break;
- }
- }
- }
- return eRetVal;
-}
-
-EComResponse COpcComLayer::processInterrupt(){
- EComResponse eRet = e_Nothing;
- EComResponse currentComResponse;
-
- {
- CCriticalRegion criticalRegion(m_oSync);
- TComResponseList::Iterator comIt(m_lComResponses.begin());
- currentComResponse = *comIt;
- m_lComResponses.popFront();
- }
-
- switch (currentComResponse){
- case e_ProcessDataOk:
- switch (m_eConnectionState){
- case e_Connected: {
- CIEC_ANY *apoRDs = m_poFb->getRDs();
- unsigned int nrRDs = m_poFb->getNumRD();
-
- TOpcProcessVarList::Iterator itEnd = m_lFBOutputVars.end();
- TOpcProcessVarList::Iterator it = m_lFBOutputVars.begin();
- for(unsigned int i = 0; i < nrRDs && it != itEnd; i++, ++it){
- setOutputValue(&apoRDs[i], &it->updateValue());
- }
-
- break;
- }
- case e_Disconnected:
- case e_Listening:
- case e_ConnectedAndListening:
- default:
- break;
- }
- eRet = e_ProcessDataOk;
- break;
- case e_InitInvalidId:
- eRet = e_InitInvalidId;
- break;
- case e_InitTerminated:
- eRet = e_InitTerminated;
- break;
- }
-
- return eRet;
-}
-
-EComResponse COpcComLayer::recvData(const void *, unsigned int){
- EComResponse eRet = e_Nothing;
-
- switch (m_poFb->getComServiceType()){
- case e_Server:
- //TODO
- break;
- case e_Client: {
- switch (m_pOpcConnection->getConnectionState()){
- case COpcConnection::e_Connected:
- // Successfully connected --> adding OPC items
- if(addOpcItems() < 0){
- //TODO
- } else {
- m_eConnectionState = e_Connected;
- }
- break;
- case COpcConnection::e_ConnectionFailed:
- {
- CCriticalRegion criticalRegion(m_oSync);
- m_lComResponses.pushBack(e_InitTerminated);
- }
- m_poFb->interruptCommFB(this);
- eRet = e_InitTerminated;
- break;
- case COpcConnection::e_ItemAddedOk:
- //do nothing
- break;
- case COpcConnection::e_ItemAddedFailed:
- {
- CCriticalRegion criticalRegion(m_oSync);
- m_lComResponses.pushBack(e_InitTerminated);
- }
- m_poFb->interruptCommFB(this);
- eRet = e_InitTerminated;
- break;
- case COpcConnection::e_DataReceived: {
- int nRetVal = m_pOpcConnection->receiveData(m_acOpcGroupName, &m_lFBOutputVars);
- if (nRetVal > 0) {
- //we successfully received data
- CCriticalRegion criticalRegion(m_oSync);
- m_lComResponses.pushBack(e_ProcessDataOk);
- }
- m_poFb->interruptCommFB(this);
- eRet = e_ProcessDataOk;
- break;
- }
- case COpcConnection::e_Disconnected:
- //TODO error during connection try
- break;
- default:
- break;
- }
- break;
- }
- case e_Publisher:
- //do nothing as publisher cannot receive data
- case e_Subscriber:
- //do nothing as OPC cannot be subscribers
- break;
- }
-
- return eRet;
-}
-
- EComResponse COpcComLayer::openConnection(char *pa_acLayerParameter){
- EComResponse eRetVal = e_InitInvalidId;
- m_eConnectionState = e_Disconnected;
-
- switch (m_poFb->getComServiceType()){
- case e_Server:
- //TODO
- break;
- case e_Client:
- processClientParams(pa_acLayerParameter);
- if(m_bLayerParamsOK){
- eRetVal = e_InitOk;
- m_pOpcConnection = COpcConnectionHandler::getInstance().getOpcConnection(m_acHost, m_acServerName, m_acOpcGroupName, m_nUpdateRate, m_nDeadBand, this);
-
- m_pOpcConnection->send_connect();
-
- COpcConnection::EOpcConnectionEvents connState = m_pOpcConnection->getConnectionState();
- if (connState == COpcConnection::e_Connected) {
- m_eConnectionState = e_Connected;
- addOpcItems();
- }
- else if(connState == COpcConnection::e_ConnectionFailed) {
- eRetVal = e_InitTerminated;
- }
- }
- break;
- case e_Publisher:
- //do nothing, OPC cannot be publisher
- break;
- case e_Subscriber:
- //do nothing, OPC cannot be subscriber
- break;
- }
-
- return eRetVal;
- }
-
- void COpcComLayer::closeConnection(){
- DEVLOG_DEBUG("COpcComLayer::closeConnection() \n");
- COpcConnectionHandler::getInstance().removeOpcConnection(m_pOpcConnection->getHost(), m_pOpcConnection->getServerName(), m_acOpcGroupName);
-
- m_eConnectionState = e_Disconnected;
- }
-
- int COpcComLayer::addOpcItems(){
- int result = 0;
-
- // Add input items
- TOpcProcessVarList::Iterator itEnd = m_lFBInputVars.end();
- for(TOpcProcessVarList::Iterator it = m_lFBInputVars.begin(); it != itEnd; ++it){
- result = m_pOpcConnection->send_addItem(*it);
- }
-
- // Add output items
- itEnd = m_lFBOutputVars.end();
- for(TOpcProcessVarList::Iterator it = m_lFBOutputVars.begin(); it != itEnd; ++it){
- result = m_pOpcConnection->send_addItem(*it);
- }
-
- return result;
- }
-
- void COpcComLayer::setOutputValue(CIEC_ANY *pa_pDataOut, Variant * pa_pValue){
- switch (pa_pDataOut->getDataTypeID()){
- case CIEC_ANY::e_BOOL:
- pa_pDataOut->setValue(CIEC_BOOL(pa_pValue->get<bool>()));
- break;
- case CIEC_ANY::e_SINT:
- pa_pDataOut->setValue(CIEC_SINT(pa_pValue->get<TForteInt8>()));
- break;
- case CIEC_ANY::e_INT:
- pa_pDataOut->setValue(CIEC_INT(pa_pValue->get<TForteInt16>()));
- break;
- case CIEC_ANY::e_DINT:
- pa_pDataOut->setValue(CIEC_DINT(pa_pValue->get<TForteInt32>()));
- break;
- case CIEC_ANY::e_LINT:
- pa_pDataOut->setValue(CIEC_LINT(pa_pValue->get<TForteInt64>()));
- break;
- case CIEC_ANY::e_USINT:
- pa_pDataOut->setValue(CIEC_USINT(pa_pValue->get<TForteUInt8>()));
- break;
- case CIEC_ANY::e_UINT:
- pa_pDataOut->setValue(CIEC_UINT(pa_pValue->get<TForteUInt16>()));
- break;
- case CIEC_ANY::e_UDINT:
- pa_pDataOut->setValue(CIEC_UDINT(pa_pValue->get<TForteUInt32>()));
- break;
- case CIEC_ANY::e_ULINT:
- pa_pDataOut->setValue(CIEC_ULINT(pa_pValue->get<TForteUInt64>()));
- break;
- case CIEC_ANY::e_BYTE:
- pa_pDataOut->setValue(CIEC_BYTE(pa_pValue->get<TForteByte>()));
- break;
- case CIEC_ANY::e_WORD:
- pa_pDataOut->setValue(CIEC_WORD(pa_pValue->get<TForteWord>()));
- break;
- case CIEC_ANY::e_DWORD:
- pa_pDataOut->setValue(CIEC_DWORD(pa_pValue->get<TForteDWord>()));
- break;
- case CIEC_ANY::e_LWORD:
- pa_pDataOut->setValue(CIEC_LWORD(pa_pValue->get<TForteLWord>()));
- break;
- case CIEC_ANY::e_REAL:
- pa_pDataOut->setValue(CIEC_REAL(pa_pValue->get<TForteFloat>()));
- break;
- case CIEC_ANY::e_LREAL:
- pa_pDataOut->setValue(CIEC_LREAL(pa_pValue->get<TForteDFloat>()));
- break;
- default:
- //TODO
- break;
- }
- }
-
- void COpcComLayer::processClientParams(char* pa_acLayerParams){
-
- char *chrStorage;
- char *chrHost;
- char *chrServer;
- char *temp;
-
- // Get Host
- chrStorage = strchr(pa_acLayerParams, ':');
- if(chrStorage == 0) {
- return;
- }
- *chrStorage = '\0';
- ++chrStorage;
- chrHost = (char*) malloc(strlen(pa_acLayerParams) + 1);
- strcpy(chrHost, pa_acLayerParams);
- if(strcmp(chrHost, "127.0.0.1") == 0 || strcmp(chrHost, "localhost") == 0) {
- m_acHost = "";
- } else {
- m_acHost = chrHost;
- }
-
- // Get server name
- temp = chrStorage;
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- if (chrHost){
- free(chrHost);
- }
- return;
- }
- *chrStorage = '\0';
- ++chrStorage;
- chrServer = (char*) malloc(strlen(temp) + 1);
- strcpy(chrServer, temp);
- m_acServerName = chrServer;
-
- // Get update rate
- m_nUpdateRate = atol(chrStorage);
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- if (chrHost){
- free(chrHost);
- }
- return;
- }
- *chrStorage = '\0';
- ++chrStorage;
-
- // Get dead band
- m_nDeadBand = (float) atof(chrStorage);
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- if (chrHost){
- free(chrHost);
- }
- return;
- }
-
- *chrStorage = '\0';
- ++chrStorage;
-
- // Get FB input items
- char * inputItems = chrStorage;
- chrStorage = strchr(chrStorage, ':');
- if(chrStorage == 0){
- if (chrHost){
- free(chrHost);
- }
- return;
- }
- *chrStorage = '\0';
- ++chrStorage;
- int nrItems = 0;
- char *pch;
- pch = strtok(inputItems, ",");
- while(pch != NULL){
- char *itemName = (char*) malloc(strlen(pch) + 1);
- strcpy(itemName, pch);
- m_lFBInputVars.pushBack(new COpcProcessVar(m_acOpcGroupName, itemName, COpcProcessVar::e_FBInput));
- nrItems++;
- pch = strtok(NULL, ",");
- }
-
- // Get FB output items
- pch = strtok(chrStorage, ",");
- while(pch != NULL){
- char *itemName = (char*) malloc(strlen(pch) + 1);
- strcpy(itemName, pch);
- m_lFBOutputVars.pushBack(new COpcProcessVar(m_acOpcGroupName, itemName, COpcProcessVar::e_FBOutput));
- nrItems++;
-
- pch = strtok(NULL, ",");
- }
-
- if(nrItems > 0) {
- m_bLayerParamsOK = true;
- }
-
- }
-
- void COpcComLayer::convertInputData(void *pa_pData, unsigned int pa_nSize){
- //CIEC_ANY *apoSDs = static_cast<CIEC_ANY*>(pa_pData);
- unsigned int nrSDs = pa_nSize;
- unsigned int sdIndex = 0;
-
- TOpcProcessVarList::Iterator it_var = m_lFBInputVars.begin();
- TOpcProcessVarList::Iterator itEnd = m_lFBInputVars.end();
-
- while(sdIndex < nrSDs && it_var != itEnd){
- // CIEC_ANY *dataIn = &apoSDs[sdIndex];
- Variant newVariant;
- //unsigned int valueSize = 0;
-
- //valueSize = getInputValueSize(dataIn, &newVariant);;
-
- it_var->setNewValue(newVariant);
-
- ++it_var;
- ++sdIndex;
- }
-
- }
-
- template<typename T>
- void COpcComLayer::getInputValue(void * pa_pData, Variant * pa_pNewValue){
- T* vData = (T*) pa_pData;
- T data = vData[0];
-
- pa_pNewValue->set<T>(data);
- }
-
- unsigned int COpcComLayer::getInputValueSize(CIEC_ANY* pa_pData, Variant * pa_pNewValue){
- switch (pa_pData->getDataTypeID()){
- case CIEC_ANY::e_BOOL:
- {
- pa_pNewValue->set<bool>((bool) *(dynamic_cast<CIEC_BOOL*>(pa_pData)));
- return sizeof(bool);
- }
- case CIEC_ANY::e_SINT:
- {
- pa_pNewValue->set<CHAR>((CHAR) *(dynamic_cast<CIEC_SINT*>(pa_pData)));
- return sizeof(TForteInt8);
- }
- case CIEC_ANY::e_INT:
- {
- CIEC_INT* tempInt = dynamic_cast<CIEC_INT*>(pa_pData);
- TForteInt16 forteInt = (TForteInt16) (*tempInt);
- pa_pNewValue->set<TForteInt16>(forteInt);
- return sizeof(TForteInt16);
- }
- case CIEC_ANY::e_DINT:
- {
- pa_pNewValue->set<TForteInt32>((TForteInt32) *(dynamic_cast<CIEC_DINT*>(pa_pData)));
- return sizeof(TForteInt32);
- }
- case CIEC_ANY::e_LINT:
- {
- pa_pNewValue->set<TForteInt64>((TForteInt64) *(dynamic_cast<CIEC_LINT*>(pa_pData)));
- return sizeof(TForteInt64);
- }
- case CIEC_ANY::e_USINT:
- {
- pa_pNewValue->set<TForteUInt8>((TForteUInt8) *(dynamic_cast<CIEC_USINT*>(pa_pData)));
- return sizeof(TForteUInt8);
- }
- case CIEC_ANY::e_UINT:
- {
- pa_pNewValue->set<TForteUInt16>((TForteUInt16) *(dynamic_cast<CIEC_UINT*>(pa_pData)));
- return sizeof(TForteUInt16);
- }
- case CIEC_ANY::e_UDINT:
- {
- pa_pNewValue->set<TForteUInt32>((TForteUInt32) *(dynamic_cast<CIEC_UDINT*>(pa_pData)));
- return sizeof(TForteUInt32);
- }
- case CIEC_ANY::e_ULINT:
- {
- pa_pNewValue->set<TForteUInt64>((TForteUInt64) *(dynamic_cast<CIEC_ULINT*>(pa_pData)));
- return sizeof(TForteUInt64);
- }
- case CIEC_ANY::e_BYTE:
- {
- pa_pNewValue->set<TForteByte>((TForteByte) *(dynamic_cast<CIEC_BYTE*>(pa_pData)));
- return sizeof(TForteByte);
- }
- case CIEC_ANY::e_WORD:
- {
- pa_pNewValue->set<TForteWord>((TForteWord) *(dynamic_cast<CIEC_WORD*>(pa_pData)));
- return sizeof(TForteWord);
- }
- case CIEC_ANY::e_DWORD:
- {
- pa_pNewValue->set<TForteDWord>((TForteDWord) *(dynamic_cast<CIEC_DWORD*>(pa_pData)));
- return sizeof(TForteDWord);
- }
- case CIEC_ANY::e_LWORD:
- {
- pa_pNewValue->set<TForteLWord>((TForteLWord) *(dynamic_cast<CIEC_LWORD*>(pa_pData)));
- return sizeof(TForteLWord);
- }
- case CIEC_ANY::e_REAL:
- {
- pa_pNewValue->set<TForteFloat>((TForteFloat) *(dynamic_cast<CIEC_REAL*>(pa_pData)));
- return sizeof(TForteFloat);
- }
- case CIEC_ANY::e_LREAL:
- {
- pa_pNewValue->set<TForteDFloat>((TForteDFloat) *(dynamic_cast<CIEC_LREAL*>(pa_pData)));
- return sizeof(TForteDFloat);
- }
- default:
- //TODO
- break;
- }
-
- return 0;
- }
diff --git a/src/modules/opc/opccomlayer.h b/src/modules/opc/opccomlayer.h
deleted file mode 100644
index fe66889..0000000
--- a/src/modules/opc/opccomlayer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2015 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCCOMLAYER_H_
-#define OPCCOMLAYER_H_
-
-#include <forte_config.h>
-#include "comlayer.h"
-#include "opcprocessvar.h"
-
-class CIEC_ANY;
-class COpcConnection;
-struct Variant;
-
-namespace forte {
-
- namespace com_infra {
-
- class COpcComLayer : public CComLayer{
- public:
- COpcComLayer(CComLayer* pa_poUpperLayer, CBaseCommFB* pa_poComFB);
- virtual ~COpcComLayer();
-
- EComResponse sendData(void *pa_pvData, unsigned int pa_unSize); // top interface, called from top
- EComResponse recvData(const void *pa_pvData, unsigned int pa_unSize);
- EComResponse processInterrupt();
-
- private:
- EComResponse openConnection(char *pa_acLayerParameter);
- void closeConnection();
- int addOpcItems();
- void setOutputValue(CIEC_ANY *pa_pDataOut, Variant * pa_pValue);
- void processClientParams(char* pa_acLayerParams);
- void convertInputData(void *pa_pData, unsigned int pa_nSize);
-
- unsigned int getInputValueSize(CIEC_ANY* pa_pData, Variant * pa_pNewValue);
-
- template<typename T>
- void getInputValue(void * pa_pData, Variant * pa_pNewValue);
-
- const char* m_acHost;
- const char* m_acServerName;
- long m_nUpdateRate;
- float m_nDeadBand;
- const char* m_acOpcGroupName;
-
- bool m_bLayerParamsOK;
-
- COpcConnection *m_pOpcConnection;
-
- typedef CSinglyLinkedList<COpcProcessVar*> TOpcProcessVarList;
- TOpcProcessVarList m_lFBOutputVars;
- TOpcProcessVarList m_lFBInputVars;
-
- EComResponse m_eInterruptResp;
- typedef CSinglyLinkedList<EComResponse> TComResponseList;
- TComResponseList m_lComResponses;
-
- CSyncObject m_oSync;
- };
-
- }
-
-}
-
-#endif /* OPCCOMLAYER_H_ */
diff --git a/src/modules/opc/opcconnection.cpp b/src/modules/opc/opcconnection.cpp
deleted file mode 100644
index 32d636a..0000000
--- a/src/modules/opc/opcconnection.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opcconnection.h"
-#include "opcconnectionimpl.h"
-#include "opceventhandler.h"
-#include "opcprocessvar.h"
-#include "Cmd_AddConnection.h"
-#include "Cmd_AddOPCProcessVar.h"
-#include "Cmd_SetProcessVarValue.h"
-
-using namespace forte::com_infra;
-
-COpcConnection::COpcConnection(const char *pa_acHost, const char *pa_acServerName, COpcEventHandler* pa_eventHandler) :
- m_nGroupCount(0), m_eConnectionEvent(e_Disconnected), m_acHost(pa_acHost), m_acServerName(pa_acServerName), m_acGroupName(0), m_nReqUpdateRate(0), m_nRealUpdateRate(0), m_nDeadBand(0), m_bIsConnected(false), m_bBlockingConnect(false),
- m_eventHandler(pa_eventHandler){
- m_pOpcConnectionImpl = new COpcConnectionImpl(pa_acHost, pa_acServerName, this);
-}
-
-COpcConnection::~COpcConnection(){
- delete m_pOpcConnectionImpl;
-}
-
-void COpcConnection::addGroup(const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand, CComLayer* pa_pComCallback){
- m_oSync.lock();
- m_lOpcGroupMapList.pushBack(new SOpcGroupMap(pa_acGroupName, m_eventHandler->addComCallback(pa_pComCallback)));
- m_oSync.unlock();
-
- m_pOpcConnectionImpl->addGroup(pa_acGroupName, pa_nReqUpdateRate, pa_nDeadBand);
-
- m_nGroupCount++;
-}
-
-void COpcConnection::removeGroup(const char* pa_acGroupName){
- m_oSync.lock();
- TOpcGroupMapList::Iterator itDelete = m_lOpcGroupMapList.begin();
- TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin();
- TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();
-
- if(it_group != itEnd_group){
- if(strcmp(it_group->m_acGroupName, pa_acGroupName) == 0){
- m_lOpcGroupMapList.popFront();
- m_nGroupCount--;
- m_oSync.unlock();
- return;
- }
- ++it_group;
- while(it_group != itEnd_group){
- if(strcmp(it_group->m_acGroupName, pa_acGroupName) == 0){
- m_lOpcGroupMapList.eraseAfter(itDelete);
- m_nGroupCount--;
- m_oSync.unlock();
- return;
- }
-
- ++itDelete;
- ++it_group;
- }
- }
-
- m_oSync.unlock();
-}
-
-int COpcConnection::send_connect(){
- switch (m_eConnectionEvent){
- case e_Disconnected:
- m_eConnectionEvent = e_Connecting;
- m_eventHandler->sendCommand(new CCmd_AddConnection(m_pOpcConnectionImpl));
- return 0;
- case e_Connecting:
- return 0;
- default: // all other connection states
- return 1;
- }
-}
-
-int COpcConnection::send_connect(bool pa_bBlocking){
- m_bBlockingConnect = pa_bBlocking;
- if(pa_bBlocking && !m_bIsConnected){
- m_pOpcConnectionImpl->connect();
- return 1;
- }
-
- return send_connect();
-}
-
-int COpcConnection::send_addItem(COpcProcessVar* pa_pNewItem){
- m_oSync.lock();
- TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();
- for(TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin(); it_group != itEnd_group; ++it_group){
- if(strcmp(it_group->m_acGroupName, pa_pNewItem->getItemGroupName()) == 0){
- if(pa_pNewItem->getItemFunction() == COpcProcessVar::e_FBOutput){
-
- //check if item already added
- TItemDataList::Iterator itEnd_item = (*it_group)->m_lReadItemsList.end();
- for(TItemDataList::Iterator it_item = (*it_group)->m_lReadItemsList.begin(); it_item != itEnd_item; ++it_item){
- if(strcmp(it_item->m_acItemName, pa_pNewItem->getItemName()) == 0){
- m_oSync.unlock();
- return 1;
- }
- }
-
- it_group->m_lReadItemsList.pushBack(new SOpcItemData(pa_pNewItem->getItemName()));
- break;
-
- }
- else if(pa_pNewItem->getItemFunction() == COpcProcessVar::e_FBInput){
- //check if item already added
- TItemDataList::Iterator itEnd_item = (*it_group)->m_lWriteItemsList.end();
- for(TItemDataList::Iterator it_item = (*it_group)->m_lWriteItemsList.begin(); it_item != itEnd_item; ++it_item){
- if(strcmp(it_item->m_acItemName, pa_pNewItem->getItemName()) == 0){
- m_oSync.unlock();
- return 1;
- }
- }
-
- it_group->m_lWriteItemsList.pushBack(new SOpcItemData(pa_pNewItem->getItemName()));
- break;
-
- }
- }
- }
- m_oSync.unlock();
-
- if(m_eConnectionEvent == e_Connected){
- m_eventHandler->sendCommand(new CCmd_AddOPCProcessVar(m_pOpcConnectionImpl, pa_pNewItem));
-
- return 0;
- }
-
- return -1;
-}
-
-int COpcConnection::send_sendItemData(COpcProcessVar* pa_pItem){
- if(pa_pItem->getIsActive()) {
- m_eventHandler->sendCommand(new CCmd_SetProcessVarValue(pa_pItem));
- }
- return 0;
-}
-
-void COpcConnection::response_connect(bool pa_bConnectionState){
- m_bIsConnected = pa_bConnectionState;
- if(pa_bConnectionState) {
- m_eConnectionEvent = e_Connected;
- } else {
- m_eConnectionEvent = e_ConnectionFailed;
- }
- //m_eConnectionEvent = e_Disconnected;
-
- if(!m_bBlockingConnect){
- m_oSync.lock();
-
- TOpcGroupMapList::Iterator itEnd = m_lOpcGroupMapList.end();
- for(TOpcGroupMapList::Iterator it = m_lOpcGroupMapList.begin(); it != itEnd; ++it){
- m_eventHandler->executeComCallback((*it)->m_nCallbackDesc);
- }
-
- m_oSync.unlock();
- }
-}
-
-void COpcConnection::response_dataReceived(const char *pa_acGroupName, TItemDataList & pa_lItemDataList){
- // Loop through OpcGroups
- m_oSync.lock();
- TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();
- for(TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin(); it_group != itEnd_group; ++it_group){
-
- if(strcmp(it_group->m_acGroupName, pa_acGroupName) == 0){
-
- // Loop through OpcItems in OpcGroup
- TItemDataList::Iterator itEnd_item = (*it_group)->m_lReadItemsList.end();
- for(TItemDataList::Iterator it_item = (*it_group)->m_lReadItemsList.begin(); it_item != itEnd_item; ++it_item){
-
- // Loop through OpcItems in ItemDataList
- TItemDataList::Iterator itEnd_newItem = pa_lItemDataList.end();
- TItemDataList::Iterator itErase = pa_lItemDataList.begin();
- for(TItemDataList::Iterator it_newItem = pa_lItemDataList.begin(); it_newItem != itEnd_newItem; ++it_newItem){
-
- if(strcmp(it_newItem->m_acItemName, it_item->m_acItemName) == 0){
- it_item->m_oItemData = it_newItem->m_oItemData;
-
- if(it_newItem == pa_lItemDataList.begin()) {
- pa_lItemDataList.popFront();
- } else {
- pa_lItemDataList.eraseAfter(itErase);
- }
-
- break;
- }
-
- if(it_newItem != pa_lItemDataList.begin()) {
- ++itErase;
- }
- }
- if(pa_lItemDataList.isEmpty()) {
- break;
- }
- }
-
- // Change state
- m_eConnectionEvent = e_DataReceived;
-
- // Notify Com Layer
- m_eventHandler->executeComCallback(it_group->m_nCallbackDesc);
- break;
- }
- }
- m_oSync.unlock();
-}
-
-void COpcConnection::response_itemAdded(COpcProcessVar* pa_pOpcItem){
- // Loop through OpcGroups
- m_oSync.lock();
- TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();
- for(TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin(); it_group != itEnd_group; ++it_group){
- if(strcmp(it_group->m_acGroupName, pa_pOpcItem->getItemGroupName()) == 0){
- // Change state
- if (pa_pOpcItem->getIsActive()) {
- m_eConnectionEvent = e_ItemAddedOk;
- } else {
- m_eConnectionEvent = e_ItemAddedFailed;
- }
- // Notify Com Layer
- m_eventHandler->executeComCallback(it_group->m_nCallbackDesc);
- break;
- }
- }
- m_oSync.unlock();
-}
-
-int COpcConnection::receiveData(const char* pa_acGroupName, TOpcProcessVarList * pa_lOpcProcessVarList){
- int nrData = 0;
- // TODO Case when lists do not match in size
-
- m_oSync.lock();
- TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();
- for(TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin(); it_group != itEnd_group; ++it_group){
-
- if(strcmp(it_group->m_acGroupName, pa_acGroupName) == 0){
-
- TItemDataList::Iterator itEnd_item = it_group->m_lReadItemsList.end();
- TItemDataList::Iterator it_item = it_group->m_lReadItemsList.begin();
-
- TOpcProcessVarList::Iterator itEnd_procVar = pa_lOpcProcessVarList->end();
- TOpcProcessVarList::Iterator it_procVar = pa_lOpcProcessVarList->begin();
-
- while(it_procVar != itEnd_procVar && it_item != itEnd_item){
-
- it_procVar->setNewValue(it_item->m_oItemData);
-
- nrData++;
-
- ++it_procVar;
- ++it_item;
- }
-
- break;
- }
-
- }
- m_oSync.unlock();
- return nrData;
-}
-
diff --git a/src/modules/opc/opcconnection.h b/src/modules/opc/opcconnection.h
deleted file mode 100644
index af810ca..0000000
--- a/src/modules/opc/opcconnection.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, ACIN, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCCONNECTION_H_
-#define OPCCONNECTION_H_
-
-#include "comlayer.h"
-#include "fortelist.h"
-#include <forte_sync.h>
-#include "windows.h"
-#include "Variant.h"
-
-class COpcConnectionImpl;
-class COpcProcessVar;
-class COpcEventHandler;
-
-struct SOpcItemData{
- const char* m_acItemName;
- Variant m_oItemData;
-
- explicit SOpcItemData(const char* pa_acItemName) :
- m_acItemName(pa_acItemName){
- m_oItemData.set<SHORT>(0);
- }
- SOpcItemData(const char* pa_acItemName, Variant pa_oItemData) :
- m_acItemName(pa_acItemName), m_oItemData(pa_oItemData){
- }
-};
-typedef CSinglyLinkedList<SOpcItemData*> TItemDataList;
-
-class COpcConnection{
- public:
-
- COpcConnection(const char *pa_acHost, const char *pa_acServerName, COpcEventHandler* pa_eventHandler);
- ~COpcConnection();
-
- /*** Functions for OpcConnectionHandler ****************************************/
- void addGroup(const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand, forte::com_infra::CComLayer* pa_pComCallback);
- void removeGroup(const char* pa_acGroupName);
- /*** END ***********************************************************************/
-
- /*** Functions for OpcComLayer *************************************************/
- int send_connect();
- int send_connect(bool pa_bBlocking);
- int send_addItem(COpcProcessVar* pa_pNewItem);
- int send_sendItemData(COpcProcessVar* pa_pItem);
-
- typedef CSinglyLinkedList<COpcProcessVar*> TOpcProcessVarList;
- int receiveData(const char* pa_acGroupName, TOpcProcessVarList * pa_lOpcProcessVarList);
-
- bool isConnected() const {
- return m_bIsConnected;
- }
- /*** END ***********************************************************************/
-
- /*** Functions for OpcConnectionImpl *******************************************/
- void response_connect(bool pa_bConnectionState);
- void response_dataReceived(const char *pa_acGroupName, TItemDataList & pa_lItemDataList);
- void response_itemAdded(COpcProcessVar* pa_pOpcItem);
- /*** END ***********************************************************************/
-
- /*** Common Functions **********************************************************/
- enum EOpcConnectionEvents{
- e_Disconnected, e_Connecting, e_ConnectionFailed, e_Connected, e_ItemAddedOk, e_ItemAddedFailed, e_DataReceived
- };
-
- const char* getHost() const {
- return m_acHost;
- }
-
- const char* getServerName() const {
- return m_acServerName;
- }
-
- unsigned int getGroupCount() const {
- return m_nGroupCount;
- }
-
- EOpcConnectionEvents getConnectionState() const {
- return m_eConnectionEvent;
- }
-
- /*** END ***********************************************************************/
-
- private:
- struct SOpcGroupMap{
- const char* m_acGroupName;
- int m_nCallbackDesc;
- TItemDataList m_lReadItemsList;
- TItemDataList m_lWriteItemsList;
-
- SOpcGroupMap(const char* pa_acGroupName, int pa_nCallbackDesc) :
- m_acGroupName(pa_acGroupName), m_nCallbackDesc(pa_nCallbackDesc){
- }
- };
-
- typedef CSinglyLinkedList<SOpcGroupMap*> TOpcGroupMapList;
- TOpcGroupMapList m_lOpcGroupMapList;
-
- unsigned int m_nGroupCount;
-
- COpcConnectionImpl *m_pOpcConnectionImpl;
-
- EOpcConnectionEvents m_eConnectionEvent;
-
- const char* m_acHost;
- const char* m_acServerName;
- const char* m_acGroupName;
- unsigned long m_nReqUpdateRate;
- unsigned long m_nRealUpdateRate;
- float m_nDeadBand;
-
- bool m_bIsConnected;
- bool m_bBlockingConnect;
-
- CSyncObject m_oSync;
-
- COpcEventHandler* m_eventHandler;
-
- //we don't want COpcConnection to be copy and assignable
- COpcConnection(const COpcConnection&);
- COpcConnection& operator = (const COpcConnection &);
-};
-
-#endif // OPCCONNECTION_H_
diff --git a/src/modules/opc/opcconnectionhandler.cpp b/src/modules/opc/opcconnectionhandler.cpp
deleted file mode 100644
index 910b930..0000000
--- a/src/modules/opc/opcconnectionhandler.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opcconnectionhandler.h"
-#include "opcconnection.h"
-#include <extevhandlerhelper.h>
-
-using namespace forte::com_infra;
-
-DEFINE_SINGLETON(COpcConnectionHandler);
-
-COpcConnectionHandler::COpcConnectionHandler(){
-
-}
-
-COpcConnectionHandler::~COpcConnectionHandler(){
- TOpcConnectionList::Iterator itEnd = m_lOpcConnectionList.end();
- for(TOpcConnectionList::Iterator it = m_lOpcConnectionList.begin(); it != itEnd; ++it){
- delete (*it);
- }
-}
-
-COpcConnection* COpcConnectionHandler::getOpcConnection(const char *pa_acHost, const char *pa_acServerName, const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand, CComLayer* pa_pComCallback){
-
- COpcConnection *newConnection = findOpcConnection(pa_acHost, pa_acServerName);
- if(newConnection == NULL){
- newConnection = new COpcConnection(pa_acHost, pa_acServerName, getExtEvHandler<COpcEventHandler>(*pa_pComCallback->getCommFB()));
-
- m_lOpcConnectionList.pushBack(newConnection);
- }
-
- newConnection->addGroup(pa_acGroupName, pa_nReqUpdateRate, pa_nDeadBand, pa_pComCallback);
-
- return newConnection;
-}
-
-void COpcConnectionHandler::removeOpcConnection(const char *pa_acHost, const char *pa_acServerName, const char* pa_acGroupName){
- COpcConnection *existingCon = findOpcConnection(pa_acHost, pa_acServerName);
- if(existingCon != NULL){
- existingCon->removeGroup(pa_acGroupName);
-
- if(existingCon->getGroupCount() == 0) {
- deleteOpcConnection(pa_acHost, pa_acServerName);
- }
- }
-}
-
-COpcConnection* COpcConnectionHandler::findOpcConnection(const char* pa_acHost, const char* pa_acServerName){
- TOpcConnectionList::Iterator itEnd = m_lOpcConnectionList.end();
- for(TOpcConnectionList::Iterator it = m_lOpcConnectionList.begin(); it != itEnd; ++it){
- if(strcmp(it->getHost(), pa_acHost) == 0 && strcmp(it->getServerName(), pa_acServerName) == 0) {
- return (*it);
- }
- }
-
- return NULL;
-}
-
-void COpcConnectionHandler::deleteOpcConnection(const char* pa_acHost, const char* pa_acServerName){
- TOpcConnectionList::Iterator itDelete = m_lOpcConnectionList.begin();
- TOpcConnectionList::Iterator it = m_lOpcConnectionList.begin();
- TOpcConnectionList::Iterator itEnd = m_lOpcConnectionList.end();
-
- if(it != itEnd){
- if(strcmp(it->getHost(), pa_acHost) == 0 && strcmp(it->getServerName(), pa_acServerName)){
- m_lOpcConnectionList.popFront();
- return;
- }
- ++it;
- while(it != itEnd){
- if(strcmp(it->getHost(), pa_acHost) == 0 && strcmp(it->getServerName(), pa_acServerName)){
- m_lOpcConnectionList.eraseAfter(itDelete);
- return;
- }
-
- ++itDelete;
- ++it;
- }
- }
-}
diff --git a/src/modules/opc/opcconnectionhandler.h b/src/modules/opc/opcconnectionhandler.h
deleted file mode 100644
index 4f9825f..0000000
--- a/src/modules/opc/opcconnectionhandler.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 -2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCCONNECTIONHANDLER_H_
-#define OPCCONNECTIONHANDLER_H_
-
-#include "singlet.h"
-#include "fortelist.h"
-#include <comlayer.h>
-#include <fortelist.h>
-
-class COpcConnection;
-
-class COpcConnectionHandler{
- DECLARE_SINGLETON(COpcConnectionHandler)
- ;
- public:
- /*! \brief returns existing or creates new OpcConnection
- *
- * If a connection to the specified server already exist a pointer to this is returned. Otherwise a
- * new connection is created. The returned connection includes the group with the specified settings.
- */
- COpcConnection* getOpcConnection(const char *pa_acHost, const char *pa_acServerName, const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand, forte::com_infra::CComLayer* pa_pComCallback);
-
- void removeOpcConnection(const char *pa_acHost, const char *pa_acServerName, const char* pa_acGroupName);
-
- private:
- COpcConnection* findOpcConnection(const char* pa_acHost, const char* pa_acServerName);
- void deleteOpcConnection(const char* pa_acHost, const char* pa_acServerName);
-
- typedef CSinglyLinkedList<COpcConnection*> TOpcConnectionList;
- TOpcConnectionList m_lOpcConnectionList;
-
-};
-
-#endif // OPCCONNECTIONHANDLER_H_
diff --git a/src/modules/opc/opcconnectionimpl.cpp b/src/modules/opc/opcconnectionimpl.cpp
deleted file mode 100644
index 2520201..0000000
--- a/src/modules/opc/opcconnectionimpl.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, ACIN
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opcconnectionimpl.h"
-
-#include "opceventhandler.h"
-#include "opcconnection.h"
-#include "opcprocessvar.h"
-
-#include "OPCClient.h"
-#include "OPCHost.h"
-#include "OPCServer.h"
-#include "OPCGroup.h"
-#include "OPCItem.h"
-
-COpcConnectionImpl::COpcConnectionImpl(const char *pa_acHost, const char *pa_acServerName, COpcConnection* pa_pOpcConn) :
- m_pOpcConn(pa_pOpcConn), m_pOpcHost(0), m_pOpcServer(0), m_acHost(pa_acHost), m_acServerName(pa_acServerName), m_acGroupName(0), m_nReqUpdateRate(0), m_nRealUpdateRate(0), m_nDeadBand(0) {
-}
-
-COpcConnectionImpl::~COpcConnectionImpl(){
-}
-
-void COpcConnectionImpl::connect(){
- try{
-
- COPCClient::init();
-
- m_pOpcHost = COPCClient::makeHost(m_acHost);
-
- m_pOpcServer = m_pOpcHost->connectDAServer(m_acServerName);
- } catch (OPCException &e){
- m_pOpcConn->response_connect(false);
- return;
- }
-
- m_pOpcConn->response_connect(true);
-}
-
-void COpcConnectionImpl::addItem(COpcProcessVar* pa_pNewItem){
- COPCGroup* itemGroup = getOpcGroup(pa_pNewItem->getItemGroupName(), pa_pNewItem->getItemFunction());
-
- ATL::CString itemName(pa_pNewItem->getItemName());
- try{
- COPCItem* newItem = itemGroup->addItem(itemName, true);
- pa_pNewItem->setOpcItem(newItem);
- pa_pNewItem->setIsActive(true);
- } catch (OPCException &e){
- pa_pNewItem->setIsActive(false);
- }
- m_pOpcConn->response_itemAdded(pa_pNewItem);
-}
-
-void COpcConnectionImpl::addGroup(const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand){
- m_lOpcGroupSettingsList.pushBack(new SOpcGroupSettings(pa_acGroupName, pa_nReqUpdateRate, pa_nDeadBand));
-}
-
-int COpcConnectionImpl::sendItemData(COpcProcessVar* pa_pNewItem){
- return 0;
-}
-
-void COpcConnectionImpl::OnDataChange(COPCGroup & group, CAtlMap<COPCItem *, OPCItemData *> & changes){
-
- TItemDataList itemList;
- for(POSITION pos = changes.GetStartPosition(); pos != NULL;){
- OPCItemData *itemData = changes.GetValueAt(pos);
- COPCItem *item = changes.GetNextKey(pos);
-
- itemList.pushBack(new SOpcItemData((LPCTSTR) (item->getName()), (Variant) itemData->vDataValue));
- }
-
- const char *c_groupName = (const char*) group.getName();
-
- int position = 0;
- const char * subStrRead = strstr(c_groupName, "_read");
- if(subStrRead != NULL) {
- position = subStrRead - c_groupName;
- }
- else{
- //TODO Should not happen error
- }
-
- char * groupName = (char*) malloc(position + 1);
- strncpy(groupName, c_groupName, position);
- groupName[position] = '\0';
-
- m_pOpcConn->response_dataReceived(groupName, itemList);
-
- free(groupName);
-}
-
-COPCGroup* COpcConnectionImpl::getOpcGroup(const char* pa_acGroupName, COpcProcessVar::EOpcProcessVarFunctions pa_eFunction){
- COPCGroup *retGroup = NULL;
-
- TOpcGroupSettingsList::Iterator itEnd = m_lOpcGroupSettingsList.end();
- for(TOpcGroupSettingsList::Iterator it = m_lOpcGroupSettingsList.begin(); it != itEnd; ++it){
- if(strcmp(it->m_acGroupName, pa_acGroupName) == 0){
- if(pa_eFunction == COpcProcessVar::e_FBOutput){
- if(!(it->m_bReadGroupAdded)){
- char *groupName = (char*) malloc(strlen(pa_acGroupName) + 5 + 1);
- strcpy(groupName, pa_acGroupName);
- strcat(groupName, "_read");
- try{
- it->m_pOpcGroupRead = retGroup = m_pOpcServer->makeGroup(groupName, true, it->m_nReqUpdateRate, it->m_nRevisedUpdateRate, it->m_nDeadBand);
- it->m_pOpcGroupRead->enableAsynch(*this);
- it->m_bReadGroupAdded = true;
- } catch (OPCException &e){
- // TODO
- }
- free(groupName);
- } else {
- retGroup = it->m_pOpcGroupRead;
- }
- }
- else if(pa_eFunction == COpcProcessVar::e_FBInput){
- if(!(it->m_bWriteGroupAdded)){
- char *groupName = (char*) malloc(strlen(pa_acGroupName) + 6 + 1);
- strcpy(groupName, pa_acGroupName);
- strcat(groupName, "_write");
- try{
- it->m_pOpcGroupWrite = retGroup = m_pOpcServer->makeGroup(groupName, true, it->m_nReqUpdateRate, it->m_nRevisedUpdateRate, it->m_nDeadBand);
- it->m_bWriteGroupAdded = true;
- } catch (OPCException &e){
- // TODO
- }
- free(groupName);
- } else {
- retGroup = it->m_pOpcGroupWrite;
- }
- }
-
- break;
- }
- }
-
- return retGroup;
-}
diff --git a/src/modules/opc/opcconnectionimpl.h b/src/modules/opc/opcconnectionimpl.h
deleted file mode 100644
index 7a6d7dc..0000000
--- a/src/modules/opc/opcconnectionimpl.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2015 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCCONNECTIONIMPL_H_
-#define OPCCONNECTIONIMPL_H_
-
-#include "fortelist.h"
-
-#include "opcprocessvar.h"
-
-// Includes from OPC library
-#include "windows.h"
-#include "opcda.h"
-#include "OPCClient.h"
-
-class COpcConnection;
-
-class COpcConnectionImpl : public IAsynchDataCallback{
- public:
- COpcConnectionImpl(const char *pa_acHost, const char *pa_acServerName, COpcConnection* pa_pOpcConn);
- ~COpcConnectionImpl();
-
- void connect();
- void addItem(COpcProcessVar* pa_pNewItem);
- void addGroup(const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand);
-
- int sendItemData(COpcProcessVar* pa_pNewItem);
- int receiveData(const char* pa_acRecvBuffer);
-
- const char* getHost(){
- return m_acHost;
- }
- const char* getServerName(){
- return m_acServerName;
- }
-
- virtual void OnDataChange(COPCGroup & group, CAtlMap<COPCItem *, OPCItemData *> & changes);
-
- private:
- COPCGroup* getOpcGroup(const char *pa_acGroupName, COpcProcessVar::EOpcProcessVarFunctions pa_eFunction);
-
- struct SOpcGroupSettings{
- COPCGroup* m_pOpcGroupRead;
- COPCGroup* m_pOpcGroupWrite;
- const char* m_acGroupName;
- unsigned long m_nReqUpdateRate;
- unsigned long m_nRevisedUpdateRate;
- float m_nDeadBand;
- bool m_bReadGroupAdded;
- bool m_bWriteGroupAdded;
-
- SOpcGroupSettings(const char* pa_acGroupName, unsigned long pa_nReqUpdateRate, float pa_nDeadBand) :
- m_pOpcGroupRead(0), m_pOpcGroupWrite(0), m_acGroupName(pa_acGroupName), m_nReqUpdateRate(pa_nReqUpdateRate), m_nRevisedUpdateRate(0), m_nDeadBand(pa_nDeadBand), m_bReadGroupAdded(false), m_bWriteGroupAdded(false){
- }
- };
-
- typedef CSinglyLinkedList<SOpcGroupSettings*> TOpcGroupSettingsList;
- TOpcGroupSettingsList m_lOpcGroupSettingsList;
-
- COpcConnection* m_pOpcConn;
-
- COPCHost* m_pOpcHost;
- COPCServer *m_pOpcServer;
-
- const char* m_acHost;
- const char* m_acServerName;
- const char* m_acGroupName;
- unsigned long m_nReqUpdateRate;
- unsigned long m_nRealUpdateRate;
- float m_nDeadBand;
-};
-
-#endif // OPCCONNECTIONIMPL_H_
diff --git a/src/modules/opc/opceventhandler.cpp b/src/modules/opc/opceventhandler.cpp
deleted file mode 100644
index f2ec4fc..0000000
--- a/src/modules/opc/opceventhandler.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 - 2014 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opceventhandler.h"
-#include "../core/devexec.h"
-#include <commfb.h>
-
-#include <ObjBase.h>
-
-DEFINE_HANDLER(COpcEventHandler);
-
-COpcEventHandler::TCallbackDescriptor COpcEventHandler::m_nCallbackDescCount = 0;
-
-COpcEventHandler::COpcEventHandler(CDeviceExecution& pa_poDeviceExecution) : CExternalEventHandler(pa_poDeviceExecution) {
- this->start();
- // Sleep to allow new thread to start
- CThread::sleep(100);
-}
-
-COpcEventHandler::~COpcEventHandler(){
- this->end();
-}
-
-void COpcEventHandler::sendCommand(ICmd *pa_pCmd){
- m_oSync.lock();
- m_lCommandQueue.pushBack(pa_pCmd);
- m_oSync.unlock();
-}
-
-void COpcEventHandler::run(){
- HRESULT result = CoInitializeEx(NULL, COINIT_MULTITHREADED);
-
- if(result == S_OK){
- while(isAlive()){
- ICmd* nextCommand = getNextCommand();
- if(nextCommand != NULL) {
- nextCommand->runCommand();
- }
-
- MSG msg;
- while(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)){
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- }
-
- CoUninitialize();
-}
-
-COpcEventHandler::TCallbackDescriptor COpcEventHandler::addComCallback(forte::com_infra::CComLayer* pa_pComCallback){
- m_oSync.lock();
- m_nCallbackDescCount++;
- TComContainer stNewNode = { m_nCallbackDescCount, pa_pComCallback };
- m_lstComCallbacks.pushBack(stNewNode);
- m_oSync.unlock();
-
- return m_nCallbackDescCount;
-}
-
-void COpcEventHandler::removeComCallback(COpcEventHandler::TCallbackDescriptor pa_nCallbackDesc){
- m_oSync.lock();
-
- TCallbackList::Iterator itRunner(m_lstComCallbacks.begin());
-
- if(itRunner->m_nCallbackDesc == pa_nCallbackDesc){
- m_lstComCallbacks.popFront();
- }
- else{
- TCallbackList::Iterator itLastPos(itRunner);
- TCallbackList::Iterator itEnd(m_lstComCallbacks.end());
- ++itRunner;
- while(itRunner != itEnd){
- if(itRunner->m_nCallbackDesc == pa_nCallbackDesc){
- m_lstComCallbacks.eraseAfter(itLastPos);
- break;
- }
- itLastPos = itRunner;
- ++itRunner;
- }
- }
- m_oSync.unlock();
-}
-
-void COpcEventHandler::executeComCallback(COpcEventHandler::TCallbackDescriptor pa_nCallbackDesc){
- m_oSync.lock();
- TCallbackList::Iterator itEnd(m_lstComCallbacks.end());
- for(TCallbackList::Iterator itCallback = m_lstComCallbacks.begin(); itCallback != itEnd; ++itCallback){
- if(itCallback->m_nCallbackDesc == pa_nCallbackDesc){
- //FIX
- TComContainer comCon = (*itCallback);
- m_oSync.unlock();
- if(forte::com_infra::e_Nothing != comCon.m_pCallback->recvData(0,0)){
- startNewEventChain(comCon.m_pCallback->getCommFB());
- }
- m_oSync.lock();
- break;
- }
- }
- m_oSync.unlock();
-}
-
-ICmd* COpcEventHandler::getNextCommand(){
- ICmd* command;
-
- m_oSync.lock();
- TCommandQueue::Iterator itBegin = m_lCommandQueue.begin();
- if(itBegin != m_lCommandQueue.end()){
- command = (*itBegin);
- m_lCommandQueue.popFront();
- } else {
- command = NULL;
- }
- m_oSync.unlock();
-
- return command;
-}
diff --git a/src/modules/opc/opceventhandler.h b/src/modules/opc/opceventhandler.h
deleted file mode 100644
index 5689d3a..0000000
--- a/src/modules/opc/opceventhandler.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2015 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCEVENTHANDLER_H_
-#define OPCEVENTHANDLER_H_
-
-#include "extevhan.h"
-#include <forte_thread.h>
-#include "fortelist.h"
-#include <forte_sync.h>
-#include "comlayer.h"
-
-#include "ICmd.h"
-
-class COpcEventHandler : public CExternalEventHandler, private CThread{
- DECLARE_HANDLER(COpcEventHandler)
- public:
- typedef int TCallbackDescriptor;
-
- void sendCommand(ICmd *pa_pCmd);
-
- TCallbackDescriptor addComCallback(forte::com_infra::CComLayer* pa_pComCallback);
- void removeComCallback(TCallbackDescriptor pa_nCallbackDesc);
-
- void executeComCallback(TCallbackDescriptor pa_nCallbackDesc);
-
- /* functions needed for the external event handler interface */
- void enableHandler(void){
- start();
- }
-
- void disableHandler(void){
- end();
- }
-
- void setPriority(int){
- //currently we are doing nothing here.
- //TODO We should adjust the thread priority.
- }
-
- int getPriority(void) const{
- //the same as for setPriority
- return 0;
- }
-
- protected:
- virtual void run(void);
-
- private:
- ICmd* getNextCommand();
-
- struct TComContainer{
- TCallbackDescriptor m_nCallbackDesc;
- forte::com_infra::CComLayer* m_pCallback;
- };
-
- typedef CSinglyLinkedList<TComContainer> TCallbackList;
- TCallbackList m_lstComCallbacks;
-
- static TCallbackDescriptor m_nCallbackDescCount;
-
- CSyncObject m_oSync;
-
- typedef CSinglyLinkedList<ICmd*> TCommandQueue;
- TCommandQueue m_lCommandQueue;
-};
-
-#endif // OPCEVENTHANDLER_H_
diff --git a/src/modules/opc/opcprocessvar.cpp b/src/modules/opc/opcprocessvar.cpp
deleted file mode 100644
index ac8af41..0000000
--- a/src/modules/opc/opcprocessvar.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "opcprocessvar.h"
-#include "OPCGroup.h"
-#include "OPCItem.h"
-
-COpcProcessVar::COpcProcessVar(const char* pa_acItemGroupName, const char* pa_acItemName, EOpcProcessVarFunctions pa_eFunction) :
- m_pOpcItem(0), m_acItemGroupName(pa_acItemGroupName), m_acItemName(pa_acItemName), m_bActive(false), m_eFunction(pa_eFunction){
- m_oCurrentValue.set<SHORT>(0);
-}
-
-void COpcProcessVar::sendItemData(){
- try{
- if(getIsActive()) {
- m_pOpcItem->writeSync(updateValue());
- }
- } catch (OPCException &e){
- setIsActive(false);
- }
-}
-
-void COpcProcessVar::setNewValue(Variant pa_oNewValue){
- m_oSync.lock();
- m_lNewValueQueue.pushBack(pa_oNewValue);
- m_oSync.unlock();
-}
-
-Variant COpcProcessVar::peekNewValue(){
- Variant retVal;
-
- m_oSync.lock();
- TVariantList::Iterator itBegin = m_lNewValueQueue.begin();
- if(itBegin != m_lNewValueQueue.end()){
- retVal = (*itBegin);
- } else {
- retVal = m_oCurrentValue;
- }
-
- m_oSync.unlock();
-
- return retVal;
-}
-
-Variant COpcProcessVar::updateValue(){
- Variant retVal;
-
- m_oSync.lock();
- TVariantList::Iterator itBegin = m_lNewValueQueue.begin();
- TVariantList::Iterator itEnd = m_lNewValueQueue.end();
- if(itBegin != m_lNewValueQueue.end()){
- m_oCurrentValue = retVal = (*itBegin);
- m_lNewValueQueue.popFront();
- } else {
- retVal = m_oCurrentValue;
- }
-
- m_oSync.unlock();
-
- return retVal;
-}
diff --git a/src/modules/opc/opcprocessvar.h b/src/modules/opc/opcprocessvar.h
deleted file mode 100644
index 0c5ae51..0000000
--- a/src/modules/opc/opcprocessvar.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, ACIN
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef OPCPROCESSVAR_H_
-#define OPCPROCESSVAR_H_
-
-#include "windows.h"
-#include "Variant.h"
-#include "fortelist.h"
-#include <forte_sync.h>
-
-class COPCItem;
-
-class COpcProcessVar{
- public:
- enum EOpcProcessVarFunctions{
- e_FBInput, e_FBOutput
- };
-
- COpcProcessVar(const char* pa_acItemGroupName, const char* pa_acItemName, EOpcProcessVarFunctions pa_eFunction);
- ~COpcProcessVar(){
- }
-
- const char* getItemName() const {
- return m_acItemName;
- }
- const char* getItemGroupName() const {
- return m_acItemGroupName;
- }
- EOpcProcessVarFunctions getItemFunction() const {
- return m_eFunction;
- }
-
- void setOpcItem(COPCItem* pa_pOpcItem){
- m_pOpcItem = pa_pOpcItem;
- }
-
- void sendItemData();
-
- void setNewValue(Variant pa_oNewValue);
- Variant peekNewValue();
-
- Variant updateValue();
-
- bool getIsActive() const {
- return m_bActive;
- }
-
- void setIsActive(bool pa_bActive){
- m_bActive = pa_bActive;
- }
-
- private:
- COPCItem* m_pOpcItem;
-
- const char* m_acItemGroupName;
- const char* m_acItemName;
- bool m_bActive;
-
- Variant m_oCurrentValue;
-
- typedef CSinglyLinkedList<Variant> TVariantList;
- TVariantList m_lNewValueQueue;
-
- Variant m_oNewValue;
-
- CSyncObject m_oSync;
-
- EOpcProcessVarFunctions m_eFunction;
-
-};
-
-#endif // OPCPROCESSVAR_H_
diff --git a/src/modules/opc/readme.txt b/src/modules/opc/readme.txt
deleted file mode 100644
index 7dffddb..0000000
--- a/src/modules/opc/readme.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-Installation Instructions
-The OPC com layer requires the following packages
- - OPC Client library release 0.4 (http://sourceforge.net/projects/opcclient/)
- - Boost Lexical Cast (http://www.boost.org)
-
-Before OPC Client is compiled the function init() in OPCClient.cpp must be changed from:
-void COPCClient::init()
-{
- HRESULT result = CoInitialize(NULL);
- if (FAILED(result))
- {
- throw OPCException("CoInitialize failed");
- }
-
- CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
-
- result = CoGetMalloc(MEMCTX_TASK, &iMalloc);
- if (FAILED(result))
- {
- throw OPCException("CoGetMalloc failed");
- }
-}
-
-to:
-void COPCClient::init()
-{
- CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
-
- HRESULT result = CoGetMalloc(MEMCTX_TASK, &iMalloc);
- if (FAILED(result))
- {
- throw OPCException("CoGetMalloc failed");
- }
-}
-
-
-Once the OPC Client library is compiled performe the steps below:
-1. Place OPC Client library in the following folder structure:
- <opcclientroot>/include - all headers should be placed here
- <opcclientroot>/lib - OPCClientToolkit.lib
-2. Choose <opcclientroot> for FORTE_COM_OPC_LIB_ROOT in CMake
-3. Choose Boost root folder <boostroot> for FORTE_COM_OPC_BOOST_ROOT
- (the lexical_cast.hpp header must be available in <boostroot>/boost)
-
-Parameter Documentation (all values are required)
-OPC Client
-opc[host:serverName:updateRate:deadBand:fbInputItems:fbOutputItems]
- - host: 127.0.0.1 etc
- - serverName: e.g. Matrikon.OPC.Simulation
- - updateRate: update frequency in milliseconds
- - deadBand: dead band used for update (same unit as value)
- - fbInputItems/fbOutputItems: items to be added, items should be separated with a comma i.e.
- Random.Int2,Bucket Brigade.Int4
-
-example: opc[127.0.0.1:Matrikon.OPC.Simulation:2000:0.01:Bucket Brigade.Int4:Random.Int2,Bucket Brigade.Int4]
diff --git a/src/modules/piface/processinterface.h b/src/modules/piface/processinterface.h
index b4d2041..45c9701 100644
--- a/src/modules/piface/processinterface.h
+++ b/src/modules/piface/processinterface.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 fortiss GmbH
+ * Copyright (c) 2016, 2021 fortiss GmbH, HIT robot group
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -8,6 +8,7 @@
*
* Contributors:
* Monika Wenger, Alois Zoitl - initial API and implementation and/or initial documentation
+ * Tibalt Zhao - adapt to new handler infrastructure
*******************************************************************************/
#ifndef PROCESSINTERFACE_H_
@@ -26,6 +27,8 @@
virtual ~CPiFaceProcessInterface();
+ friend class CDeviceExecution;
+
protected:
bool initialise(bool paInput);
bool deinitialise();
diff --git a/src/modules/powerlink/CMakeLists.txt b/src/modules/powerlink/CMakeLists.txt
deleted file mode 100644
index dd84685..0000000
--- a/src/modules/powerlink/CMakeLists.txt
+++ /dev/null
@@ -1,80 +0,0 @@
-#*******************************************************************************
-# Copyright (c) 2012 - 2014 AIT, fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
-# Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
-# *******************************************************************************/
-
-forte_add_module(POWERLINK "openPOWERLINK Service Interface Function Blocks")
-
-#############################################################################
-# COM Service Interface Function Blocks
-#############################################################################
-
-if("${FORTE_ARCHITECTURE}" STREQUAL "Win32")
- forte_add_sourcefile_cpp(EplWrapper.cpp)
- forte_add_definition( -D_CONSOLE -DWPCAP )
-
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Target/X86/Windows/WpdPack/Include)
-
- forte_add_link_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Target/X86/Windows/WpdPack/Lib)
-
- forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/EplStack/trace.c)
-
- forte_add_link_library(openPOWERLINK.lib)
- forte_add_link_library(wpcap.lib)
- forte_add_link_library(iphlpapi.lib)
-
-elseif("${FORTE_ARCHITECTURE}" STREQUAL "Posix")
- forte_add_sourcefile_cpp(EplWrapper.cpp)
- forte_add_link_library(-lpowerlink -lpcap -lrt)
-else()
- MESSAGE("openPOWERLINK is only supported for FORTE on Windows and Linux platforms. Disabled Module!")
- set(FORTE_MODULE_POWERLINK OFF)
-endif()
-
-if(FORTE_MODULE_POWERLINK)
- SET(FORTE_MODULE_POWERLINK_LIB_DIR "" CACHE PATH "Path to openPOWERLINK-V1.08.1 directory")
- SET(FORTE_MODULE_POWERLINK_TINYXML_DIR "" CACHE PATH "Path to TinyXML directory")
-
- forte_add_sourcefile_hcpp( POWERLINK_MN
- X20DO9321
- X20DO9322
- X20DI4653
- X20DI9371
- X20DI9372
- X20AI4622
- X20AO4622
- X20AT2402
- X20AT4222
- X20DO4649
- X20DO4623
- EplXmlReader
- ModuleList
- ProcessImageMatrix )
-
- forte_add_sourcefile_h( EplWrapper.h )
-
- forte_add_link_directories(${FORTE_MODULE_POWERLINK_LIB_DIR})
-
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Include)
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/SharedBuff)
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN)
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Examples/X86/Generic/powerlink_user_lib)
- forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN/EplApiProcessImageSetup.c)
- forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/EplStack/EplTgtConio.c)
-
- forte_add_include_directories(${FORTE_MODULE_POWERLINK_TINYXML_DIR})
- forte_add_sourcefile_with_path_hcpp( ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinystr
- ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxml )
-
- forte_add_sourcefile_with_path_cpp( ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlerror.cpp
- ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlparser.cpp )
-
- forte_add_definition( -DCONFIG_POWERLINK_USERSTACK )
-endif(FORTE_MODULE_POWERLINK)
diff --git a/src/modules/powerlink/EplCNCallback.h b/src/modules/powerlink/EplCNCallback.h
deleted file mode 100644
index 3d4368c..0000000
--- a/src/modules/powerlink/EplCNCallback.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, ACIN
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _EPLCNCALLBACK_H_
-#define _EPLCNCALLBACK_H_
-
-class IEplCNCallback{
- public:
-
- virtual void cnSynchCallback() = 0;
-
- protected:
- virtual ~IEplCNCallback(){
- }
- ;
-
-};
-
-#endif //_EPLCNCALLBACK_H_
diff --git a/src/modules/powerlink/EplWrapper.cpp b/src/modules/powerlink/EplWrapper.cpp
deleted file mode 100644
index f29c246..0000000
--- a/src/modules/powerlink/EplWrapper.cpp
+++ /dev/null
@@ -1,1081 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 - 2014 AIT, ACIN, fortiss
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl, Ewald Weinhandl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-#include "EplXmlReader.h"
-#include <forte_thread.h>
-
-#if (TARGET_SYSTEM == _WIN32_)
-#define _WINSOCKAPI_ // prevent windows.h from including winsock.h
-#endif // (TARGET_SYSTEM == _WIN32_)
-/* includes */
-#include "Epl.h"
-
-#undef EPL_STACK_VERSION
-#define EPL_STACK_VERSION(ver,rev,rel) (((((ver)) & 0xFF)<<24)|((((rev))&0xFF)<<16)|(((rel))&0xFFFF))
-
-#if (TARGET_SYSTEM == _LINUX_)
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <string.h>
-#include <termios.h>
-#include <pthread.h>
-#include <sys/syscall.h>
-#include <sys/resource.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <time.h>
-#include <stdarg.h>
-
-#ifndef CONFIG_POWERLINK_USERSTACK
-#include <pthread.h>
-#else
-#include <pcap.h>
-#endif
-
-#elif (TARGET_SYSTEM == _WIN32_)
-#include <Iphlpapi.h>
-#include <pcap.h>
-#endif // (TARGET_SYSTEM == _WIN32_)
-#include <EplTgtConio.h>
-//#include <conio.h>
-
-/***************************************************************************/
-/* */
-/* */
-/* G L O B A L D E F I N I T I O N S */
-/* */
-/* */
-/***************************************************************************/
-
-//---------------------------------------------------------------------------
-// const defines
-//---------------------------------------------------------------------------
-#if (TARGET_SYSTEM == _LINUX_)
-
-#define SET_CPU_AFFINITY
-#define MAIN_THREAD_PRIORITY 20
-
-#elif (TARGET_SYSTEM == _WIN32_)
-
-// TracePoint support for realtime-debugging
-#ifdef _DBG_TRACE_POINTS_
-void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
-#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
-#else
-#define TGT_DBG_SIGNAL_TRACE_POINT(p)
-#endif
-
-#endif // (TARGET_SYSTEM == _WIN32_)
-const DWORD NODEID = 0xF0; //=> MN
-const DWORD IP_ADDR = 0xc0a86401; // 192.168.100.1
-const DWORD SUBNET_MASK = 0xFFFFFF00; // 255.255.255.0
-const char* HOSTNAME = "EPL Stack";
-
-//---------------------------------------------------------------------------
-// module global vars
-//---------------------------------------------------------------------------
-
-CONST BYTE abMacAddr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static unsigned int uiNodeId_g = EPL_C_ADR_INVALID;
-
-static tEplApiProcessImageCopyJob AppProcessImageCopyJob_g;
-
-static bool waitingUntilOperational;
-
-#ifdef CONFIG_POWERLINK_USERSTACK
-
-//static char* pszCdcFilename_g = "mnobd.cdc";
-
-#else
-
-static pthread_t eventThreadId;
-static pthread_t syncThreadId;
-
-void *powerlinkEventThread(void * arg);
-void *powerlinkSyncThread(void * arg);
-
-#endif
-
-//---------------------------------------------------------------------------
-// local function prototypes
-//---------------------------------------------------------------------------
-
-// This function is the entry point for your object dictionary. It is defined
-// in OBJDICT.C by define EPL_OBD_INIT_RAM_NAME. Use this function name to define
-// this function prototype here. If you want to use more than one Epl
-// instances then the function name of each object dictionary has to differ.
-
-extern "C" tEplKernel PUBLIC EplObdInitRam (tEplObdInitParam MEM* pInitParam_p);
-
-tEplKernel PUBLIC AppCbEvent(
- tEplApiEventType EventType_p,// IN: event type (enum)
- tEplApiEventArg* pEventArg_p,// IN: event argument (union)
- void GENERIC* pUserArg_p);
-
-tEplKernel PUBLIC AppCbSync(void);
-
-char* CEplStackWrapper::allocProcImage(unsigned int n_bytes){
- char* procImage = (char*) malloc(n_bytes);
- for(unsigned int i = 0; i < n_bytes; i++){
- procImage[i] = 0x00;
- }
-
- return procImage;
-}
-
-//=========================================================================//
-// //
-// S T A T I C F U N C T I O N S //
-// //
-//=========================================================================//
-
-DEFINE_SINGLETON(CEplStackWrapper);
-
-void CEplStackWrapper::eplMainInit(){
-#if (TARGET_SYSTEM == _LINUX_)
- sigset_t mask;
-
- /*
- * We have to block the real time signals used by the timer modules so
- * that they are able to wait on them using sigwaitinfo!
- */
- sigemptyset(&mask);
- sigaddset(&mask, SIGRTMIN);
- sigaddset(&mask, SIGRTMIN + 1);
- pthread_sigmask(SIG_BLOCK, &mask, NULL);
-#endif
-}
-
-//=========================================================================//
-// //
-// C L A S S F U N C T I O N S //
-// //
-//=========================================================================//
-
-CEplStackWrapper::CEplStackWrapper(){
-}
-
-CEplStackWrapper::~CEplStackWrapper(){
-}
-
-int CEplStackWrapper::eplStackInit(char* pa_chXmlFile, char* pa_chCdcFile, char* pa_chEthDeviceName){
- tEplKernel EplRet;
- static tEplApiInitParam EplApiInitParam;
- const char* sHostname = HOSTNAME;
-
- // Read and process XML file
- CEplXmlReader xmlReader(&m_oProcMatrixIn, &m_oProcMatrixOut);
- xmlReader.readXmlFile(pa_chXmlFile);
-
- m_nProcInSize = m_oProcMatrixIn.getProcessImageSize();
- m_nProcOutSize = m_oProcMatrixOut.getProcessImageSize();
-
- m_pchAppProcessImageIn_g = allocProcImage(m_nProcInSize);
- m_pchAppProcessImageOut_g = allocProcImage(m_nProcOutSize);
-
-#ifdef CONFIG_POWERLINK_USERSTACK
-#if (TARGET_SYSTEM == _LINUX_)
- struct sched_param schedParam;
-#endif
-
- // variables for Pcap
- char sErr_Msg[PCAP_ERRBUF_SIZE];
- pcap_if_t *alldevs;
- pcap_if_t *seldev;
- int i = 0;
-#endif
-
-#ifdef CONFIG_POWERLINK_USERSTACK
-
-#if (TARGET_SYSTEM == _LINUX_)
- /* adjust process priority */
- if(nice(-20) == -1) // push nice level in case we have no RTPreempt
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- EPL_DBGLVL_ERROR_TRACE("%s() couldn't set nice value! (%s)\n", __func__, strerror(errno));
-#else
- EPL_DBGLVL_ERROR_TRACE2("%s() couldn't set nice value! (%s)\n", __func__, strerror(errno));
-#endif
-
- }
- schedParam.__sched_priority = MAIN_THREAD_PRIORITY;
- if(pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0){
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- EPL_DBGLVL_ERROR_TRACE("%s() couldn't set thread scheduling parameters! %d\n", __func__, schedParam.__sched_priority);
-#else
- EPL_DBGLVL_ERROR_TRACE2("%s() couldn't set thread scheduling parameters! %d\n", __func__, schedParam.__sched_priority);
-#endif
- }
-
- /* Initialize target specific stuff */
- // EplTgtInit();
-#elif (TARGET_SYSTEM == _WIN32_)
-
- // activate realtime priority class
- SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
- // lower the priority of this thread
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
-
-#endif // (TARGET_SYSTEM == _WIN32_)
-#endif // CONFIG_POWERLINK_USERSTACK
- /* Enabling ftrace for debugging */
- FTRACE_OPEN();
- FTRACE_ENABLE (TRUE);
-
- EPL_MEMSET(&EplApiInitParam, 0, sizeof(EplApiInitParam));
- EplApiInitParam.m_uiSizeOfStruct = sizeof(EplApiInitParam);
-
-#ifdef CONFIG_POWERLINK_USERSTACK
-
- ////////////////////////////////////////////////////////////////////////////////
- // Find ETH card specified by user //
- ////////////////////////////////////////////////////////////////////////////////
-
- bool macFound;
- char correctDevName[1024];
-
- macFound = findMAC(pa_chEthDeviceName, &correctDevName[0]);
-
- /* Retrieve the device list on the local machine */
-
- if(pcap_findalldevs(&alldevs, sErr_Msg) == -1){
- fprintf(stderr, "Error in pcap_findalldevs: %s\n", sErr_Msg);
- EplRet = kEplNoResource;
- return EplRet;
- }
-
- printf("\n");
- for(seldev = alldevs, i = 0; seldev != NULL; seldev = seldev->next, i++){
- if(seldev->description){
- printf("%d: %s\n %s\n", i, seldev->description, seldev->name);
- }
- else{
- printf("%d: %s\n", i, seldev->name);
- }
-
- if(macFound){
- const char* userDescLoc = strstr(seldev->name, correctDevName);
- if(userDescLoc != NULL){
- if(seldev->description){
- printf("\nChosen Ethernet Card: %s\n %s\n", seldev->description, seldev->name);
- }
- else{
- printf("\nChosen Ethernet Card: %s\n", seldev->name);
- }
- break;
- }
- }
-
- if(seldev->description){
- const char* userDescLoc = strstr(seldev->description, pa_chEthDeviceName);
- if(userDescLoc != NULL){
- printf("\nChosen Ethernet Card: %s\n", seldev->description);
- break;
- }
- }
- else{
- const char* userDescLoc = strstr(seldev->name, pa_chEthDeviceName);
- if(userDescLoc != NULL){
- printf("Chosen Ethernet Card: %s\n", seldev->name);
- break;
- }
- }
- }
-
- // Check if a device was found, otherwise shutdown stack
- if(!seldev){
- fprintf(stderr, "%s(Err/Warn): Invalid MAC address or device name specified. Shutting down Powerlink stack\n", __func__);
- EplRet = kEplNoResource;
- return EplRet;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // Setup EplApiInitParam (some of them can be removed as we have obd?) //
- ////////////////////////////////////////////////////////////////////////////////
-
- // pass selected device name to Edrv
- char devName[128];
- strncpy(devName, seldev->name, 127);
- EplApiInitParam.m_HwParam.m_pszDevName = devName;
-
-#endif
-
- EplApiInitParam.m_uiNodeId = uiNodeId_g = NODEID;
- EplApiInitParam.m_dwIpAddress = (0xFFFFFF00 & IP_ADDR) | EplApiInitParam.m_uiNodeId;
-
- /* write 00:00:00:00:00:00 to MAC address, so that the driver uses the real hardware address */
- EPL_MEMCPY(EplApiInitParam.m_abMacAddress, abMacAddr, sizeof(EplApiInitParam.m_abMacAddress));
-
- EplApiInitParam.m_fAsyncOnly = FALSE;
-
- EplApiInitParam.m_dwFeatureFlags = -1;
- EplApiInitParam.m_dwCycleLen = 10000; // required for error detection
- EplApiInitParam.m_uiIsochrTxMaxPayload = 256; // const
- EplApiInitParam.m_uiIsochrRxMaxPayload = 256; // const
- EplApiInitParam.m_dwPresMaxLatency = 50000; // const; only required for IdentRes
- EplApiInitParam.m_uiPreqActPayloadLimit = 36; // required for initialisation (+28 bytes)
- EplApiInitParam.m_uiPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes)
- EplApiInitParam.m_dwAsndMaxLatency = 150000; // const; only required for IdentRes
- EplApiInitParam.m_uiMultiplCycleCnt = 0; // required for error detection
- EplApiInitParam.m_uiAsyncMtu = 1500; // required to set up max frame size
- EplApiInitParam.m_uiPrescaler = 2; // required for sync
- EplApiInitParam.m_dwLossOfFrameTolerance = 500000;
- EplApiInitParam.m_dwAsyncSlotTimeout = 3000000;
- EplApiInitParam.m_dwWaitSocPreq = 150000;
- EplApiInitParam.m_dwDeviceType = -1; // NMT_DeviceType_U32
- EplApiInitParam.m_dwVendorId = -1; // NMT_IdentityObject_REC.VendorId_U32
- EplApiInitParam.m_dwProductCode = -1; // NMT_IdentityObject_REC.ProductCode_U32
- EplApiInitParam.m_dwRevisionNumber = -1; // NMT_IdentityObject_REC.RevisionNo_U32
- EplApiInitParam.m_dwSerialNumber = -1; // NMT_IdentityObject_REC.SerialNo_U32
-
- EplApiInitParam.m_dwSubnetMask = SUBNET_MASK;
- EplApiInitParam.m_dwDefaultGateway = 0;
- EPL_MEMCPY(EplApiInitParam.m_sHostname, sHostname, sizeof(EplApiInitParam.m_sHostname));
- EplApiInitParam.m_uiSyncNodeId = EPL_C_ADR_SYNC_ON_SOA;
- EplApiInitParam.m_fSyncOnPrcNode = FALSE;
-
- // set callback functions
- EplApiInitParam.m_pfnCbEvent = AppCbEvent;
-
-#ifdef CONFIG_POWERLINK_USERSTACK
- EplApiInitParam.m_pfnObdInitRam = EplObdInitRam;
- EplApiInitParam.m_pfnCbSync = AppCbSync;
-#else
- EplApiInitParam.m_pfnCbSync = NULL;
-#endif
- ////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////////////////////////////////////////////////////////
- // Initialize Powerlink Stack //
- ////////////////////////////////////////////////////////////////////////////////
- printf("\n\n Powerlink %s running.\n (build: %s / %s)\n\n", (NODEID == EPL_C_ADR_MN_DEF_NODE_ID ? "Managing Node" : "Controlled Node"), __DATE__, __TIME__);
-
- // initialize POWERLINK stack
- EplRet = EplApiInitialize(&EplApiInitParam);
- if(EplRet != kEplSuccessful){
- return EplRet;
- }
-
-#ifdef CONFIG_POWERLINK_USERSTACK
- /* At this point, we don't need any more the device list. Free it */
- pcap_freealldevs(alldevs);
-
- EplRet = EplApiSetCdcFilename(pa_chCdcFile);
- if(EplRet != kEplSuccessful){
- return EplRet;
- }
-#else
- // create event thread
- if(pthread_create(&eventThreadId, NULL, &powerlinkEventThread, NULL) != 0){
- return EplRet;
- }
-
- // create sync thread
- if(pthread_create(&syncThreadId, NULL, &powerlinkSyncThread, NULL) != 0){
- return EplRet;
- }
-#endif
-
- AppProcessImageCopyJob_g.m_fNonBlocking = FALSE;
- AppProcessImageCopyJob_g.m_uiPriority = 0;
- AppProcessImageCopyJob_g.m_In.m_pPart = m_pchAppProcessImageIn_g;
- AppProcessImageCopyJob_g.m_In.m_uiOffset = 0;
- AppProcessImageCopyJob_g.m_In.m_uiSize = m_nProcInSize;
- AppProcessImageCopyJob_g.m_Out.m_pPart = m_pchAppProcessImageOut_g;
- AppProcessImageCopyJob_g.m_Out.m_uiOffset = 0;
- AppProcessImageCopyJob_g.m_Out.m_uiSize = m_nProcOutSize;
-
- EplRet = EplApiProcessImageAlloc(m_nProcInSize, m_nProcOutSize, 2, 2);
- if(EplRet != kEplSuccessful){
- eplStackShutdown();
- }
-
- EplRet = EplApiProcessImageSetup();
- if(EplRet != kEplSuccessful){
- eplStackShutdown();
- }
-
- // start processing
- EplRet = EplApiExecNmtCommand(kEplNmtEventSwReset);
- if(EplRet != kEplSuccessful){
- eplStackShutdown();
- }
-
- waitingUntilOperational = false;
- if(m_bWait == true){
- while(!waitingUntilOperational){
- // Waiting
- CThread::sleepThread(1);
- }
- }
-
- return EplRet;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Stop the stack //
-////////////////////////////////////////////////////////////////////////////////
-int CEplStackWrapper::eplStackShutdown(void){
- tEplKernel EplRet;
-
- // halt the NMT state machine
- // so the processing of POWERLINK frames stops
- EplApiExecNmtCommand(kEplNmtEventSwitchOff);
-
- // delete process image
- EplApiProcessImageFree();
-
- // delete instance for all modules
- EplRet = EplApiShutdown();
- printf("EplApiShutdown(): 0x%X\n", EplRet);
-
- m_oProcMatrixIn.clearAll();
- m_oProcMatrixOut.clearAll();
- m_lCallbackList.clearAll();
- free(m_pchAppProcessImageIn_g);
- free(m_pchAppProcessImageOut_g);
-
- return EplRet;
-}
-
-CProcessImageMatrix* CEplStackWrapper::getProcessImageMatrixIn(){
- return &m_oProcMatrixIn;
-}
-
-CProcessImageMatrix* CEplStackWrapper::getProcessImageMatrixOut(){
- return &m_oProcMatrixOut;
-}
-
-char* CEplStackWrapper::getProcImageIn(){
- return m_pchAppProcessImageIn_g;
-}
-
-char* CEplStackWrapper::getProcImageOut(){
- return m_pchAppProcessImageOut_g;
-}
-
-void CEplStackWrapper::waitUntilOperational(bool pa_bWait){
- m_bWait = pa_bWait;
-}
-
-void CEplStackWrapper::registerCallback(IEplCNCallback* pa_pCallback){
- m_oSync.lock();
- m_lCallbackList.pushBack(pa_pCallback);
- m_oSync.unlock();
-}
-
-bool CEplStackWrapper::findMAC(const char* pa_pchUserMAC, char* pa_pchDeviceName){
- //char* correctDevName;
-
-#if (TARGET_SYSTEM == _LINUX_)
-
- int nSD; // Socket descriptor
- struct ifreq sIfReq; // Interface request
- struct if_nameindex *pIfList; // Ptr to interface name index
- struct if_nameindex *pListSave; // Ptr to interface name index
-
- //
- // Initialize this function
- //
- pIfList = (struct if_nameindex *) NULL;
- pListSave = (struct if_nameindex *) NULL;
-#ifndef SIOCGIFADDR
- // The kernel does not support the required ioctls
- return (false);
-#endif
-
- //
- // Create a socket that we can use for all of our ioctls
- //
- nSD = socket(PF_INET, SOCK_STREAM, 0);
- if(nSD < 0){
- // Socket creation failed, this is a fatal error
- printf("File %s: line %d: Socket failed\n", __FILE__, __LINE__);
- return (0);
- }
-
- //
- // Obtain a list of dynamically allocated structures
- //
- pIfList = pListSave = if_nameindex();
-
- //
- // Walk thru the array returned and query for each interface's
- // address
- //
- for(pIfList; *(char *) pIfList != 0; pIfList++){
-
- strncpy(sIfReq.ifr_name, pIfList->if_name, IF_NAMESIZE);
-
- //
- // Get the MAC address for this interface
- //
- if(ioctl(nSD, SIOCGIFHWADDR, &sIfReq) != 0){
- // We failed to get the MAC address for the interface
- printf("File %s: line %d: Ioctl failed\n", __FILE__, __LINE__);
- return false;
- }
-
- //
- // Determine if we are processing the interface that we
- // are interested in
- //
- char chMAC[6 * 2 + 5 + 2];
- sprintf(chMAC, "%02X-%02X-%02X-%02X-%02X-%02X", (unsigned char) sIfReq.ifr_hwaddr.sa_data[0], (unsigned char) sIfReq.ifr_hwaddr.sa_data[1], (unsigned char) sIfReq.ifr_hwaddr.sa_data[2], (unsigned char) sIfReq.ifr_hwaddr.sa_data[3], (unsigned char) sIfReq.ifr_hwaddr.sa_data[4], (unsigned char) sIfReq.ifr_hwaddr.sa_data[5]);
-
- if(compareMACs(chMAC, pa_pchUserMAC)){
- strncpy(pa_pchDeviceName, pIfList->if_name, IF_NAMESIZE);
-
- //
- // Clean up things and return
- //
- if_freenameindex(pListSave);
- close(nSD);
-
- return true;
- }
- }
-
- //
- // Clean up things and return
- //
- if_freenameindex(pListSave);
- close(nSD);
-
-#elif (TARGET_SYSTEM == _WIN32_)
-
- // Find MAC address
- IP_ADAPTER_INFO AdapterInfo[16];// Allocate information for up to 16 NICs
- DWORD dwBufLen = sizeof(AdapterInfo);// Save memory size of buffer
-
- DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen);
- assert(dwStatus == ERROR_SUCCESS);// Verify return value is valid, no buffer overflow
-
- PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info
-
- do{
- char* chMAC = new char[6*2+5+1];
- BYTE *macAddr = pAdapterInfo->Address;
- for (int i = 0; i < 6*2+5; i = i+2)
- {
- if (i>0){
- chMAC[i] = '-';
- i++;
- }
- sprintf(&chMAC[i],"%02x",*macAddr++);
- }
-
- if (compareMACs(chMAC, pa_pchUserMAC)){
- //correctDevName = new char[strlen(pAdapterInfo->AdapterName)+1];
- strcpy(pa_pchDeviceName,pAdapterInfo->AdapterName);
- delete chMAC;
-
- //pa_pchDeviceName = correctDevName;
- return true;
- }
-
- pAdapterInfo = pAdapterInfo->Next; // Progress through linked list
- delete chMAC;
- }
- while(pAdapterInfo); // Terminate if last adapter
-
-#endif
-
- //pa_pchDeviceName = NULL; //No effect
- return false;
-}
-
-bool CEplStackWrapper::compareMACs(const char* pa_chMACa, const char* pa_chMACb){
- if(strcmp(pa_chMACa, pa_chMACb) == 0){
- return true;
- }
-
- char* macCopyA = new char[strlen(pa_chMACa) + 1];
- strcpy(macCopyA, pa_chMACa);
- char* macCopyB = new char[strlen(pa_chMACb) + 1];
- strcpy(macCopyB, pa_chMACb);
-
- // Change to upper case
- for(int i = 0; i < strlen(pa_chMACa); i++){
- switch (macCopyA[i]){
- case 'a':
- macCopyA[i] = 'A';
- break;
- case 'b':
- macCopyA[i] = 'B';
- break;
- case 'c':
- macCopyA[i] = 'C';
- break;
- case 'd':
- macCopyA[i] = 'D';
- break;
- case 'e':
- macCopyA[i] = 'E';
- break;
- case 'f':
- macCopyA[i] = 'F';
- break;
- }
- }
- for(int i = 0; i < strlen(pa_chMACb); i++){
- switch (macCopyB[i]){
- case 'a':
- macCopyB[i] = 'A';
- break;
- case 'b':
- macCopyB[i] = 'B';
- break;
- case 'c':
- macCopyB[i] = 'C';
- break;
- case 'd':
- macCopyB[i] = 'D';
- break;
- case 'e':
- macCopyB[i] = 'E';
- break;
- case 'f':
- macCopyB[i] = 'F';
- break;
- }
- }
-
- if(strcmp(macCopyA, macCopyB) == 0){
- delete[] macCopyA;
- delete[] macCopyB;
- return true;
- }
-
- delete[] macCopyA;
- delete[] macCopyB;
- return false;
-}
-
-//=========================================================================//
-// //
-// P R I V A T E F U N C T I O N S //
-// //
-//=========================================================================//
-
-//---------------------------------------------------------------------------
-//
-// Function: AppCbEvent
-//
-// Description: event callback function called by EPL API layer within
-// user part (low priority).
-//
-// Parameters: EventType_p = event type
-// pEventArg_p = pointer to union, which describes
-// the event in detail
-// pUserArg_p = user specific argument
-//
-// Returns: tEplKernel = error code,
-// kEplSuccessful = no error
-// kEplReject = reject further processing
-// otherwise = post error event to API layer
-//
-// State:
-//
-//---------------------------------------------------------------------------
-
-tEplKernel PUBLIC AppCbEvent(
- tEplApiEventType EventType_p,// IN: event type (enum)
- tEplApiEventArg* pEventArg_p,// IN: event argument (union)
- void GENERIC* pUserArg_p)
-{
- tEplKernel EplRet = kEplSuccessful;
-
- UNUSED_PARAMETER(pUserArg_p);
-
- // check if NMT_GS_OFF is reached
- switch (EventType_p)
- {
- case kEplApiEventNmtStateChange:
- {
- switch (pEventArg_p->m_NmtStateChange.m_NewNmtState)
- {
- case kEplNmtGsOff:
- { // NMT state machine was shut down,
- // because of user signal (CTRL-C) or critical EPL stack error
- // -> also shut down EplApiProcess() and main()
- EplRet = kEplShutdown;
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent);
-#else
- PRINTF2("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent);
-#endif
- break;
- }
-
- case kEplNmtGsResetCommunication:
- {
- // continue
- }
-
- case kEplNmtGsResetConfiguration:
- {
- // continue
- }
-
- case kEplNmtMsPreOperational1:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(0x%X) originating event = 0x%X\n",
- __func__,
- pEventArg_p->m_NmtStateChange.m_NewNmtState,
- pEventArg_p->m_NmtStateChange.m_NmtEvent);
-#else
- PRINTF3("%s(0x%X) originating event = 0x%X\n",
- __func__,
- pEventArg_p->m_NmtStateChange.m_NewNmtState,
- pEventArg_p->m_NmtStateChange.m_NmtEvent);
-#endif
-
- // continue
- }
-
- case kEplNmtGsInitialising:
- case kEplNmtGsResetApplication:
- case kEplNmtMsNotActive:
- case kEplNmtCsNotActive:
- case kEplNmtCsPreOperational1:
- {
- break;
- }
- case kEplNmtCsOperational:
- case kEplNmtMsOperational:
- {
- break;
- }
- default:
- {
- break;
- }
- }
-
- break;
- }
-
- case kEplApiEventCriticalError:
- case kEplApiEventWarning:
- { // error or warning occured within the stack or the application
- // on error the API layer stops the NMT state machine
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Err/Warn): Source=%02X EplError=0x%03X",
- __func__,
- pEventArg_p->m_InternalError.m_EventSource,
- pEventArg_p->m_InternalError.m_EplError);
-#else
- PRINTF3("%s(Err/Warn): Source=%02X EplError=0x%03X",
- __func__,
- pEventArg_p->m_InternalError.m_EventSource,
- pEventArg_p->m_InternalError.m_EplError);
-#endif
- // check additional argument
- switch (pEventArg_p->m_InternalError.m_EventSource)
- {
- case kEplEventSourceEventk:
- case kEplEventSourceEventu:
- { // error occured within event processing
- // either in kernel or in user part
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource);
-#else
- PRINTF1(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource);
-#endif
- break;
- }
-
- case kEplEventSourceDllk:
- { // error occured within the data link layer (e.g. interrupt processing)
- // the DWORD argument contains the DLL state and the NMT event
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.m_dwArg);
-#else
- PRINTF1(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.m_dwArg);
-#endif
- break;
- }
-
- case kEplEventSourceObdk:
- case kEplEventSourceObdu:
- { // error occured within OBD module
- // either in kernel or in user part
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF(" Object=0x%04X/%u\n", pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiIndex, pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiSubIndex);
-#else
- PRINTF2(" Object=0x%04X/%u\n", pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiIndex, pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiSubIndex);
-#endif
- break;
- }
-
- default:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("\n");
-#else
- PRINTF0("\n");
-#endif
- break;
- }
- }
- break;
- }
-
- case kEplApiEventHistoryEntry:
- { // new history entry
- PRINTF("%s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n",
- __func__,
- pEventArg_p->m_ErrHistoryEntry.m_wEntryType,
- pEventArg_p->m_ErrHistoryEntry.m_wErrorCode,
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[0],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[1],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[2],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[3],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[4],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[5],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[6],
- (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[7]);
- break;
- }
-
- case kEplApiEventNode:
- {
- // check additional argument
- switch (pEventArg_p->m_Node.m_NodeEvent)
- {
- case kEplNmtNodeEventCheckConf:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, CheckConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, CheckConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#endif
- break;
- }
-
- case kEplNmtNodeEventUpdateConf:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, UpdateConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, UpdateConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#endif
- break;
- }
-
- case kEplNmtNodeEventNmtState:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, NmtState=0x%X)\n", __func__, pEventArg_p->m_Node.m_uiNodeId, pEventArg_p->m_Node.m_NmtState);
-#else
- PRINTF3("%s(Node=0x%X, NmtState=0x%X)\n", __func__, pEventArg_p->m_Node.m_uiNodeId, pEventArg_p->m_Node.m_NmtState);
-#endif
- if (pEventArg_p->m_Node.m_NmtState == kEplNmtCsOperational){
- printf("init finished\n");
- waitingUntilOperational = true;
- }
- break;
- }
-
- case kEplNmtNodeEventError:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, Error=0x%X)\n", __func__, pEventArg_p->m_Node.m_uiNodeId, pEventArg_p->m_Node.m_wErrorCode);
-#else
- PRINTF3("%s(Node=0x%X, Error=0x%X)\n", __func__, pEventArg_p->m_Node.m_uiNodeId, pEventArg_p->m_Node.m_wErrorCode);
-#endif
- break;
- }
-
- case kEplNmtNodeEventFound:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, Found)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, Found)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
-#endif
- break;
- }
-
- default:
- {
- break;
- }
- }
- break;
- }
-
-#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFM)) != 0)
- case kEplApiEventCfmProgress:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, pEventArg_p->m_CfmProgress.m_uiNodeId, pEventArg_p->m_CfmProgress.m_uiObjectIndex, pEventArg_p->m_CfmProgress.m_uiObjectSubIndex);
- PRINTF("%u/%u Bytes", pEventArg_p->m_CfmProgress.m_dwBytesDownloaded, pEventArg_p->m_CfmProgress.m_dwTotalNumberOfBytes);
-#else
- PRINTF4("%s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, pEventArg_p->m_CfmProgress.m_uiNodeId, pEventArg_p->m_CfmProgress.m_uiObjectIndex, pEventArg_p->m_CfmProgress.m_uiObjectSubIndex);
- PRINTF2("%u/%u Bytes", pEventArg_p->m_CfmProgress.m_dwBytesDownloaded, pEventArg_p->m_CfmProgress.m_dwTotalNumberOfBytes);
-#endif
- if ((pEventArg_p->m_CfmProgress.m_dwSdoAbortCode != 0)
- || (pEventArg_p->m_CfmProgress.m_EplError != kEplSuccessful))
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF(" -> SDO Abort=0x%lX, Error=0x%X)\n", pEventArg_p->m_CfmProgress.m_dwSdoAbortCode, pEventArg_p->m_CfmProgress.m_EplError);
-#else
- PRINTF2(" -> SDO Abort=0x%lX, Error=0x%X)\n", pEventArg_p->m_CfmProgress.m_dwSdoAbortCode, pEventArg_p->m_CfmProgress.m_EplError);
-#endif
- }
- else
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF(")\n");
-#else
- PRINTF0(")\n");
-#endif
- }
- break;
- }
-
- case kEplApiEventCfmResult:
- {
- switch (pEventArg_p->m_CfmResult.m_NodeCommand)
- {
- case kEplNmtNodeCommandConfOk:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, ConfOk)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, ConfOk)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#endif
- break;
- }
-
- case kEplNmtNodeCommandConfErr:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, ConfErr)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, ConfErr)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#endif
- break;
- }
-
- case kEplNmtNodeCommandConfReset:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, ConfReset)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, ConfReset)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#endif
- break;
- }
-
- case kEplNmtNodeCommandConfRestored:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, ConfRestored)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#else
- PRINTF2("%s(Node=0x%X, ConfRestored)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
-#endif
- break;
- }
-
- default:
- {
-#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2)
- PRINTF("%s(Node=0x%X, CfmResult=0x%X)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId, pEventArg_p->m_CfmResult.m_NodeCommand);
-#else
- PRINTF3("%s(Node=0x%X, CfmResult=0x%X)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId, pEventArg_p->m_CfmResult.m_NodeCommand);
-#endif
- break;
- }
- }
- break;
- }
-#endif
-
- default:
- break;
- }
-
- return EplRet;
-}
-
-//---------------------------------------------------------------------------
-//
-// Function: AppCbSync
-//
-// Description: sync event callback function called by event module within
-// kernel part (high priority).
-// This function sets the outputs, reads the inputs and runs
-// the control loop.
-//
-// Parameters: void
-//
-// Returns: tEplKernel = error code,
-// kEplSuccessful = no error
-// otherwise = post error event to API layer
-//
-// State:
-//
-//---------------------------------------------------------------------------
-
-tEplKernel PUBLIC AppCbSync(void){
- tEplKernel EplRet = kEplSuccessful;
-
- EplRet = EplApiProcessImageExchange(&AppProcessImageCopyJob_g);
-
- // Loop through callback list and call each FB in the list
- CEplStackWrapper::getInstance().executeAllCallbacks();
-
- return EplRet;
-}
-
-void CEplStackWrapper::executeAllCallbacks(){
- m_oSync.lock();
- CSinglyLinkedList<IEplCNCallback*>::Iterator itEnd = m_lCallbackList.end();
- for(CSinglyLinkedList<IEplCNCallback*>::Iterator it = m_lCallbackList.begin(); it != itEnd; ++it){
- it->cnSynchCallback();
- }
- m_oSync.unlock();
-}
-
-#ifndef CONFIG_POWERLINK_USERSTACK
-
-void *powerlinkEventThread(void * arg __attribute__((unused))){
- EplApiProcess();
-
- return NULL;
-}
-
-void *powerlinkSyncThread(void * arg __attribute__((unused))){
- while(1){
- AppCbSync();
- }
- return NULL;
-}
-
-#endif
-
-// EOF
diff --git a/src/modules/powerlink/EplWrapper.h b/src/modules/powerlink/EplWrapper.h
deleted file mode 100644
index 5ae4ac6..0000000
--- a/src/modules/powerlink/EplWrapper.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 - 2104 AIT, ACIN, fortiss
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _EPLWRAPPER_H_
-#define _EPLWRAPPER_H_
-
-#include "ProcessImageMatrix.h"
-#include "EplCNCallback.h"
-#include <singlet.h>
-#include <fortelist.h>
-#include <forte_sync.h>
-
-struct SEplMapping{
- struct SEplMappingValues{
- unsigned int m_nDataSize;
- unsigned int m_nPiOffset;
- unsigned int m_nBitOffset;
- char* m_pchCurrentValue;
-
- SEplMappingValues(unsigned int pa_nDataSize, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset) :
- m_nDataSize(pa_nDataSize), m_nPiOffset(pa_nPiOffset), m_nBitOffset(pa_nBitOffset){
- m_pchCurrentValue = new char[pa_nDataSize];
- for(unsigned int i = 0; i < pa_nDataSize; i++){
- m_pchCurrentValue[i] = 0x00;
- }
- }
-
- ~SEplMappingValues(){
- delete[] m_pchCurrentValue;
- }
-
- private:
- SEplMappingValues(const SEplMappingValues &obj);
- SEplMappingValues& operator=(const SEplMappingValues &obj);
- };
-
- typedef CSinglyLinkedList<SEplMappingValues*> TEplMappingList;
- TEplMappingList m_lCurrentValues;
-
- ~SEplMapping(){
- while(!m_lCurrentValues.isEmpty()){
- delete *(TEplMappingList::Iterator) m_lCurrentValues.begin();
- m_lCurrentValues.popFront();
- }
- }
-};
-
-// CEplStackWrapper implemented as class
-// cppcheck-suppress noConstructor
-class CEplStackWrapper{
- DECLARE_SINGLETON(CEplStackWrapper)
- ;
- public:
- /*! \brief Blocking of real-time signals
- *
- * This must be called in main.cpp before the event execution thread is started
- */
- static void eplMainInit();
-
- int eplStackInit(char* pa_chXmlFile, char* pa_chCdcFile, char* pa_chEthDeviceName);
-
- int eplStackShutdown(void);
-
- CProcessImageMatrix* getProcessImageMatrixIn();
- CProcessImageMatrix* getProcessImageMatrixOut();
-
- char* getProcImageIn();
- char* getProcImageOut();
-
- void waitUntilOperational(bool pa_bWait);
-
- void registerCallback(IEplCNCallback* pa_pCallback);
-
- void executeAllCallbacks();
-
- private:
- char* allocProcImage(unsigned int n_bytes);
-
- bool findMAC(const char* pa_pchUserMAC, char* pa_pchDevieName);
-
- bool compareMACs(const char* pa_chMACa, const char* pa_chMACb);
-
- CProcessImageMatrix m_oProcMatrixIn;
- CProcessImageMatrix m_oProcMatrixOut;
-
- unsigned int m_nProcInSize;
- char* m_pchAppProcessImageIn_g;
- unsigned int m_nProcOutSize;
- char* m_pchAppProcessImageOut_g;
-
- bool m_bWait;
-
- CSinglyLinkedList<IEplCNCallback*> m_lCallbackList;
-
- CSyncObject m_oSync;
-
-};
-
-#endif
diff --git a/src/modules/powerlink/EplXmlReader.cpp b/src/modules/powerlink/EplXmlReader.cpp
deleted file mode 100644
index fc46fe3..0000000
--- a/src/modules/powerlink/EplXmlReader.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 - 2014 AIT, ACIN, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "EplXmlReader.h"
-
-#include <string_utils.h>
-#include <cstdlib>
-#include <iostream>
-#include <fstream>
-#include <string.h>
-using namespace std;
-
-#include <tinyxml.h>
-
-CEplXmlReader::CEplXmlReader(CProcessImageMatrix* pa_pIn, CProcessImageMatrix* pa_pOut){
- m_pProcImageIn = pa_pIn;
- m_pProcImageOut = pa_pOut;
-}
-
-CEplXmlReader::~CEplXmlReader(){
-
-}
-
-void CEplXmlReader::setProcessImageIn(CProcessImageMatrix* pa_pIn){
- m_pProcImageIn = pa_pIn;
-}
-
-void CEplXmlReader::setProcessImageOut(CProcessImageMatrix* pa_pOut){
- m_pProcImageOut = pa_pOut;
-}
-
-void CEplXmlReader::readXmlFile(const char* pa_pchFileName){
-
- TiXmlDocument xmlDoc(pa_pchFileName);
-
- if(xmlDoc.LoadFile()){
- TiXmlNode *appProcess = xmlDoc.FirstChild("ApplicationProcess");
- TiXmlNode *processImageIn;
- for(TiXmlNode *processImage = appProcess->ToElement()->FirstChild("ProcessImage"); processImage != NULL; processImage = processImage->NextSibling("ProcessImage")){
- if(strcmp(processImage->ToElement()->Attribute("type"), "output") == 0){
- createProcImageOut(processImage);
- }
- else if(strcmp(processImage->ToElement()->Attribute("type"), "input") == 0){
- processImageIn = processImage;
- }
- }
- createProcImageIn(processImageIn);
- }
- else{
- cout << "ERROR: Could not open XML file" << endl;
- }
-}
-
-void CEplXmlReader::createProcImageOut(TiXmlNode* pa_pProcessImage){
- int currentCnId = -1;
- int currentModuleNr = -1;
- char currentModuleId[256];
- int currentIoNr = -1;
-
- TiXmlNode *channel;
- for(channel = pa_pProcessImage->FirstChild("Channel"); channel != NULL; channel = channel->NextSibling("Channel")){
- // New IO
- currentIoNr++;
-
- // Get "Name" attribute
- const char *ioName = channel->ToElement()->Attribute("Name");
- char *nameStr = new char[strlen(ioName) + 1];
- strcpy(nameStr, ioName);
-
- // Get CN ID
- char* pch = strtok(nameStr, ".CN");
- int cnId = forte::core::util::strtol(pch,0,10);
-
- // Get module ID
- char* modId = strtok(NULL, ".");
-
- // Get dataSize
- const char *temp = channel->ToElement()->Attribute("dataSize");
- int dSize = forte::core::util::strtoul(temp,0,10);
-
- // Get PIOffset
- temp = channel->ToElement()->Attribute("PIOffset");
- long piOffset = forte::core::util::strtol(temp, NULL, 16);
-
- // Get BitOffset
- long bitOffset = 0;
- temp = channel->ToElement()->Attribute("BitOffset");
- if(temp != NULL){
- bitOffset = forte::core::util::strtol(temp, NULL, 16);
- }
-
- // Check CN id, module number and add new IO
- if(cnId != currentCnId){ // New CN
- currentCnId = cnId;
- currentModuleNr = 0;
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListOut.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageOut->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else if(m_oModuleListOut.moduleNameExist(ioName)){ // IO name exist => this must be a new module with same brand as another
- currentModuleNr++;
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListOut.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageOut->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else if(strcmp(modId, currentModuleId) == 0){ // same module ID as IO before => must be same module
-
- m_pProcImageOut->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else{ // new module ID => new module
- currentModuleNr++;
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListOut.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageOut->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
-
- cout << "<< " << currentCnId << ", " << currentModuleNr << ", " << ioName << ", " << currentIoNr << ", " << dSize << ", " << piOffset << ", " << bitOffset << endl;
-
- delete[] nameStr;
- }
-}
-
-void CEplXmlReader::createProcImageIn(TiXmlNode *pa_pProcessImage){
- int currentCnId = -1;
- int currentModuleNr = -1;
- char currentModuleId[256];
- int currentIoNr = -1;
-
- TiXmlNode *channel;
- for(channel = pa_pProcessImage->FirstChild("Channel"); channel != NULL; channel = channel->NextSibling("Channel")){
- // New IO
- currentIoNr++;
-
- // Get "Name" attribute
- const char *ioName = channel->ToElement()->Attribute("Name");
- char *nameStr = new char[strlen(ioName) + 1];
- strcpy(nameStr, ioName);
-
- // Get CN ID
- char* pch = strtok(nameStr, ".CN");
- int cnId = forte::core::util::strtoul(pch,0,10);
-
- // Get module ID
- char* modId = strtok(NULL, ".");
-
- // Get dataSize
- const char *temp = channel->ToElement()->Attribute("dataSize");
- int dSize = forte::core::util::strtoul(temp,0,10);
-
- // Get PIOffset
- temp = channel->ToElement()->Attribute("PIOffset");
- long piOffset = forte::core::util::strtol(temp, NULL, 16);
-
- // Get BitOffset
- long bitOffset = 0;
- temp = channel->ToElement()->Attribute("BitOffset");
- if(temp != NULL){
- bitOffset = forte::core::util::strtol(temp, NULL, 16);
- }
-
- // Check CN id, module number and add new IO
- if(cnId != currentCnId){ // New CN
- currentCnId = cnId;
-
- currentModuleNr = getModuleNr(ioName);
-
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListIn.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageIn->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else if(m_oModuleListIn.moduleNameExist(ioName)){ // IO name exist => this must be a new module with same brand as another
-
- currentModuleNr = getModuleNr(ioName);
-
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListIn.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageIn->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else if(strcmp(modId, currentModuleId) == 0){ // same module ID as IO before => must be same module
-
- m_pProcImageIn->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
- else{ // new module ID => new module
-
- currentModuleNr = getModuleNr(ioName);
-
- strcpy(currentModuleId, modId);
- currentIoNr = 0;
-
- m_oModuleListIn.addEntry(ioName, piOffset, bitOffset, currentModuleNr);
- m_pProcImageIn->addEntry(cnId, currentModuleNr, currentIoNr, dSize, piOffset, bitOffset);
-
- }
-
- cout << ">> " << currentCnId << ", " << currentModuleNr << ", " << ioName << ", " << currentIoNr << ", " << dSize << ", " << piOffset << ", " << bitOffset << endl;
-
- delete[] nameStr;
- }
-}
-
-int CEplXmlReader::getModuleNr(const char* pa_pchIoId){
- char localCopy[256];
- strcpy(localCopy, pa_pchIoId);
-
- char dest[256];
- char* pch = strtok(localCopy, ".");
- strcpy(dest, pch);
- strcat(dest, ".");
- pch = strtok(NULL, ".");
- strcat(dest, pch);
-
- int occurences = m_oModuleListIn.getNrOfModules(dest);
- int modNr = m_oModuleListOut.getModuleNr(dest, occurences + 1);
- if(modNr == -1) {
- cout << "ShouldNotHappenError" << endl;
- }
-
- return modNr;
-}
diff --git a/src/modules/powerlink/EplXmlReader.h b/src/modules/powerlink/EplXmlReader.h
deleted file mode 100644
index 12cedfb..0000000
--- a/src/modules/powerlink/EplXmlReader.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, ACIN
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _EPLXMLREADER_H_
-#define _EPLXMLREADER_H_
-
-#include "ProcessImageMatrix.h"
-#include "ModuleList.h"
-
-class TiXmlNode;
-
-class CEplXmlReader{
- public:
- CEplXmlReader(CProcessImageMatrix* pa_pIn, CProcessImageMatrix* pa_pOut);
- ~CEplXmlReader();
-
- void setProcessImageIn(CProcessImageMatrix* pa_pIn);
- void setProcessImageOut(CProcessImageMatrix* pa_pOut);
-
- void readXmlFile(const char* pa_pchFileName);
-
- int getProcessImageIn();
-
- private:
- CModuleList m_oModuleListOut;
- CModuleList m_oModuleListIn;
- CProcessImageMatrix* m_pProcImageOut;
- CProcessImageMatrix* m_pProcImageIn;
-
- void createProcImageOut(TiXmlNode* pa_pProcessImage);
- void createProcImageIn(TiXmlNode* pa_pProcessImage);
-
- int getModuleNr(const char* pa_pchIoId);
-
-};
-
-#endif
diff --git a/src/modules/powerlink/ModuleList.cpp b/src/modules/powerlink/ModuleList.cpp
deleted file mode 100644
index bf56a2f..0000000
--- a/src/modules/powerlink/ModuleList.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 AIT, ACIN, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "ModuleList.h"
-#include <cstring>
-
-CModuleList::IoModule::IoModule(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset, unsigned int pa_nModuleNr) :
- m_nPiOffset(pa_nPiOffset), m_nBitOffset(pa_nBitOffset), m_nModuleNr(pa_nModuleNr){
-
- m_pchName = new char[strlen(pa_pchName) + 1];
- strcpy(m_pchName, pa_pchName);
-}
-
-CModuleList::IoModule::~IoModule(){
- delete[] m_pchName;
-}
-
-CModuleList::CModuleList() :
- m_nNumberOfModules(0){
-
-}
-
-CModuleList::~CModuleList(){
- // Delete modules in list
- m_lModules.clearAll();
-
-}
-
-void CModuleList::addEntry(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset, unsigned int pa_nModuleNr){
- m_lModules.pushBack(new IoModule(pa_pchName, pa_nPiOffset, pa_nBitOffset, pa_nModuleNr));
-
- m_nNumberOfModules++;
-}
-
-int CModuleList::getModuleNr(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset){
-
- TModuleList::Iterator itEnd(m_lModules.end());
- for(TModuleList::Iterator it(m_lModules.begin()); it != itEnd; ++it){
- if(strcmp(it->m_pchName, pa_pchName) == 0 && it->m_nPiOffset == pa_nPiOffset && it->m_nBitOffset == pa_nBitOffset){
- return it->m_nModuleNr;
- }
- }
-
- return -1;
-}
-
-int CModuleList::getModuleNr(const char* pa_pchName, unsigned int pa_nOccurence){
- unsigned int nrOcc = 0;
-
- TModuleList::Iterator itEnd(m_lModules.end());
- for(TModuleList::Iterator it(m_lModules.begin()); it != itEnd; ++it){
- char* pch = strstr(it->m_pchName, pa_pchName);
- if(pch != NULL){
- nrOcc++;
- if(nrOcc == pa_nOccurence){
- return it->m_nModuleNr;
- }
- }
- }
-
- return -1;
-}
-
-int CModuleList::getNrOfModules(const char* pa_pchName){
- int nrMods = 0;
-
- TModuleList::Iterator itEnd(m_lModules.end());
- for(TModuleList::Iterator it(m_lModules.begin()); it != itEnd; ++it){
- char* pch = strstr(it->m_pchName, pa_pchName);
- if(pch != NULL){
- nrMods++;
- }
- }
-
- return nrMods;
-}
-
-bool CModuleList::moduleNameExist(const char* pa_pchName){
-
- TModuleList::Iterator itEnd(m_lModules.end());
- for(TModuleList::Iterator it(m_lModules.begin()); it != itEnd; ++it){
- if(strcmp(it->m_pchName, pa_pchName) == 0){
- return true;
- }
- }
-
- return false;
-}
diff --git a/src/modules/powerlink/ModuleList.h b/src/modules/powerlink/ModuleList.h
deleted file mode 100644
index 69220fb..0000000
--- a/src/modules/powerlink/ModuleList.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, ACIN
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _MODULELIST_H_
-#define _MODULELIST_H_
-
-#include <fortelist.h>
-
-class CModuleList{
- public:
- CModuleList();
- ~CModuleList();
-
- void addEntry(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset, unsigned int pa_nModuleNr);
-
- int getModuleNr(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset);
-
- int getModuleNr(const char* pa_pchName, unsigned int pa_nOccurence);
-
- int getNrOfModules(const char* pa_pchName);
-
- bool moduleNameExist(const char* pa_pchName);
-
- private:
- class IoModule{
- public:
- IoModule(const char* pa_pchName, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset, unsigned int pa_nModuleNr);
- ~IoModule();
-
- char* m_pchName;
- unsigned int m_nPiOffset;
- unsigned int m_nBitOffset;
-
- unsigned int m_nModuleNr;
-
- private:
- IoModule(const IoModule& obj);
- IoModule& operator=(const IoModule& obj);
- };
-
- //std::vector<IoModule*> m_lModules;
-
- typedef CSinglyLinkedList<IoModule*> TModuleList;
- TModuleList m_lModules;
-
- unsigned int m_nNumberOfModules;
-};
-
-#endif
diff --git a/src/modules/powerlink/POWERLINK_MN.cpp b/src/modules/powerlink/POWERLINK_MN.cpp
deleted file mode 100644
index b59997f..0000000
--- a/src/modules/powerlink/POWERLINK_MN.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "POWERLINK_MN.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "POWERLINK_MN_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include <cstdio>
-
-DEFINE_FIRMWARE_FB(FORTE_POWERLINK_MN, g_nStringIdPOWERLINK_MN)
-
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCDC_CFG, g_nStringIdAPP_CFG, g_nStringIdDEV_NAME };
-
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING };
-
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_POWERLINK_MN::scm_anEIWithIndexes[] = { 0 };
-const TDataIOID FORTE_POWERLINK_MN::scm_anEIWith[] = { 0, 1, 2, 3, 255 };
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anEventInputNames[] = { g_nStringIdINIT };
-
-const TDataIOID FORTE_POWERLINK_MN::scm_anEOWith[] = { 0, 1, 255 };
-const TForteInt16 FORTE_POWERLINK_MN::scm_anEOWithIndexes[] = { 0, -1 };
-const CStringDictionary::TStringId FORTE_POWERLINK_MN::scm_anEventOutputNames[] = { g_nStringIdINITO };
-
-const SFBInterfaceSpec FORTE_POWERLINK_MN::scm_stFBInterfaceSpec = { 1, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 1, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 4, scm_anDataInputNames, scm_anDataInputTypeIds, 2, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-FORTE_POWERLINK_MN::~FORTE_POWERLINK_MN(){
- shutdownStack();
-}
-
-void FORTE_POWERLINK_MN::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
-
- if(QI() == true){
- QO() = QI();
-
- CEplStackWrapper* eplStack = &CEplStackWrapper::getInstance();
-
- eplStack->waitUntilOperational(false);
- eplStack->eplStackInit(APP_CFG().getValue(), CDC_CFG().getValue(), DEV_NAME().getValue());
-
- //TODO check if error occured during initialization
-
- }
- else if(QI() == false){
- QO() = QI();
- shutdownStack();
- }
-
- sendOutputEvent(scm_nEventINITOID);
- break;
- }
-}
-
-void FORTE_POWERLINK_MN::shutdownStack(){
- CEplStackWrapper::getInstance().eplStackShutdown();
-}
-
diff --git a/src/modules/powerlink/POWERLINK_MN.h b/src/modules/powerlink/POWERLINK_MN.h
deleted file mode 100644
index 3c9a361..0000000
--- a/src/modules/powerlink/POWERLINK_MN.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _POWERLINK_MN_H_
-#define _POWERLINK_MN_H_
-
-#include <funcbloc.h>
-
-class FORTE_POWERLINK_MN : public CFunctionBlock{
- DECLARE_FIRMWARE_FB(FORTE_POWERLINK_MN)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_STRING &CDC_CFG(){
- return *static_cast<CIEC_STRING*>(getDI(1));
- }
- ;
-
- CIEC_STRING &APP_CFG(){
- return *static_cast<CIEC_STRING*>(getDI(2));
- }
- ;
-
- CIEC_STRING &DEV_NAME(){
- return *static_cast<CIEC_STRING*>(getDI(3));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(1));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(1, 4, 2, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- void shutdownStack();
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_POWERLINK_MN){
- };
-
- virtual ~FORTE_POWERLINK_MN();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/ProcessImageMatrix.cpp b/src/modules/powerlink/ProcessImageMatrix.cpp
deleted file mode 100644
index 2074b60..0000000
--- a/src/modules/powerlink/ProcessImageMatrix.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "ProcessImageMatrix.h"
-
-CProcessImageMatrix::CProcessImageMatrix(){
-
- m_nBitSize = 0;
- m_nNumberOfEntries = 0;
-
-}
-
-CProcessImageMatrix::~CProcessImageMatrix(){
- clearAll();
-}
-
-void CProcessImageMatrix::addEntry(unsigned int pa_nCN, unsigned int pa_nModule, unsigned int pa_nIoId, unsigned int pa_nDataSize, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset){
-
- m_lMatrix.pushBack(new SChannelEntry(pa_nCN, pa_nModule, pa_nIoId, pa_nDataSize, pa_nPiOffset, pa_nBitOffset));
-
- // Check if 8, 16, 32 bit aligned
- if((pa_nDataSize % 32 == 0) || (pa_nDataSize % 16 == 0) || (pa_nDataSize % 8 == 0)){
- if(m_nBitSize % pa_nDataSize != 0){
- unsigned long fillBits = pa_nDataSize - (m_nBitSize % pa_nDataSize);
- m_nBitSize += fillBits;
- }
- }
- m_nBitSize += pa_nDataSize;
-
- m_nNumberOfEntries++;
-}
-
-// getEntry: Returns an array with [dataSize, PIOffset, BitOffset]
-unsigned int* CProcessImageMatrix::getEntry(unsigned int pa_nCN, unsigned int pa_nModule, unsigned int pa_nIoId){
- static unsigned int data[3] = { 0, 0, 0 };
-
- TChannelList::Iterator itEnd = m_lMatrix.end();
- for(TChannelList::Iterator it = m_lMatrix.begin(); it != itEnd; ++it){
- if(it->m_nCN == pa_nCN && it->m_nModuleId == pa_nModule && it->m_nIOid == pa_nIoId){
- data[0] = it->m_nDataSize;
- data[1] = it->m_nPIOffset;
- data[2] = it->m_nBitOffset;
- return data;
- }
- }
-
- return NULL;
-}
-
-// getEntry: same as above but returns the values on row "index"
-unsigned int* CProcessImageMatrix::getEntry(unsigned int pa_nIndex){
- if(pa_nIndex < m_nNumberOfEntries){
- static unsigned int data[3] = { 0, 0, 0 };
- TChannelList::Iterator it = m_lMatrix.begin();
- for(unsigned int i = 0; i < pa_nIndex; i++){
- ++it;
- }
- data[0] = it->m_nDataSize;
- data[1] = it->m_nPIOffset;
- data[2] = it->m_nBitOffset;
- return data;
- }
-
- return NULL;
-}
-
-unsigned int CProcessImageMatrix::getNrOfEntries() const {
- return m_nNumberOfEntries;
-}
-
-CProcessImageMatrix* CProcessImageMatrix::getModuleEntries(unsigned int pa_nCN, unsigned int pa_nModule){
- CProcessImageMatrix* newMatrix = NULL;
-
- TChannelList::Iterator itEnd = m_lMatrix.end();
- for(TChannelList::Iterator it(m_lMatrix.begin()); it != itEnd; ++it){
- if(it->m_nCN == pa_nCN && it->m_nModuleId == pa_nModule){
- if(newMatrix == NULL) {
- newMatrix = new CProcessImageMatrix();
- }
-
- newMatrix->addEntry(it->m_nCN, it->m_nModuleId, it->m_nIOid, it->m_nDataSize, it->m_nPIOffset, it->m_nBitOffset);
- }
- }
-
- return newMatrix;
-}
-
-unsigned long CProcessImageMatrix::getProcessImageSize() const {
- // Check if the whole matrix is 32 bit aligned
- if(m_nBitSize % 32 != 0){
- int fillBits = 32 - (m_nBitSize % 32);
- return (unsigned long) (m_nBitSize + fillBits) / 8;
- }
- return (unsigned long) m_nBitSize / 8;
-}
-
-void CProcessImageMatrix::clearAll(){
- while(!m_lMatrix.isEmpty()){
- delete *(TChannelList::Iterator) m_lMatrix.begin();
- m_lMatrix.popFront();
- }
-}
diff --git a/src/modules/powerlink/ProcessImageMatrix.h b/src/modules/powerlink/ProcessImageMatrix.h
deleted file mode 100644
index 87704bf..0000000
--- a/src/modules/powerlink/ProcessImageMatrix.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT, fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _PROCIMAGEMATRIX_H_
-#define _PROCIMAGEMATRIX_H_
-
-//#include <vector>
-#include <fortelist.h>
-
-class CProcessImageMatrix{
- public:
- CProcessImageMatrix();
- ~CProcessImageMatrix();
-
- void addEntry(unsigned int pa_nCN, unsigned int pa_nModule, unsigned int pa_nIoId, unsigned int pa_nDataSize, unsigned int pa_nPiOffset, unsigned int pa_nBitOffset);
-
- // getEntry: Returns an array with [dataSize, PIOffset, BitOffset]
- unsigned int* getEntry(unsigned int pa_nCN, unsigned int pa_nModule, unsigned int pa_nIoId);
- unsigned int* getEntry(unsigned int pa_nIndex);
-
- unsigned int getNrOfEntries() const;
-
- //ProcessImageMatrix* is owned by caller
- CProcessImageMatrix* getModuleEntries(unsigned int pa_nCN, unsigned int pa_nModule);
-
- unsigned long getProcessImageSize() const ;
-
- void clearAll();
-
- private:
- struct SChannelEntry{
- unsigned int m_nCN;
- unsigned int m_nModuleId;
- unsigned int m_nIOid;
- unsigned int m_nDataSize;
- unsigned int m_nPIOffset;
- unsigned int m_nBitOffset;
-
- SChannelEntry(unsigned int pa_nCN, unsigned int pa_nModuleId, unsigned int pa_nIOid, unsigned int pa_nDataSize, unsigned int pa_nPIOffset, unsigned int pa_nBitOffset) :
- m_nCN(pa_nCN), m_nModuleId(pa_nModuleId), m_nIOid(pa_nIOid), m_nDataSize(pa_nDataSize), m_nPIOffset(pa_nPIOffset), m_nBitOffset(pa_nBitOffset){
- }
- ;
-
- };
-
- typedef CSinglyLinkedList<SChannelEntry*> TChannelList;
- TChannelList m_lMatrix;
-
- unsigned long m_nBitSize;
-
- unsigned int m_nNumberOfEntries;
-};
-
-#endif
diff --git a/src/modules/powerlink/X20AI4622.cpp b/src/modules/powerlink/X20AI4622.cpp
deleted file mode 100644
index cf5538e..0000000
--- a/src/modules/powerlink/X20AI4622.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren, Thomas Strasser - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20AI4622.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20AI4622_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20AI4622, g_nStringIdX20AI4622)
-
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdAI01, g_nStringIdAI02, g_nStringIdAI03, g_nStringIdAI04 };
-
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT };
-
-const TForteInt16 FORTE_X20AI4622::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20AI4622::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20AI4622::scm_anEOWith[] = { 0, 1, 2, 255, 2, 3, 4, 5, 6, 0, 255 };
-const TForteInt16 FORTE_X20AI4622::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20AI4622::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20AI4622::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 7, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20AI4622::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for inputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- short ioVal = 0x0000;
- ioVal = *((short*) (it->m_pchCurrentValue));
- *static_cast<CIEC_INT*>(getDO(i)) = ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20AI4622::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(; it != itEnd; ++it){
- short ioVal = 0x0000;
- char lowByte;
- char highByte;
- lowByte = (eplStack.getProcImageOut()[it->m_nPiOffset] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- highByte = (eplStack.getProcImageOut()[it->m_nPiOffset + 1] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte);
-
- *((short*) (it->m_pchCurrentValue)) = ioVal;
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20AI4622.h b/src/modules/powerlink/X20AI4622.h
deleted file mode 100644
index cc2bd6f..0000000
--- a/src/modules/powerlink/X20AI4622.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20AI4622_H_
-#define _X20AI4622_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20AI4622 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20AI4622)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_INT &AI01(){
- return *static_cast<CIEC_INT*>(getDO(3));
- }
- ;
-
- CIEC_INT &AI02(){
- return *static_cast<CIEC_INT*>(getDO(4));
- }
- ;
-
- CIEC_INT &AI03(){
- return *static_cast<CIEC_INT*>(getDO(5));
- }
- ;
-
- CIEC_INT &AI04(){
- return *static_cast<CIEC_INT*>(getDO(6));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(3, 3, 7, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20AI4622){
- };
-
- virtual ~FORTE_X20AI4622(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20AO4622.cpp b/src/modules/powerlink/X20AO4622.cpp
deleted file mode 100644
index 0474df0..0000000
--- a/src/modules/powerlink/X20AO4622.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20AO4622.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20AO4622_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20AO4622, g_nStringIdX20AO4622)
-
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdAO01, g_nStringIdAO02, g_nStringIdAO03, g_nStringIdAO04 };
-
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT };
-
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_X20AO4622::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20AO4622::scm_anEIWith[] = { 0, 1, 2, 255, 3, 4, 5, 6, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20AO4622::scm_anEOWith[] = { 0, 1, 2, 255, 2, 0, 255 };
-const TForteInt16 FORTE_X20AO4622::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20AO4622::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20AO4622::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 7, scm_anDataInputNames, scm_anDataInputTypeIds, 3, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20AO4622::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Outputs (process inputs) always start with i = 0
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 0; i < moduleIOs->getNrOfEntries(); i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDIs && it != itEnd; i++, ++it){
- short ioVal = *static_cast<CIEC_INT*>(getDI(i));
- *((short*) (it->m_pchCurrentValue)) = ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20AO4622::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- short ioVal = *((short*) (it->m_pchCurrentValue));
- char highByte = (char) ((ioVal & 0xFF00) >> 8);
- char lowByte = (char) (ioVal & 0x00FF);
- (eplStack.getProcImageIn())[it->m_nPiOffset] &= (~(0xFF << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset] |= (lowByte << (it->m_nBitOffset));
-
- (eplStack.getProcImageIn())[it->m_nPiOffset + 1] &= (~(0xFF << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset + 1] |= (highByte << (it->m_nBitOffset));
- }
-
- m_oSync.unlock();
-}
diff --git a/src/modules/powerlink/X20AO4622.h b/src/modules/powerlink/X20AO4622.h
deleted file mode 100644
index 1ae6629..0000000
--- a/src/modules/powerlink/X20AO4622.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20AO4622_H_
-#define _X20AO4622_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20AO4622 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20AO4622)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- CIEC_INT &AO01(){
- return *static_cast<CIEC_INT*>(getDI(3));
- }
- ;
-
- CIEC_INT &AO02(){
- return *static_cast<CIEC_INT*>(getDI(4));
- }
- ;
-
- CIEC_INT &AO03(){
- return *static_cast<CIEC_INT*>(getDI(5));
- }
- ;
-
- CIEC_INT &AO04(){
- return *static_cast<CIEC_INT*>(getDI(6));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 7, 3, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20AO4622){
- };
-
- virtual ~FORTE_X20AO4622(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20AT2402.cpp b/src/modules/powerlink/X20AT2402.cpp
deleted file mode 100644
index 8fefb01..0000000
--- a/src/modules/powerlink/X20AT2402.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20AT2402.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20AT2402_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20AT2402, g_nStringIdX20AT2402)
-
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02 };
-
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL };
-
-const TForteInt16 FORTE_X20AT2402::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20AT2402::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20AT2402::scm_anEOWith[] = { 0, 1, 2, 255, 2, 3, 4, 0, 255 };
-const TForteInt16 FORTE_X20AT2402::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20AT2402::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20AT2402::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 5, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20AT2402::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- short ioVal = *((short*) (it->m_pchCurrentValue));
- TForteFloat ioValFloat = static_cast<TForteFloat>(ioVal);
- *static_cast<CIEC_REAL*>(getDO(i)) = ioValFloat / 10;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20AT2402::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- short ioVal = 0x0000;
- char lowByte;
- char highByte;
- lowByte = (eplStack.getProcImageOut()[it->m_nPiOffset] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- highByte = (eplStack.getProcImageOut()[it->m_nPiOffset + 1] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte);
-
- *((short*) (it->m_pchCurrentValue)) = ioVal;
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20AT2402.h b/src/modules/powerlink/X20AT2402.h
deleted file mode 100644
index 2bd2b74..0000000
--- a/src/modules/powerlink/X20AT2402.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20AT2402_H_
-#define _X20AT2402_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20AT2402 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20AT2402)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_REAL &T01(){
- return *static_cast<CIEC_REAL*>(getDO(3));
- }
- ;
-
- CIEC_REAL &T02(){
- return *static_cast<CIEC_REAL*>(getDO(4));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 5, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20AT2402){
- };
-
- virtual ~FORTE_X20AT2402(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20AT4222.cpp b/src/modules/powerlink/X20AT4222.cpp
deleted file mode 100644
index 9acbba3..0000000
--- a/src/modules/powerlink/X20AT4222.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20AT4222.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20AT4222_gen.cpp"
-#endif
-
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20AT4222, g_nStringIdX20AT4222)
-
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02, g_nStringIdT03, g_nStringIdT04 };
-
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL };
-
-const TForteInt16 FORTE_X20AT4222::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20AT4222::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20AT4222::scm_anEOWith[] = { 0, 1, 2, 255, 2, 3, 4, 0, 5, 6, 255 };
-const TForteInt16 FORTE_X20AT4222::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20AT4222::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20AT4222::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 7, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20AT4222::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- short ioVal = *((short*) (it->m_pchCurrentValue));
- TForteFloat ioValFloat = static_cast<TForteFloat>(ioVal);
- *static_cast<CIEC_REAL*>(getDO(i)) = ioValFloat / 10;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20AT4222::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- short ioVal = 0x0000;
- char lowByte;
- char highByte;
- lowByte = (eplStack.getProcImageOut()[it->m_nPiOffset] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- highByte = (eplStack.getProcImageOut()[it->m_nPiOffset + 1] & (0xFF << it->m_nBitOffset)) >> it->m_nBitOffset;
- ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte);
-
- *((short*) (it->m_pchCurrentValue)) = ioVal;
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20AT4222.h b/src/modules/powerlink/X20AT4222.h
deleted file mode 100644
index b35e406..0000000
--- a/src/modules/powerlink/X20AT4222.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20AT4222_H_
-#define _X20AT4222_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20AT4222 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20AT4222)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_REAL &T01(){
- return *static_cast<CIEC_REAL*>(getDO(3));
- }
- ;
-
- CIEC_REAL &T02(){
- return *static_cast<CIEC_REAL*>(getDO(4));
- }
- ;
-
- CIEC_REAL &T03(){
- return *static_cast<CIEC_REAL*>(getDO(5));
- }
- ;
-
- CIEC_REAL &T04(){
- return *static_cast<CIEC_REAL*>(getDO(6));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 7, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20AT4222){
- };
-
- virtual ~FORTE_X20AT4222(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DI4653.cpp b/src/modules/powerlink/X20DI4653.cpp
deleted file mode 100644
index dfaf11f..0000000
--- a/src/modules/powerlink/X20DI4653.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DI4653.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DI4653_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_X20DI4653, g_nStringIdX20DI4653)
-
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID};
-
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT};
-
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04};
-
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL};
-
-const TForteInt16 FORTE_X20DI4653::scm_anEIWithIndexes[] = {0, 4};
-const TDataIOID FORTE_X20DI4653::scm_anEIWith[] = {0, 1, 2, 255, 0, 255};
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ};
-
-const TDataIOID FORTE_X20DI4653::scm_anEOWith[] = {0, 2, 1, 255, 3, 4, 5, 6, 2, 0, 255};
-const TForteInt16 FORTE_X20DI4653::scm_anEOWithIndexes[] = {0, 4, -1};
-const CStringDictionary::TStringId FORTE_X20DI4653::scm_anEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF};
-
-const SFBInterfaceSpec FORTE_X20DI4653::scm_stFBInterfaceSpec = {
- 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes,
- 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds,
- 7, scm_anDataOutputNames, scm_anDataOutputTypeIds,
- 0, 0
-};
-
-
-void FORTE_X20DI4653::executeEvent(int pa_nEIID){
- switch(pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- *static_cast<CIEC_BOOL*>(getDO(i)) = ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DI4653::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(; it != itEnd; ++it){
- bool ioVal = (eplStack.getProcImageOut()[it->m_nPiOffset] & (char) (0x01 << it->m_nBitOffset)) != 0x00;
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
-
- m_oSync.unlock();
-}
-
-
-
diff --git a/src/modules/powerlink/X20DI4653.h b/src/modules/powerlink/X20DI4653.h
deleted file mode 100644
index 634bb18..0000000
--- a/src/modules/powerlink/X20DI4653.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DI4653_H_
-#define _X20DI4653_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DI4653: public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DI4653)
-
-private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI() {
- return *static_cast<CIEC_BOOL*>(getDI(0));
- };
-
- CIEC_USINT &CNID() {
- return *static_cast<CIEC_USINT*>(getDI(1));
- };
-
- CIEC_UINT &MODID() {
- return *static_cast<CIEC_UINT*>(getDI(2));
- };
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO() {
- return *static_cast<CIEC_BOOL*>(getDO(0));
- };
-
- CIEC_USINT &CNIDO() {
- return *static_cast<CIEC_USINT*>(getDO(1));
- };
-
- CIEC_STRING &STATUS() {
- return *static_cast<CIEC_STRING*>(getDO(2));
- };
-
- CIEC_BOOL &DI01() {
- return *static_cast<CIEC_BOOL*>(getDO(3));
- };
-
- CIEC_BOOL &DI02() {
- return *static_cast<CIEC_BOOL*>(getDO(4));
- };
-
- CIEC_BOOL &DI03() {
- return *static_cast<CIEC_BOOL*>(getDO(5));
- };
-
- CIEC_BOOL &DI04() {
- return *static_cast<CIEC_BOOL*>(getDO(6));
- };
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 7, 0);
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
-
- SEplMapping m_oEplMapping;
- CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
-public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DI4653){
- };
-
- virtual ~FORTE_X20DI4653(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
-
diff --git a/src/modules/powerlink/X20DI9371.cpp b/src/modules/powerlink/X20DI9371.cpp
deleted file mode 100644
index 15243fc..0000000
--- a/src/modules/powerlink/X20DI9371.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DI9371.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DI9371_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_X20DI9371, g_nStringIdX20DI9371)
-
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 };
-
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const TForteInt16 FORTE_X20DI9371::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20DI9371::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20DI9371::scm_anEOWith[] = { 0, 2, 1, 255, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, 255 };
-const TForteInt16 FORTE_X20DI9371::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20DI9371::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20DI9371::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 15, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DI9371::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- *static_cast<CIEC_BOOL*>(getDO(i)) = ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DI9371::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(; it != itEnd; ++it){
- bool ioVal = (eplStack.getProcImageOut()[it->m_nPiOffset] & (char) (0x01 << it->m_nBitOffset)) != 0x00;
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20DI9371.h b/src/modules/powerlink/X20DI9371.h
deleted file mode 100644
index 6ee6031..0000000
--- a/src/modules/powerlink/X20DI9371.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DI9371_H_
-#define _X20DI9371_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DI9371 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DI9371)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_BOOL &DI01(){
- return *static_cast<CIEC_BOOL*>(getDO(3));
- }
- ;
-
- CIEC_BOOL &DI02(){
- return *static_cast<CIEC_BOOL*>(getDO(4));
- }
- ;
-
- CIEC_BOOL &DI03(){
- return *static_cast<CIEC_BOOL*>(getDO(5));
- }
- ;
-
- CIEC_BOOL &DI04(){
- return *static_cast<CIEC_BOOL*>(getDO(6));
- }
- ;
-
- CIEC_BOOL &DI05(){
- return *static_cast<CIEC_BOOL*>(getDO(7));
- }
- ;
-
- CIEC_BOOL &DI06(){
- return *static_cast<CIEC_BOOL*>(getDO(8));
- }
- ;
-
- CIEC_BOOL &DI07(){
- return *static_cast<CIEC_BOOL*>(getDO(9));
- }
- ;
-
- CIEC_BOOL &DI08(){
- return *static_cast<CIEC_BOOL*>(getDO(10));
- }
- ;
-
- CIEC_BOOL &DI09(){
- return *static_cast<CIEC_BOOL*>(getDO(11));
- }
- ;
-
- CIEC_BOOL &DI10(){
- return *static_cast<CIEC_BOOL*>(getDO(12));
- }
- ;
-
- CIEC_BOOL &DI11(){
- return *static_cast<CIEC_BOOL*>(getDO(13));
- }
- ;
-
- CIEC_BOOL &DI12(){
- return *static_cast<CIEC_BOOL*>(getDO(14));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 15, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
-
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DI9371){
- };
-
- virtual ~FORTE_X20DI9371(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DI9372.cpp b/src/modules/powerlink/X20DI9372.cpp
deleted file mode 100644
index b7e2f68..0000000
--- a/src/modules/powerlink/X20DI9372.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DI9372.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DI9372_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20DI9372, g_nStringIdX20DI9372)
-
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 };
-
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const TForteInt16 FORTE_X20DI9372::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20DI9372::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20DI9372::scm_anEOWith[] = { 0, 2, 1, 255, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, 255 };
-const TForteInt16 FORTE_X20DI9372::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20DI9372::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20DI9372::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 15, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DI9372::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for inputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- *static_cast<CIEC_BOOL*>(getDO(i)) = ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DI9372::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(; it != itEnd; ++it){
- bool ioVal = (eplStack.getProcImageOut()[it->m_nPiOffset] & (char) (0x01 << it->m_nBitOffset)) != 0x00;
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
-
- m_oSync.unlock();
-}
diff --git a/src/modules/powerlink/X20DI9372.h b/src/modules/powerlink/X20DI9372.h
deleted file mode 100644
index ad3d8da..0000000
--- a/src/modules/powerlink/X20DI9372.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DI9372_H_
-#define _X20DI9372_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DI9372 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DI9372)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_BOOL &DI01(){
- return *static_cast<CIEC_BOOL*>(getDO(3));
- }
- ;
-
- CIEC_BOOL &DI02(){
- return *static_cast<CIEC_BOOL*>(getDO(4));
- }
- ;
-
- CIEC_BOOL &DI03(){
- return *static_cast<CIEC_BOOL*>(getDO(5));
- }
- ;
-
- CIEC_BOOL &DI04(){
- return *static_cast<CIEC_BOOL*>(getDO(6));
- }
- ;
-
- CIEC_BOOL &DI05(){
- return *static_cast<CIEC_BOOL*>(getDO(7));
- }
- ;
-
- CIEC_BOOL &DI06(){
- return *static_cast<CIEC_BOOL*>(getDO(8));
- }
- ;
-
- CIEC_BOOL &DI07(){
- return *static_cast<CIEC_BOOL*>(getDO(9));
- }
- ;
-
- CIEC_BOOL &DI08(){
- return *static_cast<CIEC_BOOL*>(getDO(10));
- }
- ;
-
- CIEC_BOOL &DI09(){
- return *static_cast<CIEC_BOOL*>(getDO(11));
- }
- ;
-
- CIEC_BOOL &DI10(){
- return *static_cast<CIEC_BOOL*>(getDO(12));
- }
- ;
-
- CIEC_BOOL &DI11(){
- return *static_cast<CIEC_BOOL*>(getDO(13));
- }
- ;
-
- CIEC_BOOL &DI12(){
- return *static_cast<CIEC_BOOL*>(getDO(14));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 15, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DI9372){
- };
-
- virtual ~FORTE_X20DI9372(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DI937X.cpp b/src/modules/powerlink/X20DI937X.cpp
deleted file mode 100644
index 6391410..0000000
--- a/src/modules/powerlink/X20DI937X.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DI937X.h"
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20DI937X, g_nStringIdX20DI937X)
-
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID };
-
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT };
-
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 };
-
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const TForteInt16 FORTE_X20DI937X::scm_anEIWithIndexes[] = { 0, -1, -1 };
-const TDataIOID FORTE_X20DI937X::scm_anEIWith[] = { 0, 1, 2, 255 };
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ, g_nStringIdRSP };
-
-const TDataIOID FORTE_X20DI937X::scm_anEOWith[] = { 0, 2, 1, 255, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 255, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 255 };
-const TForteInt16 FORTE_X20DI937X::scm_anEOWithIndexes[] = { 0, 4, 18, -1 };
-const CStringDictionary::TStringId FORTE_X20DI937X::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF, g_nStringIdIND };
-
-const SFBInterfaceSpec FORTE_X20DI937X::scm_stFBInterfaceSpec = { 3, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 3, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 15, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DI937X::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID: {
- //#error add code for INIT event!
-
- EplStackWrapper &eplStack = EplStackWrapper::getInstance();
-
- // Get settings for intputs
- ProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID());
-
- // Inputs (process inputs) always start with i = 1
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_anDataSizes[i] = moduleIOs->getEntry(i)[0];
- m_oEplMapping.m_anPiOffsets[i] = moduleIOs->getEntry(i)[1];
- m_oEplMapping.m_anBitOffsets[i] = moduleIOs->getEntry(i)[2];
-
- char* newVal = new char[m_oEplMapping.m_anDataSizes[i]]();
- m_oEplMapping.m_lCurrentValues.pushBack(newVal);
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- }
- case scm_nEventREQID: {
- m_oSync.lock();
- CSinglyLinkedList<char*>::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- CSinglyLinkedList<char*>::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, ++it){
- bool ioVal = (bool) **it;
- *static_cast<CIEC_BOOL*>(getDO(i)) = ioVal;
- }
- m_oSync.unlock();
-
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
- case scm_nEventRSPID:
- break;
- }
-}
-
-void FORTE_X20DI937X::cnSynchCallback(){
- EplStackWrapper &eplStack = EplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- CSinglyLinkedList<char*>::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- CSinglyLinkedList<char*>::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3, j = 1; i < m_pstInterfaceSpec->m_nNumDOs && it != itEnd; i++, j++, ++it){
- bool ioVal = (bool) (eplStack.getProcImageOut()[m_oEplMapping.m_anPiOffsets[j]] & (char) (0x01 << m_oEplMapping.m_anBitOffsets[j]));
- **it = (char) ioVal;
- }
-
- m_oSync.unlock();
-}
diff --git a/src/modules/powerlink/X20DI937X.h b/src/modules/powerlink/X20DI937X.h
deleted file mode 100644
index 0ac6e3a..0000000
--- a/src/modules/powerlink/X20DI937X.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DI937X_H_
-#define _X20DI937X_H_
-
-#include <funcbloc.h>
-
-#include <fortelist.h>
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-class FORTE_X20DI937X : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DI937X)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_BOOL &DI01(){
- return *static_cast<CIEC_BOOL*>(getDO(3));
- }
- ;
-
- CIEC_BOOL &DI02(){
- return *static_cast<CIEC_BOOL*>(getDO(4));
- }
- ;
-
- CIEC_BOOL &DI03(){
- return *static_cast<CIEC_BOOL*>(getDO(5));
- }
- ;
-
- CIEC_BOOL &DI04(){
- return *static_cast<CIEC_BOOL*>(getDO(6));
- }
- ;
-
- CIEC_BOOL &DI05(){
- return *static_cast<CIEC_BOOL*>(getDO(7));
- }
- ;
-
- CIEC_BOOL &DI06(){
- return *static_cast<CIEC_BOOL*>(getDO(8));
- }
- ;
-
- CIEC_BOOL &DI07(){
- return *static_cast<CIEC_BOOL*>(getDO(9));
- }
- ;
-
- CIEC_BOOL &DI08(){
- return *static_cast<CIEC_BOOL*>(getDO(10));
- }
- ;
-
- CIEC_BOOL &DI09(){
- return *static_cast<CIEC_BOOL*>(getDO(11));
- }
- ;
-
- CIEC_BOOL &DI10(){
- return *static_cast<CIEC_BOOL*>(getDO(12));
- }
- ;
-
- CIEC_BOOL &DI11(){
- return *static_cast<CIEC_BOOL*>(getDO(13));
- }
- ;
-
- CIEC_BOOL &DI12(){
- return *static_cast<CIEC_BOOL*>(getDO(14));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TEventID scm_nEventRSPID = 2;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TEventID scm_nEventINDID = 2;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(3, 3, 15, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
-
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
-
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DI937X){
- };
-
- virtual ~FORTE_X20DI937X(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DO4623.cpp b/src/modules/powerlink/X20DO4623.cpp
deleted file mode 100644
index f9f9073..0000000
--- a/src/modules/powerlink/X20DO4623.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DO4623.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DO4623_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_X20DO4623, g_nStringIdX20DO4623)
-
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04};
-
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL};
-
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS};
-
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING};
-
-const TForteInt16 FORTE_X20DO4623::scm_anEIWithIndexes[] = {0, 4};
-const TDataIOID FORTE_X20DO4623::scm_anEIWith[] = {0, 1, 2, 255, 3, 4, 5, 6, 0, 255};
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ};
-
-const TDataIOID FORTE_X20DO4623::scm_anEOWith[] = {0, 2, 1, 255, 2, 0, 255};
-const TForteInt16 FORTE_X20DO4623::scm_anEOWithIndexes[] = {0, 4, -1};
-const CStringDictionary::TStringId FORTE_X20DO4623::scm_anEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF};
-
-const SFBInterfaceSpec FORTE_X20DO4623::scm_stFBInterfaceSpec = {
- 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes,
- 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 7, scm_anDataInputNames, scm_anDataInputTypeIds,
- 3, scm_anDataOutputNames, scm_anDataOutputTypeIds,
- 0, 0
-};
-
-
-void FORTE_X20DO4623::executeEvent(int pa_nEIID){
- switch(pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Outputs (process inputs) always start with i = 0
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDIs && it != itEnd; i++, ++it){
- bool ioVal = *static_cast<CIEC_BOOL*>(getDI(i));
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DO4623::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- (eplStack.getProcImageIn())[it->m_nPiOffset] &= (char) (~(0x01 << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset] |= (char) (ioVal << it->m_nBitOffset);
- }
-
- m_oSync.unlock();
-}
-
-
-
diff --git a/src/modules/powerlink/X20DO4623.h b/src/modules/powerlink/X20DO4623.h
deleted file mode 100644
index af4cfd1..0000000
--- a/src/modules/powerlink/X20DO4623.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DO4623_H_
-#define _X20DO4623_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DO4623: public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DO4623)
-
-private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI() {
- return *static_cast<CIEC_BOOL*>(getDI(0));
- };
-
- CIEC_USINT &CNID() {
- return *static_cast<CIEC_USINT*>(getDI(1));
- };
-
- CIEC_UINT &MODID() {
- return *static_cast<CIEC_UINT*>(getDI(2));
- };
-
- CIEC_BOOL &DO01() {
- return *static_cast<CIEC_BOOL*>(getDI(3));
- };
-
- CIEC_BOOL &DO02() {
- return *static_cast<CIEC_BOOL*>(getDI(4));
- };
-
- CIEC_BOOL &DO03() {
- return *static_cast<CIEC_BOOL*>(getDI(5));
- };
-
- CIEC_BOOL &DO04() {
- return *static_cast<CIEC_BOOL*>(getDI(6));
- };
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO() {
- return *static_cast<CIEC_BOOL*>(getDO(0));
- };
-
- CIEC_USINT &CNIDO() {
- return *static_cast<CIEC_USINT*>(getDO(1));
- };
-
- CIEC_STRING &STATUS() {
- return *static_cast<CIEC_STRING*>(getDO(2));
- };
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 7, 3, 0);
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;
- CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
-public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DO4623){
- };
-
- virtual ~FORTE_X20DO4623(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
-
diff --git a/src/modules/powerlink/X20DO4649.cpp b/src/modules/powerlink/X20DO4649.cpp
deleted file mode 100644
index 409713b..0000000
--- a/src/modules/powerlink/X20DO4649.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DO4649.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DO4649_gen.cpp"
-#endif
-
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20DO4649, g_nStringIdX20DO4649)
-
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04 };
-
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_X20DO4649::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20DO4649::scm_anEIWith[] = { 0, 1, 2, 255, 3, 4, 5, 6, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20DO4649::scm_anEOWith[] = { 0, 2, 1, 255, 2, 0, 255 };
-const TForteInt16 FORTE_X20DO4649::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20DO4649::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20DO4649::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 7, scm_anDataInputNames, scm_anDataInputTypeIds, 3, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DO4649::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Outputs (process inputs) always start with i = 0
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDIs && it != itEnd; i++, ++it){
- bool ioVal = *static_cast<CIEC_BOOL*>(getDI(i));
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DO4649::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- (eplStack.getProcImageIn())[it->m_nPiOffset] &= (char) (~(0x01 << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset] |= (char) (ioVal << it->m_nBitOffset);
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20DO4649.h b/src/modules/powerlink/X20DO4649.h
deleted file mode 100644
index 163bddf..0000000
--- a/src/modules/powerlink/X20DO4649.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DO4649_H_
-#define _X20DO4649_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DO4649 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DO4649)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- CIEC_BOOL &DO01(){
- return *static_cast<CIEC_BOOL*>(getDI(3));
- }
- ;
-
- CIEC_BOOL &DO02(){
- return *static_cast<CIEC_BOOL*>(getDI(4));
- }
- ;
-
- CIEC_BOOL &DO03(){
- return *static_cast<CIEC_BOOL*>(getDI(5));
- }
- ;
-
- CIEC_BOOL &DO04(){
- return *static_cast<CIEC_BOOL*>(getDI(6));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 7, 3, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DO4649){
- };
-
- virtual ~FORTE_X20DO4649(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DO9321.cpp b/src/modules/powerlink/X20DO9321.cpp
deleted file mode 100644
index eaa8aa7..0000000
--- a/src/modules/powerlink/X20DO9321.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DO9321.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DO9321_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20DO9321, g_nStringIdX20DO9321)
-
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12 };
-
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_X20DO9321::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20DO9321::scm_anEIWith[] = { 0, 1, 2, 255, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20DO9321::scm_anEOWith[] = { 0, 2, 1, 255, 2, 0, 255 };
-const TForteInt16 FORTE_X20DO9321::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20DO9321::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20DO9321::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 15, scm_anDataInputNames, scm_anDataInputTypeIds, 3, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DO9321::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for inputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Outputs (process inputs) always start with i = 0
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
-
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDIs && it != itEnd; i++, ++it){
- bool ioVal = *static_cast<CIEC_BOOL*>(getDI(i));
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DO9321::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- (eplStack.getProcImageIn())[it->m_nPiOffset] &= (char) (~(0x01 << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset] |= (char) (ioVal << it->m_nBitOffset);
- }
-
- m_oSync.unlock();
-}
-
diff --git a/src/modules/powerlink/X20DO9321.h b/src/modules/powerlink/X20DO9321.h
deleted file mode 100644
index 63e4572..0000000
--- a/src/modules/powerlink/X20DO9321.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DO9321_H_
-#define _X20DO9321_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DO9321 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DO9321)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- CIEC_BOOL &DO01(){
- return *static_cast<CIEC_BOOL*>(getDI(3));
- }
- ;
-
- CIEC_BOOL &DO02(){
- return *static_cast<CIEC_BOOL*>(getDI(4));
- }
- ;
-
- CIEC_BOOL &DO03(){
- return *static_cast<CIEC_BOOL*>(getDI(5));
- }
- ;
-
- CIEC_BOOL &DO04(){
- return *static_cast<CIEC_BOOL*>(getDI(6));
- }
- ;
-
- CIEC_BOOL &DO05(){
- return *static_cast<CIEC_BOOL*>(getDI(7));
- }
- ;
-
- CIEC_BOOL &DO06(){
- return *static_cast<CIEC_BOOL*>(getDI(8));
- }
- ;
-
- CIEC_BOOL &DO07(){
- return *static_cast<CIEC_BOOL*>(getDI(9));
- }
- ;
-
- CIEC_BOOL &DO08(){
- return *static_cast<CIEC_BOOL*>(getDI(10));
- }
- ;
-
- CIEC_BOOL &DO09(){
- return *static_cast<CIEC_BOOL*>(getDI(11));
- }
- ;
-
- CIEC_BOOL &DO10(){
- return *static_cast<CIEC_BOOL*>(getDI(12));
- }
- ;
-
- CIEC_BOOL &DO11(){
- return *static_cast<CIEC_BOOL*>(getDI(13));
- }
- ;
-
- CIEC_BOOL &DO12(){
- return *static_cast<CIEC_BOOL*>(getDI(14));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 15, 3, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DO9321){
- };
-
- virtual ~FORTE_X20DO9321(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/X20DO9322.cpp b/src/modules/powerlink/X20DO9322.cpp
deleted file mode 100644
index efb5ce9..0000000
--- a/src/modules/powerlink/X20DO9322.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#include "X20DO9322.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "X20DO9322_gen.cpp"
-#endif
-
-#include "EplWrapper.h"
-#include "ProcessImageMatrix.h"
-
-DEFINE_FIRMWARE_FB(FORTE_X20DO9322, g_nStringIdX20DO9322)
-
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12 };
-
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL };
-
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_X20DO9322::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_X20DO9322::scm_anEIWith[] = { 0, 1, 2, 255, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 255 };
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_X20DO9322::scm_anEOWith[] = { 0, 2, 1, 255, 2, 0, 255 };
-const TForteInt16 FORTE_X20DO9322::scm_anEOWithIndexes[] = { 0, 4, -1 };
-const CStringDictionary::TStringId FORTE_X20DO9322::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_X20DO9322::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 15, scm_anDataInputNames, scm_anDataInputTypeIds, 3, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_X20DO9322::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- if(QI() == true){
- m_bInitOk = false;
-
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- // Get settings for intputs
- CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID());
-
- if(moduleIOs){
- // Outputs (process inputs) always start with i = 0
- // Check xap.xml if a BitUnused is present
- for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){
- m_oEplMapping.m_lCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2]));
- }
- delete moduleIOs;
-
- eplStack.registerCallback(static_cast<IEplCNCallback*>(this));
-
- m_bInitOk = true;
- }
- }
- QO() = QI();
- CNIDO() = CNID();
- sendOutputEvent(scm_nEventINITOID);
- break;
- case scm_nEventREQID:
- if(QI() == true && m_bInitOk){
- m_oSync.lock();
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(int i = 3; i < m_pstInterfaceSpec->m_nNumDIs && it != itEnd; i++, ++it){
- bool ioVal = *static_cast<CIEC_BOOL*>(getDI(i));
- *(it->m_pchCurrentValue) = (char) ioVal;
- }
- m_oSync.unlock();
- }
- QO() = QI();
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_X20DO9322::cnSynchCallback(){
- CEplStackWrapper &eplStack = CEplStackWrapper::getInstance();
-
- m_oSync.lock();
-
- SEplMapping::TEplMappingList::Iterator itEnd = m_oEplMapping.m_lCurrentValues.end();
- SEplMapping::TEplMappingList::Iterator it = m_oEplMapping.m_lCurrentValues.begin();
- for(it; it != itEnd; ++it){
- bool ioVal = *(it->m_pchCurrentValue) != 0x00;
- (eplStack.getProcImageIn())[it->m_nPiOffset] &= (char) (~(0x01 << it->m_nBitOffset));
- (eplStack.getProcImageIn())[it->m_nPiOffset] |= (char) (ioVal << it->m_nBitOffset);
- }
-
- m_oSync.unlock();
-}
diff --git a/src/modules/powerlink/X20DO9322.h b/src/modules/powerlink/X20DO9322.h
deleted file mode 100644
index 2b2541c..0000000
--- a/src/modules/powerlink/X20DO9322.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 AIT
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Filip Andren - initial API and implementation and/or initial documentation
- *******************************************************************************/
-#ifndef _X20DO9322_H_
-#define _X20DO9322_H_
-
-#include <funcbloc.h>
-
-#include "EplCNCallback.h"
-#include "EplWrapper.h"
-
-// cppcheck-suppress noConstructor
-class FORTE_X20DO9322 : public CFunctionBlock, public IEplCNCallback{
- DECLARE_FIRMWARE_FB(FORTE_X20DO9322)
-
- private:
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_USINT &CNID(){
- return *static_cast<CIEC_USINT*>(getDI(1));
- }
- ;
-
- CIEC_UINT &MODID(){
- return *static_cast<CIEC_UINT*>(getDI(2));
- }
- ;
-
- CIEC_BOOL &DO01(){
- return *static_cast<CIEC_BOOL*>(getDI(3));
- }
- ;
-
- CIEC_BOOL &DO02(){
- return *static_cast<CIEC_BOOL*>(getDI(4));
- }
- ;
-
- CIEC_BOOL &DO03(){
- return *static_cast<CIEC_BOOL*>(getDI(5));
- }
- ;
-
- CIEC_BOOL &DO04(){
- return *static_cast<CIEC_BOOL*>(getDI(6));
- }
- ;
-
- CIEC_BOOL &DO05(){
- return *static_cast<CIEC_BOOL*>(getDI(7));
- }
- ;
-
- CIEC_BOOL &DO06(){
- return *static_cast<CIEC_BOOL*>(getDI(8));
- }
- ;
-
- CIEC_BOOL &DO07(){
- return *static_cast<CIEC_BOOL*>(getDI(9));
- }
- ;
-
- CIEC_BOOL &DO08(){
- return *static_cast<CIEC_BOOL*>(getDI(10));
- }
- ;
-
- CIEC_BOOL &DO09(){
- return *static_cast<CIEC_BOOL*>(getDI(11));
- }
- ;
-
- CIEC_BOOL &DO10(){
- return *static_cast<CIEC_BOOL*>(getDI(12));
- }
- ;
-
- CIEC_BOOL &DO11(){
- return *static_cast<CIEC_BOOL*>(getDI(13));
- }
- ;
-
- CIEC_BOOL &DO12(){
- return *static_cast<CIEC_BOOL*>(getDI(14));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_USINT &CNIDO(){
- return *static_cast<CIEC_USINT*>(getDO(1));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 15, 3, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- // Variables for mapping between inputs and POWERLINK stack
- SEplMapping m_oEplMapping;CSyncObject m_oSync;
- bool m_bInitOk;
- // ...
-
- public:
- FUNCTION_BLOCK_CTOR(FORTE_X20DO9322){
- };
-
- virtual ~FORTE_X20DO9322(){};
-
- void cnSynchCallback();
-
-};
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/powerlink/readme.txt b/src/modules/powerlink/readme.txt
deleted file mode 100644
index ef7c87b..0000000
--- a/src/modules/powerlink/readme.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-openPOWERLINK interface for FORTE
-
-Instructions
-
-Prerequisits
-The following is needed in order to use openPOWERLINK with FORTE:
-
- - openPOWERLINK V1.8.0
- - TinyXML
-
-To use openPOWERLINK download openPOWERLINK V1.8.0 from Sourceforge (http://sourceforge.net/projects/openpowerlink/). The stack should be compiled using at least the following options in CMake:
-
- - CFG_POWERLINK_CHM
- - CFG_POWERLINK_PROCESS_IMAGE
- - CFG_X86_WINDOWS_DLL (only available on Windows)
-
-If compiled on Windows the resulting DLL and LIB must be copied to the main openPOWERLINK-V1.8.0 folder.
-
-TinyXML can be downloaded from http://sourceforge.net/projects/tinyxml/.
-
-Configure FORTE
-Check FORTE_MODULE_POWERLINK and set FORTE_MODULE_POWERLINK_LIB_DIR to [OPENPOWERLINK-V1.08.0_HOME] and FORTE_MODULE_POWERLINK_TINYXML_DIR to the directory where you unpacked TinyXML.
diff --git a/src/modules/ros/CMakeLists.txt b/src/modules/ros/CMakeLists.txt
deleted file mode 100644
index d57b0eb..0000000
--- a/src/modules/ros/CMakeLists.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-#############################################################################
-# Copyright (c) 2018 fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
-# Ben Schneider - initial API and implementation and/or initial documentation
-#############################################################################
-
-#############################################################################
-# ROS Example Publish and Subscribe FBs
-#############################################################################
-
-forte_add_module(ROS "Function Blocks to communicate with ROS (publish/subscribe)")
-
-if (FORTE_MODULE_ROS)
- forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-
- forte_add_definition("-DFORTE_ROS")
-
- #############################################################################
- # Communication Layer for ROS (publish, subscribe)
- #############################################################################
-
- forte_add_handler(CROSManager ROSManager)
- forte_add_handler(CServiceCallManager ServiceCallManager)
-
-
- forte_add_network_layer(ROS ON "ros" CROSLayer ROSLayer "Layer for providing and receiving data to/from ROS via publish/subscribe")
-
- forte_add_sourcefile_hcpp(ROSManager)
- forte_add_sourcefile_hcpp(ServiceCallManager)
- forte_add_sourcefile_hcpp(TRIGGER_SERVICE_CLIENT)
- forte_add_sourcefile_hcpp(TRIGGER_SERVICE_SERVER)
- forte_add_sourcefile_hcpp(EXECUTE_ACTION_CLIENT)
- forte_add_sourcefile_hcpp(EXECUTE_ACTION_SERVER)
-
-
- find_package(catkin QUIET COMPONENTS actionlib reapp_msgs roscpp std_msgs std_srvs topic_tools)
- if (catkin_FOUND)
- forte_add_include_directories(${catkin_INCLUDE_DIRS})
- else()
- forte_add_link_directories(/opt/ros/indigo/lib)
- forte_add_include_system_directories(/opt/ros/indigo/include)
-
- set(catkin_LIBRARIES
- -lroscpp
- -lrosconsole
- -lroscpp_serialization
- -ltopic_tools
- -lactionlib
-
- -lrostime
- -lboost_system
- -lboost_thread
- )
- endif(catkin_FOUND)
-
- forte_add_link_library(${catkin_LIBRARIES})
-
-endif(FORTE_MODULE_ROS)
diff --git a/src/modules/ros/EXECUTE_ACTION_CLIENT.cpp b/src/modules/ros/EXECUTE_ACTION_CLIENT.cpp
deleted file mode 100644
index ba91046..0000000
--- a/src/modules/ros/EXECUTE_ACTION_CLIENT.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include <ros/ros.h>
-#include "ROSManager.h"
-#include <extevhandlerhelper.h>
-
-#include "EXECUTE_ACTION_CLIENT.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "EXECUTE_ACTION_CLIENT_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_EXECUTE_ACTION_CLIENT, g_nStringIdEXECUTE_ACTION_CLIENT)
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdACTIONNAMESPACE, g_nStringIdACTIONMSGNAME, g_nStringIdCOMMAND, g_nStringIdID1, g_nStringIdID2 };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdDINT, g_nStringIdDINT };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdFBSTATUS, g_nStringIdACTIONSTATUS, g_nStringIdRESULT, g_nStringIdID, g_nStringIdSTATE };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdDINT, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_EXECUTE_ACTION_CLIENT::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_EXECUTE_ACTION_CLIENT::scm_anEIWith[] = { 0, 1, 2, 255, 0, 3, 4, 5, 255 };
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_EXECUTE_ACTION_CLIENT::scm_anEOWith[] = { 0, 1, 255, 0, 1, 2, 4, 3, 255, 5, 255 };
-const TForteInt16 FORTE_EXECUTE_ACTION_CLIENT::scm_anEOWithIndexes[] = { 0, 3, 9 };
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_CLIENT::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_EXECUTE_ACTION_CLIENT::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 6, scm_anDataInputNames, scm_anDataInputTypeIds, 6, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_EXECUTE_ACTION_CLIENT::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- //initialize FB
- if(!m_Initiated){
-
- connectToActionServer();
- QO() = true;
- }
- //already initialized
- else if(QI() && m_Initiated){
- FBSTATUS() = "Already initiated";
- QO() = true;
- }
- //termintate FB
- else if(!QI() && m_Initiated){
- m_ActionClient->cancelAllGoals();
- ros::shutdown();
- m_Initiated = false;
- FBSTATUS() = "Terminated - All goals canceled";
- QO() = false;
- }
- sendOutputEvent(scm_nEventINITOID);
- break;
-
- case scm_nEventREQID:
- //send new goal to the action server
- if(m_Initiated){
- //send new goal
- if(QI() && !m_GoalActive){
- if(m_ActionClient->isServerConnected()){
- //register the external eventchain on the thread of the Request event
- setEventChainExecutor(m_poInvokingExecEnv);
- reapp_msgs::ExecuteGoal goal;
- goal.id1 = ID1();
- goal.id2 = ID2();
- goal.command = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(COMMAND());
-
- m_ActionClient->sendGoal(goal, boost::bind(&FORTE_EXECUTE_ACTION_CLIENT::doneCallback, this, _1, _2), boost::bind(&FORTE_EXECUTE_ACTION_CLIENT::activeCallback, this), boost::bind(&FORTE_EXECUTE_ACTION_CLIENT::feedbackCallback, this, _1));
-
- FBSTATUS() = "New action goal sent";
- QO() = true;
- }
- else{ //not connected
- FBSTATUS() = "Sending goal not possible. Server not Connected";
- QO() = false;
- }
- }
- //ignore goals that are sent while another goal is active
- else if(!QI() && !m_GoalActive){
- FBSTATUS() = "Goal not sent, server busy";
- }
- //cancel the goal at the action server that was sent by the client
- else if(!QI() && m_GoalActive){
- FBSTATUS() = "Canceling goals";
- m_ActionClient->cancelAllGoals();
- FBSTATUS() = "Goals canceled";
- QO() = false;
- sendOutputEvent(scm_nEventCNFID);
- }
- }
-
- //FB is not initiated at all/correctly
- else{
- FBSTATUS() = "FB not initiated";
- QO() = false;
- }
- break;
-
- case cg_nExternalEventID:
- //we received feedback (QO=false)
- if(false == QO()){
-
- const std::string callbackFeedback = m_ExecuteFeedbackConstPtr->state;
-
- STATE() = callbackFeedback.c_str();
- FBSTATUS() = "Feedback received";
- }
- //we received a result (QO=true)
- else{
- const std::string callbackResultResult = m_ExecuteResultConstPtr->result;
- const int callbackResultID = m_ExecuteResultConstPtr->id;
- ID() = callbackResultID;
- RESULT() = callbackResultResult.c_str();
-
- ACTIONSTATUS() = getCurrentActionState().c_str();
- FBSTATUS() = "Result received";
- }
- sendOutputEvent(scm_nEventCNFID);
- break;
- }
-}
-
-void FORTE_EXECUTE_ACTION_CLIENT::doneCallback(const actionlib::SimpleClientGoalState&, const ExecuteResultConstPtr& pa_result){
- m_ExecuteResultConstPtr = pa_result;
-
- ACTIONSTATUS() = getCurrentActionState().c_str();
- QO() = true;
- m_GoalActive = false;
- getExtEvHandler<CROSManager>(*this).startChain(this);
-}
-
-void FORTE_EXECUTE_ACTION_CLIENT::activeCallback(){
- ACTIONSTATUS() = getCurrentActionState().c_str();
- m_GoalActive = true;
-}
-
-void FORTE_EXECUTE_ACTION_CLIENT::feedbackCallback(const ExecuteFeedbackConstPtr &pa_feedback){
- m_ExecuteFeedbackConstPtr = pa_feedback;
-
- ACTIONSTATUS() = getCurrentActionState().c_str();
- QO() = false;
- getExtEvHandler<CROSManager>(*this).startChain(this);
-}
-
-std::string FORTE_EXECUTE_ACTION_CLIENT::getCurrentActionState(){
- std::string retVal = "UNKNOWN";
-
- int i = m_ActionClient->getState().state_;
- switch (i){
- case actionlib::SimpleClientGoalState::PENDING:
- retVal = "PENDING";
- break;
- case actionlib::SimpleClientGoalState::ACTIVE:
- retVal = "ACTIVE";
- break;
- case actionlib::SimpleClientGoalState::PREEMPTED:
- retVal = "PREEMPTED";
- break;
- case actionlib::SimpleClientGoalState::SUCCEEDED:
- retVal = "SUCCEEDED";
- break;
- case actionlib::SimpleClientGoalState::ABORTED:
- case actionlib::SimpleClientGoalState::REJECTED:
- retVal = "ABORTED";
- break;
- case actionlib::SimpleClientGoalState::RECALLED:
- retVal = "RECALLED";
- break;
- case actionlib::SimpleClientGoalState::LOST:
- retVal = "LOST";
- break;
- }
- return retVal;
-}
-
-void FORTE_EXECUTE_ACTION_CLIENT::connectToActionServer(){
- m_RosNamespace = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(ACTIONNAMESPACE());
- m_RosMsgName = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(ACTIONMSGNAME());
- DEVLOG_DEBUG("[EXEC_CLIENT] Namespace: %s \nMessage name : %s \n", m_RosNamespace.c_str(), m_RosMsgName.c_str());
-
- nh = new ros::NodeHandle(m_RosNamespace);
-
- m_ActionClient = new actionClient(*nh, m_RosMsgName, true);
-
- FBSTATUS() = "Client waits for server";
- m_ActionClient->waitForServer();
- FBSTATUS() = "Client connected to server";
- m_Initiated = true;
-}
diff --git a/src/modules/ros/EXECUTE_ACTION_CLIENT.h b/src/modules/ros/EXECUTE_ACTION_CLIENT.h
deleted file mode 100644
index cd47601..0000000
--- a/src/modules/ros/EXECUTE_ACTION_CLIENT.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef _EXECUTE_ACTION_CLIENT_H_
-#define _EXECUTE_ACTION_CLIENT_H_
-
-#include <esfb.h>
-#include <forte_bool.h>
-#include <forte_string.h>
-#include <forte_dint.h>
-
-#include <actionlib/client/simple_action_client.h>
-#include <reapp_msgs/ExecuteAction.h>
-#include <reapp_msgs/ExecuteResult.h>
-
-typedef boost::shared_ptr<reapp_msgs::ExecuteResult const> ExecuteResultConstPtr;
-typedef boost::shared_ptr<reapp_msgs::ExecuteFeedback const> ExecuteFeedbackConstPtr;
-
-typedef actionlib::SimpleActionClient<reapp_msgs::ExecuteAction> actionClient;
-
-// cppcheck-suppress noConstructor
-class FORTE_EXECUTE_ACTION_CLIENT : public CEventSourceFB{
- DECLARE_FIRMWARE_FB(FORTE_EXECUTE_ACTION_CLIENT)
-
- private:
-
- bool m_Initiated;
- bool m_GoalActive;
- actionClient* m_ActionClient;
- ExecuteResultConstPtr m_ExecuteResultConstPtr;
- ExecuteFeedbackConstPtr m_ExecuteFeedbackConstPtr;
- bool mResultReady;
-
- ros::NodeHandle* nh;
- std::string m_RosNamespace;
- std::string m_RosMsgName;
-
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_STRING &ACTIONNAMESPACE(){
- return *static_cast<CIEC_STRING*>(getDI(1));
- }
- ;
-
- CIEC_STRING &ACTIONMSGNAME(){
- return *static_cast<CIEC_STRING*>(getDI(2));
- }
- ;
-
- CIEC_STRING &COMMAND(){
- return *static_cast<CIEC_STRING*>(getDI(3));
- }
- ;
-
- CIEC_DINT &ID1(){
- return *static_cast<CIEC_DINT*>(getDI(4));
- }
- ;
-
- CIEC_DINT &ID2(){
- return *static_cast<CIEC_DINT*>(getDI(5));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_STRING &FBSTATUS(){
- return *static_cast<CIEC_STRING*>(getDO(1));
- }
- ;
-
- CIEC_STRING &ACTIONSTATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_STRING &RESULT(){
- return *static_cast<CIEC_STRING*>(getDO(3));
- }
- ;
-
- CIEC_DINT &ID(){
- return *static_cast<CIEC_DINT*>(getDO(4));
- }
- ;
-
- CIEC_STRING &STATE(){
- return *static_cast<CIEC_STRING*>(getDO(5));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 6, 6, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- void doneCallback(const actionlib::SimpleClientGoalState& state, const ExecuteResultConstPtr& result);
- void activeCallback();
- void feedbackCallback(const ExecuteFeedbackConstPtr &feedback);
-
- std::string getCurrentActionState();
-
- void connectToActionServer();
-
- public:
- EVENT_SOURCE_FUNCTION_BLOCK_CTOR(FORTE_EXECUTE_ACTION_CLIENT), m_Initiated(false), m_GoalActive(false), m_ActionClient(0), mResultReady(false), nh(0), m_RosNamespace(""), m_RosMsgName(""){
- };
-
- virtual ~FORTE_EXECUTE_ACTION_CLIENT(){};
-
- };
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/ros/EXECUTE_ACTION_SERVER.cpp b/src/modules/ros/EXECUTE_ACTION_SERVER.cpp
deleted file mode 100644
index 194ca0e..0000000
--- a/src/modules/ros/EXECUTE_ACTION_SERVER.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ROSManager.h"
-#include <ros/ros.h>
-#include <extevhandlerhelper.h>
-
-#include "EXECUTE_ACTION_SERVER.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "EXECUTE_ACTION_SERVER_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_EXECUTE_ACTION_SERVER, g_nStringIdEXECUTE_ACTION_SERVER)
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdACTIONNAMESPACE, g_nStringIdACTIONMSGNAME, g_nStringIdRESULT, g_nStringIdID, g_nStringIdSTATE };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdDINT, g_nStringIdSTRING };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdFBSTATUS, g_nStringIdACTIONSTATUS, g_nStringIdCOMMAND, g_nStringIdID1, g_nStringIdID2 };
-
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdDINT, g_nStringIdDINT };
-
-const TForteInt16 FORTE_EXECUTE_ACTION_SERVER::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_EXECUTE_ACTION_SERVER::scm_anEIWith[] = { 0, 1, 2, 255, 0, 5, 4, 3, 255 };
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdRSP };
-
-const TDataIOID FORTE_EXECUTE_ACTION_SERVER::scm_anEOWith[] = { 0, 1, 255, 0, 1, 3, 2, 4, 5, 255 };
-const TForteInt16 FORTE_EXECUTE_ACTION_SERVER::scm_anEOWithIndexes[] = { 0, 3, -1 };
-const CStringDictionary::TStringId FORTE_EXECUTE_ACTION_SERVER::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdIND };
-
-const SFBInterfaceSpec FORTE_EXECUTE_ACTION_SERVER::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 6, scm_anDataInputNames, scm_anDataInputTypeIds, 6, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_EXECUTE_ACTION_SERVER::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
-
- if(QI() && !m_Initiated){
-
- m_RosNamespace = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(ACTIONNAMESPACE());
- m_RosMsgName = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(ACTIONMSGNAME());
- DEVLOG_DEBUG("[EXEC_SERVER] Namespace: %s \n[EXEC_SERVER] Message name : %s \n", m_RosNamespace.c_str(), m_RosMsgName.c_str());
-
- m_nh = new ros::NodeHandle(m_RosNamespace);
-
- m_ActionServer = new actionServer(*m_nh, m_RosMsgName, boost::bind(&FORTE_EXECUTE_ACTION_SERVER::ActionExecuteCB, this, _1), false);
- m_ActionServer->start(); //not needed if auto_start=true (last param in ctor of server)
-
- QO() = true;
- m_Initiated = true;
- FBSTATUS() = "Server started";
- }
-
- //server already initialized
- else if(QI() && m_Initiated){
- FBSTATUS() = "Server already initialized";
- QO() = true;
- }
- //terminate server and function block
- else{
- m_Initiated = false;
- m_ResultAvailable = false;
- if(m_ActionServer->isActive()){
- m_ActionServer->setAborted();
- }
- m_ActionServer->shutdown(); //TODO test this!
- //ros::shutdown();
- FBSTATUS() = "Action Server Shutdown";
- //DEVLOG_DEBUG("[EXEC_SERVER] Action server shutdown\n");
- }
- sendOutputEvent(scm_nEventINITOID);
- break;
-
- case scm_nEventRSPID:
- //send a result (see executeCB)
- if(QI()){
- m_Result.result = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(RESULT());
- m_Result.id = ID();
- FBSTATUS() = "Server sends result";
- m_ResultAvailable = true;
- }
- //send feedback
- else{
- // get feedback data from STATE() input
- m_Feedback.state = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(STATE());
- m_ActionServer->publishFeedback(m_Feedback);
- }
- break;
-
- //The server received a new goal
- case cg_nExternalEventID:
- if(m_ActionServer->isPreemptRequested() || !ros::ok()){
- m_ActionServer->setPreempted();
- ACTIONSTATUS() = "PREEMPTED";
- QO() = false;
- //DEVLOG_DEBUG("[EXEC_SERVER] ExternalEvent: preempted or !ok\n");
- }
- else{
- int stringLength = std::strlen(m_GoalConstPtr->command.c_str());
- CIEC_STRING tmpResult;
- tmpResult.assign(m_GoalConstPtr->command.c_str(), static_cast<TForteUInt16>(stringLength));
- COMMAND().saveAssign(tmpResult);
- ID1() = m_GoalConstPtr->id1;
- ID2() = m_GoalConstPtr->id2;
-
- FBSTATUS() = "Server received new goal";
- ACTIONSTATUS() = "ACTIVE";
- QO() = true;
- }
- sendOutputEvent(scm_nEventINDID);
- break;
- }
-}
-
-void FORTE_EXECUTE_ACTION_SERVER::ActionExecuteCB(const ExecuteGoalConstPtr &pa_goal){
-
- m_GoalConstPtr = pa_goal;
- ros::Rate r(2); //2Hz
-
- setEventChainExecutor(m_poInvokingExecEnv);
- //DEVLOG_DEBUG("[EXEC_SERVER] Received goal is: %s \n", mGoalConstPtr->command.c_str());
- getExtEvHandler<CROSManager>(*this).startChain(this);
-
- // FIXME better idea as flag polling?
- //wait for an available result(mResultAvailable set in case of RSP+)
- while(!m_ResultAvailable && m_Initiated){
- // send cyclic feedback here if needed
- // mActionServer->publishFeedback(mFeedback);
-
- r.sleep();
- }
- m_ResultAvailable = false;
- m_ActionServer->setSucceeded(m_Result);
- //DEVLOG_DEBUG("[EXEC_SERVER] result is: %s \n", mResult.result.c_str());
- FBSTATUS() = "Server has sent result for current goal";
- ACTIONSTATUS() = "SUCCEEDED";
-}
diff --git a/src/modules/ros/EXECUTE_ACTION_SERVER.h b/src/modules/ros/EXECUTE_ACTION_SERVER.h
deleted file mode 100644
index 1c39930..0000000
--- a/src/modules/ros/EXECUTE_ACTION_SERVER.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef _EXECUTE_ACTION_SERVER_H_
-#define _EXECUTE_ACTION_SERVER_H_
-
-#include <esfb.h>
-#include <forte_bool.h>
-#include <forte_string.h>
-#include <forte_dint.h>
-
-#include <actionlib/server/simple_action_server.h>
-#include <reapp_msgs/ExecuteAction.h>
-#include <reapp_msgs/ExecuteResult.h>
-
-typedef boost::shared_ptr<reapp_msgs::ExecuteGoal const> ExecuteGoalConstPtr; //Warum funktioniert boost::bind mit typedef, aber nicht ohne??
-typedef actionlib::SimpleActionServer<reapp_msgs::ExecuteAction> actionServer;
-
-// cppcheck-suppress noConstructor
-class FORTE_EXECUTE_ACTION_SERVER : public CEventSourceFB{
- DECLARE_FIRMWARE_FB(FORTE_EXECUTE_ACTION_SERVER)
-
- private:
-
- ros::NodeHandle* m_nh;
- std::string m_RosNamespace;
- std::string m_RosMsgName;
-
- bool m_Initiated;
- bool m_ResultAvailable;
- actionServer* m_ActionServer;
- reapp_msgs::ExecuteFeedback m_Feedback;
- reapp_msgs::ExecuteResult m_Result;
- ExecuteGoalConstPtr m_GoalConstPtr;
-
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_STRING &ACTIONNAMESPACE(){
- return *static_cast<CIEC_STRING*>(getDI(1));
- }
- ;
-
- CIEC_STRING &ACTIONMSGNAME(){
- return *static_cast<CIEC_STRING*>(getDI(2));
- }
- ;
-
- CIEC_STRING &RESULT(){
- return *static_cast<CIEC_STRING*>(getDI(3));
- }
- ;
-
- CIEC_DINT &ID(){
- return *static_cast<CIEC_DINT*>(getDI(4));
- }
- ;
-
- CIEC_STRING &STATE(){
- return *static_cast<CIEC_STRING*>(getDI(5));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_STRING &FBSTATUS(){
- return *static_cast<CIEC_STRING*>(getDO(1));
- }
- ;
-
- CIEC_STRING &ACTIONSTATUS(){
- return *static_cast<CIEC_STRING*>(getDO(2));
- }
- ;
-
- CIEC_STRING &COMMAND(){
- return *static_cast<CIEC_STRING*>(getDO(3));
- }
- ;
-
- CIEC_DINT &ID1(){
- return *static_cast<CIEC_DINT*>(getDO(4));
- }
- ;
-
- CIEC_DINT &ID2(){
- return *static_cast<CIEC_DINT*>(getDO(5));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventRSPID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventINDID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 6, 6, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- void ActionExecuteCB(const ExecuteGoalConstPtr &pa_goal);
-
- public:
- // cppcheck-suppress noConstructor
- EVENT_SOURCE_FUNCTION_BLOCK_CTOR(FORTE_EXECUTE_ACTION_SERVER), m_nh(0) ,m_RosNamespace(""), m_RosMsgName(""), m_Initiated(false), m_ResultAvailable(false), m_ActionServer(0) {
- };
-
- virtual ~FORTE_EXECUTE_ACTION_SERVER(){};
-
- };
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/ros/ROSLayer.cpp b/src/modules/ros/ROSLayer.cpp
deleted file mode 100644
index d569af6..0000000
--- a/src/modules/ros/ROSLayer.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ROSLayer.h"
-#include "ROSManager.h"
-
-#include <std_msgs/Float64.h>
-#include <std_msgs/Int32.h>
-#include <std_msgs/String.h>
-#include <std_msgs/Bool.h>
-#include <std_msgs/Empty.h>
-#include <commfb.h>
-
-using namespace forte::com_infra;
-
-CROSLayer::CROSLayer(CComLayer* pa_poUpperLayer, CBaseCommFB* pa_poComFB) :
- CComLayer(pa_poUpperLayer, pa_poComFB){
-
- m_eInterruptResp = e_ProcessDataOk;
- m_TopicName = "";
- m_TopicType = "";
- m_NumSDs = -1;
- m_NumRDs = -1;
-}
-
-CROSLayer::~CROSLayer(){
-
-}
-
-// initializes current layer
-EComResponse CROSLayer::openConnection(char *pa_acLayerParameter){
-
- EComResponse retVal = e_InitOk;
- m_eCommServiceType = getCommFB()->getComServiceType();
-
- std::string layerParams = pa_acLayerParameter;
-
- // extract layerparams from ID input between the square brackets
- // example: ID = ros[/signal:std_msgs/Float64], layerparams = /signal:std_msgs/Float64
- int doublePoint = static_cast<int>(layerParams.find_last_of(":"));
- m_TopicName = layerParams.substr(0, doublePoint);
-
- if(e_Subscriber == m_eCommServiceType){
-
- m_NumRDs = getCommFB()->getNumRD();
-
- if(0 == m_NumRDs || 1 == m_NumRDs){
- m_Sub = m_Nh.subscribe < topic_tools::ShapeShifter > (m_TopicName, 100, &CROSLayer::handleReceivedValue, const_cast<CROSLayer*>(this));
- }
- else{
- DEVLOG_ERROR("[ROSLAYER] Subscribers with more than 1 RD output are not supported at the moment");
- }
- }
- else if(e_Publisher == m_eCommServiceType){
- m_NumSDs = getCommFB()->getNumSD();
-
- if(0 == m_NumSDs){
- m_Pub = m_Nh.advertise < std_msgs::Empty > (m_TopicName, 100);
- }
- else if(1 == m_NumSDs){
-
- m_TopicType = layerParams.substr(doublePoint + 1);
-
- if("std_msgs/Float64" == m_TopicType) {
- m_Pub = m_Nh.advertise < std_msgs::Float64 > (m_TopicName, 100);
- } else if("std_msgs/Int32" == m_TopicType) {
- m_Pub = m_Nh.advertise < std_msgs::Int32 > (m_TopicName, 100);
- } else if("std_msgs/Bool" == m_TopicType) {
- m_Pub = m_Nh.advertise < std_msgs::Bool > (m_TopicName, 100);
- } else if("std_msgs/String" == m_TopicType) {
- m_Pub = m_Nh.advertise < std_msgs::String > (m_TopicName, 100);
- } else {
- DEVLOG_ERROR("[ROSLAYER] Publisher could not be initialized: unknown topic type \n");
- }
- //FIXME successful initialization message also on error..
- }
- else{
- retVal = e_InitInvalidId;
- DEVLOG_ERROR("[ROSLAYER] Publishers with more than 1 SD intput are not supported at the moment. There are %d SD inputs configured", m_NumSDs);
- }
- }
- // We are a Service
- else if(e_Server == m_eCommServiceType){
- //TODO implement this
- }
- else if(e_Client == m_eCommServiceType){
- //TODO implement this
- }
-
- else{
- retVal = e_InitInvalidId;
- DEVLOG_ERROR("[ROSLAYER] SIFB could not be initialized with an appropriate ROS communication type: block type is neither Publisher nor Subscriber nor Server nor Client\n");
- }
-
- return retVal;
-}
-
-// callback for subscribers
-void CROSLayer::handleReceivedValue(const boost::shared_ptr<const topic_tools::ShapeShifter>& pa_Message){
-
- // writing received values to RD output: getRDs() returns adress of Data from the RDs -> overwrite them
- CIEC_ANY *DataArray = getCommFB()->getRDs();
-
- m_TopicType = pa_Message->getDataType();
-
- if(0 == m_NumRDs){
-
- }
- else if(1 == m_NumRDs){
-
- if("std_msgs/Float64" == m_TopicType){
- boost::shared_ptr < std_msgs::Float64 > instantiated = pa_Message->instantiate<std_msgs::Float64>();
- double ROSValue = instantiated->data;
- *(CIEC_LREAL *) DataArray = ROSValue;
- }
- else if("std_msgs/Int32" == m_TopicType){
- boost::shared_ptr < std_msgs::Int32 > instantiated = pa_Message->instantiate<std_msgs::Int32>();
- int ROSValue = instantiated->data;
- *(CIEC_DINT *) DataArray = ROSValue;
- }
- else if("std_msgs/Bool" == m_TopicType){
- boost::shared_ptr < std_msgs::Bool > instantiated = pa_Message->instantiate<std_msgs::Bool>();
- bool ROSValue = instantiated->data;
- *(CIEC_BOOL *) DataArray = ROSValue;
- }
- else if("std_msgs/String" == m_TopicType){
- boost::shared_ptr < std_msgs::String > instantiated = pa_Message->instantiate<std_msgs::String>();
- std::string ROSValue = instantiated->data;
-
- int stringLength = static_cast<int>(std::strlen(ROSValue.c_str()));
- CIEC_STRING tmpString;
- tmpString.assign(ROSValue.c_str(), static_cast<TForteUInt16>(stringLength));
-
- *(CIEC_STRING *) DataArray = tmpString;
- }
- else{
- DEVLOG_ERROR("[ROSLAYER] Subscriber received a message with unknown type: %s \n", m_TopicType.c_str());
- }
- }
- else{
- // TODO implement this:
- DEVLOG_ERROR("[ROSLAYER] More than 1 RD outputs are not supported at the Moment \n");
- }
-
- getCommFB()->interruptCommFB(this);
-
- getExtEvHandler<CROSManager>().startChain(this->getCommFB());
-}
-
-void CROSLayer::closeConnection(){
- m_Nh.shutdown();
-}
-
-//TODO use sendData parameters instead of e.g., getCommFB()->getSDs()
-EComResponse CROSLayer::sendData(void *, unsigned int){
- EComResponse RetVal = e_ProcessDataOk;
-
- CIEC_ANY *DataArray = getCommFB()->getSDs();
-
- // process SD inputs
- if(0 == m_NumSDs){ //Publish 0
- std_msgs::Empty ROSValue;
- m_Pub.publish(ROSValue);
- }
- // Publish 1
- else if(1 == m_NumSDs){
- switch (DataArray->getDataTypeID()){
- case CIEC_ANY::e_BOOL: {
- std_msgs::Bool ROSValue;
- bool FORTEValue = (*(CIEC_BOOL *) DataArray);
-
- ROSValue.data = FORTEValue;
- m_Pub.publish(ROSValue);
- }
- break;
- case CIEC_ANY::e_LREAL: {
- std_msgs::Float64 ROSValue;
-
- double FORTEValue = *(CIEC_LREAL *) DataArray;
- ROSValue.data = FORTEValue;
-
- m_Pub.publish(ROSValue);
- }
- break;
- case CIEC_ANY::e_DINT: {
- std_msgs::Int32 ROSValue;
-
- int FORTEValue = *(CIEC_DINT *) DataArray;
- ROSValue.data = FORTEValue;
-
- m_Pub.publish(ROSValue);
- }
- break;
- case CIEC_ANY::e_STRING: {
- std_msgs::String ROSValue;
-
- CIEC_STRING ciecString = *(CIEC_STRING *) DataArray;
- const char * buf = ciecString.getValue();
- std::size_t len = std::strlen(buf);
- std::string tmpString(buf, 0, len);
-
- ROSValue.data = tmpString;
- m_Pub.publish(ROSValue);
- }
- break;
- case CIEC_ANY::e_ANY:
- case CIEC_ANY::e_SINT:
- case CIEC_ANY::e_INT:
- case CIEC_ANY::e_USINT:
- case CIEC_ANY::e_UINT:
- case CIEC_ANY::e_BYTE:
- case CIEC_ANY::e_WORD:
- case CIEC_ANY::e_LINT:
- case CIEC_ANY::e_UDINT:
- case CIEC_ANY::e_ULINT:
- case CIEC_ANY::e_DWORD:
- case CIEC_ANY::e_LWORD:
- case CIEC_ANY::e_REAL:
- case CIEC_ANY::e_WSTRING:
- case CIEC_ANY::e_DATE:
- case CIEC_ANY::e_DATE_AND_TIME:
- case CIEC_ANY::e_TIME_OF_DAY:
- case CIEC_ANY::e_TIME:
- case CIEC_ANY::e_DerivedData:
- case CIEC_ANY::e_DirectlyDerivedData:
- case CIEC_ANY::e_EnumeratedData:
- case CIEC_ANY::e_SubrangeData:
- case CIEC_ANY::e_ARRAY:
- case CIEC_ANY::e_STRUCT:
- case CIEC_ANY::e_External:
- case CIEC_ANY::e_Max:
- DEVLOG_ERROR("[ROSLAYER] Publisher with unsupported data type");
- break;
- }
- }
- // Publish n for n > 1
- else{
- DEVLOG_ERROR("[ROSLAYER] Publisher with more than 1 SD input is not supported at the moment");
- }
- return RetVal;
-}
-
-EComResponse CROSLayer::recvData(const void *, unsigned int){
- return e_ProcessDataOk;
-}
-
-EComResponse CROSLayer::processInterrupt(){
- //we don't need to do anything here (only 1 layer)
- return m_eInterruptResp;
-}
diff --git a/src/modules/ros/ROSLayer.h b/src/modules/ros/ROSLayer.h
deleted file mode 100644
index 849e1c1..0000000
--- a/src/modules/ros/ROSLayer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef CROSLAYER_H_
-#define CROSLAYER_H_
-
-#include <ros/ros.h>
-#include <ros/service_callback_helper.h>
-#include <topic_tools/shape_shifter.h>
-
-#include <comlayer.h>
-#include <extevhan.h>
-#include <forte_thread.h>
-#include <singlet.h>
-
-#include <string>
-
-class CROSLayer : public forte::com_infra::CComLayer{
-
- public:
- CROSLayer(forte::com_infra::CComLayer* pa_poUpperLayer, forte::com_infra::CBaseCommFB* pa_poComFB);
- virtual ~CROSLayer();
-
- virtual void closeConnection();
-
- virtual forte::com_infra::EComResponse sendData(void *pa_pvData, unsigned int pa_unSize);
- virtual forte::com_infra::EComResponse recvData(const void *pa_pvData, unsigned int pa_unSize);
-
- virtual forte::com_infra::EComResponse processInterrupt();
-
- private:
- virtual forte::com_infra::EComResponse openConnection(char *pa_acLayerParameter);
-
- forte::com_infra::EComServiceType m_eCommServiceType;
- forte::com_infra::EComResponse m_eInterruptResp;
-
- ros::NodeHandle m_Nh;
- ros::Publisher m_Pub;
- ros::Subscriber m_Sub;
- std::string m_TopicName;
- std::string m_TopicType;
- int m_NumRDs;
- int m_NumSDs;
-
- void handleReceivedValue(const boost::shared_ptr<const topic_tools::ShapeShifter>& pa_message);
-};
-
-#endif //_CROSLAYER_H_
diff --git a/src/modules/ros/ROSManager.cpp b/src/modules/ros/ROSManager.cpp
deleted file mode 100644
index 5769dd9..0000000
--- a/src/modules/ros/ROSManager.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ROSManager.h"
-
-#include <ros/ros.h>
-
-//------------------------- CROSLayer::CROSManager -------------------------
-
-DEFINE_HANDLER(CROSManager);
-
-CROSManager::CROSManager(CDeviceExecution& paDeviceExecution) : CExternalEventHandler(paDeviceExecution),
- CThread(/* long stacksize , 3500*/){
- start();
-}
-
-CROSManager::~CROSManager(){
- end();
-}
-
-void CROSManager::enableHandler(){
-
-}
-
-void CROSManager::disableHandler(){
- ros::shutdown();
-}
-
-void CROSManager::setPriority(int){
-//FIXME adjust thread priority correctly
-}
-
-int CROSManager::getPriority() const{
- return 0;
-}
-
-void CROSManager::startChain(CEventSourceFB *pa_poECStartF){
- if(0 != pa_poECStartF){
- startNewEventChain(pa_poECStartF);
- }
-}
-
-void CROSManager::run(){
- while(isAlive() && ros::ok()){
- ros::spinOnce();
- }
-}
-
-std::string CROSManager::ciecStringToStdString(const CIEC_STRING &pa_DataInput){
- return std::string(pa_DataInput.getValue());
-}
-
-CIEC_STRING CROSManager::stdStringToCiecString(const std::string &pa_inputString){
- int stringLength = static_cast<int>(std::strlen(pa_inputString.c_str()));
- CIEC_STRING tmpString;
- tmpString.assign(pa_inputString.c_str(), static_cast<TForteUInt16>(stringLength));
- return tmpString;
-}
diff --git a/src/modules/ros/ROSManager.h b/src/modules/ros/ROSManager.h
deleted file mode 100644
index ff852a0..0000000
--- a/src/modules/ros/ROSManager.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef CROSMANAGER_H_
-#define CROSMANAGER_H_
-
-#include <extevhan.h>
-#include <forte_thread.h>
-
-#include <forte_string.h>
-#include <string>
-
-class CROSManager : public CExternalEventHandler, private CThread{
- DECLARE_HANDLER(CROSManager)
-
- public:
- virtual void enableHandler();
- virtual void disableHandler();
- virtual void setPriority(int pa_prio);
- virtual int getPriority() const;
-
- void startChain(CEventSourceFB *pa_poECStartF);
- std::string ciecStringToStdString(const CIEC_STRING &pa_DataInput);
- CIEC_STRING stdStringToCiecString(const std::string &pa_inputString);
-
- protected:
- virtual void run();
-
-};
-
-#endif /* CROSMANAGER_H_ */
diff --git a/src/modules/ros/ServiceCallManager.cpp b/src/modules/ros/ServiceCallManager.cpp
deleted file mode 100644
index 9ac864b..0000000
--- a/src/modules/ros/ServiceCallManager.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ServiceCallManager.h"
-#include "TRIGGER_SERVICE_CLIENT.h"
-#include <ros/ros.h>
-#include <std_srvs/Trigger.h>
-
-//TODO add locking for the vector..
-
-DEFINE_HANDLER(CServiceCallManager);
-
-CServiceCallManager::CServiceCallManager(CDeviceExecution& paDeviceExecution) : CExternalEventHandler(paDeviceExecution),
- CThread(/* long stacksize , 3500*/){
- start();
-}
-
-CServiceCallManager::~CServiceCallManager(){
- end();
-}
-
-void CServiceCallManager::enableHandler(){
-}
-
-void CServiceCallManager::disableHandler(){
- ros::shutdown();
-}
-
-void CServiceCallManager::setPriority(int){
-}
-
-int CServiceCallManager::getPriority() const{
- return 0;
-}
-
-void CServiceCallManager::startChain(CEventSourceFB *pa_poECStartF){
- if(0 != pa_poECStartF){
- startNewEventChain(pa_poECStartF);
- }
-}
-
-void CServiceCallManager::queueServiceCall(FORTE_TRIGGER_SERVICE_CLIENT* pa_serviceClientPtr){
- m_callerVector.push_back(pa_serviceClientPtr);
-}
-
-void CServiceCallManager::queueConnectWait(FORTE_TRIGGER_SERVICE_CLIENT* pa_serviceClientPtr){
- m_connectVector.push_back(pa_serviceClientPtr);
-}
-
-void CServiceCallManager::run(){
- while(isAlive() && ros::ok()){
-
- if(!m_connectVector.empty()){
- m_connectVector.front()->waitForServer();
- m_connectVector.erase(m_connectVector.begin());
- }
-
- if(!m_callerVector.empty()){
- m_callerVector.front()->callService();
- m_callerVector.erase(m_callerVector.begin());
- }
- //TODO maybe sleep for a small amount of time?
- //this.waitfor(std::chrono::milliseconds(1));
- //this.sleepfor();
- }
-}
diff --git a/src/modules/ros/ServiceCallManager.h b/src/modules/ros/ServiceCallManager.h
deleted file mode 100644
index 85b76ad..0000000
--- a/src/modules/ros/ServiceCallManager.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef CSERVICECALLMANAGER_H
-#define CSERVICECALLMANAGER_H
-
-#include <esfb.h>
-#include <extevhan.h>
-#include <forte_thread.h>
-
-#include <vector>
-
-class FORTE_TRIGGER_SERVICE_CLIENT;
-
-class CServiceCallManager : public CExternalEventHandler, private CThread{
- DECLARE_HANDLER(CServiceCallManager)
-
- private:
- std::vector<FORTE_TRIGGER_SERVICE_CLIENT*> m_callerVector;
- std::vector<FORTE_TRIGGER_SERVICE_CLIENT*> m_connectVector;
-
- public:
- virtual void enableHandler();
- virtual void disableHandler();
- virtual void setPriority(int pa_prio);
- virtual int getPriority() const;
-
- void startChain(CEventSourceFB* pa_poECStartF);
- void queueServiceCall(FORTE_TRIGGER_SERVICE_CLIENT* pa_serviceClientPtr);
- void queueConnectWait(FORTE_TRIGGER_SERVICE_CLIENT* pa_serviceClientPtr);
-
- protected:
- virtual void run();
-
-};
-
-#endif
diff --git a/src/modules/ros/TRIGGER_SERVICE_CLIENT.cpp b/src/modules/ros/TRIGGER_SERVICE_CLIENT.cpp
deleted file mode 100644
index cb7603f..0000000
--- a/src/modules/ros/TRIGGER_SERVICE_CLIENT.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ServiceCallManager.h"
-#include "ROSManager.h"
-#include <extevhandlerhelper.h>
-
-#include "TRIGGER_SERVICE_CLIENT.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "TRIGGER_SERVICE_CLIENT_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_TRIGGER_SERVICE_CLIENT, g_nStringIdTRIGGER_SERVICE_CLIENT)
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdNAMESPACE, g_nStringIdSRVNAME };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS, g_nStringIdSUCCESS, g_nStringIdMESSAGE };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_TRIGGER_SERVICE_CLIENT::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_TRIGGER_SERVICE_CLIENT::scm_anEIWith[] = { 0, 1, 2, 255, 0, 255 };
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ };
-
-const TDataIOID FORTE_TRIGGER_SERVICE_CLIENT::scm_anEOWith[] = { 0, 1, 255, 0, 1, 2, 3, 255 };
-const TForteInt16 FORTE_TRIGGER_SERVICE_CLIENT::scm_anEOWithIndexes[] = { 0, 3, -1 };
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_CLIENT::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF };
-
-const SFBInterfaceSpec FORTE_TRIGGER_SERVICE_CLIENT::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 3, scm_anDataInputNames, scm_anDataInputTypeIds, 4, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_TRIGGER_SERVICE_CLIENT::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- //initiate
- if(!m_Initiated && QI()){
- setEventChainExecutor(m_poInvokingExecEnv);
- m_RosNamespace = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(NAMESPACE());
- m_RosMsgName = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(SRVNAME());
- m_nh = new ros::NodeHandle(m_RosNamespace);
- m_triggerClient = m_nh->serviceClient < std_srvs::Trigger > (m_RosMsgName);
- STATUS() = "Client waits for server";
-
- getExtEvHandler<CServiceCallManager>(*this).queueConnectWait(this);
- }
- //terminate
- else if(m_Initiated && !QI()){
- m_nh->shutdown();
- STATUS() = "Client terminated";
- QO() = false;
- m_Initiated = false;
- sendOutputEvent(scm_nEventINITOID);
- }
- //silently ignore other cases
- else{
- STATUS() = "Unknown init command sequence";
- sendOutputEvent(scm_nEventINITOID);
- }
- break;
- case scm_nEventREQID:
- //call service
- if(m_Initiated && QI()){
- STATUS() = "Request sent";
- //add to queue
- getExtEvHandler<CServiceCallManager>(*this).queueServiceCall(this);
- }
- //uninitialized or REQ-
- else{
- STATUS() = "Sending request not possible";
- QO() = false;
- sendOutputEvent(scm_nEventCNFID);
- }
- break;
- case cg_nExternalEventID:
- //waitForExistence returned
- if(!m_Initiated){
- m_Initiated = true;
- STATUS() = "Client connected to server";
- QO() = true;
- sendOutputEvent(scm_nEventINITOID);
- }
- //call returned
- else{
- sendOutputEvent(scm_nEventCNFID);
- }
- break;
- }
-}
-
-void FORTE_TRIGGER_SERVICE_CLIENT::callService(){
- bool srv_success = m_triggerClient.call(m_srv);
-
- SUCCESS() = m_srv.response.success;
- MESSAGE() = getExtEvHandler<CROSManager>(*this).stdStringToCiecString(m_srv.response.message);
-
- if(srv_success){
- QO() = true;
- STATUS() = "Response received";
- }
- else{
- QO() = false;
- STATUS() = "Receiving response failed";
- SUCCESS() = false;
- MESSAGE() = "failed";
- }
- getExtEvHandler<CServiceCallManager>(*this).startChain(this);
-}
-
-void FORTE_TRIGGER_SERVICE_CLIENT::waitForServer(){
-
- if (!m_triggerClient.waitForExistence()){
- DEVLOG_ERROR("[FORTE_TRIGGER_SERVICE_CLIENT] connection failed. Server not existing. \n");
- }
- else {
- getExtEvHandler<CServiceCallManager>(*this).startChain(this);
- }
-}
diff --git a/src/modules/ros/TRIGGER_SERVICE_CLIENT.h b/src/modules/ros/TRIGGER_SERVICE_CLIENT.h
deleted file mode 100644
index 565774c..0000000
--- a/src/modules/ros/TRIGGER_SERVICE_CLIENT.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef _TRIGGER_SERVICE_CLIENT_H_
-#define _TRIGGER_SERVICE_CLIENT_H_
-
-#include <esfb.h>
-#include <forte_bool.h>
-#include <forte_string.h>
-#include <ros/ros.h>
-#include <std_srvs/Trigger.h>
-
-class CServiceCallManager;
-
-// cppcheck-suppress noConstructor
-class FORTE_TRIGGER_SERVICE_CLIENT : public CEventSourceFB{
- DECLARE_FIRMWARE_FB(FORTE_TRIGGER_SERVICE_CLIENT)
-
- private:
-
- bool m_Initiated;
- ros::NodeHandle* m_nh;
- std::string m_RosNamespace;
- std::string m_RosMsgName;
-
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_STRING &NAMESPACE(){
- return *static_cast<CIEC_STRING*>(getDI(1));
- }
- ;
-
- CIEC_STRING &SRVNAME(){
- return *static_cast<CIEC_STRING*>(getDI(2));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(1));
- }
- ;
-
- CIEC_BOOL &SUCCESS(){
- return *static_cast<CIEC_BOOL*>(getDO(2));
- }
- ;
-
- CIEC_STRING &MESSAGE(){
- return *static_cast<CIEC_STRING*>(getDO(3));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventREQID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventCNFID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 3, 4, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- public:
- ros::ServiceClient m_triggerClient;
- std_srvs::Trigger m_srv;
-
- void callService();
- void waitForServer();
-
- // cppcheck-suppress noConstructor
- EVENT_SOURCE_FUNCTION_BLOCK_CTOR(FORTE_TRIGGER_SERVICE_CLIENT), m_Initiated(false) , m_RosNamespace(""), m_RosMsgName(""){
- };
-
- virtual ~FORTE_TRIGGER_SERVICE_CLIENT(){};
-
- };
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/ros/TRIGGER_SERVICE_SERVER.cpp b/src/modules/ros/TRIGGER_SERVICE_SERVER.cpp
deleted file mode 100644
index 4b558ae..0000000
--- a/src/modules/ros/TRIGGER_SERVICE_SERVER.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#include "ROSManager.h"
-#include <ros/ros.h>
-#include <extevhandlerhelper.h>
-
-#include "TRIGGER_SERVICE_SERVER.h"
-#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
-#include "TRIGGER_SERVICE_SERVER_gen.cpp"
-#endif
-
-DEFINE_FIRMWARE_FB(FORTE_TRIGGER_SERVICE_SERVER, g_nStringIdTRIGGER_SERVICE_SERVER)
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anDataInputNames[] = { g_nStringIdQI, g_nStringIdNAMESPACE, g_nStringIdSRVNAME, g_nStringIdSUCCESS, g_nStringIdMESSAGE };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdSTRING };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS };
-
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING };
-
-const TForteInt16 FORTE_TRIGGER_SERVICE_SERVER::scm_anEIWithIndexes[] = { 0, 4 };
-const TDataIOID FORTE_TRIGGER_SERVICE_SERVER::scm_anEIWith[] = { 0, 1, 2, 255, 0, 3, 4, 255 };
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anEventInputNames[] = { g_nStringIdINIT, g_nStringIdRSP };
-
-const TDataIOID FORTE_TRIGGER_SERVICE_SERVER::scm_anEOWith[] = { 0, 1, 255, 0, 1, 255 };
-const TForteInt16 FORTE_TRIGGER_SERVICE_SERVER::scm_anEOWithIndexes[] = { 0, 3, -1 };
-const CStringDictionary::TStringId FORTE_TRIGGER_SERVICE_SERVER::scm_anEventOutputNames[] = { g_nStringIdINITO, g_nStringIdIND };
-
-const SFBInterfaceSpec FORTE_TRIGGER_SERVICE_SERVER::scm_stFBInterfaceSpec = { 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes, 2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 5, scm_anDataInputNames, scm_anDataInputTypeIds, 2, scm_anDataOutputNames, scm_anDataOutputTypeIds, 0, 0 };
-
-void FORTE_TRIGGER_SERVICE_SERVER::executeEvent(int pa_nEIID){
- switch (pa_nEIID){
- case scm_nEventINITID:
- //initiate
- if(!m_Initiated && QI()){
-
- m_RosNamespace = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(NAMESPACE());
- m_RosMsgName = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(SRVNAME());
- m_nh = new ros::NodeHandle(m_RosNamespace);
- m_triggerServer = m_nh->advertiseService < FORTE_TRIGGER_SERVICE_SERVER > (m_RosMsgName, &FORTE_TRIGGER_SERVICE_SERVER::triggerCallback, const_cast<FORTE_TRIGGER_SERVICE_SERVER*>(this));
- m_Initiated = true;
- STATUS() = "Server initiated";
- QO() = true;
- }
- //terminate
- else if(m_Initiated && !QI()){
- m_nh->shutdown();
- STATUS() = "Server terminated";
- QO() = false;
- }
- else{
- STATUS() = "initiation or termination failed";
- QO() = false;
- }
- sendOutputEvent(scm_nEventINITOID);
- break;
-
- case scm_nEventRSPID:
- STATUS() = "Processing service request finished";
- m_ResponseAvailable = true;
- break;
-
- case cg_nExternalEventID:
- QO() = true;
- sendOutputEvent(scm_nEventINDID);
- break;
- }
-}
-
-//TODO use or delete first parameter
-bool FORTE_TRIGGER_SERVICE_SERVER::triggerCallback(std_srvs::Trigger::Request &, std_srvs::Trigger::Response &pa_resp){
- setEventChainExecutor(m_poInvokingExecEnv);
- getExtEvHandler<CROSManager>(*this).startChain(this);
-
- // is a response available
- ros::Rate r(2); //1Hz
- while(!m_ResponseAvailable){
- r.sleep();
- }
-
- //write response
- pa_resp.success = SUCCESS();
- pa_resp.message = getExtEvHandler<CROSManager>(*this).ciecStringToStdString(MESSAGE());
-
- m_ResponseAvailable = false;
-
- return true;
-}
diff --git a/src/modules/ros/TRIGGER_SERVICE_SERVER.h b/src/modules/ros/TRIGGER_SERVICE_SERVER.h
deleted file mode 100644
index 8ec3ed3..0000000
--- a/src/modules/ros/TRIGGER_SERVICE_SERVER.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 - 2017 fortiss GmbH
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Ben Schneider
- * - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef _TRIGGER_SERVICE_SERVER_H_
-#define _TRIGGER_SERVICE_SERVER_H_
-
-#include <esfb.h>
-#include <forte_bool.h>
-#include <forte_string.h>
-
-#include <std_srvs/Trigger.h>
-#include <string>
-
-// cppcheck-suppress noConstructor
-class FORTE_TRIGGER_SERVICE_SERVER : public CEventSourceFB{
- DECLARE_FIRMWARE_FB(FORTE_TRIGGER_SERVICE_SERVER)
-
- private:
-
- bool m_Initiated;
- ros::NodeHandle* m_nh;
- ros::ServiceServer m_triggerServer;
- std_srvs::Trigger m_srv;
- std::string m_RosNamespace;
- std::string m_RosMsgName;
- bool m_ResponseAvailable;
-
- static const CStringDictionary::TStringId scm_anDataInputNames[];
- static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
- CIEC_BOOL &QI(){
- return *static_cast<CIEC_BOOL*>(getDI(0));
- }
- ;
-
- CIEC_STRING &NAMESPACE(){
- return *static_cast<CIEC_STRING*>(getDI(1));
- }
- ;
-
- CIEC_STRING &SRVNAME(){
- return *static_cast<CIEC_STRING*>(getDI(2));
- }
- ;
-
- CIEC_BOOL &SUCCESS(){
- return *static_cast<CIEC_BOOL*>(getDI(3));
- }
- ;
-
- CIEC_STRING &MESSAGE(){
- return *static_cast<CIEC_STRING*>(getDI(4));
- }
- ;
-
- static const CStringDictionary::TStringId scm_anDataOutputNames[];
- static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
- CIEC_BOOL &QO(){
- return *static_cast<CIEC_BOOL*>(getDO(0));
- }
- ;
-
- CIEC_STRING &STATUS(){
- return *static_cast<CIEC_STRING*>(getDO(1));
- }
- ;
-
- static const TEventID scm_nEventINITID = 0;
- static const TEventID scm_nEventRSPID = 1;
- static const TForteInt16 scm_anEIWithIndexes[];
- static const TDataIOID scm_anEIWith[];
- static const CStringDictionary::TStringId scm_anEventInputNames[];
-
- static const TEventID scm_nEventINITOID = 0;
- static const TEventID scm_nEventINDID = 1;
- static const TForteInt16 scm_anEOWithIndexes[];
- static const TDataIOID scm_anEOWith[];
- static const CStringDictionary::TStringId scm_anEventOutputNames[];
-
- static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- FORTE_FB_DATA_ARRAY(2, 5, 2, 0)
- ;
-
- void executeEvent(int pa_nEIID);
-
- bool triggerCallback(std_srvs::Trigger::Request &pa_req, std_srvs::Trigger::Response &pa_resp);
-
- public:
- // cppcheck-suppress noConstructor
- EVENT_SOURCE_FUNCTION_BLOCK_CTOR(FORTE_TRIGGER_SERVICE_SERVER), m_Initiated(false), m_RosNamespace(""), m_RosMsgName(""), m_ResponseAvailable(false){
- };
-
- virtual ~FORTE_TRIGGER_SERVICE_SERVER(){};
- };
-
-#endif //close the ifdef sequence from the beginning of the file
diff --git a/src/modules/utils/E_STOPWATCH.h b/src/modules/utils/E_STOPWATCH.h
index 6289811..ac06bd9 100644
--- a/src/modules/utils/E_STOPWATCH.h
+++ b/src/modules/utils/E_STOPWATCH.h
@@ -78,7 +78,7 @@
CBasicFB(pa_poSrcRes, &scm_stFBInterfaceSpec, pa_nInstanceNameId, &scm_stInternalVars, m_anFBConnData, m_anFBVarsData) {
};
- virtual ~FORTE_E_STOPWATCH() = default;
+ virtual ~FORTE_E_STOPWATCH() {};
};
#endif // _E_STOPWATCH_H_
diff --git a/src/stdfblib/ita/DEV_MGR.cpp b/src/stdfblib/ita/DEV_MGR.cpp
index 22e9543..929fc81 100644
--- a/src/stdfblib/ita/DEV_MGR.cpp
+++ b/src/stdfblib/ita/DEV_MGR.cpp
@@ -61,6 +61,10 @@
if((true == QI()) && (false == QO())){
//this is the first time init is called try to load a boot file
ForteBootFileLoader loader(*this);
+ if(loader.needsExit()){
+ getResource().getDevice().changeFBExecutionState(cg_nMGM_CMD_Kill);
+ return;
+ }
if(loader.isOpen() && LOAD_RESULT_OK == loader.loadBootFile()){
DEVLOG_INFO("Bootfile correctly loaded\n");
}
diff --git a/src/stdfblib/ita/ForteBootFileLoader.cpp b/src/stdfblib/ita/ForteBootFileLoader.cpp
index 13d1dc5..a37114a 100644
--- a/src/stdfblib/ita/ForteBootFileLoader.cpp
+++ b/src/stdfblib/ita/ForteBootFileLoader.cpp
@@ -21,7 +21,7 @@
char* gCommandLineBootFile = 0;
-ForteBootFileLoader::ForteBootFileLoader(IBootFileCallback &paCallback) : mBootfile(0), mCallback(paCallback){
+ForteBootFileLoader::ForteBootFileLoader(IBootFileCallback &paCallback) : mBootfile(0), mCallback(paCallback), mNeedsExit(false){
openBootFile();
}
@@ -62,7 +62,7 @@
else{
if(0 != getenv("FORTE_BOOT_FILE_FAIL_MISSING")){
DEVLOG_ERROR("Boot file %s could not be opened and FORTE_BOOT_FILE_FAIL_MISSING is set. Failing...\n", bootFileName.getValue());
- exit(2);
+ mNeedsExit = true;
}
else{
DEVLOG_INFO("Boot file %s could not be opened. Skipping...\n", bootFileName.getValue());
diff --git a/src/stdfblib/ita/ForteBootFileLoader.h b/src/stdfblib/ita/ForteBootFileLoader.h
index 24d2d3c..8b1be33 100644
--- a/src/stdfblib/ita/ForteBootFileLoader.h
+++ b/src/stdfblib/ita/ForteBootFileLoader.h
@@ -44,9 +44,14 @@
return (0 != mBootfile);
}
+ bool needsExit() const {
+ return mNeedsExit;
+ }
+
private:
FILE *mBootfile;
IBootFileCallback &mCallback; //for now with one callback is enough for all cases
+ bool mNeedsExit;
bool openBootFile();
bool readLine(CIEC_STRING &line);