[openrtm-commit:02673] r3012 - in trunk/OpenRTM-aist: examples examples/SimpleIO src/lib src/lib/coil src/lib/coil/vxworks/coil src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 7月 11日 (火) 19:10:16 JST
Author: miyamoto
Date: 2017-07-11 19:10:16 +0900 (Tue, 11 Jul 2017)
New Revision: 3012
Added:
trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.cpp
trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.h
trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.cpp
trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.h
Modified:
trunk/OpenRTM-aist/examples/CMakeLists.txt
trunk/OpenRTM-aist/examples/SimpleIO/ConsoleInComp.cpp
trunk/OpenRTM-aist/src/lib/CMakeLists.txt
trunk/OpenRTM-aist/src/lib/Toolchain-vxworks6.cmake
trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
trunk/OpenRTM-aist/src/lib/rtm/CMakeLists.txt
trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
trunk/OpenRTM-aist/src/lib/rtm/RTObject.cpp
Log:
[incompat, VxWorks] add VxWorksRTExecutionContext and VxWorksInterruptExecutionContext.
Modified: trunk/OpenRTM-aist/examples/CMakeLists.txt
===================================================================
--- trunk/OpenRTM-aist/examples/CMakeLists.txt 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/examples/CMakeLists.txt 2017-07-11 10:10:16 UTC (rev 3012)
@@ -5,5 +5,5 @@
add_subdirectory(ExtTrigger)
add_subdirectory(SimpleService)
#add_subdirectory(StringIO)
+add_subdirectory(ConfigSample)
-
Modified: trunk/OpenRTM-aist/examples/SimpleIO/ConsoleInComp.cpp
===================================================================
--- trunk/OpenRTM-aist/examples/SimpleIO/ConsoleInComp.cpp 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/examples/SimpleIO/ConsoleInComp.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -96,10 +96,7 @@
int main (int argc, char** argv)
{
RTC::Manager* manager;
- const int argc_ = 5;
- const char *argv_[argc_] = { "ManagerTest", "-f", "/home/openrtm/testRTM/rtc.conf", "-o", "corba.nameservers:192.168.200.254" };
- manager = RTC::Manager::init(argc_, const_cast<char**>(argv_));
- //manager = RTC::Manager::init(argc, argv);
+ manager = RTC::Manager::init(argc, argv);
// Set module initialization proceduer
// This procedure will be invoked in activateManager() function.
Modified: trunk/OpenRTM-aist/src/lib/CMakeLists.txt
===================================================================
--- trunk/OpenRTM-aist/src/lib/CMakeLists.txt 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/CMakeLists.txt 2017-07-11 10:10:16 UTC (rev 3012)
@@ -8,17 +8,17 @@
SET(IDLCOMMAND_FLAGS -m -a -ex -fhh -fxcc -fc_c -fs -q -dOE_IDL -I${ORB_ROOT}/idl )
elseif(CORBA MATCHES "omniORB")
if(NOT IDL_COMPILE_COMMAND)
- set(IDL_COMPILE_COMMAND /home/openrtm/omniORB-4.2.2/build/bin/omniidl)
+ set(IDL_COMPILE_COMMAND ${ORB_ROOT}/build/bin/omniidl)
endif()
SET(IDLCOMMAND_FLAGS -bcxx -Wba -nf)
endif()
if(UNIX)
- set(SKELWRAPPER_COMMAND ${OPENRTM_DIRS}/utils/rtm-skelwrapper/rtm-skelwrapper)
+ set(SKELWRAPPER_COMMAND ${CMAKE_SOURCE_DIR}/utils/rtm-skelwrapper/rtm-skelwrapper)
elseif(VXWORKS)
- set(SKELWRAPPER_COMMAND ${OPENRTM_DIRS}/utils/rtm-skelwrapper/rtm-skelwrapper)
+ set(SKELWRAPPER_COMMAND ${CMAKE_SOURCE_DIR}/utils/rtm-skelwrapper/rtm-skelwrapper)
elseif(MSVC)
- set(SKELWRAPPER_COMMAND ${OPENRTM_DIRS}/utils/rtm-skelwrapper/rtm-skelwrapper.py)
+ set(SKELWRAPPER_COMMAND ${CMAKE_SOURCE_DIR}/utils/rtm-skelwrapper/rtm-skelwrapper.py)
endif()
Modified: trunk/OpenRTM-aist/src/lib/Toolchain-vxworks6.cmake
===================================================================
--- trunk/OpenRTM-aist/src/lib/Toolchain-vxworks6.cmake 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/Toolchain-vxworks6.cmake 2017-07-11 10:10:16 UTC (rev 3012)
@@ -31,6 +31,7 @@
+
#message(STATUS "test")
#message(STATUS ${VX_CPU_FAMILY})
@@ -40,18 +41,10 @@
SET (VX_CPU_VARIANT _ppc85XX_e500v2)
-if(NOT VX_VERSION)
- SET (VX_VERSION vxworks-6.9)
-endif()
-if("${VX_VERSION}" STREQUAL "vxworks-6.9")
- SET (GNU_VERSION 4.3.3)
- ADD_DEFINITIONS (-DVXWORKS_69)
-else()
- SET (GNU_VERSION 4.1.2)
- ADD_DEFINITIONS (-DVXWORKS_66)
-endif()
+
+
# ホストOSの判定
FIND_PROGRAM (UNAME uname)
MARK_AS_ADVANCED (UNAME)
@@ -69,6 +62,27 @@
SET (WIND_HOME "$ENV{WIND_HOME}")
ENDIF (VXWORKS_HOST_OS MATCHES "SunOS")
+
+if(NOT VX_VERSION)
+ SET (VX_VERSION vxworks-6.9)
+endif()
+
+if("${VX_VERSION}" STREQUAL "vxworks-6.9")
+ SET (GNU_VERSION 4.3.3)
+ ADD_DEFINITIONS (-DVXWORKS_69)
+ SET (WIND_UTIL_PATH ${WIND_HOME}/utilities-1.0/x86-linux2/bin)
+ SET (VXWORKS_MAJOR 6)
+ SET (VXWORKS_MINOR 9)
+else()
+ SET (GNU_VERSION 4.1.2)
+ ADD_DEFINITIONS (-DVXWORKS_66)
+ SET (WIND_UTIL_PATH ${WIND_HOME}/workbench-3.0/x86-linux2/bin)
+ SET (VXWORKS_MAJOR 6)
+ SET (VXWORKS_MINOR 6)
+endif()
+
+
+
# Path Settings
SET (WIND_BASE ${WIND_HOME}/${VX_VERSION})
SET (WIND_GNU_BASE ${WIND_HOME}/gnu/${GNU_VERSION}-${VX_VERSION}/${WIND_HOST_TYPE})
@@ -80,9 +94,8 @@
################################################################################
SET (VXWORKS ON)
-SET (VXWORKS_MAJOR 6)
-SET (VXWORKS_MINOR 6)
+
SET (CMAKE_SYSTEM_NAME VxWorks)
SET (CMAKE_SYSTEM_VERSION ${VX_VERSION})
SET (CMAKE_SYSTEM_PROCESSOR ${VX_CPU_FAMILY})
@@ -94,31 +107,34 @@
CMAKE_FORCE_CXX_COMPILER(${WIND_GNU_BASE}/bin/c++ppc GNU)
SET (CMAKE_LINKER ${WIND_GNU_BASE}/bin/ldppc CACHE FILEPATH "vxworks linker")
SET (CMAKE_AR ${WIND_GNU_BASE}/bin/arppc CACHE FILEPATH "vxworks ar")
- SET (CMAKE_NM ${WIND_GNU_BASE}/bin/nmppc CACHE FILEPATH "vxworks nm")
- SET (CMAKE_STRIP ${WIND_GNU_BASE}/bin/stripppc CACHE FILEPATH "vxworks strip")
- SET (CMAKE_OBJCOPY ${WIND_GNU_BASE}/bin/objcopyppc CACHE FILEPATH "vxworks objcopy")
- SET (CMAKE_OBJDUMP ${WIND_GNU_BASE}/bin/objdumpppc CACHE FILEPATH "vxworks objdump")
+ SET (CMAKE_NM ${WIND_UTIL_PATH}/nmppc CACHE FILEPATH "vxworks nm")
+ SET (CMAKE_STRIP ${WIND_UTIL_PATH}/stripppc CACHE FILEPATH "vxworks strip")
+ SET (CMAKE_OBJCOPY ${WIND_UTIL_PATH}/objcopyppc CACHE FILEPATH "vxworks objcopy")
+ SET (CMAKE_OBJDUMP ${WIND_UTIL_PATH}/objdumpppc CACHE FILEPATH "vxworks objdump")
SET (CMAKE_RANLIB ${WIND_GNU_BASE}/bin/ranlibppc CACHE FILEPATH "vxworks ranlib")
+ SET (CPU_TYPE powerpc)
elseif("${VX_CPU_FAMILY}" STREQUAL "simpentium")
CMAKE_FORCE_C_COMPILER(${WIND_GNU_BASE}/bin/ccpentium GNU)
CMAKE_FORCE_CXX_COMPILER(${WIND_GNU_BASE}/bin/c++pentium GNU)
SET (CMAKE_LINKER ${WIND_GNU_BASE}/bin/ldpentium CACHE FILEPATH "vxworks linker")
SET (CMAKE_AR ${WIND_GNU_BASE}/bin/arpentium CACHE FILEPATH "vxworks ar")
- SET (CMAKE_NM ${WIND_GNU_BASE}/bin/nmpentium CACHE FILEPATH "vxworks nm")
- SET (CMAKE_STRIP ${WIND_GNU_BASE}/bin/strippentium CACHE FILEPATH "vxworks strip")
- SET (CMAKE_OBJCOPY ${WIND_GNU_BASE}/bin/objcopypentium CACHE FILEPATH "vxworks objcopy")
- SET (CMAKE_OBJDUMP ${WIND_GNU_BASE}/bin/objdumppentium CACHE FILEPATH "vxworks objdump")
+ SET (CMAKE_NM ${WIND_UTIL_PATH}/nmpentium CACHE FILEPATH "vxworks nm")
+ SET (CMAKE_STRIP ${WIND_UTIL_PATH}/strippentium CACHE FILEPATH "vxworks strip")
+ SET (CMAKE_OBJCOPY ${WIND_UTIL_PATH}/objcopypentium CACHE FILEPATH "vxworks objcopy")
+ SET (CMAKE_OBJDUMP ${WIND_UTIL_PATH}/objdumppentium CACHE FILEPATH "vxworks objdump")
SET (CMAKE_RANLIB ${WIND_GNU_BASE}/bin/ranlibpentium CACHE FILEPATH "vxworks ranlib")
+ SET (CPU_TYPE simpentium)
elseif("${VX_CPU_FAMILY}" STREQUAL "simlinux")
CMAKE_FORCE_C_COMPILER(${WIND_GNU_BASE}/bin/ccpentium GNU)
CMAKE_FORCE_CXX_COMPILER(${WIND_GNU_BASE}/bin/c++pentium GNU)
SET (CMAKE_LINKER ${WIND_GNU_BASE}/bin/ldpentium CACHE FILEPATH "vxworks linker")
SET (CMAKE_AR ${WIND_GNU_BASE}/bin/arpentium CACHE FILEPATH "vxworks ar")
- SET (CMAKE_NM ${WIND_GNU_BASE}/bin/nmpentium CACHE FILEPATH "vxworks nm")
- SET (CMAKE_STRIP ${WIND_GNU_BASE}/bin/strippentium CACHE FILEPATH "vxworks strip")
- SET (CMAKE_OBJCOPY ${WIND_GNU_BASE}/bin/objcopypentium CACHE FILEPATH "vxworks objcopy")
- SET (CMAKE_OBJDUMP ${WIND_GNU_BASE}/bin/objdumppentium CACHE FILEPATH "vxworks objdump")
+ SET (CMAKE_NM ${WIND_UTIL_PATH}/nmpentium CACHE FILEPATH "vxworks nm")
+ SET (CMAKE_STRIP ${WIND_UTIL_PATH}/strippentium CACHE FILEPATH "vxworks strip")
+ SET (CMAKE_OBJCOPY ${WIND_UTIL_PATH}/objcopypentium CACHE FILEPATH "vxworks objcopy")
+ SET (CMAKE_OBJDUMP ${WIND_UTIL_PATH}/objdumppentium CACHE FILEPATH "vxworks objdump")
SET (CMAKE_RANLIB ${WIND_GNU_BASE}/bin/ranlibpentium CACHE FILEPATH "vxworks ranlib")
+ SET (CPU_TYPE simlinux)
endif()
@@ -128,12 +144,17 @@
SET (CMAKE_EXE_LINKER_FLAGS_INIT -r)
+SET (VSB_DIR ${WIND_BASE}/target/lib)
+SET (VSB_CONFIG_FILE ${VSB_DIR}/h/config/vsbConfig.h)
FIND_PROGRAM (SH sh REQUIRED)
-SET (MUNCH ${WIND_BASE}/host/${WIND_HOST_TYPE}/bin/munch CACHE FILEPATH "munch")
+
+
+
+
SET (CMAKE_C_COMPILE_OBJECT
"${WIND_ENV} <CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
SET (CMAKE_CXX_COMPILE_OBJECT
@@ -158,6 +179,7 @@
SET (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "")
SET (CC_ARCH_SPEC "-mhard-float -fno-implicit-fp -mstrict-align -mregnames -D_WRS_HARDWARE_FP")
+ SET (NM_FLAG ppc)
elseif("${VX_CPU_FAMILY}" STREQUAL "simpentium")
@@ -171,6 +193,7 @@
SET (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "")
SET (CC_ARCH_SPEC "-mtune=i486 -march=i486")
+ SET (NM_FLAG pentium)
elseif("${VX_CPU_FAMILY}" STREQUAL "simlinux")
@@ -185,23 +208,46 @@
SET (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "")
SET (CC_ARCH_SPEC "-mtune=i486 -march=i486")
+ SET (NM_FLAG pentium)
endif()
if(RTP)
#set(CMAKE_EXE_LINKER_FLAGS "${CC_ARCH_SPEC} ${RTP_C_FLAGS} -fno-strict-aliasing -fasm -Wall" )
- set(CMAKE_EXE_LINKER_FLAGS "${CC_ARCH_SPEC} ${RTP_C_FLAGS} -fno-strict-aliasing -lstdc++ -fasm -D_WRS_HARDWARE_FP -Wall" )
+ set(CMAKE_EXE_LINKER_FLAGS "${CC_ARCH_SPEC} ${RTP_C_FLAGS} -Xbind-lazy -non-static -fno-strict-aliasing -lstdc++ -fasm -D_WRS_HARDWARE_FP -Wall" )
else(RTP)
+ set(CMAKE_PARTICALIMAGE_LINKER_FLAGS "-nostdlib -Wl,-X " )
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,-X -T ${WIND_BASE}/target/h/tool/gnu/ldscripts/link.OUT " )
endif()
+if(RTP)
+ SET (CMAKE_C_LINK_EXECUTABLE
+ "${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ SET (CMAKE_CXX_LINK_EXECUTABLE
+ "${CMAKE_CXX_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+else(RTP)
+#SET (MUNCH ${WIND_BASE}/host/${WIND_HOST_TYPE}/bin/munch CACHE FILEPATH "munch")
+SET (MUNCH ${WIND_BASE}/host/resource/hutils/tcl/munch.tcl CACHE FILEPATH "munch")
+ if("${VX_VERSION}" STREQUAL "vxworks-6.9")
+ SET (TCLSH ${WIND_HOME}/workbench-3.3/foundation/x86-linux2/bin/tclsh CACHE FILEPATH "tclsh")
+ else()
+ SET (TCLSH ${WIND_HOME}/workbench-3.0/foundation/4.1.1/x86-linux2/bin/tclsh CACHE FILEPATH "tclsh")
+
+ endif()
+ SET (TAGS ${VSB_DIR}/tags/${VX_CPU_FAMILY}/${VX_CPU}/common/dkm.tags CACHE FILEPATH "tags")
+ string(REPLACE ";" " " VXWORKS_C_FLAGS_LIST_STR "${VXWORKS_C_FLAGS_LIST}")
+ SET (RUN_MUNCH_SCRIPT ${CMAKE_SOURCE_DIR}/run_munch.sh)
+ SET (CMAKE_C_LINK_EXECUTABLE
+ "${CMAKE_C_COMPILER} ${CMAKE_PARTICALIMAGE_LINKER_FLAGS} -o <TARGET>_partialImage.o <OBJECTS> <LINK_LIBRARIES>"
+ "sh ${RUN_MUNCH_SCRIPT} ${CMAKE_NM} <TARGET>_partialImage.o ${TCLSH} ${MUNCH} ${NM_FLAG} ${TAGS} ctdt.c"
+# "${CMAKE_NM} <TARGET>_partialImage.o | ${TCLSH} ${MUNCH} -c ${VX_CPU_FAMILY} -tags ${TAGS} > ctdt.c"
+ "${CMAKE_C_COMPILER} ${CC_ARCH_SPEC} -nostdlib -fno-builtin -fdollars-in-identifiers -Wall ${VXWORKS_C_FLAGS_LIST_STR} -o ctdt.o -c ctdt.c"
+ "${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -o <TARGET> <TARGET>_partialImage.o ctdt.o <LINK_LIBRARIES> -lstdc++"
+ )
+ SET (CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
+endif()
-SET (CMAKE_C_LINK_EXECUTABLE
- "${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
-SET (CMAKE_CXX_LINK_EXECUTABLE
- "${CMAKE_CXX_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
-
#if(RTP)
# set(CMAKE_EXE_LINKER_FLAGS "${CC_ARCH_SPEC} ${RTP_C_FLAGS} -fno-strict-aliasing -fasm -Wall" )
#else(RTP)
@@ -225,12 +271,10 @@
INCLUDE_DIRECTORIES (
${VX_VW_BASE}/h
${VX_VW_BASE}/h/wrn/coreip)
-message(STATUS ${VX_VW_BASE}/h/wrn/coreip)
+#message(STATUS ${VX_VW_BASE}/h/wrn/coreip)
endif()
-SET (VSB_DIR ${WIND_BASE}/target/lib)
-SET (VSB_CONFIG_FILE ${VSB_DIR}/h/config/vsbConfig.h)
@@ -237,29 +281,24 @@
+
SET (VXWORKS_C_FLAGS_LIST
+ -DCPU=${VX_CPU} -DVX_CPU_CARD=${VX_CPU_CARD} -DTOOL_FAMILY=${VX_TOOL_FAMILY} -DTOOL=${VX_TOOL} -DCPU_VARIANT=${VX_CPU_VARIANT} -DVXWORKS_MAJOR=${VXWORKS_MAJOR} -DVXWORKS_MINOR=${VXWORKS_MINOR} -DVXWORKS )
+
+
# -D_VX_CPU=_VX_${VX_CPU}
# -D_VX_CPU_FAMILY=_VX_${VX_CPU}
# -D_VX_TOOL_FAMILY=${VX_TOOL_FAMILY}
# -D_VX_TOOL=${VX_TOOL}
- -DCPU=${VX_CPU}
- -DVX_CPU_CARD=${VX_CPU_CARD}
# -DCPU_FAMILY=_${CPU_FAMILY}
- -DTOOL_FAMILY=${VX_TOOL_FAMILY}
- -DTOOL=${VX_TOOL}
- -D_WRS_KERNEL
- -DCPU_VARIANT=${VX_CPU_VARIANT}
# -D_VSB_CONFIG_FILE="${VSB_CONFIG_FILE}"
- -DVXWORKS_MAJOR=${VXWORKS_MAJOR}
- -DVXWORKS_MINOR=${VXWORKS_MINOR}
- -DVXWORKS
+# -D_WRS_KERNEL
# ${CC_ARCH_SPEC}
# -ansi
# -mrtp
- )
-ADD_DEFINITIONS (${VXWORKS_C_FLAGS_LIST})
+ADD_DEFINITIONS (${VXWORKS_C_FLAGS_LIST} -Xbind-lazy -non-static)
@@ -270,12 +309,6 @@
if("${VX_CPU_FAMILY}" STREQUAL "ppc")
if(RTP)
SET (CPU_C_FLAGS_LIST
- ${RTP_C_FLAGS}
- -mregnames
- -msoft-float
- )
- else(RTP)
- SET (CPU_C_FLAGS_LIST
-mlongcall
-fstrength-reduce
-fno-builtin
@@ -288,6 +321,13 @@
-fno-implicit-fp
${RTP_C_FLAGS}
)
+ else(RTP)
+ SET (CPU_C_FLAGS_LIST
+ ${RTP_C_FLAGS}
+ -mregnames
+ -msoft-float
+ -D_WRS_KERNEL
+ )
endif()
elseif("${VX_CPU_FAMILY}" STREQUAL "simpentium")
SET (CPU_C_FLAGS_LIST
@@ -302,6 +342,7 @@
-march=i486
-ansi
${RTP_C_FLAGS}
+ -D_WRS_KERNEL
)
endif()
Modified: trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt 2017-07-11 10:10:16 UTC (rev 3012)
@@ -28,7 +28,7 @@
option (HAVE_SYS_TYPES_H "Define to 1 if you have the <sys/types.h> header file." ON)
option (HAVE_UNAME "Define to 1 if you have the `uname' function." ON)
option (HAVE_UNISTD_H "Define to 1 if you have the <unistd.h> header file." ON)
-option (STDC_HEADERS "Define to 1 if you have the ANSI C header files." ON)
+option (STDC_HEADERS "Define to 1 if you have the ANSI C header files." OFF)
option (WITH_ACE "compiled with ACE" OFF)
option (WITH_DMALLOC "Define if using the dmalloc debugging malloc package" OFF)
option (_REENTRANT "Multi Thread Support" ON)
Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h 2017-07-11 10:10:16 UTC (rev 3012)
@@ -23,6 +23,10 @@
#include <algorithm>
#include <ctime>
+#include <semLib.h>
+#include <sysLib.h>
+#include <taskLib.h>
+/*
#ifdef __RTP__
#include <semLib.h>
#include <sysLib.h>
@@ -34,6 +38,7 @@
#include <sys/time.h>
#endif
#endif
+*/
@@ -75,11 +80,14 @@
Condition(M& mutex)
: m_mutex(mutex)
{
+ m_cond = semCCreate(SEM_Q_PRIORITY, 0);
+/*
#ifdef __RTP__
m_cond = semCCreate(SEM_Q_PRIORITY, 0);
#else
::pthread_cond_init(&m_cond, 0);
#endif
+*/
}
/*!
@@ -99,11 +107,14 @@
*/
~Condition()
{
+ semDelete(m_cond);
+/*
#ifdef __RTP__
semDelete(m_cond);
#else
::pthread_cond_destroy(&m_cond);
#endif
+*/
}
/*!
@@ -123,11 +134,14 @@
*/
inline void signal()
{
+ semGive(m_cond);
+/*
#ifdef __RTP__
semGive(m_cond);
#else
::pthread_cond_signal(&m_cond);
#endif
+*/
}
/*!
@@ -147,11 +161,14 @@
*/
inline void broadcast()
{
+ semFlush(m_cond);
+/*
#ifdef __RTP__
semFlush(m_cond);
#else
::pthread_cond_broadcast(&m_cond);
#endif
+*/
}
/*!
@@ -175,6 +192,21 @@
*/
bool wait()
{
+#ifndef __RTP__
+ taskLock();
+#endif
+ m_mutex.unlock();
+ STATUS status = semTake(m_cond, WAIT_FOREVER);
+#ifndef __RTP__
+ taskUnlock();
+#endif
+ if(status != OK)
+ {
+ return -1;
+ }
+ m_mutex.lock();
+ return 0;
+/*
#ifdef __RTP__
//taskLock();
m_mutex.unlock();
@@ -189,6 +221,7 @@
#else
return 0 == ::pthread_cond_wait(&m_cond, &m_mutex.mutex_);
#endif
+*/
}
/*!
@@ -218,6 +251,27 @@
*/
bool wait(long second, long nano_second = 0)
{
+#ifndef __RTP__
+ taskLock();
+#endif
+ m_mutex.unlock();
+ long timeout = (second*1000 + nano_second/1000000l);
+ int ticks = (timeout*sysClkRateGet()) / 1000l;
+ STATUS status = semTake(m_cond, ticks);
+#ifndef __RTP__
+ taskUnlock();
+#endif
+
+ m_mutex.lock();
+ if(status != OK)
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+/*
#ifdef __RTP__
//taskLock();
m_mutex.unlock();
@@ -255,16 +309,20 @@
}
return 0 == ::pthread_cond_timedwait(&m_cond, &m_mutex.mutex_, &abstime);
#endif
+*/
}
private:
Condition(const M&);
Condition& operator=(const M &);
+ SEM_ID m_cond;
+/*
#ifdef __RTP__
SEM_ID m_cond;
#else
pthread_cond_t m_cond;
#endif
+*/
M& m_mutex;
};
};
Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h 2017-07-11 10:10:16 UTC (rev 3012)
@@ -22,9 +22,12 @@
#include <pthread.h>
+#include <semLib.h>
+/*
#ifdef __RTP__
#include <semLib.h>
#endif
+*/
namespace coil
{
@@ -65,11 +68,14 @@
*/
Mutex(const char * const name = 0)
{
+ mutex_ = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE);
+/*
#ifdef __RTP__
mutex_ = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE);
#else
::pthread_mutex_init(&mutex_, 0);
#endif
+*/
}
/*!
@@ -89,11 +95,14 @@
*/
~Mutex()
{
+ semDelete(mutex_);
+/*
#ifdef __RTP__
semDelete(mutex_);
#else
::pthread_mutex_destroy(&mutex_);
#endif
+*/
}
/*!
@@ -113,11 +122,14 @@
*/
inline void lock()
{
+ semTake(mutex_, WAIT_FOREVER);
+/*
#ifdef __RTP__
semTake(mutex_, WAIT_FOREVER);
#else
::pthread_mutex_lock(&mutex_);
#endif
+*/
}
/*!
@@ -137,6 +149,9 @@
*/
inline bool trylock()
{
+ STATUS status = semTake(mutex_, NO_WAIT);
+ return (status == OK);
+/*
#ifdef __RTP__
STATUS status = semTake(mutex_, NO_WAIT);
return (status == OK);
@@ -143,6 +158,7 @@
#else
return ::pthread_mutex_trylock(&mutex_);
#endif
+*/
}
/*!
@@ -162,11 +178,14 @@
*/
inline void unlock()
{
+ semGive(mutex_);
+/*
#ifdef __RTP__
semGive(mutex_);
#else
::pthread_mutex_unlock(&mutex_);
#endif
+*/
}
/*!
@@ -180,11 +199,14 @@
*
* @endif
*/
+ SEM_ID mutex_;
+/*
#ifdef __RTP__
SEM_ID mutex_;
#else
pthread_mutex_t mutex_;
#endif
+*/
private:
Mutex(const Mutex&);
Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -41,6 +41,7 @@
: m_count(0)
,m_priority(DEFAULT_PRIORITY)
,m_stacksize(DEFAULT_STACKSIZE)
+ ,m_tid(-1)
{
}
/*
@@ -264,6 +265,8 @@
*
*
* @param priority Í¥ÀèÅÙ
+ *
+ * @return
*
* @else
*
@@ -271,16 +274,57 @@
*
*
* @param priority
+ *
+ * @return
*
* @endif
*/
- void Task::set_priority(int priority)
+ STATUS Task::set_priority(int priority)
{
- m_priority = priority;
+ if(m_tid == -1)
+ {
+ m_priority = priority;
+ return OK;
+ }
+ else
+ {
+ m_priority = priority;
+ return taskPrioritySet(m_tid, m_priority);
+ }
}
/*!
* @if jp
*
+ * @brief ¥¿¥¹¥¯¤ÎÍ¥ÀèÅÙ¤ò½êÆÀ
+ *
+ *
+ * @return priority Í¥ÀèÅÙ
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @return priority
+ *
+ * @endif
+ */
+ int Task::get_priority()
+ {
+ if(m_tid == -1)
+ {
+ return m_priority;
+ }
+ else
+ {
+ int priority = -1;
+ taskPriorityGet(m_tid, &priority);
+ return priority;
+ }
+ }
+ /*!
+ * @if jp
+ *
* @brief ¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤ÎÀßÄê
*
*
Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h 2017-07-11 10:10:16 UTC (rev 3012)
@@ -293,10 +293,28 @@
*
* @endif
*/
- void set_priority(int priority);
+ STATUS set_priority(int priority);
/*!
* @if jp
*
+ * @brief ¥¿¥¹¥¯¤ÎÍ¥ÀèÅÙ¤ò½êÆÀ
+ *
+ *
+ * @return priority Í¥ÀèÅÙ
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @return priority
+ *
+ * @endif
+ */
+ int get_priority();
+ /*!
+ * @if jp
+ *
* @brief ¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤ÎÀßÄê
*
*
Modified: trunk/OpenRTM-aist/src/lib/rtm/CMakeLists.txt
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/CMakeLists.txt 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/rtm/CMakeLists.txt 2017-07-11 10:10:16 UTC (rev 3012)
@@ -128,10 +128,17 @@
include_directories(${ORB_INCLUDE_DIR})
set(ORB_LIBRARIES omniDynamic4 omniORB4 omnithread)
- SET (ORB_C_FLAGS_LIST
- -D__vxWorks__
- -D__x86__
- )
+ if("${VX_CPU_FAMILY}" STREQUAL "ppc")
+ SET (ORB_C_FLAGS_LIST
+ -D__vxWorks__
+ -D__powerpc__
+ )
+ else()
+ SET (ORB_C_FLAGS_LIST
+ -D__vxWorks__
+ -D__x86__
+ )
+ endif()
ADD_DEFINITIONS(${ORB_C_FLAGS_LIST})
set (ORB_IS_OMNIORB ON)
set (ORB_IS_OMNIORB ON PARENT_SCOPE)
@@ -252,6 +259,14 @@
NumberingPolicy.cpp
)
+if(VXWORKS)
+ set(rtm_srcs ${rtm_srcs} VxWorksRTExecutionContext.cpp)
+ if(RTP)
+ else(RTP)
+ set(rtm_srcs ${rtm_srcs} VxWorksInterruptExecutionContext.cpp)
+ endif(RTP)
+endif(VXWORKS)
+
#message(STATUS ${ALL_IDL_SRCS})
#message(STATUS ${ORB_LIBRARIES})
Modified: trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -45,6 +45,13 @@
#include <rtm/LogstreamBase.h>
#include <rtm/NumberingPolicyBase.h>
+#ifdef RTM_OS_VXWORKS
+#include <rtm/VxWorksRTExecutionContext.h>
+#ifndef __RTP__
+#include <rtm/VxWorksInterruptExecutionContext.h>
+#endif
+#endif
+
#ifdef RTM_OS_LINUX
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -872,6 +879,9 @@
"exec_cxt.deactivation_timeout",
"exec_cxt.reset_timeout",
"exec_cxt.cpu_affinity",
+ "exec_cxt.priority",
+ "exec_cxt.stack_size",
+ "exec_cxt.interrupt",
"logger.enable",
"logger.log_level",
"naming.enable",
@@ -1859,7 +1869,12 @@
PeriodicExecutionContextInit(this);
ExtTrigExecutionContextInit(this);
OpenHRPExecutionContextInit(this);
-
+#ifdef RTM_OS_VXWORKS
+ VxWorksRTExecutionContextInit(this);
+#ifndef __RTP__
+ VxWorksInterruptExecutionContextInit(this);
+#endif
+#endif
// initialize CPU affinity
#ifdef RTM_OS_LINUX
initCpuAffinity();
Modified: trunk/OpenRTM-aist/src/lib/rtm/RTObject.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/RTObject.cpp 2017-07-07 04:15:23 UTC (rev 3011)
+++ trunk/OpenRTM-aist/src/lib/rtm/RTObject.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -2144,6 +2144,7 @@
PortableServer::RefCountServantBase* servant(NULL);
servant =
dynamic_cast<PortableServer::RefCountServantBase*>(m_eclist[i]);
+
if (servant == NULL)
{
RTC_ERROR(("Dynamic cast error: ECBase -> Servant."));
@@ -2547,6 +2548,9 @@
"deactivation_timeout",
"reset_timeout",
"cpu_affinity",
+ "priority",
+ "stack_size",
+ "interrupt",
""
};
coil::Properties* p = m_properties.findNode("exec_cxt");
@@ -2805,6 +2809,10 @@
"activation_timeout",
"deactivation_timeout",
"reset_timeout",
+ "cpu_affinity",
+ "priority",
+ "stack_size",
+ "interrupt",
""
};
Added: trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -0,0 +1,683 @@
+// -*- C++ -*-
+/*!
+ * @file VxWorksIOTrigExecutionContext.cpp
+ * @brief VxWorksIOTrigExecutionContext class
+ * @date $Date: 2017-07-11 15:49:16 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#include <coil/TimeValue.h>
+#include <coil/Guard.h>
+
+#include <rtm/VxWorksInterruptExecutionContext.h>
+#include <rtm/ECFactory.h>
+#include <rtm/RTObjectStateMachine.h>
+
+#include <iostream>
+
+
+#if defined(__powerpc__)
+#include <arch/ppc/ivPpc.h>
+#define IV_CI 0
+#define IV_SRI 4
+#define IV_STI 5
+#define IV_JRI 6
+#define IV_JTI 7
+#define IV_D0I 8
+#define IV_D1I 9
+#define IV_D2I 10
+#define IV_D3I 11
+#define IV_E0I 27
+#define IV_E1I 28
+#define IV_E2I 29
+#define IV_E3I 30
+#define IV_E4I 31
+#else
+#include <arch/simlinux/ivSimlinux.h>
+#endif
+
+
+
+namespace RTC
+{
+ static void tickHandler(int param)
+ {
+ VxWorksInterruptExecutionContext* ec = (VxWorksInterruptExecutionContext*)param;
+ ec->tick();
+ }
+
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ VxWorksInterruptExecutionContext::VxWorksInterruptExecutionContext()
+ : ExecutionContextBase("vxworks_interrupt_ec"),
+ rtclog("vxworks_interrupt_ec"),
+ m_svc(false),
+ exception_number(-1)
+ {
+ RTC_TRACE(("VxWorksInterruptExecutionContext()"));
+
+ // getting my reference
+ setObjRef(this->_this());
+
+ // profile initialization
+ setKind(RTC::PERIODIC);
+ setRate(DEFAULT_EXECUTION_RATE);
+
+ RTC_DEBUG(("Actual period: %d [sec], %d [usec]",
+ m_profile.getPeriod().sec(), m_profile.getPeriod().usec()));
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ VxWorksInterruptExecutionContext::~VxWorksInterruptExecutionContext()
+ {
+ RTC_TRACE(("~VxWorksInterruptExecutionContext()"));
+ {
+ {
+ Guard guard(m_svcmutex);
+ m_svc = false;
+ }
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ }
+ }
+ wait();
+ }
+
+ void VxWorksInterruptExecutionContext::init(coil::Properties& props)
+ {
+ RTC_TRACE(("init()"));
+ ExecutionContextBase::init(props);
+
+ setInterrupt(props);
+
+ RTC_DEBUG(("init() done"));
+ }
+
+ /*------------------------------------------------------------
+ * Start activity
+ * ACE_Task class method over ride.
+ *------------------------------------------------------------*/
+ /*!
+ * @if jp
+ * @brief ExecutionContext用アクティビティスレッドを生成する
+ * @else
+ * @brief Generate internal activity thread for ExecutionContext
+ * @endif
+ */
+ int VxWorksInterruptExecutionContext::open(void *args)
+ {
+ RTC_TRACE(("open()"));
+ activate();
+ return 0;
+ }
+
+
+ /*!
+ * @if jp
+ * @brief 各 Component の処理を呼び出す。
+ * @else
+ * @brief Invoke each component's operation
+ * @endif
+ */
+ int VxWorksInterruptExecutionContext::svc(void)
+ {
+ RTC_TRACE(("svc()"));
+ unsigned int count(0);
+ do
+ {
+ {
+ Guard gurad(m_worker.mutex_);
+ RTC_DEBUG(("Start of worker invocation. ticked = %s",
+ m_worker.ticked_ ? "true" : "false"));
+ while (!m_worker.ticked_)
+ {
+ m_worker.cond_.wait(); // wait for tick
+ RTC_DEBUG(("Thread was woken up."));
+ }
+ if (!m_worker.ticked_) { continue; }
+ }
+ coil::TimeValue t0(coil::gettimeofday());
+ ExecutionContextBase::invokeWorkerPreDo();
+ ExecutionContextBase::invokeWorkerDo();
+ ExecutionContextBase::invokeWorkerPostDo();
+ coil::TimeValue t1(coil::gettimeofday());
+ {
+ Guard gurad(m_worker.mutex_);
+ m_worker.ticked_ = false;
+ }
+ coil::TimeValue period(getPeriod());
+ if (1) //count > 1000)
+ {
+ RTC_PARANOID(("Period: %f [s]", (double)period));
+ RTC_PARANOID(("Execution: %f [s]", (double)(t1 - t0)));
+ RTC_PARANOID(("Sleep: %f [s]", (double)(period - (t1 - t0))));
+ }
+ coil::TimeValue t2(coil::gettimeofday());
+ if (period > (t1 - t0))
+ {
+ if (1 /*count > 1000*/) { RTC_PARANOID(("sleeping...")); }
+ coil::sleep((coil::TimeValue)(period - (t1 - t0)));
+ }
+ if (1) //count > 1000)
+ {
+ coil::TimeValue t3(coil::gettimeofday());
+ RTC_PARANOID(("Slept: %f [s]", (double)(t3 - t2)));
+ count = 0;
+ }
+ ++count;
+ } while (threadRunning());
+
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ * @endif
+ */
+ int VxWorksInterruptExecutionContext::close(unsigned long flags)
+ {
+ RTC_TRACE(("close()"));
+ // At this point, this component have to be finished.
+ // Current state and Next state should be RTC_EXITING.
+ return 0;
+ }
+ //============================================================
+ // ExecutionContextService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief 処理を1ステップ進める
+ * @else
+ * @brief Move forward one step of ExecutionContext
+ * @endif
+ */
+ void VxWorksInterruptExecutionContext::tick()
+ {
+ if (!isRunning())
+ {
+ return;
+ }
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ return;
+ }
+ /*!
+ * @if jp
+ * @brief ExecutionContext 実行状態確認関数
+ * @else
+ * @brief Check for ExecutionContext running state
+ * @endif
+ */
+ CORBA::Boolean VxWorksInterruptExecutionContext::is_running()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::isRunning();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を開始
+ * @else
+ * @brief Start the ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::start()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::start();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を停止
+ * @else
+ * @brief Stop the ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::stop()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::stop();
+ }
+
+
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を取得する
+ * @else
+ * @brief Get execution rate(Hz) of ExecutionContext
+ * @endif
+ */
+ CORBA::Double VxWorksInterruptExecutionContext::get_rate()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getRate();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を設定する
+ * @else
+ * @brief Set execution rate(Hz) of ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::set_rate(CORBA::Double rate)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::setRate(rate);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを追加する
+ * @else
+ * @brief Add an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t
+ VxWorksInterruptExecutionContext::add_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::addComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief コンポーネントをコンポーネントリストから削除する
+ * @else
+ * @brief Remove the RT-Component from participant list
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ remove_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::removeComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをアクティブ化する
+ * @else
+ * @brief Activate an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::activateComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを非アクティブ化する
+ * @else
+ * @brief Deactivate an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::deactivateComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをリセットする
+ * @else
+ * @brief Reset the RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::resetComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントの状態を取得する
+ * @else
+ * @brief Get RT-Component's state
+ * @endif
+ */
+ RTC::LifeCycleState VxWorksInterruptExecutionContext::
+ get_component_state(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getComponentState(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionKind を取得する
+ * @else
+ * @brief Get the ExecutionKind
+ * @endif
+ */
+ RTC::ExecutionKind VxWorksInterruptExecutionContext::get_kind()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getKind();
+ }
+
+ //------------------------------------------------------------
+ // ExecutionContextService interfaces
+ //------------------------------------------------------------
+ /*!
+ * @if jp
+ * @brief ExecutionContextProfile を取得する
+ * @else
+ * @brief Get the ExecutionContextProfile
+ * @endif
+ */
+ RTC::ExecutionContextProfile* VxWorksInterruptExecutionContext::get_profile()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getProfile();
+ }
+
+ //============================================================
+ // protected functions
+ //============================================================
+ /*!
+ * @brief onStarted() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::onStarted()
+ {
+ // change EC thread state
+ Guard gurad(m_svcmutex);
+ if (!m_svc)
+ { // If start() is called first time, start the worker thread.
+ m_svc = true;
+ this->open(0);
+ }
+ return RTC::RTC_OK;
+ }
+ // template virtual functions adding/removing component
+ /*!
+ * @brief onAddedComponent() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ onAddedComponent(RTC::LightweightRTObject_ptr rtobj)
+ {
+ Guard guard(m_worker.mutex_);
+ if (m_worker.ticked_ == false)
+ {
+ ExecutionContextBase::m_worker.updateComponentList();
+ }
+ return RTC::RTC_OK;
+ }
+ /*!
+ * @brief onRemovedComponent() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ onRemovedComponent(RTC::LightweightRTObject_ptr rtobj)
+ {
+ Guard guard(m_worker.mutex_);
+ if (m_worker.ticked_ == false)
+ {
+ ExecutionContextBase::m_worker.updateComponentList();
+ }
+ return RTC::RTC_OK;
+ }
+
+ /*!
+ * @brief onWaitingActivated() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingActivated(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ // Now comp's next state must be ACTIVE state
+ // If worker thread is stopped, restart worker thread.
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ * @brief onWaitingDeactivated() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ onWaitingDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingDeactivated(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ return RTC::RTC_OK;
+ }
+
+ /*!
+ * @brief onWaitingReset() template function
+ */
+ RTC::ReturnCode_t VxWorksInterruptExecutionContext::
+ onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingReset(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ return RTC::RTC_OK;
+ }
+ /*!
+ * @if jp
+ * @brief 割り込みの設定
+ *
+ * @param props
+ *
+ * @return
+ *
+ * @else
+ *
+ * @brief set Interrupt
+ *
+ * @param props
+ *
+ * @return
+ *
+ * @endif
+ */
+ STATUS VxWorksInterruptExecutionContext::setInterrupt(coil::Properties& props)
+ {
+ std::string int_param;
+ int int_value = -1;
+ getProperty(props, "interrupt", int_param);
+#if defined(__powerpc__)
+ if(int_param == "CI")
+ {
+ int_value = IV_CI;
+ }
+ else if(int_param == "SRI")
+ {
+ int_value = IV_SRI;
+ }
+ else if(int_param == "STI")
+ {
+ int_value = IV_STI;
+ }
+ else if(int_param == "JRI")
+ {
+ int_value = IV_JRI;
+ }
+ else if(int_param == "JTI")
+ {
+ int_value = IV_JTI;
+ }
+ else if(int_param == "D0I")
+ {
+ int_value = IV_D0I;
+ }
+ else if(int_param == "D1I")
+ {
+ int_value = IV_D1I;
+ }
+ else if(int_param == "D2I")
+ {
+ int_value = IV_D2I;
+ }
+ else if(int_param == "D3I")
+ {
+ int_value = IV_D3I;
+ }
+ else if(int_param == "E0I")
+ {
+ int_value = IV_E0I;
+ }
+ else if(int_param == "E1I")
+ {
+ int_value = IV_E1I;
+ }
+ else if(int_param == "E2I")
+ {
+ int_value = IV_E2I;
+ }
+ else if(int_param == "E3I")
+ {
+ int_value = IV_E3I;
+ }
+ else if(int_param == "E4I")
+ {
+ int_value = IV_E4I;
+ }
+#else
+ if(int_param == "HUP")
+ {
+ int_value = IV_HUP;
+ }
+ else if(int_param == "INT")
+ {
+ int_value = IV_INT;
+ }
+ else if(int_param == "ILL")
+ {
+ int_value = IV_ILL;
+ }
+ else if(int_param == "TRAP")
+ {
+ int_value = IV_TRAP;
+ }
+ else if(int_param == "BUS")
+ {
+ int_value = IV_BUS;
+ }
+ else if(int_param == "FPE")
+ {
+ int_value = IV_FPE;
+ }
+ else if(int_param == "SEGV")
+ {
+ int_value = IV_SEGV;
+ }
+ else if(int_param == "CLOCK1")
+ {
+ int_value = IV_CLOCK1;
+ }
+ else if(int_param == "USR1")
+ {
+ int_value = IV_USR1;
+ }
+ else if(int_param == "USR2")
+ {
+ int_value = IV_USR2;
+ }
+ else if(int_param == "IO")
+ {
+ int_value = IV_IO;
+ }
+ else if(int_param == "CLOCK2")
+ {
+ int_value = IV_CLOCK2;
+ }
+ else if(int_param == "CLOCK3")
+ {
+ int_value = IV_CLOCK3;
+ }
+ else if(int_param == "IPI0")
+ {
+ int_value = IV_IPI0;
+ }
+ else if(int_param == "IPI1")
+ {
+ int_value = IV_IPI1;
+ }
+ else if(int_param == "IPI2")
+ {
+ int_value = IV_IPI2;
+ }
+ else if(int_param == "IPI3")
+ {
+ int_value = IV_IPI3;
+ }
+#endif
+std::cout << props << std::endl;
+std::cout << int_param << std::endl;
+ if(int_value >= 0)
+ {
+ intConnect(INUM_TO_IVEC(int_value), (VOIDFUNCPTR)tickHandler, (int)this);
+ }
+ }
+};
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief 当該 ExecutionContext 用Factoryクラスの登録。
+ * @else
+ * @brief Register Factory class for this ExecutionContext
+ * @endif
+ */
+ void VxWorksInterruptExecutionContextInit(RTC::Manager* manager)
+ {
+ RTC::ExecutionContextFactory::
+ instance().addFactory("VxWorksInterruptExecutionContext",
+ ::coil::Creator< ::RTC::ExecutionContextBase,
+ ::RTC::VxWorksInterruptExecutionContext>,
+ ::coil::Destructor< ::RTC::ExecutionContextBase,
+ ::RTC::VxWorksInterruptExecutionContext>);
+ }
+};
+
Added: trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/VxWorksInterruptExecutionContext.h 2017-07-11 10:10:16 UTC (rev 3012)
@@ -0,0 +1,723 @@
+// -*- C++ -*-
+/*!
+ * @file VxWorksInterruptExecutionContext.h
+ * @brief VxWorksInterruptExecutionContext class
+ * @date $Date: 2017-07-11 15:49:16 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_VXWORKSINTERRUPTEXECUTIONCONTEXT_H
+#define RTC_VXWORKSINTERRUPTEXECUTIONCONTEXT_H
+
+#include <rtm/RTC.h>
+
+#include <coil/Mutex.h>
+#include <coil/Condition.h>
+#include <coil/Task.h>
+
+#include <rtm/ExecutionContextBase.h>
+
+#include <intLib.h>
+
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @class VxWorksInterruptExecutionContext
+ * @brief ハードウェア割り込み、ソフトウェア割り込みで実行する ExecutionContext クラス
+ *
+ *
+ * ExecutionContextクラス。
+ * 割り込みによるメソッド呼びだしによって時間が1周期づつ進む。
+ *
+ * @since 1.2.0
+ *
+ * @else
+ * @brief
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ class VxWorksInterruptExecutionContext
+ : public virtual POA_RTC::ExecutionContextService,
+ public virtual PortableServer::RefCountServantBase,
+ public RTC::ExecutionContextBase,
+ public coil::Task
+ {
+ typedef coil::Mutex Mutex;
+ typedef coil::Condition<Mutex> Condition;
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ *
+ * コンストラクタ
+ *
+ * @else
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ VxWorksInterruptExecutionContext();
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ *
+ * デストラクタ
+ *
+ * @else
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~VxWorksInterruptExecutionContext(void);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextの初期化を行う
+ *
+ * ExecutionContextの初期化処理
+ *
+ * @else
+ * @brief Initialize the ExecutionContext
+ *
+ * This operation initialize the ExecutionContext
+ *
+ * @endif
+ */
+ virtual void init(coil::Properties& props);
+ /*!
+ * @if jp
+ * @brief ExecutionContext用アクティビティスレッドを生成する
+ *
+ * Executioncontext 用の内部アクティビティスレッドを生成し起動する。
+ * これは coil::Task サービスクラスメソッドのオーバーライド。
+ *
+ * @param args 通常は0
+ *
+ * @return 生成処理実行結果
+ *
+ * @else
+ *
+ * @brief Generate internal activity thread for ExecutionContext
+ *
+ * Generate internal activity thread and run. This is coil::Task
+ * class method's override.
+ *
+ * @param args Usually give 0
+ *
+ * @return The generation result
+ *
+ * @endif
+ */
+ virtual int open(void *args);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ *
+ * ExecutionContext 用のスレッド終了時に呼ばれる。コンポーネントオ
+ * ブジェクトの非アクティブ化、マネージャへの通知を行う。これは
+ * coil::Task サービスクラスメソッドのオーバーライド。
+ *
+ * @param flags 終了処理フラグ
+ *
+ * @return 終了処理結果
+ *
+ * @else
+ *
+ * @brief Thread execution function for ExecutionContext
+ *
+ * This function is invoked when activity thread for
+ * ExecutionContext exits. Deactivate the component object and
+ * notify it to manager. This is coil::Task class method's
+ * override.
+ *
+ * @param flags Flag of the close
+ *
+ * @return The close result
+ *
+ * @endif
+ */
+ virtual int close(unsigned long flags);
+
+ /*!
+ * @if jp
+ * @brief 各 Component の処理を呼び出す。
+ *
+ * ExecutionContext に attach されている各 Component の処理を呼び出す。
+ * 全 Component の処理を呼び出した後、次の呼出が発生するまで休止する。
+ *
+ * @return 処理結果
+ *
+ * @else
+ * @brief Invoke each component's operation
+ *
+ * Invoke each component's operation which is attached this
+ * ExecutionContext. Stop until the next operation is invoked
+ * after all component operations are invoked.
+ *
+ * @return Operation result
+ *
+ * @endif
+ */
+ virtual int svc(void);
+
+ //============================================================
+ // ExecutionContextService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief 処理を1ステップ進める
+ *
+ * ExecutionContextの処理を1周期分進める。
+ *
+ * @else
+ * @brief Move forward one step of ExecutionContext
+ *
+ * Move forward one step of the ExecutionContext processing.
+ *
+ * @endif
+ */
+ virtual void tick();
+ /*!
+ * @if jp
+ * @brief ExecutionContext 実行状態確認関数
+ *
+ * この操作は ExecutionContext が Runnning 状態の場合に true を返す。
+ * Executioncontext が Running の間、当該 Executioncontext に参加し
+ * ている全てのアクティブRTコンポーネントが、ExecutionContext の実
+ * 行種類に応じて実行される。
+ *
+ * @return 状態確認関数(動作中:true、停止中:false)
+ *
+ * @else
+ *
+ * @brief Check for ExecutionContext running state
+ *
+ * This operation shall return true if the context is in the
+ * Running state. While the context is Running, all Active RTCs
+ * participating in the context shall be executed according to the
+ * context’s execution kind.
+ *
+ * @return Check state function (Running:true、Stopping:false)
+ *
+ * @endif
+ */
+ virtual CORBA::Boolean is_running(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を開始
+ *
+ * ExecutionContext の実行状態を Runnning とするためのリクエストを
+ * 発行する。ExecutionContext の状態が遷移すると
+ * ComponentAction::on_startup が呼び出される。参加しているRTコンポー
+ * ネントが、初期化されるまで ExecutionContext を開始することはでき
+ * ない。ExecutionContext は複数回開始/停止を繰り返すことができる。
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Start the ExecutionContext
+ *
+ * Request that the context enter the Running state. Once the
+ * state transition occurs, the ComponentAction::on_startup
+ * operation will be invoked. An execution context may not be
+ * started until the RT-Components that participate in it have
+ * been initialized. An execution context may be started and
+ * stopped multiple times.
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t start(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を停止
+ *
+ * ExecutionContext の状態を Stopped とするためのリクエストを発行す
+ * る。遷移が発生した場合は、ComponentAction::on_shutdown が呼び出
+ * される。参加しているRTコンポーネントが終了する前に
+ * ExecutionContext を停止する必要がある。ExecutionContext は複数回
+ * 開始/停止を繰り返すことができる。
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Stop the ExecutionContext
+ *
+ * Request that the context enter the Stopped state. Once the
+ * transition occurs, the ComponentAction::on_shutdown operation
+ * will be invoked. An execution context must be stopped before
+ * the RT components that participate in it are finalized. An
+ * execution context may be started and stopped multiple times.
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t stop(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を取得する
+ *
+ * Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す
+ * る。
+ *
+ * @return 処理周期(単位:Hz)
+ *
+ * @else
+ *
+ * @brief Get execution rate(Hz) of ExecutionContext
+ *
+ * This operation shall return the rate (in hertz) at which its
+ * Active participating RTCs are being invoked.
+ *
+ * @return Execution cycle(Unit:Hz)
+ *
+ * @endif
+ */
+ virtual CORBA::Double get_rate(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を設定する
+ *
+ * Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す
+ * る。実行周期の変更は、DataFlowComponentAction の
+ * on_rate_changed によって各RTコンポーネントに伝達される。
+ *
+ * @param rate 処理周期(単位:Hz)
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Set execution rate(Hz) of ExecutionContext
+ *
+ * This operation shall set the rate (in hertz) at which this
+ * context’s Active participating RTCs are being called. If the
+ * execution kind of the context is PERIODIC, a rate change shall
+ * result in the invocation of on_rate_changed on any RTCs
+ * realizing DataFlowComponentAction that are registered with any
+ * RTCs participating in the context.
+ *
+ * @param rate Execution cycle(Unit:Hz)
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t set_rate(CORBA::Double rate)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをアクティブ化する
+ *
+ * Inactive 状態にあるRTコンポーネントをActive に遷移させ、アクティ
+ * ブ化する。この操作が呼ばれた結果、on_activate が呼び出される。指
+ * 定したRTコンポーネントが参加者リストに含まれない場合は、
+ * BAD_PARAMETER が返される。指定したRTコンポーネントの状態が
+ * Inactive 以外の場合は、PRECONDITION_NOT_MET が返される。
+ *
+ * @param comp アクティブ化対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Activate an RT-component
+ *
+ * The given participant RTC is Inactive and is therefore not
+ * being invoked according to the execution context’s execution
+ * kind. This operation shall cause the RTC to transition to the
+ * Active state such that it may subsequently be invoked in this
+ * execution context. The callback on_activate shall be called as
+ * a result of calling this operation. This operation shall not
+ * return until the callback has returned, and shall result in an
+ * error if the callback does.
+ *
+ * @param comp The target RT-Component for activation
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを非アクティブ化する
+ *
+ * Inactive 状態にあるRTコンポーネントを非アクティブ化し、Inactive
+ * に遷移させる。この操作が呼ばれた結果、on_deactivate が呼び出され
+ * る。指定したRTコンポーネントが参加者リストに含まれない場合は、
+ * BAD_PARAMETER が返される。指定したRTコンポーネントの状態が
+ * Active 以外の場合は、PRECONDITION_NOT_MET が返される。
+ *
+ * @param comp 非アクティブ化対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Deactivate an RT-component
+ *
+ * The given RTC is Active in the execution context. Cause it to
+ * transition to the Inactive state such that it will not be
+ * subsequently invoked from the context unless and until it is
+ * activated again. The callback on_deactivate shall be called as
+ * a result of calling this operation. This operation shall not
+ * return until the callback has returned, and shall result in an
+ * error if the callback does.
+ *
+ * @param comp The target RT-Component for deactivate
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをリセットする
+ *
+ * Error 状態のRTコンポーネントの復帰を試みる。この操作が呼ばれた結
+ * 果、on_reset が呼び出される。指定したRTコンポーネントが参加者リ
+ * ストに含まれない場合は、BAD_PARAMETER が返される。指定したRTコン
+ * ポーネントの状態が Error 以外の場合は、PRECONDITION_NOT_MET が返
+ * される。
+ *
+ * @param comp リセット対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Reset the RT-component
+ *
+ * Attempt to recover the RTC when it is in Error. The
+ * ComponentAction::on_reset callback shall be invoked. This
+ * operation shall not return until the callback has returned, and
+ * shall result in an error if the callback does. If possible, the
+ * RTC developer should implement that callback such that the RTC
+ * may be returned to a valid state.
+ *
+ * @param comp The target RT-Component for reset
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントの状態を取得する
+ *
+ * 指定したRTコンポーネントの状態(LifeCycleState)を取得する。指定し
+ * たRTコンポーネントが参加者リストに含まれない場合は、
+ * UNKNOWN_STATE が返される。
+ *
+ * @param comp 状態取得対象RTコンポーネント
+ *
+ * @return 現在の状態(LifeCycleState)
+ *
+ * @else
+ *
+ * @brief Get RT-component's state
+ *
+ * This operation shall report the LifeCycleState of the given
+ * participant RTC. UNKNOWN_STATE will be returned, if the given
+ * RT-Component is not inclued in the participant list.
+ *
+ * @param comp The target RT-Component to get the state
+ *
+ * @return The current state of the target RT-Component(LifeCycleState)
+ *
+ * @endif
+ */
+ virtual RTC::LifeCycleState
+ get_component_state(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionKind を取得する
+ *
+ * 本 ExecutionContext の ExecutionKind を取得する
+ *
+ * @return ExecutionKind
+ *
+ * @else
+ *
+ * @brief Get the ExecutionKind
+ *
+ * This operation shall report the execution kind of the execution
+ * context.
+ *
+ * @return ExecutionKind
+ *
+ * @endif
+ */
+ virtual RTC::ExecutionKind get_kind(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを追加する
+ *
+ * 指定したRTコンポーネントを参加者リストに追加する。追加されたRTコ
+ * ンポーネントは attach_context が呼ばれ、Inactive 状態に遷移する。
+ * 指定されたRTコンポーネントがnullの場合は、BAD_PARAMETER が返され
+ * る。指定されたRTコンポーネントが DataFlowComponent 以外の場合は、
+ * BAD_PARAMETER が返される。
+ *
+ * @param comp 追加対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Add an RT-component
+ *
+ * The operation causes the given RTC to begin participating in
+ * the execution context. The newly added RTC will receive a call
+ * to LightweightRTComponent::attach_context and then enter the
+ * Inactive state. BAD_PARAMETER will be invoked, if the given
+ * RT-Component is null or if the given RT-Component is other than
+ * DataFlowComponent.
+ *
+ * @param comp The target RT-Component for add
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを参加者リストから削除する
+ *
+ * 指定したRTコンポーネントを参加者リストから削除する。削除された
+ * RTコンポーネントは detach_context が呼ばれる。指定されたRTコンポー
+ * ネントが参加者リストに登録されていない場合は、BAD_PARAMETER が返
+ * される。
+ *
+ * @param comp 削除対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Remove the RT-Component from participant list
+ *
+ * This operation causes a participant RTC to stop participating in the
+ * execution context.
+ * The removed RTC will receive a call to
+ * LightweightRTComponent::detach_context.
+ * BAD_PARAMETER will be returned, if the given RT-Component is not
+ * participating in the participant list.
+ *
+ * @param comp The target RT-Component for delete
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ remove_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextProfile を取得する
+ *
+ * 本 ExecutionContext のプロファイルを取得する。
+ *
+ * @return ExecutionContextProfile
+ *
+ * @else
+ *
+ * @brief Get the ExecutionContextProfile
+ *
+ * This operation provides a profile “descriptor” for the execution
+ * context.
+ *
+ * @return ExecutionContextProfile
+ *
+ * @endif
+ */
+ virtual RTC::ExecutionContextProfile* get_profile(void)
+ throw (CORBA::SystemException);
+
+ protected:
+ template <class T>
+ void getProperty(coil::Properties& prop, const char* key, T& value)
+ {
+ if (prop.findNode(key) != 0)
+ {
+ T tmp;
+ if (coil::stringTo(tmp, prop[key].c_str()))
+ {
+ value = tmp;
+ }
+ }
+ }
+ /*!
+ * @brief onStarted() template function
+ */
+ virtual RTC::ReturnCode_t onStarted();
+ // template virtual functions adding/removing component
+ /*!
+ * @brief onAddedComponent() template function
+ */
+ virtual RTC::ReturnCode_t
+ onAddedComponent(RTC::LightweightRTObject_ptr rtobj);
+ /*!
+ * @brief onRemovedComponent() template function
+ */
+ virtual RTC::ReturnCode_t
+ onRemovedComponent(RTC::LightweightRTObject_ptr rtobj);
+ /*!
+ * @brief onWaitingActivated() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count);
+ /*!
+ * @brief onWaitingDeactivated() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count);
+ /*!
+ * @brief onWaitingReset() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count);
+
+ private:
+ bool threadRunning()
+ {
+ Guard guard(m_svcmutex);
+ return m_svc;
+ }
+ /*!
+ * @if jp
+ * @brief 割り込みの設定
+ *
+ * @param props
+ *
+ * @return
+ *
+ * @else
+ *
+ * @brief set Interrupt
+ *
+ * @param props
+ *
+ * @return
+ *
+ * @endif
+ */
+ STATUS setInterrupt(coil::Properties& props);
+ /*!
+ * @if jp
+ * @brief ロガーストリーム
+ * @else
+ * @brief Logger stream
+ * @endif
+ */
+ RTC::Logger rtclog;
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext のスレッド実行フラグ
+ * @else
+ * @brief The thread running flag of ExecutionContext
+ * @endif
+ */
+ bool m_svc;
+ Mutex m_svcmutex;
+
+ /*!
+ * @if jp
+ * @brief worker 用状態変数クラス
+ * @else
+ * @brief Condition variable class for worker
+ * @endif
+ */
+ struct Worker
+ {
+ Worker() : cond_(mutex_), ticked_(false) {};
+ Mutex mutex_;
+ Condition cond_;
+ bool ticked_;
+ };
+ // A condition variable for external triggered worker
+ Worker m_worker;
+ int exception_number;
+ }; // class VxWorksInterruptExecutionContext
+}; // namespace RTC
+
+
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief 当該 ExecutionContext 用Factoryクラスの登録。
+ *
+ * このExecutionContextを生成するFactoryクラスを
+ * ExecutionContext管理用ObjectManagerに登録する。
+ *
+ * @else
+ * @brief Register Factory class for this ExecutionContext
+ *
+ * Register the Factory class to create this ExecutionContext
+ * to the ObjectManager for management ExecutionContext
+ *
+ * @endif
+ */
+ void VxWorksInterruptExecutionContextInit(RTC::Manager* manager);
+};
+
+#endif // RTC_VXWORKSINTERRUPTEXECUTIONCONTEXT_H
+
Added: trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.cpp 2017-07-11 10:10:16 UTC (rev 3012)
@@ -0,0 +1,341 @@
+// -*- C++ -*-
+/*!
+ * @file VxWorksRTExecutionContext.cpp
+ * @brief VxWorksRTExecutionContext class
+ * @date $Date: 2017-07-11 10:53:05 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * Nobuhiko Miyamoto
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+
+#include <coil/Time.h>
+
+#include <taskLib.h>
+#include <sysLib.h>
+#include <rtm/VxWorksRTExecutionContext.h>
+#include <rtm/RTObjectStateMachine.h>
+
+#define TIMEVALUE_ONE_SECOND_IN_NSECS 1000000000l // 1 [sec] = 1000000000 [nsec]
+
+
+namespace RTC_exp
+{
+ /*!
+ * @if jp
+ * @brief デフォルトコンストラクタ
+ * @else
+ * @brief Default constructor
+ * @endif
+ */
+ VxWorksRTExecutionContext::
+ VxWorksRTExecutionContext()
+ {
+ RTC_TRACE(("VxWorksRTExecutionContext()"));
+
+ RTC_DEBUG(("Actual period: %d [sec], %d [usec]",
+ m_profile.getPeriod().sec(), m_profile.getPeriod().usec()));
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ VxWorksRTExecutionContext::~VxWorksRTExecutionContext()
+ {
+ RTC_TRACE(("~VxWorksRTExecutionContext()"));
+
+ }
+
+
+
+ void VxWorksRTExecutionContext::init(coil::Properties& props)
+ {
+ RTC_TRACE(("init()"));
+ ExecutionContextBase::init(props);
+
+ setCpuAffinity(props);
+ setPriority(props);
+ setStackSize(props);
+
+ RTC_DEBUG(("init() done"));
+ }
+
+
+ /*------------------------------------------------------------
+ * Run by a daemon thread to handle deferred processing
+ * ACE_Task class method over ride.
+ *------------------------------------------------------------*/
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ * @endif
+ */
+ int VxWorksRTExecutionContext::svc(void)
+ {
+ RTC_TRACE(("svc()"));
+ int count(0);
+
+
+
+ do
+ {
+ ExecutionContextBase::invokeWorkerPreDo();
+ // Thread will stopped when all RTCs are INACTIVE.
+ // Therefore WorkerPreDo(updating state) have to be invoked
+ // before stopping thread.
+ {
+ Guard guard(m_workerthread.mutex_);
+ while (!m_workerthread.running_)
+ {
+ m_workerthread.cond_.wait();
+ }
+ }
+ timespec ts;
+ ::clock_gettime(CLOCK_MONOTONIC, &ts);
+ TimeValue_nano t0(ts.tv_sec, ts.tv_nsec);
+
+ ExecutionContextBase::invokeWorkerDo();
+ ExecutionContextBase::invokeWorkerPostDo();
+
+ ::clock_gettime(CLOCK_MONOTONIC, &ts);
+ TimeValue_nano t1(ts.tv_sec, ts.tv_nsec);
+
+ TimeValue_nano period(1.0/getRate());
+ if (count > 1000)
+ {
+ RTC_PARANOID(("Period: %f [s]", (double)period));
+ RTC_PARANOID(("Execution: %f [s]", (double)(t1 - t0)));
+ RTC_PARANOID(("Sleep: %f [s]", (double)(period - (t1 - t0))));
+ }
+ ::clock_gettime(CLOCK_MONOTONIC, &ts);
+ TimeValue_nano t2(ts.tv_sec, ts.tv_nsec);
+ if (!m_nowait && period > (t1 - t0))
+ {
+ if (count > 1000) { RTC_PARANOID(("sleeping...")); }
+ sleep_nano((TimeValue_nano)(period - (t1 - t0)));
+ }
+ if (count > 1000)
+ {
+ ::clock_gettime(CLOCK_MONOTONIC, &ts);
+ TimeValue_nano t3(ts.tv_sec, ts.tv_nsec);
+ RTC_PARANOID(("Slept: %f [s]", (double)(t3 - t2)));
+ count = 0;
+ }
+ ++count;
+ } while (threadRunning());
+ RTC_DEBUG(("Thread terminated."));
+ return 0;
+ }
+
+
+ void VxWorksRTExecutionContext::setPriority(coil::Properties& props)
+ {
+ RTC_TRACE(("setPriority()"));
+ std::string priority;
+ getProperty(props, "priority", priority);
+ int num;
+ if (coil::stringTo(num, priority.c_str()))
+ {
+ set_priority(num);
+ }
+ }
+
+
+ void VxWorksRTExecutionContext::setStackSize(coil::Properties& props)
+ {
+ RTC_TRACE(("setStackSize()"));
+ std::string stack_size;
+ getProperty(props, "stack_size", stack_size);
+ int num;
+ if (coil::stringTo(num, stack_size.c_str()))
+ {
+ set_stacksize(num);
+ }
+ }
+
+ int VxWorksRTExecutionContext::sleep_nano(TimeValue_nano interval)
+ {
+ int tps = sysClkRateGet();
+ if(taskDelay((double)interval.sec()*tps + (double)(interval.nsec()*tps)/TIMEVALUE_ONE_SECOND_IN_NSECS) == OK)
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+
+ TimeValue_nano::TimeValue_nano(long sec, long nsec)
+ {
+ m_sec = sec;
+ m_nsec = nsec;
+ normalize();
+ }
+ TimeValue_nano::TimeValue_nano(double timeval)
+ {
+ double dbHalfAdj;
+ if ( timeval >= 0 )
+ {
+ dbHalfAdj = +0.5;
+ }
+ else
+ {
+ dbHalfAdj = -0.5;
+ }
+ m_sec = (long int)timeval;
+ m_nsec = (long)((timeval - (double)m_sec)
+ * TIMEVALUE_ONE_SECOND_IN_NSECS + dbHalfAdj );
+ normalize();
+ }
+ TimeValue_nano::~TimeValue_nano()
+ {
+ }
+ TimeValue_nano TimeValue_nano::operator-(TimeValue_nano& tm)
+ {
+ TimeValue_nano res;
+ if (m_sec >= tm.m_sec) // +
+ {
+ if (m_nsec >= tm.m_nsec) /* 繰り下がり無し */
+ {
+ res.m_sec = m_sec - tm.m_sec; // -
+ res.m_nsec = m_nsec - tm.m_nsec; // +
+ }
+ else /* m_usec < tm.m_usec 繰り下がり有り */
+ {
+ res.m_sec = m_sec - tm.m_sec - 1;
+ res.m_nsec = (m_nsec + TIMEVALUE_ONE_SECOND_IN_NSECS) - tm.m_nsec;
+ }
+ }
+ else // m_sec < tm.m_sec // -
+ {
+ if (tm.m_nsec >= m_nsec) /* 繰り下がり無し */
+ {
+ res.m_sec = - (tm.m_sec - m_sec); // +
+ res.m_nsec = - (tm.m_nsec - m_nsec); // +
+ }
+ else /* tm.m_usec < m_usec 繰り下がり有り */
+ {
+ res.m_sec = - (tm.m_sec - m_sec - 1);
+ res.m_nsec = - (tm.m_nsec + TIMEVALUE_ONE_SECOND_IN_NSECS) + m_nsec;
+ }
+ }
+ res.normalize();
+ return res;
+ }
+ TimeValue_nano TimeValue_nano::operator+(TimeValue_nano& tm)
+ {
+ TimeValue_nano res;
+ res.m_sec = m_sec + tm.m_sec;
+ res.m_nsec = m_nsec + tm.m_nsec;
+ if (res.m_nsec >= TIMEVALUE_ONE_SECOND_IN_NSECS)
+ {
+ ++res.m_sec;
+ res.m_nsec -= TIMEVALUE_ONE_SECOND_IN_NSECS;
+ }
+ res.normalize();
+ return res;
+ }
+ TimeValue_nano TimeValue_nano::operator=(double time)
+ {
+ double dbHalfAdj;
+ if ( time >= 0 )
+ {
+ dbHalfAdj = +0.5;
+ }
+ else
+ {
+ dbHalfAdj = -0.5;
+ }
+
+ m_sec = (long)time;
+ m_nsec = (long)((time - (double)m_sec)*TIMEVALUE_ONE_SECOND_IN_NSECS + dbHalfAdj);
+ normalize();
+ return *this;
+ }
+ TimeValue_nano::operator double() const
+ {
+ return (double)m_sec + ((double)m_nsec/TIMEVALUE_ONE_SECOND_IN_NSECS);
+ }
+ int TimeValue_nano::sign() const
+ {
+ if (m_sec > 0) return 1;
+ if (m_sec < 0) return -1;
+ if (m_nsec > 0) return 1;
+ if (m_nsec < 0) return -1;
+ return 0;
+ }
+ void TimeValue_nano::normalize()
+ {
+ if (m_nsec >= TIMEVALUE_ONE_SECOND_IN_NSECS)
+ {
+ do
+ {
+ ++m_sec;
+ m_nsec -= TIMEVALUE_ONE_SECOND_IN_NSECS;
+ }
+ while (m_nsec >= TIMEVALUE_ONE_SECOND_IN_NSECS);
+ }
+ else if (m_nsec <= -TIMEVALUE_ONE_SECOND_IN_NSECS)
+ {
+ do
+ {
+ --m_sec;
+ m_nsec += TIMEVALUE_ONE_SECOND_IN_NSECS;
+ }
+ while (m_nsec <= -TIMEVALUE_ONE_SECOND_IN_NSECS);
+ }
+
+ if (m_sec >= 1 && m_nsec < 0)
+ {
+ --m_sec;
+ m_nsec += TIMEVALUE_ONE_SECOND_IN_NSECS;
+ }
+ else if (m_sec < 0 && m_nsec > 0)
+ {
+ ++m_sec;
+ m_nsec -= TIMEVALUE_ONE_SECOND_IN_NSECS;
+ }
+ }
+
+}; // namespace RTC
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief ECFactoryへの登録のための初期化関数
+ * @else
+ * @brief Initialization function to register to ECFactory
+ * @endif
+ */
+
+ void VxWorksRTExecutionContextInit(RTC::Manager* manager)
+ {
+ RTC::ExecutionContextFactory::
+ instance().addFactory("VxWorksRTExecutionContext",
+ ::coil::Creator< ::RTC::ExecutionContextBase,
+ ::RTC_exp::VxWorksRTExecutionContext>,
+ ::coil::Destructor< ::RTC::ExecutionContextBase,
+ ::RTC_exp::VxWorksRTExecutionContext>);
+
+ coil::vstring ecs;
+ ecs = RTC::ExecutionContextFactory::instance().getIdentifiers();
+ }
+};
+
+
Added: trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/VxWorksRTExecutionContext.h 2017-07-11 10:10:16 UTC (rev 3012)
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+/*!
+ * @file VxWorksRTExecutionContext.h
+ * @brief VxWorksRTExecutionContext class
+ * @date $Date: 2017-07-11 10:53:05 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * Nobuhiko Miyamoto
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_VXWORKSRTEXECUTIONCONTEXT_H
+#define RTC_VXWORKSRTEXECUTIONCONTEXT_H
+
+#include <vector>
+#include <iostream>
+
+#include <coil/Task.h>
+#include <coil/Mutex.h>
+#include <coil/Condition.h>
+
+#include <rtm/PeriodicExecutionContext.h>
+
+
+
+namespace RTC_exp
+{
+ class TimeValue_nano;
+ /*!
+ * @if jp
+ * @class VxWorksRTExecutionContext
+ * @brief VxWorksRTExecutionContext クラス
+ *
+ * Periodic Sampled Data Processing(周期実行用)ExecutionContextクラス。
+ *
+ * @since 0.4.0
+ *
+ * @else
+ * @class VxWorksRTExecutionContext
+ * @brief VxWorksRTExecutionContext class
+ *
+ * Periodic Sampled Data Processing (for the execution cycles)
+ * ExecutionContext class
+ *
+ * @since 0.4.0
+ *
+ * @endif
+ */
+ class VxWorksRTExecutionContext
+ : public RTC_exp::PeriodicExecutionContext
+ {
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ /*!
+ * @if jp
+ * @brief デフォルトコンストラクタ
+ *
+ * デフォルトコンストラクタ
+ * プロファイルに以下の項目を設定する。
+ * - kind : PERIODIC
+ * - rate : 0.0
+ *
+ * @else
+ * @brief Default Constructor
+ *
+ * Default Constructor
+ * Set the following items to profile.
+ * - kind : PERIODIC
+ * - rate : 0.0
+ *
+ * @endif
+ */
+ VxWorksRTExecutionContext();
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ *
+ * デストラクタ
+ *
+ * @else
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~VxWorksRTExecutionContext(void);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextの初期化を行う
+ *
+ * ExecutionContextの初期化処理
+ *
+ * @else
+ * @brief Initialize the ExecutionContext
+ *
+ * This operation initialize the ExecutionContext
+ *
+ * @endif
+ */
+ virtual void init(coil::Properties& props);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ *
+ * ExecutionContext 用のスレッド実行関数。登録されたコンポーネント
+ * の処理を呼び出す。
+ *
+ * @return 実行結果
+ *
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ *
+ * Thread execution function for ExecutionContext. Invoke the
+ * registered components operation.
+ *
+ * @return The execution result
+ *
+ * @endif
+ */
+ virtual int svc(void);
+
+
+
+ protected:
+ private:
+ /*!
+ * @if jp
+ * @brief 優先度の設定
+ *
+ * @param prop
+ *
+ * @return
+ *
+ * @else
+ * @brief set priority
+ *
+ * @param prop
+ *
+ * @return
+ *
+ * @endif
+ */
+ void setPriority(coil::Properties& props);
+ /*!
+ * @if jp
+ * @brief スタックサイズの設定
+ *
+ * @param prop
+ *
+ * @return
+ *
+ * @else
+ * @brief set stack size
+ *
+ * @param prop
+ *
+ * @return
+ *
+ * @endif
+ */
+ void setStackSize(coil::Properties& props);
+ /*!
+ * @if jp
+ * @brief ナノ秒単位のsleep
+ *
+ * @param interval
+ *
+ * @return
+ *
+ * @else
+ * @brief
+ *
+ * @param interval
+ *
+ * @return
+ *
+ * @endif
+ */
+ int sleep_nano(TimeValue_nano interval);
+ }; // class VxWorksRTExecutionContext
+ class TimeValue_nano
+ {
+ public:
+ TimeValue_nano(long sec=0, long usec=0);
+ TimeValue_nano(double timeval);
+ ~TimeValue_nano();
+ TimeValue_nano operator-(TimeValue_nano& tm);
+ TimeValue_nano operator+(TimeValue_nano& tm);
+ TimeValue_nano operator=(double time);
+ operator double() const;
+ int sign() const;
+ void normalize();
+ inline long int sec() const {return m_sec;}
+ inline long int nsec() const {return m_nsec;}
+ private:
+ long int m_sec;
+ long int m_nsec;
+ };
+}; // namespace RTC
+
+#ifdef WIN32
+#pragma warning( default : 4290 )
+#endif
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief ECFactoryへの登録のための初期化関数
+ * @else
+ * @brief Initialization function to register to ECFactory
+ * @endif
+ */
+ void VxWorksRTExecutionContextInit(RTC::Manager* manager);
+};
+
+#endif // RTC_VXWORKSRTEXECUTIONCONTEXT_H
+
More information about the openrtm-commit
mailing list