start CDUtils
git-svn-id: svn://db.shs.com.ru/libs@96 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
67
cd_utils/CMakeLists.txt
Normal file
67
cd_utils/CMakeLists.txt
Normal file
@@ -0,0 +1,67 @@
|
||||
project(cd_utils)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
if (NOT LIBPROJECT)
|
||||
find_package(PIP REQUIRED)
|
||||
endif ()
|
||||
if (MINGW)
|
||||
find_package(MinGW REQUIRED)
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
|
||||
set(PULT_NAME "cd_pult")
|
||||
option(PULT "Build ${PULT_NAME}" 1)
|
||||
option(LIB "System install" 1)
|
||||
option(DEBUG "Build with -g3" 0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
||||
if (DEBUG)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||
endif ()
|
||||
set(CPPS_UTILS "cdutils.cpp")
|
||||
set(HDRS_UTILS "cdutils.h")
|
||||
if (DEFINED ENV{QNX_HOST})
|
||||
add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS} ${HDRS_UTILS})
|
||||
else ()
|
||||
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS})
|
||||
endif ()
|
||||
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
|
||||
|
||||
add_executable(cdutilsngtest WIN32 "cdutilstest.cpp")
|
||||
target_link_libraries(cdutilsngtest ${PIP_LIBRARY} ${PROJECT_NAME})
|
||||
|
||||
# if (NOT DEFINED ENV{QNX_HOST})
|
||||
# if (PULT)
|
||||
# find_package(Qt4 REQUIRED)
|
||||
# find_package(OpenGL REQUIRED)
|
||||
# include_directories(${QT_INCLUDES})
|
||||
# set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
|
||||
# set(MOCS "kx_pult.h")
|
||||
# file(GLOB UIS "*.ui")
|
||||
# file(GLOB RES "*.qrc")
|
||||
# qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||
# qt4_wrap_ui(CUIS ${UIS})
|
||||
# qt4_add_resources(RESS ${RES})
|
||||
# add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
||||
# set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets)
|
||||
# target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME})
|
||||
# endif ()
|
||||
# endif ()
|
||||
# if (LIB)
|
||||
# if (WIN32)
|
||||
# set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||
# install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
|
||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
|
||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
|
||||
# else ()
|
||||
# set(CMAKE_INSTALL_PREFIX /usr)
|
||||
# install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||
# install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
# endif ()
|
||||
# message(STATUS "Install to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
# else ()
|
||||
# install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
# message(STATUS "Install to local \"bin\"")
|
||||
# endif ()
|
||||
# if (NOT DEFINED ENV{QNX_HOST})
|
||||
# if (KX_PULT)
|
||||
# install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
# endif ()
|
||||
# endif ()
|
||||
40
cd_utils/cdutils.cpp
Normal file
40
cd_utils/cdutils.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "cdutils.h"
|
||||
|
||||
volatile double X[KX_COUNT];
|
||||
volatile PIMap<int, double> K;
|
||||
|
||||
static const char connection_config[] =
|
||||
"include = ip.conf\n\
|
||||
[connection]\n\
|
||||
device.c = eth://UDP:127.0.0.1:36102:127.0.0.1:36101 #s\n\
|
||||
device.c.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k = eth://UDP:127.0.0.1:26102:127.0.0.1:26101 #s\n\
|
||||
device.k.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x = eth://UDP:127.0.0.1:16102:127.0.0.1:16101 #s\n\
|
||||
device.x.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.c_eth = eth://UDP:${ip_kx}:36102:${ip_kxpult}:36101 #s\n\
|
||||
device.c_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k_eth = eth://UDP:${ip_kx}:26102:${ip_kxpult}:26101 #s\n\
|
||||
device.k_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x_eth = eth://UDP:${ip_kx}:16102:${ip_kxpult}:16101 #s\n\
|
||||
device.x_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
channel.0.from = eth://UDP:127.0.0.1:16102:127.0.0.1:16101 #s\n\
|
||||
channel.0.to = eth://UDP:${ip_kx}:16102:${ip_kxpult}:16101 #s\n\
|
||||
channel.1.from = eth://UDP:127.0.0.1:26102:127.0.0.1:26101 #s\n\
|
||||
channel.1.to = eth://UDP:${ip_kx}:26102:${ip_kxpult}:26101 #s\n\
|
||||
channel.2.from = eth://UDP:127.0.0.1:36102:127.0.0.1:36101 #s\n\
|
||||
channel.2.to = eth://UDP:${ip_kx}:36102:${ip_kxpult}:36101 #s\n\
|
||||
[]\n\
|
||||
connectionmodel = AAAWNHja7ZbfShtBFMa/Xf9UrYLSXnqhErxrdSNYKBRXEMQbEVGhBBRJgob4J6SxSZBC38ELb32UBR/AV/ARfAP9MjmzyQ7TGGkaGzeznMycmTNnZn/zLRkAH5HGOc74ZNkqIac8YBhwLlk7tEHUi1trP7KwHqCN+AhLLeYHpqC7HEeFqbLygJal3XHfPjxE2/kX69UxYK32en62vnqwIXvJwOr7m1JLvPZZ3tGmBR0ErSNYXY20gbuPvxl/eSaKuxxY/RC/xPfxdwb/3u8o7u+w+iF+ie/j7wj+IBXFH+zD6mvcOr7L+PXW3xz+nIH7KLD6If4c+urvIP6qgb96Y/VD/NW/xa/W5rj7SeImg2Jg5nRlji7M4dwJk1U9jzaOAz4lVFHgHUuOsjEHo9IXnrceXJe+cbXQGQ5xak3wgTYG9ZPnSlmudWykuo7sJ8OYn7zppa3pDnS6PUn1FQt8dnkYW2wncMmpBYblUcEv9iSxDA+LrM3RAi5wwhzNUZ6xtW+Rtzzl9TPTGtOAkSAlCeZpc5yc48cQvdPusK+G7pzbKVlST6gT90ciX9Rgk8TnZdIYyigyWUntEGrHRbYPkWkIq0k0CfSCaCqvIRqvLdF48RONX7jvBdGkX0M0S22JZik2opk1RaP/Ev8gmttOimalTdG816fsElE0xdULxJLSabatYvEoii/4zGOvm2fIpdV4jISi7zH/uVDy3RVK8hmhJGMolAR6QSiV7grFe0YoMbivPAGq7YwD"
|
||||
;
|
||||
|
||||
CDUtils::CDUtils() {
|
||||
PIString s(connection_config);
|
||||
connection.configureFromString(&s);
|
||||
// connection.start();
|
||||
}
|
||||
|
||||
void CDUtils::test() {
|
||||
//piCoutObj << connection.makeConfig();
|
||||
piCoutObj << connection.boundedDevices().size();
|
||||
}
|
||||
25
cd_utils/cdutils.h
Normal file
25
cd_utils/cdutils.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CDUTILS_H
|
||||
#define CDUTILS_H
|
||||
|
||||
#include "piconnection.h"
|
||||
#include "pidatatransfer.h"
|
||||
|
||||
|
||||
#define KX_COUNT 16384
|
||||
|
||||
extern volatile double X[KX_COUNT];
|
||||
extern volatile PIMap<int, double> K;
|
||||
|
||||
class CDUtils : public PIObject
|
||||
{
|
||||
PIOBJECT(CDUtils)
|
||||
public:
|
||||
CDUtils();
|
||||
void test();
|
||||
|
||||
private:
|
||||
PIConnection connection;
|
||||
|
||||
};
|
||||
|
||||
#endif // CDUTILS_H
|
||||
9
cd_utils/cdutilstest.cpp
Normal file
9
cd_utils/cdutilstest.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "cdutils.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
CDUtils cd;
|
||||
piMSleep(1000);
|
||||
cd.test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user