1 Commits

Author SHA1 Message Date
a29302e2e6 Added additional poll method without timeout 2020-07-16 12:03:27 +03:00
747 changed files with 22055 additions and 21129 deletions

View File

@@ -9,84 +9,18 @@ project(libs)
set(PIP_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pip/cmake") set(PIP_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pip/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${PIP_CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/qad/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${PIP_CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/qad/cmake")
set(LIBPROJECT 1) set(LIBPROJECT 1)
set(_qt_libs )
set(_qt_apps )
set(_qt_plugs)
include(GenerateExportHeader)
include(SDKMacros) include(SDKMacros)
include(QADMacros)
include(DeployMacros) include(DeployMacros)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(NOT DEFINED BUILD_NUMBER) if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999) set(BUILD_NUMBER 9999)
endif() endif()
if("x${BUILD_NUMBER}" STREQUAL "x") if("x${BUILD_NUMBER}" STREQUAL "x")
set(BUILD_NUMBER 0) set(BUILD_NUMBER 0)
endif() endif()
set(_COMPANY SHS)
set(_DOMAIN org.SHS)
if(STATIC_LIB)
set(QAD_LIB_TYPE STATIC)
add_definitions(-DQAD_STATIC_DEFINE)
set(QAD_LIB_TYPE_MSG "Static")
else()
set(QAD_LIB_TYPE SHARED)
set(QAD_LIB_TYPE_MSG "Shared")
endif()
set(_QAD_MAJOR 1)
set(_QAD_MINOR 9)
set(_QAD_REVISION 0)
set(_QAD_SUFFIX )
set(_QAD_COMPANY SHS)
set(_QAD_DOMAIN org.SHS)
set(QAD_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/qad/qad_version.h")
set_version(QAD
MAJOR "${_QAD_MAJOR}"
MINOR "${_QAD_MINOR}"
REVISION "${_QAD_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_QAD_SUFFIX}"
OUTPUT "${QAD_VERSION_FILE}")
set_deploy_property(QAD ${QAD_LIB_TYPE}
FULLNAME "${_QAD_DOMAIN}.*"
COMPANY "${_QAD_COMPANY}")
if(STATIC_LIB)
set(PIQt_LIB_TYPE STATIC)
add_definitions(-DPIQt_STATIC_DEFINE)
set(PIQt_LIB_TYPE_MSG "Static")
else()
set(PIQt_LIB_TYPE SHARED)
set(PIQt_LIB_TYPE_MSG "Shared")
endif()
set(_PIQt_MAJOR 1)
set(_PIQt_MINOR 0)
set(_PIQt_REVISION 0)
set(_PIQt_SUFFIX )
set(_PIQt_COMPANY SHS)
set(_PIQt_DOMAIN org.SHS)
if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999)
endif()
set(PIQt_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/piqt/piqt_version.h")
set_version(PIQt
MAJOR "${_PIQt_MAJOR}"
MINOR "${_PIQt_MINOR}"
REVISION "${_PIQt_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIQt_SUFFIX}"
OUTPUT "${PIQt_VERSION_FILE}")
set_deploy_property(PIQt ${_PIQt_LIB_TYPE}
FULLNAME "${_PIQt_DOMAIN}.*"
COMPANY "${_PIQt_COMPANY}")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip) include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/qad)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/piqt)
if(MINGW) if(MINGW)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
else() else()
@@ -111,22 +45,21 @@ if (DEFINED ANDROID_PLATFORM)
#message("${ANDROID_NDK}/sysroot/usr/include") #message("${ANDROID_NDK}/sysroot/usr/include")
endif() endif()
set(INSTALL_PREFIX "") set(INSTALL_PREFIX "")
set(_plugins_default_ ON) set(_plugins_default_ 1)
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(_plugins_default_ OFF) set(_plugins_default_ 0)
set(INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}/") set(INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}/")
else() else()
set(INSTALL_PREFIX "${CMAKE_STAGING_PREFIX}") set(INSTALL_PREFIX "${CMAKE_STAGING_PREFIX}")
endif() endif()
endif() endif()
option(CROSSTOOLS "Crosstools minimal build" OFF) option(CROSSTOOLS "Crosstools minimal build" 0)
option(LIB "System install" ON) option(LIB "System install" 1)
option(QGLVIEW "Build QGLview library and utils" OFF) option(QGLVIEW "Build QGLview library and utils" 0)
option(QGLENGINE "Build QGLENGINE library and utils" OFF) option(QGLENGINE "Build QGLENGINE library and utils" 0)
option(UTILS "Build various utils" ${_plugins_default_}) option(UTILS "Build various utils" ${_plugins_default_})
option(DESIGNER_PLUGINS "Build qt designer plugins" ${_plugins_default_}) option(DESIGNER_PLUGINS "Build qt designer plugins" ${_plugins_default_})
option(STATIC_LIB OFF)
if (CROSSTOOLS) if (CROSSTOOLS)
set(LIB 1) set(LIB 1)
set(QGLVIEW 0) set(QGLVIEW 0)
@@ -144,6 +77,7 @@ endif()
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(PIP_LIBRARY pip) set(PIP_LIBRARY pip)
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
set(PIP_INCLUDES) set(PIP_INCLUDES)
if(LIB) if(LIB)
@@ -167,6 +101,9 @@ else()
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif() endif()
foreach(F ${PIP_FOLDERS})
list(APPEND PIP_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/pip/lib/main/${F}")
endforeach(F)
#message(${PIP_INCLUDES}) #message(${PIP_INCLUDES})
if(CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) if(CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
set(PIP_CMG "pip_cmg") set(PIP_CMG "pip_cmg")
@@ -182,7 +119,6 @@ if(WIN32)
endif() endif()
set(QAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qad) set(QAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qad)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (CROSSTOOLS) if (CROSSTOOLS)
@@ -207,27 +143,20 @@ else()
endif() endif()
endforeach() endforeach()
#if(UTILS) if(UTILS)
# message(STATUS "Building with utils") message(STATUS "Building with utils")
#else() else()
# message(STATUS "Building only libraries") message(STATUS "Building only libraries")
#endif() endif()
add_subdirectory(pip) add_subdirectory(pip)
foreach(F ${PIP_MAIN_FOLDERS})
list(APPEND PIP_INCLUDES "${F}")
endforeach(F)
add_subdirectory(cd_utils)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cd_utils" "${CMAKE_CURRENT_BINARY_DIR}/cd_utils")
set(_DIRS) set(_DIRS)
if (SomeQtFound) if (SomeQtFound)
#message(STATUS "Building Qt-derived targets for ${QtVersions}") message(STATUS "Building Qt-derived targets for ${QtVersions}")
add_subdirectory(qad) add_subdirectory(qad)
include_directories(${qad_includes}) set(_DIRS piqt piqt_utils qcd_utils)
add_subdirectory(piqt)
include_directories(${piqt_includes})
set(_DIRS)
if (Qt5) if (Qt5)
list(APPEND _DIRS)
if (QGLVIEW) if (QGLVIEW)
list(APPEND _DIRS qglview) list(APPEND _DIRS qglview)
endif() endif()
@@ -237,62 +166,21 @@ else()
endif() endif()
foreach(_D ${_DIRS}) foreach(_D ${_DIRS})
list(APPEND QT_MULTILIB_LIST ${_D}) list(APPEND QT_MULTILIB_LIST ${_D})
add_subdirectory(${_D})
endforeach(_D) endforeach(_D)
include_directories(piqt)
macro(align_list _list _out)
set(_max_len 0)
foreach(_m ${_list})
string(LENGTH "${_m}" _clen)
if (_clen GREATER _max_len)
set(_max_len ${_clen})
endif()
endforeach()
set(${_out})
foreach(_m ${_list})
set(_am "${_m}")
while(TRUE)
string(LENGTH "${_am}" _clen)
if (_clen GREATER_EQUAL ${_max_len})
break()
endif()
string(APPEND _am " ")
endwhile()
list(APPEND ${_out} "${_am}")
endforeach()
endmacro()
macro(print_list _list _name)
if (NOT "x${_list}" STREQUAL "x")
message("")
message(" ${_name}:")
#align_list("${_list}" _alist)
foreach(_m ${_list})
message(" * ${_m}")
endforeach()
endif()
endmacro()
message("----------QAD-----------")
message(" Build for ${QtVersions}")
message(" QAD Version: ${QAD_VERSION}")
message(" QAD Linkage: ${QAD_LIB_TYPE_MSG}")
message(" PIQt Version: ${PIQt_VERSION}")
message(" PIQt Linkage: ${PIQt_LIB_TYPE_MSG}")
print_list("${_qt_libs}" "Libraries")
print_list("${_qt_apps}" "Applications")
print_list("${_qt_plugs}" "Plugins")
message("-----------------------")
message("")
else() else()
message(STATUS "None of Qt found, skip Qt-derived targets") message(STATUS "None of Qt found, skip Qt-derived targets")
endif() endif()
include_directories(cd_utils)
list(INSERT _DIRS 0 cd_utils)
foreach(_D ${_DIRS})
add_subdirectory(${_D})
endforeach(_D)
endif() endif()
if(WIN32) if(WIN32)
foreach(PIP_LT ${PIP_MODULES}) foreach(PIP_LT ${PIP_LIBS_TARGETS})
if (SomeQtFound) if (SomeQtFound)
qt_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pip/lib${PIP_LT}.dll" DESTINATION QtBin) qt_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pip/lib${PIP_LT}.dll" DESTINATION QtBin)
endif() endif()

View File

@@ -1,107 +1,35 @@
macro(sdk_install _DIR IS_APP _TARGET _H_FILES _QM_FILES) macro(sdk_install _DIR _TARGET _H_FILES _QM_FILES)
#message("QM=${_QM_FILES}") #message("QM=${_QM_FILES}")
if((NOT ${IS_APP}) AND (NOT "${_H_FILES}" STREQUAL "")) if(LIB)
if(LIB) if(WIN32)
if(WIN32) if(NOT "x${_H_FILES}" STREQUAL "x")
install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR}) install(FILES ${_H_FILES} DESTINATION ${MINGW_INCLUDE}/${_DIR})
else() endif()
install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR}) qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB})
endif() qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN})
else() qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin)
install(FILES ${_H_FILES} DESTINATION include/${_DIR}) else()
endif() if (NOT "x${_H_FILES}" STREQUAL "x")
endif() install(FILES ${_H_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${_DIR})
if (NOT "${_TARGET}" STREQUAL "") endif()
if(LIB) qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
if(WIN32) endif()
if (${IS_APP}) if(NOT "x${_QM_FILES}" STREQUAL "x")
qt_install(TARGETS ${_TARGET} DESTINATION ${MINGW_BIN}) qt_install(LANG ${_QM_FILES} DESTINATION QtLang)
qt_install(TARGETS ${_TARGET} DESTINATION QtBin) endif()
else() else()
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION ${MINGW_LIB}) if(NOT "x${_H_FILES}" STREQUAL "x")
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION ${MINGW_BIN}) install(FILES ${_H_FILES} DESTINATION include/${_DIR})
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION QtBin) endif()
endif() if(WIN32)
else() qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin)
if (${IS_APP}) qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib)
qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else()
else() qt_install(TARGETS ${_TARGET} DESTINATION lib)
qt_install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) endif()
endif() if(NOT "x${_QM_FILES}" STREQUAL "x")
endif() qt_install(LANG ${_QM_FILES} DESTINATION lang)
if(NOT "x${_QM_FILES}" STREQUAL "x") endif()
qt_install(LANG ${_QM_FILES} DESTINATION QtLang) endif()
endif() endmacro()
else()
if(${IS_APP})
qt_install(TARGETS ${_TARGET} DESTINATION bin)
else()
if(WIN32)
qt_install(TARGETS ${_TARGET} RUNTIME DESTINATION bin)
qt_install(TARGETS ${_TARGET} ARCHIVE DESTINATION lib)
else()
qt_install(TARGETS ${_TARGET} DESTINATION lib)
endif()
endif()
if(NOT "x${_QM_FILES}" STREQUAL "x")
qt_install(LANG ${_QM_FILES} DESTINATION lang)
endif()
endif()
endif()
endmacro()
macro(copy_to_parent _inc_var)
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
set(_qt_libs ${_qt_libs} PARENT_SCOPE)
set(_qt_apps ${_qt_apps} PARENT_SCOPE)
set(_qt_plugs ${_qt_plugs} PARENT_SCOPE)
if (NOT "x${_inc_var}" STREQUAL "x")
set(${_inc_var} ${${_inc_var}} PARENT_SCOPE)
endif()
if (LIB)
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()
endmacro()
macro(add_directories_with_include multilib_prefix)
set(DIRS)
file(GLOB _dl "[^.]*")
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d})
list(APPEND DIRS ${_d})
endif()
endforeach()
set(inc_var ${multilib_prefix}includes)
set(${inc_var})
foreach(_d ${DIRS})
get_filename_component(_dname "${_d}" NAME)
list(APPEND QT_MULTILIB_LIST ${multilib_prefix}${_dname})
list(APPEND ${inc_var} "${_d}")
list(APPEND ${inc_var} "${CMAKE_CURRENT_BINARY_DIR}/${_dname}")
endforeach()
include_directories(${${inc_var}})
foreach(_d ${DIRS})
add_subdirectory(${_d})
endforeach()
copy_to_parent(${inc_var})
endmacro()
macro(add_directories multilib_prefix)
include_directories(${${multilib_prefix}includes})
file(GLOB _dl "[^.]*")
foreach(_d ${_dl})
if(IS_DIRECTORY ${_d})
add_subdirectory(${_d})
endif()
endforeach()
copy_to_parent(${multilib_prefix}includes)
endmacro()

View File

@@ -0,0 +1,6 @@
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY FIRST)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE FIRST)
set(CMAKE_PREFIX_PATH /soft/android/${ANDROID_ABI})
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}/lib)
include_directories(${CMAKE_PREFIX_PATH}/include)

View File

@@ -1,37 +1,86 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(cd_utils) project(cd_utils)
find_package(MinGW REQUIRED) if (NOT LIBPROJECT)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES}) find_package(PIP REQUIRED)
file(GLOB CPPS_UTILS "cdutils_*.cpp") option(LIB "System install" 1)
file(GLOB HDRS_UTILS "cdutils_*.h") option(DEBUG "Build with -g3" 0)
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY}) if (DEBUG)
generate_export_header(${PROJECT_NAME}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
list(APPEND HDRS_UTILS "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h") endif()
endif()
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h") if (MINGW)
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME}) find_package(MinGW REQUIRED)
message(STATUS "Building ${PROJECT_NAME}") endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
if(LIB) #file(GLOB HDRS_UTILS "*.h")
list(APPEND _ALL_TARGETS ${PROJECT_NAME}) #file(GLOB CPPS_UTILS "*.cpp")
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) file(GLOB CPPS_UTILS "cdutils_*.cpp")
if(WIN32) file(GLOB HDRS_UTILS "cdutils_*.h")
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE}) if (DEFINED ENV{QNX_HOST})
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB}) add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS} ${HDRS_UTILS})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN}) else()
else() add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS} ${HDRS_UTILS})
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) endif()
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
endif()
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") # # Apple crosscompiling rpath patch
else() # if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
if(WIN32) # foreach(_RP ${CMAKE_INSTALL_RPATH})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) # add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib) # COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
else() # "-add_rpath" "${_RP}"
install(TARGETS ${PROJECT_NAME} DESTINATION lib) # "$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
endif() # COMMENT "Add to ${PROJECT_NAME} rpath \"${_RP}\"")
install(FILES ${HDRS_UTILS} DESTINATION include) # endforeach()
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"") # endif()
endif()
add_executable(cdutilstest "cdutilstest.cpp" "cdtest.h")
target_link_libraries(cdutilstest ${PIP_LIBRARY} ${PROJECT_NAME})
message(STATUS "Building ${PROJECT_NAME}")
if(NOT LIBPROJECT)
if(LIB)
if(WIN32)
if(MINGW)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
endif()
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
endif()
endif()
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif()
endif()
if(LIB)
list(APPEND _ALL_TARGETS ${PROJECT_NAME})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
if(WIN32)
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
else()
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(WIN32)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
else()
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif()
install(FILES ${HDRS_UTILS} DESTINATION include)
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
endif()

View File

@@ -1,10 +1,10 @@
#ifndef CDTEST_H #ifndef CDTEST_H
#define CDTEST_H #define CDTEST_H
enum KDescription { enum KDescription {
First, //f Первый First, //f Первый
Second, //b Второй Second, //b Второй
}; };
#endif // CDTEST_H #endif // CDTEST_H

View File

@@ -1,41 +1,41 @@
#include "cdutils_c.h" #include "cdutils_c.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
CInterface C; CInterface C;
CInterface::CInterface(): Interface(CDType::cdC) { CInterface::CInterface(): Interface(CDType::cdC) {
} }
void CInterface::sendCommand(const CDType & c) { void CInterface::sendCommand(const CDType & c) {
core->sendCommand(c); core->sendCommand(c);
} }
void CInterface::connect(const CDType & c, PIObject * o, Handler eh) { void CInterface::connect(const CDType & c, PIObject * o, Handler eh) {
core->registerCHandler(c, o, eh); core->registerCHandler(c, o, eh);
} }
void CInterface::autoConnect(PIObject * o, const PIString & prefix) { void CInterface::autoConnect(PIObject * o, const PIString & prefix) {
if (!o) return; if (!o) return;
uint cid = o->classNameID(); uint cid = o->classNameID();
if (!PIObject::__meta_data().contains(cid)) return; if (!PIObject::__meta_data().contains(cid)) return;
PIMap<PIString, Handler> eh_map; PIMap<PIString, Handler> eh_map;
PIObject::__MetaData & md(PIObject::__meta_data()[cid]); PIObject::__MetaData & md(PIObject::__meta_data()[cid]);
PIMap<const void * , __MetaFunc>::const_iterator it; PIMap<const void * , __MetaFunc>::const_iterator it;
for (it = md.eh_func.constBegin(); it != md.eh_func.constEnd(); ++it) { for (it = md.eh_func.constBegin(); it != md.eh_func.constEnd(); ++it) {
eh_map[it.value().func_name] = (Handler)it.value().addr; eh_map[it.value().func_name] = (Handler)it.value().addr;
//piCout << "func" << it.value().func_name; //piCout << "func" << it.value().func_name;
} }
PIVector<CDType * > cl = C.root().children(); PIVector<CDType * > cl = C.root().children();
piForeachC (CDType * c, cl) { piForeachC (CDType * c, cl) {
PIString cp = prefix + c->pathString().join("_"); PIString cp = prefix + c->pathString().join("_");
if (cp.isEmpty()) continue; if (cp.isEmpty()) continue;
if (!eh_map.contains(cp)) continue; if (!eh_map.contains(cp)) continue;
connect(*c, o, eh_map[cp]); connect(*c, o, eh_map[cp]);
} }
} }

View File

@@ -1,46 +1,45 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_C_H #ifndef CDUTILS_C_H
#define CDUTILS_C_H #define CDUTILS_C_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CInterface: public Interface
class CD_UTILS_EXPORT CInterface: public Interface {
{ PIOBJECT_SUBCLASS(CInterface, Interface)
PIOBJECT_SUBCLASS(CInterface, Interface) public:
public: CInterface();
CInterface();
void sendCommand(const CDType & c);
void sendCommand(const CDType & c); void connect(const CDType & c, PIObject * o, Handler eh);
void connect(const CDType & c, PIObject * o, Handler eh); void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_"));
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_"));
};
};
}
}
extern CDUtils::CInterface C;
extern CD_UTILS_EXPORT CDUtils::CInterface C;
#endif // CDUTILS_C_H
#endif // CDUTILS_C_H

View File

@@ -1,606 +1,606 @@
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdutils_parser.h" #include "cdutils_parser.h"
#include "piconfig.h" #include "piconfig.h"
#include "piiobytearray.h" #include "piiobytearray.h"
#include "piiostring.h" #include "piiostring.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
const char CDCore::app_config[] = const char CDCore::app_config[] =
"include = cd_ip.conf\n\ "include = cd_ip.conf\n\
port_rec = 2\n\ port_rec = 2\n\
port_send = 1\n\ port_send = 1\n\
[connection]\n\ [connection]\n\
device.cd = peer://cd_app:cd_pult #s\n\ device.cd = peer://cd_app:cd_pult #s\n\
[]\n\ []\n\
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\ connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
"; ";
const char CDCore::pult_config[] = const char CDCore::pult_config[] =
"include = cd_ip.conf\n\ "include = cd_ip.conf\n\
port_rec = 1\n\ port_rec = 1\n\
port_send = 2\n\ port_send = 2\n\
[connection]\n\ [connection]\n\
device.cd = peer://cd_pult:cd_app #s\n\ device.cd = peer://cd_pult:cd_app #s\n\
[]\n\ []\n\
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\ connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
"; ";
int __Core_Initializer__::count_(0); int __Core_Initializer__::count_(0);
CDCore * __Core_Initializer__::__instance__(0); CDCore * __Core_Initializer__::__instance__(0);
const uchar header_direct = 0x80; const uchar header_direct = 0x80;
const uchar header_transfer = 0x81; const uchar header_transfer = 0x81;
__Core_Initializer__::__Core_Initializer__() { __Core_Initializer__::__Core_Initializer__() {
count_++; count_++;
if (count_ > 1) return; if (count_ > 1) return;
__instance__ = new CDCore(); __instance__ = new CDCore();
} }
__Core_Initializer__::~__Core_Initializer__() { __Core_Initializer__::~__Core_Initializer__() {
count_--; count_--;
if (count_ < 0) { if (count_ < 0) {
count_ = 0; count_ = 0;
return; return;
} }
if (count_ > 0) return; if (count_ > 0) return;
if (__instance__) { if (__instance__) {
delete __instance__; delete __instance__;
__instance__ = 0; __instance__ = 0;
} }
} }
CDCore::CDCore() { CDCore::CDCore() {
setName("CDCore"); setName("CDCore");
x_timer.setName("__S__.CDCore.x_timer"); x_timer.setName("__S__.CDCore.x_timer");
datatr.setPacketSize(960); datatr.setPacketSize(960);
CONNECTU(&connection, dataReceivedEvent, this, dataReceived); CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished); CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished);
/*PIString s(app_config); /*PIString s(app_config);
connection.configureFromString(&s); connection.configureFromString(&s);
connection.start();*/ connection.start();*/
need_rebuild_x = x_pult_side = false; need_rebuild_x = x_pult_side = false;
k_.cd_type_ = CDType::cdK; k_.cd_type_ = CDType::cdK;
x_.cd_type_ = CDType::cdX; x_.cd_type_ = CDType::cdX;
c_.cd_type_ = CDType::cdC; c_.cd_type_ = CDType::cdC;
m_.cd_type_ = CDType::cdM; m_.cd_type_ = CDType::cdM;
initRoot(&k_); initRoot(&k_);
initRoot(&x_); initRoot(&x_);
initRoot(&c_); initRoot(&c_);
initRoot(&m_); initRoot(&m_);
CONNECTU(&sendt, started, this, sendThread) CONNECTU(&sendt, started, this, sendThread)
CONNECTU(&datatr, sendRequest, this, dtSendRequest) CONNECTU(&datatr, sendRequest, this, dtSendRequest)
CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished) CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished)
CONNECTU(&x_timer, tickEvent, this, xTimerTick) CONNECTU(&x_timer, tickEvent, this, xTimerTick)
/*k_[1] = KType(1, "123", "120+3", "comment"); /*k_[1] = KType(1, "123", "120+3", "comment");
k_[2] = KType(2, "1", "2", "comm"); k_[2] = KType(2, "1", "2", "comm");
k_[4] = KType(4, "-0.6", "-6/10", "mment"); k_[4] = KType(4, "-0.6", "-6/10", "mment");
k_.section(10)[5] = KType(5, "8", "2*2*2", "88"); k_.section(10)[5] = KType(5, "8", "2*2*2", "88");
k_.section(10).section(50)[100] = KType(100, "8", "2*2*2", "88"); k_.section(10).section(50)[100] = KType(100, "8", "2*2*2", "88");
k_.section(11)[3] = KType(3, "1", "1", "88"); k_.section(11)[3] = KType(3, "1", "1", "88");
k_.section(11)[4] = KType(4, "0", "0", "88"); k_.section(11)[4] = KType(4, "0", "0", "88");
k_.section(11)[6] = KType(6, "0", "0", "88");*/ k_.section(11)[6] = KType(6, "0", "0", "88");*/
//piCout << s; //piCout << s;
} }
CDCore::~CDCore() { CDCore::~CDCore() {
x_timer.stop(true); x_timer.stop(true);
datatr.stop(); datatr.stop();
sendt.stop(); sendt.stop();
sendt.waitForFinish(10); sendt.waitForFinish(10);
connection.stop(); connection.stop();
} }
void CDCore::cd_write(CDSection * cd, PIIODevice * d) { void CDCore::cd_write(CDSection * cd, PIIODevice * d) {
cd->write(d, PIString()); cd->write(d, PIString());
} }
void CDCore::cd_read(CDSection * cd, PIIODevice * d) { void CDCore::cd_read(CDSection * cd, PIIODevice * d) {
PIConfig conf(d, PIIODevice::ReadOnly); PIConfig conf(d, PIIODevice::ReadOnly);
cd->read(&(conf.rootEntry())); cd->read(&(conf.rootEntry()));
if (cd->cd_type_ == CDType::cdX) if (cd->cd_type_ == CDType::cdX)
x_selected = cd->collectX(); x_selected = cd->collectX();
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
/*PIVector<PIIODevice * > ds = connection.allDevices(); /*PIVector<PIIODevice * > ds = connection.allDevices();
piForeach(PIIODevice * d, ds) { piForeach(PIIODevice * d, ds) {
if (d) if (d)
piCoutObj << d->constructFullPath() << d->isOpened(); piCoutObj << d->constructFullPath() << d->isOpened();
}*/ }*/
} }
void CDCore::cd_parse(CDSection * cd, PIIODevice * d) { void CDCore::cd_parse(CDSection * cd, PIIODevice * d) {
*cd = CDParser::parse(d, cd->cd_type_); *cd = CDParser::parse(d, cd->cd_type_);
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_update(CDSection * cd, PIIODevice * d, UpdateModeFlags mode) { void CDCore::cd_update(CDSection * cd, PIIODevice * d, UpdateModeFlags mode) {
CDSection ucd = *cd; CDSection ucd = *cd;
cd_parse(cd, d); cd_parse(cd, d);
/*bool kn = true; /*bool kn = true;
if (!ucd.isEmpty()) if (!ucd.isEmpty())
if (!ucd.isSameStructure(k_)) { if (!ucd.isSameStructure(k_)) {
piCout << "ask for save names"; piCout << "ask for save names";
K_KeepNamesRequest(&kn); K_KeepNamesRequest(&kn);
}*/ }*/
ucd.update(*cd, mode); ucd.update(*cd, mode);
//piCout << k_.count() << ucd.count(); //piCout << k_.count() << ucd.count();
*cd = ucd; *cd = ucd;
initRoot(cd); initRoot(cd);
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_calculate(CDSection * cd) { void CDCore::cd_calculate(CDSection * cd) {
cd->calculate(); cd->calculate();
raiseChangedGlobal(cd->cd_type_); raiseChangedGlobal(cd->cd_type_);
} }
void CDCore::cd_send(CDSection * cd, CDPacketType pt, bool direct) { void CDCore::cd_send(CDSection * cd, CDPacketType pt, bool direct) {
if (!cd) return; if (!cd) return;
PIByteArray ba, sba; PIByteArray ba, sba;
PIIOByteArray iob(&ba, PIIODevice::ReadWrite); PIIOByteArray iob(&ba, PIIODevice::ReadWrite);
cd_write(cd, &iob); cd_write(cd, &iob);
//piCoutObj << PIString(ba); //piCoutObj << PIString(ba);
sba = makeHeader(pt, 0); sba = makeHeader(pt, 0);
sba << ba; sba << ba;
if (direct) if (direct)
sendDirect(sba); sendDirect(sba);
else else
sendThreaded(sba); sendThreaded(sba);
} }
void CDCore::send(CDType::cdT cdt) { void CDCore::send(CDType::cdT cdt) {
CDPacketType pt = CD_Ping; CDPacketType pt = CD_Ping;
switch (cdt) { switch (cdt) {
case CDType::cdK: pt = CD_KSend; break; case CDType::cdK: pt = CD_KSend; break;
case CDType::cdX: pt = CD_XSend; break; case CDType::cdX: pt = CD_XSend; break;
case CDType::cdC: pt = CD_CSend; break; case CDType::cdC: pt = CD_CSend; break;
case CDType::cdM: pt = CD_MSend; break; case CDType::cdM: pt = CD_MSend; break;
default: break; default: break;
} }
piCoutObj << "send" << typeLetter(cdt); piCoutObj << "send" << typeLetter(cdt);
cd_send(root(cdt), pt); cd_send(root(cdt), pt);
} }
void CDCore::request(CDType::cdT cdt) { void CDCore::request(CDType::cdT cdt) {
CDPacketType pt = CD_Ping; CDPacketType pt = CD_Ping;
switch (cdt) { switch (cdt) {
case CDType::cdK: pt = CD_KQuery; break; case CDType::cdK: pt = CD_KQuery; break;
case CDType::cdX: pt = CD_XQuery; break; case CDType::cdX: pt = CD_XQuery; break;
case CDType::cdC: pt = CD_CQuery; break; case CDType::cdC: pt = CD_CQuery; break;
case CDType::cdM: pt = CD_MQuery; break; case CDType::cdM: pt = CD_MQuery; break;
default: break; default: break;
} }
piCoutObj << "request" << typeLetter(cdt); piCoutObj << "request" << typeLetter(cdt);
PIByteArray sba = makeHeader(pt, 0); PIByteArray sba = makeHeader(pt, 0);
sendThreaded(sba); sendThreaded(sba);
} }
void CDCore::initApp() { void CDCore::initApp() {
init(appConfig(), false); init(appConfig(), false);
} }
void CDCore::initPult() { void CDCore::initPult() {
init(pultConfig(), true); init(pultConfig(), true);
} }
void CDCore::init(const PIString & configuration, bool pult) { void CDCore::init(const PIString & configuration, bool pult) {
PIString c = configuration; PIString c = configuration;
//piCoutObj << "init" << c; //piCoutObj << "init" << c;
connection.stop(); connection.stop();
connection.removeAllDevices(); connection.removeAllDevices();
connection.configureFromString(&c); connection.configureFromString(&c);
connection.start(); connection.start();
x_pult_side = pult; x_pult_side = pult;
} }
void CDCore::stop() { void CDCore::stop() {
x_timer.stop(); x_timer.stop();
x_timer.waitForFinish(1000); x_timer.waitForFinish(1000);
connection.stop(); connection.stop();
} }
void CDCore::release() { void CDCore::release() {
stop(); stop();
connection.removeAllDevices(); connection.removeAllDevices();
} }
void CDCore::startX(double freq) { void CDCore::startX(double freq) {
//piCout << "start x" << x_timer.isRunning() << freq; //piCout << "start x" << x_timer.isRunning() << freq;
if (!x_timer.isRunning()) if (!x_timer.isRunning())
x_timer.start(1000. / piMaxd(freq, 0.01)); x_timer.start(1000. / piMaxd(freq, 0.01));
} }
void CDCore::stopX() { void CDCore::stopX() {
x_timer.stop(); x_timer.stop();
x_timer.waitForFinish(1000); x_timer.waitForFinish(1000);
} }
void CDCore::sendCommand(const CDType & c) { void CDCore::sendCommand(const CDType & c) {
//piCoutObj << "C_sendCommand" << c; //piCoutObj << "C_sendCommand" << c;
PIByteArray sba = makeHeader(CD_Command, 0); PIByteArray sba = makeHeader(CD_Command, 0);
sba << c.path(); sba << c.path();
sendDirect(sba); sendDirect(sba);
} }
void CDCore::registerCHandler(const CDType & c, PIObject * o, Handler h) { void CDCore::registerCHandler(const CDType & c, PIObject * o, Handler h) {
PIString sp = pathToString(c.path()); PIString sp = pathToString(c.path());
if (sp.isEmpty() || !h) return; if (sp.isEmpty() || !h) return;
//piCout << "register" << sp; //piCout << "register" << sp;
c_handlers[sp] = OHPair(o, h); c_handlers[sp] = OHPair(o, h);
} }
void CDCore::sendMessage(const CDType & m, MessageType mt, const PIString & msg) { void CDCore::sendMessage(const CDType & m, MessageType mt, const PIString & msg) {
if (msg.isEmpty() || (m.cd_type() != CDType::cdM)) return; if (msg.isEmpty() || (m.cd_type() != CDType::cdM)) return;
PIByteArray sba = makeHeader(CD_Message, 0); PIByteArray sba = makeHeader(CD_Message, 0);
sba << m.path() << int(mt) << msg; sba << m.path() << int(mt) << msg;
sendDirect(sba); sendDirect(sba);
} }
CDSection * CDCore::root(CDType::cdT cdt) { CDSection * CDCore::root(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: return &k_; break; case CDType::cdK: return &k_; break;
case CDType::cdX: return &x_; break; case CDType::cdX: return &x_; break;
case CDType::cdC: return &c_; break; case CDType::cdC: return &c_; break;
case CDType::cdM: return &m_; break; case CDType::cdM: return &m_; break;
default: break; default: break;
} }
return 0; return 0;
} }
PIString CDCore::typeLetter(CDType::cdT cdt) { PIString CDCore::typeLetter(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: return PIStringAscii("k"); break; case CDType::cdK: return PIStringAscii("k"); break;
case CDType::cdX: return PIStringAscii("x"); break; case CDType::cdX: return PIStringAscii("x"); break;
case CDType::cdC: return PIStringAscii("c"); break; case CDType::cdC: return PIStringAscii("c"); break;
case CDType::cdM: return PIStringAscii("m"); break; case CDType::cdM: return PIStringAscii("m"); break;
default: break; default: break;
} }
return PIString(); return PIString();
} }
CDCore * CDCore::instance() { CDCore * CDCore::instance() {
/*static CDCore * ret = new CDCore(); /*static CDCore * ret = new CDCore();
return ret;*/ return ret;*/
return __Core_Initializer__::__instance__; return __Core_Initializer__::__instance__;
} }
bool CDCore::destroy() { bool CDCore::destroy() {
if (!__Core_Initializer__::__instance__) return false; if (!__Core_Initializer__::__instance__) return false;
// piCout << "delete Core ..."; // piCout << "delete Core ...";
delete __Core_Initializer__::__instance__; delete __Core_Initializer__::__instance__;
// piCout << "delete Core ok"; // piCout << "delete Core ok";
__Core_Initializer__::__instance__ = 0; __Core_Initializer__::__instance__ = 0;
__Core_Initializer__::count_ = 0; __Core_Initializer__::count_ = 0;
return true; return true;
} }
void CDUtils::CDCore::K_DirectChange(PIDeque<int> path, PIString value) { void CDUtils::CDCore::K_DirectChange(PIDeque<int> path, PIString value) {
// piCoutObj << "K_DirectChange"; // piCoutObj << "K_DirectChange";
PacketKDirectChange p; PacketKDirectChange p;
p.path = path; p.path = path;
p.value = value; p.value = value;
PIByteArray sba = makeHeader(CD_KDirectChange, 0); PIByteArray sba = makeHeader(CD_KDirectChange, 0);
sba << p; sba << p;
sendDirect(sba); sendDirect(sba);
} }
void CDCore::sendThread() { void CDCore::sendThread() {
if (send_data.size_s() < 4) return; if (send_data.size_s() < 4) return;
PacketHeader h; PacketHeader h;
memcpy(&h, send_data.data(), sizeof(h)); memcpy(&h, send_data.data(), sizeof(h));
bool ok = datatr.send(send_data); bool ok = datatr.send(send_data);
switch (h.type) { switch (h.type) {
case CD_KSend: case CD_KSend:
if (ok) K_Sended(); if (ok) K_Sended();
else K_SendFail(); else K_SendFail();
break; break;
case CD_KQuery: case CD_KQuery:
if (!ok) K_ReceiveFail(); if (!ok) K_ReceiveFail();
break; break;
case CD_XSend: case CD_XSend:
if (ok) X_Sended(); if (ok) X_Sended();
else X_SendFail(); else X_SendFail();
break; break;
case CD_XQuery: case CD_XQuery:
if (!ok) X_ReceiveFail(); if (!ok) X_ReceiveFail();
break; break;
case CD_CSend: case CD_CSend:
if (ok) C_Sended(); if (ok) C_Sended();
else C_SendFail(); else C_SendFail();
break; break;
case CD_CQuery: case CD_CQuery:
if (!ok) C_ReceiveFail(); if (!ok) C_ReceiveFail();
break; break;
case CD_MSend: case CD_MSend:
if (ok) M_Sended(); if (ok) M_Sended();
else M_SendFail(); else M_SendFail();
break; break;
case CD_MQuery: case CD_MQuery:
if (!ok) M_ReceiveFail(); if (!ok) M_ReceiveFail();
break; break;
default: break; default: break;
} }
} }
void CDCore::xTimerTick() { void CDCore::xTimerTick() {
//piCout << "x tick" << x_pult_side; //piCout << "x tick" << x_pult_side;
PIByteArray ba; PIByteArray ba;
x_mutex.lock(); x_mutex.lock();
if (x_pult_side) { if (x_pult_side) {
ba = makeHeader(CD_XRequest, 0); ba = makeHeader(CD_XRequest, 0);
if (need_rebuild_x) { if (need_rebuild_x) {
x_selected = x_.collectX(); x_selected = x_.collectX();
//piCout << "collectX" << x_selected.size(); //piCout << "collectX" << x_selected.size();
need_rebuild_x = false; need_rebuild_x = false;
} }
ba << x_selected; ba << x_selected;
//piCout << "x pult send" << x_selected.size(); //piCout << "x pult send" << x_selected.size();
} else { } else {
ba = makeHeader(CD_XValues, 0); ba = makeHeader(CD_XValues, 0);
ba << x_selected; ba << x_selected;
piForeachC (PIDeque<int> & p, x_selected) { piForeachC (PIDeque<int> & p, x_selected) {
x_[p].writeX(ba); x_[p].writeX(ba);
} }
//piCout << "x app" << x_selected.size(); //piCout << "x app" << x_selected.size();
} }
x_mutex.unlock(); x_mutex.unlock();
sendDirect(ba); sendDirect(ba);
} }
void CDCore::piCoutFinished(int id, PIString * buffer) { void CDCore::piCoutFinished(int id, PIString * buffer) {
if (!buffer || !(id == 1)) return; if (!buffer || !(id == 1)) return;
PIString sp = buffer->takeRange("[", "]"); PIString sp = buffer->takeRange("[", "]");
PIDeque<int> p = CDCore::stringToPath(sp); PIDeque<int> p = CDCore::stringToPath(sp);
sendMessage(m_[p], Log, *buffer); sendMessage(m_[p], Log, *buffer);
delete buffer; delete buffer;
} }
void CDCore::initRoot(CDSection * r) { void CDCore::initRoot(CDSection * r) {
r->name = "__root__"; r->name = "__root__";
r->alias = "root"; r->alias = "root";
r->makePath(); r->makePath();
r->calculate(); r->calculate();
} }
PIByteArray CDCore::makeHeader(CDPacketType type, int session_id) const { PIByteArray CDCore::makeHeader(CDPacketType type, int session_id) const {
PacketHeader h; PacketHeader h;
h.type = type; h.type = type;
h.session_id = session_id; h.session_id = session_id;
PIByteArray ret; ret << h; PIByteArray ret; ret << h;
return ret; return ret;
} }
void CDCore::sendDirect(PIByteArray & ba) { void CDCore::sendDirect(PIByteArray & ba) {
ba.push_front(header_direct); ba.push_front(header_direct);
connection.writeByName("cd", ba); connection.writeByName("cd", ba);
} }
void CDCore::sendThreaded(PIByteArray & ba) { void CDCore::sendThreaded(PIByteArray & ba) {
if (sendt.isRunning()) { if (sendt.isRunning()) {
piCoutObj << "Send in process, abort"; piCoutObj << "Send in process, abort";
return; return;
} }
send_data = ba; send_data = ba;
sendt.startOnce(); sendt.startOnce();
} }
void CDCore::procReceivedPacket(PIByteArray & ba) { void CDCore::procReceivedPacket(PIByteArray & ba) {
PacketHeader h; PacketHeader h;
ba >> h; ba >> h;
switch(h.type) { switch(h.type) {
case CD_Ping: case CD_Ping:
//piCoutObj << "ping"; //piCoutObj << "ping";
break; break;
case CD_KQuery: case CD_KQuery:
send(CDType::cdK); send(CDType::cdK);
break; break;
case CD_KSend: { case CD_KSend: {
PIByteArray k; PIByteArray k;
ba >> k; ba >> k;
k << uchar(0); k << uchar(0);
PIString s = PIString::fromUTF8((const char *)k.data()); PIString s = PIString::fromUTF8((const char *)k.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&k_, &ios); cd_read(&k_, &ios);
K_Received(); K_Received();
piCoutObj << "K received"; piCoutObj << "K received";
} break; } break;
case CD_KDirectChange: { case CD_KDirectChange: {
PacketKDirectChange p; PacketKDirectChange p;
ba >> p; ba >> p;
k_[p.path].setValue(p.value); k_[p.path].setValue(p.value);
} break; } break;
case CD_XQuery: case CD_XQuery:
send(CDType::cdX); send(CDType::cdX);
break; break;
case CD_XSend: { case CD_XSend: {
PIByteArray x; PIByteArray x;
ba >> x; ba >> x;
x << uchar(0); x << uchar(0);
PIString s = PIString::fromUTF8((const char *)x.data()); PIString s = PIString::fromUTF8((const char *)x.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&x_, &ios); cd_read(&x_, &ios);
x_selected = x_.collectX(); x_selected = x_.collectX();
X_Received(); X_Received();
piCoutObj << "X received"; piCoutObj << "X received";
} break; } break;
case CD_XRequest: { case CD_XRequest: {
if (x_pult_side) break; if (x_pult_side) break;
//break; //break;
x_mutex.lock(); x_mutex.lock();
x_selected.clear(); x_selected.clear();
ba >> x_selected; ba >> x_selected;
//piCout << "X req" << x_selected.size(); //piCout << "X req" << x_selected.size();
x_.setSelectedX(false); x_.setSelectedX(false);
piForeachC (PIDeque<int> & p, x_selected) { piForeachC (PIDeque<int> & p, x_selected) {
x_[p].x_enabled = true; x_[p].x_enabled = true;
} }
x_mutex.unlock(); x_mutex.unlock();
} break; } break;
case CD_XValues: { case CD_XValues: {
if (!x_pult_side) break; if (!x_pult_side) break;
PIVector<PIDeque<int> > x_vals; PIVector<PIDeque<int> > x_vals;
ba >> x_vals; ba >> x_vals;
x_mutex.lock(); x_mutex.lock();
piForeachC (PIDeque<int> & p, x_vals) { piForeachC (PIDeque<int> & p, x_vals) {
x_[p].readX(ba); x_[p].readX(ba);
} }
x_mutex.unlock(); x_mutex.unlock();
X_ReceivedX(x_vals); X_ReceivedX(x_vals);
} break; } break;
case CD_CQuery: case CD_CQuery:
send(CDType::cdC); send(CDType::cdC);
break; break;
case CD_CSend: { case CD_CSend: {
piCoutObj << "C received"; piCoutObj << "C received";
PIByteArray c; PIByteArray c;
ba >> c; ba >> c;
c << uchar(0); c << uchar(0);
PIString s = PIString::fromUTF8((const char *)c.data()); PIString s = PIString::fromUTF8((const char *)c.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&c_, &ios); cd_read(&c_, &ios);
C_Received(); C_Received();
} break; } break;
case CD_Command: { case CD_Command: {
piCoutObj << "C command"; piCoutObj << "C command";
PIDeque<int> p; PIDeque<int> p;
ba >> p; ba >> p;
if (p.isEmpty()) return; if (p.isEmpty()) return;
PIString sp = pathToString(p); PIString sp = pathToString(p);
OHPair h = c_handlers.value(sp, OHPair(0, 0)); OHPair h = c_handlers.value(sp, OHPair(0, 0));
//piCoutObj << "found" << sp << h.first; //piCoutObj << "found" << sp << h.first;
if (h.first && h.second) h.second(h.first); if (h.first && h.second) h.second(h.first);
} break; } break;
case CD_MQuery: case CD_MQuery:
send(CDType::cdM); send(CDType::cdM);
break; break;
case CD_MSend: { case CD_MSend: {
piCoutObj << "M received"; piCoutObj << "M received";
PIByteArray c; PIByteArray c;
ba >> c; ba >> c;
c << uchar(0); c << uchar(0);
PIString s = PIString::fromUTF8((const char *)c.data()); PIString s = PIString::fromUTF8((const char *)c.data());
PIIOString ios(&s); PIIOString ios(&s);
cd_read(&m_, &ios); cd_read(&m_, &ios);
M_Received(); M_Received();
} break; } break;
case CD_Message: { case CD_Message: {
PIDeque<int> p; PIDeque<int> p;
ba >> p; ba >> p;
piCoutObj << "M message" << p; piCoutObj << "M message" << p;
if (p.isEmpty()) return; if (p.isEmpty()) return;
int t = 0; int t = 0;
PIString msg; PIString msg;
ba >> t >> msg; ba >> t >> msg;
//piCoutObj << "found" << sp << h.first; //piCoutObj << "found" << sp << h.first;
//piCoutObj << "M message invoke"; //piCoutObj << "M message invoke";
M_Message(p, t, msg); M_Message(p, t, msg);
} break; } break;
default: break; default: break;
} }
} }
void CDCore::raiseChangedGlobal(CDType::cdT cdt) { void CDCore::raiseChangedGlobal(CDType::cdT cdt) {
switch (cdt) { switch (cdt) {
case CDType::cdK: K_ChangedGlobal(); break; case CDType::cdK: K_ChangedGlobal(); break;
case CDType::cdX: X_ChangedGlobal(); break; case CDType::cdX: X_ChangedGlobal(); break;
case CDType::cdC: C_ChangedGlobal(); break; case CDType::cdC: C_ChangedGlobal(); break;
case CDType::cdM: M_ChangedGlobal(); break; case CDType::cdM: M_ChangedGlobal(); break;
default: break; default: break;
} }
} }
PIString CDCore::pathToString(const PIDeque<int> & p) { PIString CDCore::pathToString(const PIDeque<int> & p) {
PIString ret; PIString ret;
for (int i = 0; i < p.size_s(); ++i) { for (int i = 0; i < p.size_s(); ++i) {
if (!ret.isEmpty()) ret += "."; if (!ret.isEmpty()) ret += ".";
ret << p[i]; ret << p[i];
} }
return ret; return ret;
} }
PIDeque<int> CDCore::stringToPath(const PIString & p) { PIDeque<int> CDCore::stringToPath(const PIString & p) {
PIDeque<int> ret; PIDeque<int> ret;
PIStringList sl = p.split("."); PIStringList sl = p.split(".");
piForeachC (PIString & s, sl) piForeachC (PIString & s, sl)
ret << s.toInt(); ret << s.toInt();
return ret; return ret;
} }
void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) { void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) {
//piCoutObj << "dataReceived" << from << data.size(); //piCoutObj << "dataReceived" << from << data.size();
PIIODevice * d = connection.deviceByName("cd"); PIIODevice * d = connection.deviceByName("cd");
if (d && d == connection.deviceByFullPath(from)) { if (d && d == connection.deviceByFullPath(from)) {
if (data.size() >= sizeof(4)) { if (data.size() >= sizeof(4)) {
PIByteArray ba = data; PIByteArray ba = data;
uchar header = ba.take_front(); uchar header = ba.take_front();
if (header == header_transfer) { if (header == header_transfer) {
datatr.received(ba); datatr.received(ba);
} }
if (header == header_direct) { if (header == header_direct) {
procReceivedPacket(ba); procReceivedPacket(ba);
} }
} }
} }
} }
void CDCore::dtSendRequest(PIByteArray & data) { void CDCore::dtSendRequest(PIByteArray & data) {
data.push_front(header_transfer); data.push_front(header_transfer);
connection.writeByName("cd", data); connection.writeByName("cd", data);
//piCoutObj << "send" << data.size() << ret; //piCoutObj << "send" << data.size() << ret;
} }
void CDCore::dtReceiveFinished(bool ok) { void CDCore::dtReceiveFinished(bool ok) {
if (!ok) return; if (!ok) return;
PIByteArray ba = datatr.data(); PIByteArray ba = datatr.data();
procReceivedPacket(ba); procReceivedPacket(ba);
} }

View File

@@ -1,147 +1,146 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_CORE_H #ifndef CDUTILS_CORE_H
#define CDUTILS_CORE_H #define CDUTILS_CORE_H
#include "cdutils_types.h" #include "cdutils_types.h"
#include "cdutils_protocol.h" #include "cdutils_protocol.h"
#include "piconnection.h" #include "piconnection.h"
#include "pidatatransfer.h" #include "pidatatransfer.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CDCore;
class CDCore;
class __Core_Initializer__ {
class CD_UTILS_EXPORT __Core_Initializer__ { public:
public: __Core_Initializer__();
__Core_Initializer__(); ~__Core_Initializer__();
~__Core_Initializer__(); static int count_;
static int count_; static CDCore * __instance__;
static CDCore * __instance__; };
};
class CDCore: public PIObject
class CD_UTILS_EXPORT CDCore: public PIObject {
{ PIOBJECT(CDUtils::CDCore)
PIOBJECT(CDUtils::CDCore) friend class __Core_Initializer__;
friend class __Core_Initializer__; friend class CDSection;
friend class CDSection; friend class Interface;
friend class Interface; friend class XInterface;
friend class XInterface; public:
public: static CDCore * instance();
static CDCore * instance(); static bool destroy();
static bool destroy();
EVENT(K_Sended)
EVENT(K_Sended) EVENT(K_SendFail)
EVENT(K_SendFail) EVENT(K_Received)
EVENT(K_Received) EVENT(K_ReceiveFail)
EVENT(K_ReceiveFail) EVENT(K_ChangedGlobal)
EVENT(K_ChangedGlobal) EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value);
EVENT_HANDLER2(void, K_DirectChange, PIDeque<int>, path, PIString, value);
EVENT(X_Sended)
EVENT(X_Sended) EVENT(X_SendFail)
EVENT(X_SendFail) EVENT(X_Received)
EVENT(X_Received) EVENT(X_ReceiveFail)
EVENT(X_ReceiveFail) EVENT(X_ChangedGlobal)
EVENT(X_ChangedGlobal) EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes)
EVENT1(X_ReceivedX, PIVector<PIDeque<int> >, pathes)
EVENT(C_Sended)
EVENT(C_Sended) EVENT(C_SendFail)
EVENT(C_SendFail) EVENT(C_Received)
EVENT(C_Received) EVENT(C_ReceiveFail)
EVENT(C_ReceiveFail) EVENT(C_ChangedGlobal)
EVENT(C_ChangedGlobal)
EVENT(M_Sended)
EVENT(M_Sended) EVENT(M_SendFail)
EVENT(M_SendFail) EVENT(M_Received)
EVENT(M_Received) EVENT(M_ReceiveFail)
EVENT(M_ReceiveFail) EVENT(M_ChangedGlobal)
EVENT(M_ChangedGlobal) EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg)
EVENT3(M_Message, PIDeque<int>, path, int, type, PIString, msg)
void cd_write (CDSection * cd, PIIODevice * d);
void cd_write (CDSection * cd, PIIODevice * d); void cd_read (CDSection * cd, PIIODevice * d);
void cd_read (CDSection * cd, PIIODevice * d); void cd_parse (CDSection * cd, PIIODevice * d);
void cd_parse (CDSection * cd, PIIODevice * d); void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode);
void cd_update (CDSection * cd, PIIODevice * d, UpdateModeFlags mode); void cd_calculate(CDSection * cd);
void cd_calculate(CDSection * cd); void cd_send (CDSection * cd, CDPacketType pt, bool direct = false);
void cd_send (CDSection * cd, CDPacketType pt, bool direct = false); void send(CDType::cdT cdt);
void send(CDType::cdT cdt); void request(CDType::cdT cdt);
void request(CDType::cdT cdt); void initApp();
void initApp(); void initPult();
void initPult(); void init(const PIString & configuration, bool pult = false);
void init(const PIString & configuration, bool pult = false); void stop();
void stop(); void release();
void release(); void startX(double freq = 20.);
void startX(double freq = 20.); void stopX();
void stopX(); void sendCommand(const CDType & c);
void sendCommand(const CDType & c); void registerCHandler(const CDType & c, PIObject * o, Handler h);
void registerCHandler(const CDType & c, PIObject * o, Handler h); bool inProgress() {return sendt.isRunning();}
bool inProgress() {return sendt.isRunning();} void sendMessage(const CDType & m, MessageType mt, const PIString & msg);
void sendMessage(const CDType & m, MessageType mt, const PIString & msg);
CDSection * root(CDType::cdT cdt);
CDSection * root(CDType::cdT cdt); PIString typeLetter(CDType::cdT cdt);
PIString typeLetter(CDType::cdT cdt); static PIString pathToString(const PIDeque<int> & p);
static PIString pathToString(const PIDeque<int> & p); static PIDeque<int> stringToPath(const PIString & p);
static PIDeque<int> stringToPath(const PIString & p);
static PIString pultConfig() {return PIString(pult_config);}
static PIString pultConfig() {return PIString(pult_config);} static PIString appConfig() {return PIString(app_config);}
static PIString appConfig() {return PIString(app_config);}
private:
private: CDCore();
CDCore(); ~CDCore();
~CDCore(); EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data);
EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data); EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data);
EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data); EVENT_HANDLER1(void, dtReceiveFinished, bool, ok);
EVENT_HANDLER1(void, dtReceiveFinished, bool, ok); EVENT_HANDLER(void, sendThread);
EVENT_HANDLER(void, sendThread); EVENT_HANDLER(void, xTimerTick);
EVENT_HANDLER(void, xTimerTick); EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer);
EVENT_HANDLER2(void, piCoutFinished, int, id, PIString*, buffer); void initRoot(CDSection * r);
void initRoot(CDSection * r); PIByteArray makeHeader(CDPacketType type, int session_id = 0) const;
PIByteArray makeHeader(CDPacketType type, int session_id = 0) const; void sendDirect(PIByteArray & ba);
void sendDirect(PIByteArray & ba); void sendThreaded(PIByteArray & ba);
void sendThreaded(PIByteArray & ba); void procReceivedPacket(PIByteArray & ba);
void procReceivedPacket(PIByteArray & ba); void raiseChangedGlobal(CDType::cdT cdt);
void raiseChangedGlobal(CDType::cdT cdt);
typedef PIPair<PIObject * , Handler> OHPair;
typedef PIPair<PIObject * , Handler> OHPair;
static const char app_config[], pult_config[];
static const char app_config[], pult_config[]; PIConnection connection;
PIConnection connection; PIDataTransfer datatr;
PIDataTransfer datatr; PIByteArray send_data;
PIByteArray send_data; PIThread sendt;
PIThread sendt; PITimer x_timer;
PITimer x_timer; CDSection k_, x_, c_, m_;
CDSection k_, x_, c_, m_; PIMutex x_mutex;
PIMutex x_mutex; PIVector<PIDeque<int> > x_selected;
PIVector<PIDeque<int> > x_selected; PIMap<PIString, OHPair> c_handlers;
PIMap<PIString, OHPair> c_handlers; bool need_rebuild_x, x_pult_side;
bool need_rebuild_x, x_pult_side;
};
};
static __Core_Initializer__ __Core_initializer__;
static __Core_Initializer__ __Core_initializer__;
}
}
#endif // CDUTILS_CORE_H
#endif // CDUTILS_CORE_H

View File

@@ -1,217 +1,217 @@
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "piconfig.h" #include "piconfig.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
Interface::Interface(CDType::cdT type_) { Interface::Interface(CDType::cdT type_) {
core = CDCore::instance(); core = CDCore::instance();
s = core->root(type_); s = core->root(type_);
type = type_; type = type_;
//piCoutObj << (void*)this << core; //piCoutObj << (void*)this << core;
file_ = core->typeLetter(type_) + PIStringAscii(".dat"); file_ = core->typeLetter(type_) + PIStringAscii(".dat");
file_size = 0; file_size = 0;
switch (type) { switch (type) {
case CDType::cdK: case CDType::cdK:
CONNECTU(core, K_Sended, this, sended); CONNECTU(core, K_Sended, this, sended);
CONNECTU(core, K_SendFail, this, sendFailed); CONNECTU(core, K_SendFail, this, sendFailed);
CONNECTU(core, K_Received, this, received); CONNECTU(core, K_Received, this, received);
CONNECTU(core, K_ReceiveFail, this, receiveFailed); CONNECTU(core, K_ReceiveFail, this, receiveFailed);
CONNECTU(core, K_ChangedGlobal, this, changedGlobal); CONNECTU(core, K_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdX: case CDType::cdX:
CONNECTU(core, X_Sended, this, sended); CONNECTU(core, X_Sended, this, sended);
CONNECTU(core, X_SendFail, this, sendFailed); CONNECTU(core, X_SendFail, this, sendFailed);
CONNECTU(core, X_Received, this, received); CONNECTU(core, X_Received, this, received);
CONNECTU(core, X_ReceiveFail, this, receiveFailed); CONNECTU(core, X_ReceiveFail, this, receiveFailed);
CONNECTU(core, X_ChangedGlobal, this, changedGlobal); CONNECTU(core, X_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdC: case CDType::cdC:
CONNECTU(core, C_Sended, this, sended); CONNECTU(core, C_Sended, this, sended);
CONNECTU(core, C_SendFail, this, sendFailed); CONNECTU(core, C_SendFail, this, sendFailed);
CONNECTU(core, C_Received, this, received); CONNECTU(core, C_Received, this, received);
CONNECTU(core, C_ReceiveFail, this, receiveFailed); CONNECTU(core, C_ReceiveFail, this, receiveFailed);
CONNECTU(core, C_ChangedGlobal, this, changedGlobal); CONNECTU(core, C_ChangedGlobal, this, changedGlobal);
break; break;
case CDType::cdM: case CDType::cdM:
CONNECTU(core, M_Sended, this, sended); CONNECTU(core, M_Sended, this, sended);
CONNECTU(core, M_SendFail, this, sendFailed); CONNECTU(core, M_SendFail, this, sendFailed);
CONNECTU(core, M_Received, this, received); CONNECTU(core, M_Received, this, received);
CONNECTU(core, M_ReceiveFail, this, receiveFailed); CONNECTU(core, M_ReceiveFail, this, receiveFailed);
CONNECTU(core, M_ChangedGlobal, this, changedGlobal); CONNECTU(core, M_ChangedGlobal, this, changedGlobal);
break; break;
default: break; default: break;
} }
} }
bool Interface::test(int v) { bool Interface::test(int v) {
return s->test(v); return s->test(v);
} }
CDType & Interface::operator [](const PIString & name_) { CDType & Interface::operator [](const PIString & name_) {
return (*s)[name_]; return (*s)[name_];
} }
const CDType Interface::operator [](const PIString & name_) const { const CDType Interface::operator [](const PIString & name_) const {
return (*s)[name_]; return (*s)[name_];
} }
CDType & Interface::operator [](const PIDeque<int> & path_) { CDType & Interface::operator [](const PIDeque<int> & path_) {
return (*s)[path_]; return (*s)[path_];
} }
const CDType Interface::operator [](const PIDeque<int> & path_) const { const CDType Interface::operator [](const PIDeque<int> & path_) const {
return (*s)[path_]; return (*s)[path_];
} }
CDType & Interface::operator [](int v) { CDType & Interface::operator [](int v) {
//piCout << (void*)this << "[]" << core; //piCout << (void*)this << "[]" << core;
return (*s)[v]; return (*s)[v];
} }
const CDType Interface::operator [](int v) const { const CDType Interface::operator [](int v) const {
//piCout << (void*)this << "[]" << core; //piCout << (void*)this << "[]" << core;
return (*s)[v]; return (*s)[v];
} }
CDSection & Interface::section(int v) { CDSection & Interface::section(int v) {
// CDSection & ret = s->section(v); // CDSection & ret = s->section(v);
// piCout << "[get section]" << v << ret.name; // piCout << "[get section]" << v << ret.name;
return s->section(v); return s->section(v);
} }
const CDSection Interface::section(int v) const { const CDSection Interface::section(int v) const {
return s->section(v); return s->section(v);
} }
CDSection & Interface::section(const PIDeque<int> &path) { CDSection & Interface::section(const PIDeque<int> &path) {
PIDeque<int> spath = path; PIDeque<int> spath = path;
CDSection * rs = s; CDSection * rs = s;
while (!spath.isEmpty()) { while (!spath.isEmpty()) {
rs = &(rs->section(spath.take_front())); rs = &(rs->section(spath.take_front()));
} }
return *rs; return *rs;
} }
CDSection & Interface::root() { CDSection & Interface::root() {
return *s; return *s;
} }
const CDSection & Interface::root() const { const CDSection & Interface::root() const {
return *s; return *s;
} }
int Interface::count(bool recursive) const { int Interface::count(bool recursive) const {
return s->count(recursive); return s->count(recursive);
} }
bool Interface::exists(PIDeque<int> path) const { bool Interface::exists(PIDeque<int> path) const {
return s->exists(path); return s->exists(path);
} }
void Interface::setFileName(const PIString & _file) { void Interface::setFileName(const PIString & _file) {
file_ = _file; file_ = _file;
} }
bool Interface::configure(const PIString & config) { bool Interface::configure(const PIString & config) {
PIConfig conf(config, PIIODevice::ReadOnly); PIConfig conf(config, PIIODevice::ReadOnly);
PIConfig::Entry & e(conf.getValue(core->typeLetter(s->cd_type_))); PIConfig::Entry & e(conf.getValue(core->typeLetter(s->cd_type_)));
bool ret = false; bool ret = false;
setFileName(e.getValue("file", file(), &ret).toString()); setFileName(e.getValue("file", file(), &ret).toString());
return ret; return ret;
} }
void Interface::reinitConnection(const PIString & configuration) { void Interface::reinitConnection(const PIString & configuration) {
core->init(configuration); core->init(configuration);
} }
void Interface::releaseConnection() { void Interface::releaseConnection() {
core->release(); core->release();
} }
void Interface::write(PIIODevice * d) { void Interface::write(PIIODevice * d) {
core->cd_write(s, d); core->cd_write(s, d);
} }
void Interface::read(PIIODevice * d) { void Interface::read(PIIODevice * d) {
core->cd_read(s, d); core->cd_read(s, d);
} }
void Interface::parse(PIIODevice * d) { void Interface::parse(PIIODevice * d) {
core->cd_parse(s, d); core->cd_parse(s, d);
} }
void Interface::update(PIIODevice * d, UpdateModeFlags mode) { void Interface::update(PIIODevice * d, UpdateModeFlags mode) {
core->cd_update(s, d, mode); core->cd_update(s, d, mode);
} }
void Interface::calculate() { void Interface::calculate() {
core->cd_calculate(s); core->cd_calculate(s);
} }
PIString Interface::appConfig() { PIString Interface::appConfig() {
return core->appConfig(); return core->appConfig();
} }
PIString Interface::pultConfig() { PIString Interface::pultConfig() {
return core->pultConfig(); return core->pultConfig();
} }
void Interface::readFile() { void Interface::readFile() {
if (file_.isEmpty()) return; if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadOnly); PIFile f(file_, PIIODevice::ReadOnly);
read(&f); read(&f);
file_size = f.size(); file_size = f.size();
} }
void Interface::writeFile() { void Interface::writeFile() {
if (file_.isEmpty()) return; if (file_.isEmpty()) return;
PIFile f(file_, PIIODevice::ReadWrite); PIFile f(file_, PIIODevice::ReadWrite);
f.clear(); f.clear();
write(&f); write(&f);
file_size = f.size(); file_size = f.size();
} }
bool Interface::inProgress() { bool Interface::inProgress() {
return core->inProgress(); return core->inProgress();
} }
void Interface::send() { void Interface::send() {
core->send(type); core->send(type);
} }
void Interface::request() { void Interface::request() {
core->request(type); core->request(type);
} }

View File

@@ -1,96 +1,95 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_INTERFACE_H #ifndef CDUTILS_INTERFACE_H
#define CDUTILS_INTERFACE_H #define CDUTILS_INTERFACE_H
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piobject.h" #include "piobject.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class CDCore;
class CDCore;
class Interface: public PIObject
class CD_UTILS_EXPORT Interface: public PIObject {
{ PIOBJECT(CDUtils::Interface)
PIOBJECT(CDUtils::Interface) public:
public: Interface(CDType::cdT type_);
Interface(CDType::cdT type_);
bool test(int v);
bool test(int v); CDType & operator [](int v);
CDType & operator [](int v); const CDType operator [](int v) const;
const CDType operator [](int v) const; CDType & operator [](const PIString & name_);
CDType & operator [](const PIString & name_); const CDType operator [](const PIString & name_) const;
const CDType operator [](const PIString & name_) const; CDType & operator [](const PIDeque<int> & path_);
CDType & operator [](const PIDeque<int> & path_); const CDType operator [](const PIDeque<int> & path_) const;
const CDType operator [](const PIDeque<int> & path_) const; CDSection & section(int v);
CDSection & section(int v); const CDSection section(int v) const;
const CDSection section(int v) const; CDSection & section(const PIDeque<int> & path);
CDSection & section(const PIDeque<int> & path); CDSection & root();
CDSection & root(); const CDSection & root() const;
const CDSection & root() const;
int count(bool recursive = true) const;
int count(bool recursive = true) const; const PIString file() const {return file_;}
const PIString file() const {return file_;} int fileSize() const {return file_size;}
int fileSize() const {return file_size;} CDType::cdT cdType() const {return type;}
CDType::cdT cdType() const {return type;} bool exists(PIDeque<int> path) const;
bool exists(PIDeque<int> path) const;
void setFileName(const PIString & _file);
void setFileName(const PIString & _file); bool configure(const PIString & config);
bool configure(const PIString & config); void reinitConnection(const PIString & configuration);
void reinitConnection(const PIString & configuration); void releaseConnection();
void releaseConnection(); void write(PIIODevice * d);
void write(PIIODevice * d); void read(PIIODevice * d);
void read(PIIODevice * d); void parse(PIIODevice * d);
void parse(PIIODevice * d); void update(PIIODevice * d, UpdateModeFlags mode = SaveByName);
void update(PIIODevice * d, UpdateModeFlags mode = SaveByName); void calculate();
void calculate();
PIString appConfig();
PIString appConfig(); PIString pultConfig();
PIString pultConfig();
void readFile();
void readFile(); void writeFile();
void writeFile(); bool inProgress();
bool inProgress();
EVENT(sended)
EVENT(sended) EVENT(sendFailed)
EVENT(sendFailed) EVENT(received)
EVENT(received) EVENT(receiveFailed)
EVENT(receiveFailed) EVENT(changedGlobal)
EVENT(changedGlobal) EVENT_HANDLER(void, send);
EVENT_HANDLER(void, send); EVENT_HANDLER(void, request);
EVENT_HANDLER(void, request);
protected:
protected: CDCore * core;
CDCore * core; CDSection * s;
CDSection * s; CDType::cdT type;
CDType::cdT type; PIString file_;
PIString file_; int file_size;
int file_size;
};
};
}
}
#endif // CDUTILS_INTERFACE_H
#endif // CDUTILS_INTERFACE_H

View File

@@ -1,20 +1,20 @@
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
KInterface K; KInterface K;
KInterface::KInterface(): Interface(CDType::cdK) { KInterface::KInterface(): Interface(CDType::cdK) {
} }
void KInterface::directChange(const CDType & k) { void KInterface::directChange(const CDType & k) {
core->K_DirectChange(k.path(), k.value()); core->K_DirectChange(k.path(), k.value());
} }
void KInterface::directChange(const CDType & k, double v) { void KInterface::directChange(const CDType & k, double v) {
core->K_DirectChange(k.path(), PIString::fromNumber(v)); core->K_DirectChange(k.path(), PIString::fromNumber(v));
} }

View File

@@ -1,47 +1,46 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_K_H #ifndef CDUTILS_K_H
#define CDUTILS_K_H #define CDUTILS_K_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class KInterface: public Interface
class CD_UTILS_EXPORT KInterface: public Interface {
{ PIOBJECT_SUBCLASS(KInterface, Interface)
PIOBJECT_SUBCLASS(KInterface, Interface) public:
public: KInterface();
KInterface();
EVENT1(keepNamesRequest, bool*, kn)
EVENT1(keepNamesRequest, bool*, kn)
void directChange(const CDType & k);
void directChange(const CDType & k); void directChange(const CDType & k, double v);
void directChange(const CDType & k, double v);
};
};
}
}
extern CDUtils::KInterface K;
extern CD_UTILS_EXPORT CDUtils::KInterface K;
#endif // CDUTILS_K_H
#endif // CDUTILS_K_H

View File

@@ -1,22 +1,22 @@
#include "cdutils_m.h" #include "cdutils_m.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
MInterface M; MInterface M;
MInterface::MInterface(): Interface(CDType::cdM) { MInterface::MInterface(): Interface(CDType::cdM) {
CONNECTU(core, M_Message, this, messageReceived); CONNECTU(core, M_Message, this, messageReceived);
} }
void MInterface::messageBox(const CDType & m, const PIString & msg) { void MInterface::messageBox(const CDType & m, const PIString & msg) {
core->sendMessage(m, MessageBox, msg); core->sendMessage(m, MessageBox, msg);
} }
PICout MInterface::createPICout(const CDType & m) const { PICout MInterface::createPICout(const CDType & m) const {
PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]"); PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]");
return PICout(buff, 1); return PICout(buff, 1);
} }

View File

@@ -1,56 +1,55 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_M_H #ifndef CDUTILS_M_H
#define CDUTILS_M_H #define CDUTILS_M_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class MInterface: public Interface
class CD_UTILS_EXPORT MInterface: public Interface {
{ PIOBJECT_SUBCLASS(MInterface, Interface)
PIOBJECT_SUBCLASS(MInterface, Interface) public:
public: MInterface();
MInterface();
PICout operator [](int v) {return createPICout((*s)[v]);}
PICout operator [](int v) {return createPICout((*s)[v]);} PICout operator [](int v) const {return createPICout((*s)[v]);}
PICout operator [](int v) const {return createPICout((*s)[v]);} PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);}
PICout operator [](const PIString & name_) {return createPICout((*s)[name_]);} PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);}
PICout operator [](const PIString & name_) const {return createPICout((*s)[name_]);} PICout operator [](const PIDeque<int> & path_) {return createPICout((*s)[path_]);}
PICout operator [](const PIDeque<int> & path_) {return createPICout((*s)[path_]);} PICout operator [](const PIDeque<int> & path_) const {return createPICout((*s)[path_]);}
PICout operator [](const PIDeque<int> & path_) const {return createPICout((*s)[path_]);}
void messageBox(const CDType & m, const PIString & msg);
void messageBox(const CDType & m, const PIString & msg);
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
EVENT3(messageReceived, PIDeque<int>, path, int, type, PIString, msg)
private:
private: PICout createPICout(const CDType & m) const;
PICout createPICout(const CDType & m) const;
};
};
}
}
extern CDUtils::MInterface M;
extern CD_UTILS_EXPORT CDUtils::MInterface M;
#endif // CDUTILS_M_H
#endif // CDUTILS_M_H

View File

@@ -1,196 +1,196 @@
#include "cdutils_parser.h" #include "cdutils_parser.h"
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piiostring.h" #include "piiostring.h"
#include "piiobytearray.h" #include "piiobytearray.h"
#include "pifile.h" #include "pifile.h"
using namespace CDUtils; using namespace CDUtils;
enum Phase { enum Phase {
eName = 1, eName = 1,
eBracketOpen, eBracketOpen,
eBracketClose, eBracketClose,
eMemberName, eMemberName,
eMemberEqual, eMemberEqual,
eMemberValue, eMemberValue,
eMemberComma, eMemberComma,
eComment, eComment,
eMultiComment eMultiComment
}; };
void removeComment(PIString & line, PIString * type, PIString * comment) { void removeComment(PIString & line, PIString * type, PIString * comment) {
int ci = line.find("//"); int ci = line.find("//");
if (ci >= 0) { if (ci >= 0) {
if (comment) *comment = line.right(line.size_s() - ci - 2); if (comment) *comment = line.right(line.size_s() - ci - 2);
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
if (type && comment && !line.isEmpty()) { if (type && comment && !line.isEmpty()) {
*type = comment->takeLeft(1); *type = comment->takeLeft(1);
comment->trim(); comment->trim();
} }
} }
} }
void parseEnumLine(PIString & line, int * value, PIString * type, PIString * comment) { void parseEnumLine(PIString & line, int * value, PIString * type, PIString * comment) {
removeComment(line, type, comment); removeComment(line, type, comment);
int ci = line.find("="); int ci = line.find("=");
if (ci >= 0) { if (ci >= 0) {
if (value) *value = line.right(line.size_s() - ci - 1).trim().toInt(); if (value) *value = line.right(line.size_s() - ci - 1).trim().toInt();
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
} }
if (line.trim().endsWith(",")) line.cutRight(1); if (line.trim().endsWith(",")) line.cutRight(1);
} }
void parseInsert(PIString line, PIString & alias, PIStringList & out) { void parseInsert(PIString line, PIString & alias, PIStringList & out) {
out.clear(); out.clear();
int ci = line.find("="); int ci = line.find("=");
if (ci < 0) return; if (ci < 0) return;
alias = line.right(line.size_s() - ci - 1).trim(); alias = line.right(line.size_s() - ci - 1).trim();
line.cutRight(line.size_s() - ci).trim(); line.cutRight(line.size_s() - ci).trim();
while (line.find("[") > 0) { while (line.find("[") > 0) {
int is = line.find("["), ie = line.find("]"); int is = line.find("["), ie = line.find("]");
PIString arr = line.mid(is + 1, ie - is - 1); PIString arr = line.mid(is + 1, ie - is - 1);
out << arr; out << arr;
line.cutMid(is, ie - is + 1); line.cutMid(is, ie - is + 1);
} }
if (!line.isEmpty()) out.insert(0, line); if (!line.isEmpty()) out.insert(0, line);
} }
PIVector<int> enumValues(const PIString & e, const PIMap<PIString, CDSection> & sections, PIStringList & enames) { PIVector<int> enumValues(const PIString & e, const PIMap<PIString, CDSection> & sections, PIStringList & enames) {
PIVector<int> ret; PIVector<int> ret;
enames.clear(); enames.clear();
if (sections.contains(e)) { if (sections.contains(e)) {
ret = sections[e].indexes(); ret = sections[e].indexes();
enames = sections[e].index_names(); enames = sections[e].index_names();
} else { } else {
int v = e.toInt(); int v = e.toInt();
if (v < 2) return ret; if (v < 2) return ret;
for (int i = 0; i < v; ++i) { for (int i = 0; i < v; ++i) {
ret << i; ret << i;
enames << "";//PIString::fromNumber(i); enames << "";//PIString::fromNumber(i);
} }
} }
return ret; return ret;
} }
CDSection CDParser::parse(PIIODevice * d, int cdsection_type) { CDSection CDParser::parse(PIIODevice * d, int cdsection_type) {
CDType::cdT et = (CDType::cdT)cdsection_type; CDType::cdT et = (CDType::cdT)cdsection_type;
if (!d) return CDSection(et); if (!d) return CDSection(et);
if (!d->canRead()) return CDSection(et); if (!d->canRead()) return CDSection(et);
//piCout << "[CDSection] parse start"; //piCout << "[CDSection] parse start";
CDSection cs(et); CDSection cs(et);
CDType ck; CDType ck;
PIMap<PIString, CDSection> sections; PIMap<PIString, CDSection> sections;
PIMap<PIString, int> enum_values; PIMap<PIString, int> enum_values;
PIString content, line, alias, type, comment; PIString content, line, alias, type, comment;
PIStringList iarr; PIStringList iarr;
if (PIStringAscii(d->className()) == PIStringAscii("PIFile")) { if (PIStringAscii(d->className()) == PIStringAscii("PIFile")) {
PIByteArray c = ((PIFile*)d)->readAll(); PIByteArray c = ((PIFile*)d)->readAll();
c << uchar(0); c << uchar(0);
content = PIString::fromUTF8((const char *)c.data()); content = PIString::fromUTF8((const char *)c.data());
} }
if (PIStringAscii(d->className()) == PIStringAscii("PIIOString")) content = *(((PIIOString*)d)->string()); if (PIStringAscii(d->className()) == PIStringAscii("PIIOString")) content = *(((PIIOString*)d)->string());
if (PIStringAscii(d->className()) == PIStringAscii("PIIOByteArray")) content = PIString(*(((PIIOByteArray*)d)->byteArray())); if (PIStringAscii(d->className()) == PIStringAscii("PIIOByteArray")) content = PIString(*(((PIIOByteArray*)d)->byteArray()));
PIIOString ios(&content); PIIOString ios(&content);
//int phase = 0; //int phase = 0;
int cind = -1; int cind = -1;
while ((cind = content.find("enum", cind)) >= 0) { while ((cind = content.find("enum", cind)) >= 0) {
ios.seek(cind); ios.seek(cind);
line = ios.readLine().trim(); line = ios.readLine().trim();
type.clear(); type.clear();
comment.clear(); comment.clear();
removeComment(line, &type, &comment); removeComment(line, &type, &comment);
if (line.find("{") < 0) { if (line.find("{") < 0) {
cind += 4; cind += 4;
continue; continue;
} }
line.cutLeft(line.find("enum") + 4).trim(); line.cutLeft(line.find("enum") + 4).trim();
line.cutRight(line.size_s() - line.find("{")).trim(); line.cutRight(line.size_s() - line.find("{")).trim();
if (line.isEmpty()) { if (line.isEmpty()) {
cind += 4; cind += 4;
continue; continue;
} }
cs = CDSection(et); cs = CDSection(et);
cs.name = line; cs.name = line;
//piCout << "enum" << cs.name; //piCout << "enum" << cs.name;
int cev = 0; int cev = 0;
// cevalues.clear(); // cevalues.clear();
while (!ios.isEnd()) { while (!ios.isEnd()) {
line = ios.readLine().trim(); line = ios.readLine().trim();
comment.clear(); comment.clear();
removeComment(line, &type, &comment); removeComment(line, &type, &comment);
if (line.find("}") >= 0) break; if (line.find("}") >= 0) break;
if (line.isEmpty()) { if (line.isEmpty()) {
if (comment.find("=") >= 0) { if (comment.find("=") >= 0) {
parseInsert(comment, alias, iarr); parseInsert(comment, alias, iarr);
if (!iarr.isEmpty()) { if (!iarr.isEmpty()) {
// piCout << "#" << enum_values; // piCout << "#" << enum_values;
if (!enum_values.contains(alias)) { if (!enum_values.contains(alias)) {
piCout << "Parse error: can`t find section alias \"" << alias << "\"!"; piCout << "Parse error: can`t find section alias \"" << alias << "\"!";
return CDSection(et); return CDSection(et);
} }
if (!sections.contains(iarr.front())) { if (!sections.contains(iarr.front())) {
piCout << "Parse error: can`t find section \"" << iarr.front() << "\"!"; piCout << "Parse error: can`t find section \"" << iarr.front() << "\"!";
return CDSection(et); return CDSection(et);
} }
//piCout << "insert" << alias << iarr; //piCout << "insert" << alias << iarr;
int aval = enum_values.value(alias); int aval = enum_values.value(alias);
CDSection is = sections.value(iarr.take_front()), ts; CDSection is = sections.value(iarr.take_front()), ts;
int ibpos = is.name.size_s(); int ibpos = is.name.size_s();
piForeachRC (PIString & a, iarr) { piForeachRC (PIString & a, iarr) {
PIStringList enames; PIStringList enames;
PIVector<int> evals = enumValues(a, sections, enames); PIVector<int> evals = enumValues(a, sections, enames);
//piCout << a << evals; //piCout << a << evals;
for (int i = 0; i < evals.size_s(); ++i) { for (int i = 0; i < evals.size_s(); ++i) {
ts.section(evals[i]) = is; ts.section(evals[i]) = is;
ts.section(evals[i]).alias = enames[i]; ts.section(evals[i]).alias = enames[i];
} }
ts.name = is.name; ts.name = is.name;
ts.name.insert(ibpos, PIString("[") << a << "]"); ts.name.insert(ibpos, PIString("[") << a << "]");
is = ts; is = ts;
ts = CDSection(et); ts = CDSection(et);
} }
is.alias = alias; is.alias = alias;
cs.section(aval) = is; cs.section(aval) = is;
} }
} }
} else { } else {
parseEnumLine(line, &cev, &type, &comment); parseEnumLine(line, &cev, &type, &comment);
//piCout << line << "=" << cev << "//" << type << comment; //piCout << line << "=" << cev << "//" << type << comment;
ck = CDType(cev, line, type, "", "", comment, et); ck = CDType(cev, line, type, "", "", comment, et);
if (type == "e") { if (type == "e") {
if (comment.startsWith("${")) { if (comment.startsWith("${")) {
comment.cutLeft(1); comment.cutLeft(1);
PIString en = comment.inBrackets('{', '}'); PIString en = comment.inBrackets('{', '}');
comment.cutLeft(en.size_s() + 2).trim(); comment.cutLeft(en.size_s() + 2).trim();
ck.setEnumValues(sections.value(en).enumValues()); ck.setEnumValues(sections.value(en).enumValues());
ck.setComment(comment); ck.setComment(comment);
//piCout << "enum" << en << ck.enumValues(); //piCout << "enum" << en << ck.enumValues();
} }
} }
cs[cev] = ck; cs[cev] = ck;
//cevalues[line] = cev; //cevalues[line] = cev;
enum_values[line] = cev; enum_values[line] = cev;
++cev; ++cev;
} }
} }
//piCout << cs.name << cs.k; //piCout << cs.name << cs.k;
sections[cs.name] = cs; sections[cs.name] = cs;
// piCout << "#" << cevalues; // piCout << "#" << cevalues;
// enum_values << cevalues; // enum_values << cevalues;
cind += 4; cind += 4;
} }
// piCout << "[CDSection] parse end"; // piCout << "[CDSection] parse end";
switch (et) { switch (et) {
case CDType::cdK: return sections.value("KDescription"); case CDType::cdK: return sections.value("KDescription");
case CDType::cdX: return sections.value("XDescription"); case CDType::cdX: return sections.value("XDescription");
case CDType::cdC: return sections.value("CDescription"); case CDType::cdC: return sections.value("CDescription");
case CDType::cdM: return sections.value("MDescription"); case CDType::cdM: return sections.value("MDescription");
default: return CDSection(et); default: return CDSection(et);
} }
return CDSection(et); return CDSection(et);
} }

View File

@@ -1,39 +1,38 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_PARSER_H #ifndef CDUTILS_PARSER_H
#define CDUTILS_PARSER_H #define CDUTILS_PARSER_H
#include "cd_utils_export.h"
class PIIODevice;
class PIIODevice;
namespace CDUtils {
namespace CDUtils {
class CDSection;
class CDSection;
namespace CDParser {
namespace CDParser {
CDSection parse(PIIODevice * d, int cdsection_type);
CD_UTILS_EXPORT CDSection parse(PIIODevice * d, int cdsection_type);
}
}
}
}
#endif // CDUTILS_PARSER_H
#endif // CDUTILS_PARSER_H

View File

@@ -1,73 +1,72 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_PROTOCOL_H #ifndef CDUTILS_PROTOCOL_H
#define CDUTILS_PROTOCOL_H #define CDUTILS_PROTOCOL_H
#include "pistring.h" #include "pibytearray.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
enum CDPacketType {
enum CDPacketType { CD_Ping,
CD_Ping, CD_Pong,
CD_Pong,
CD_KQuery,
CD_KQuery, CD_KSend,
CD_KSend, CD_KDirectChange,
CD_KDirectChange,
CD_XQuery,
CD_XQuery, CD_XSend,
CD_XSend, CD_XRequest,
CD_XRequest, CD_XValues,
CD_XValues,
CD_CQuery,
CD_CQuery, CD_CSend,
CD_CSend, CD_Command,
CD_Command,
CD_MQuery,
CD_MQuery, CD_MSend,
CD_MSend, CD_Message,
CD_Message, };
};
# pragma pack(push,1)
# pragma pack(push,1)
struct PacketHeader {
struct CD_UTILS_EXPORT PacketHeader { int type; // CDPacketType
int type; // CDPacketType int session_id;
int session_id; };
};
struct PacketKDirectChange {
struct CD_UTILS_EXPORT PacketKDirectChange { PIDeque<int> path;
PIDeque<int> path; PIString value;
PIString value; };
};
# pragma pack(pop)
# pragma pack(pop)
inline PIByteArray & operator <<(PIByteArray & s, const PacketHeader & v) {s << v.type << v.session_id; return s;}
inline PIByteArray & operator <<(PIByteArray & s, const PacketHeader & v) {s << v.type << v.session_id; return s;} inline PIByteArray & operator >>(PIByteArray & s, PacketHeader & v) {s >> v.type >> v.session_id; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketHeader & v) {s >> v.type >> v.session_id; return s;}
inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;}
inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;} inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;}
}
}
#endif // CDUTILS_PROTOCOL_H
#endif // CDUTILS_PROTOCOL_H

View File

@@ -1,762 +1,763 @@
#include "cdutils_types.h" #include "cdutils_types.h"
#include "piconfig.h" #include "piconfig.h"
#include "pifile.h" #include "pifile.h"
#include "pievaluator.h" #include "pievaluator.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
//int cdtype_debug_cnt = 1; //int cdtype_debug_cnt = 1;
const int cd_x_history_max_size = 4000; const int cd_x_history_max_size = 4000;
CDType::CDType() { CDType::CDType() {
index_ = -1; index_ = -1;
value_d = 0.; value_d = 0.;
value_i = 0; value_i = 0;
value_b = calculated = x_enabled = false; value_b = calculated = x_enabled = false;
cd_type_ = cdNull; cd_type_ = cdNull;
parent = 0; parent = 0;
avg_size = 1; avg_size = 1;
mode_ = rmode_ = X_Current; mode_ = rmode_ = X_Current;
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType]" << "create Null" << debug_cnt; // piCout << "[CDType]" << "create Null" << debug_cnt;
} }
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) { CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
index_ = i; index_ = i;
name_ = n.trimmed(); name_ = n.trimmed();
type_ = t.trimmed(); type_ = t.trimmed();
value_s = v.trimmed(); value_s = v.trimmed();
formula_ = f.trimmed(); formula_ = f.trimmed();
comment_ = c.trimmed(); comment_ = c.trimmed();
value_d = v.toDouble(); value_d = v.toDouble();
value_i = v.toInt(); value_i = v.toInt();
value_b = v.toBool(); value_b = v.toBool();
cd_type_ = cd_t; cd_type_ = cd_t;
calculated = x_enabled = false; calculated = x_enabled = false;
parent = 0; parent = 0;
avg_size = 1; avg_size = 1;
mode_ = rmode_ = X_Current; mode_ = rmode_ = X_Current;
if (type_ == "e") { if (type_ == "e") {
enum_values = parseEnumComment(comment_); enum_values = parseEnumComment(comment_);
// piCout << enum_values.size() << enum_values; // piCout << enum_values.size() << enum_values;
} }
// piCout << type_.size() << type_.toUTF8(); // piCout << type_.size() << type_.toUTF8();
// piCout << formula_.size() << formula_.toUTF8(); // piCout << formula_.size() << formula_.toUTF8();
// piCout << comment_.size() << comment_.toUTF8(); // piCout << comment_.size() << comment_.toUTF8();
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
} }
CDType & CDType::operator =(double x) { CDType & CDType::operator =(double x) {
value_d = x; value_d = x;
value_i = x; value_i = x;
value_b = x > 0.; value_b = x > 0.;
if (mode_ == X_All_Avg) { if (mode_ == X_All_Avg) {
avg_h << x; avg_h << x;
double val = 0; double val = 0;
if (avg_h.size_s() >= avg_size) { if (avg_h.size_s() >= avg_size) {
for (int i = 0; i < avg_h.size_s(); i++) for (int i = 0; i < avg_h.size_s(); i++)
val += avg_h[i]; val += avg_h[i];
val /= avg_h.size(); val /= avg_h.size();
avg_h.clear(); avg_h.clear();
if (history.size() < cd_x_history_max_size) if (history.size() < cd_x_history_max_size)
history << val; history << val;
} }
} }
return *this; return *this;
} }
PIString CDType::type() const { PIString CDType::type() const {
if (type_.trimmed().isEmpty()) return "f"; if (type_.trimmed().isEmpty()) return "f";
// piCout << "type =" << type_.trimmed() << ";" << type_ << "#"; // piCout << "type =" << type_.trimmed() << ";" << type_ << "#";
return type_; return type_;
} }
PIString CDType::value() const { PIString CDType::value() const {
if (type_ == "b") return PIString::fromBool(value_b); if (type_ == "b") return PIString::fromBool(value_b);
return value_s; return value_s;
} }
PIVariant CDType::variantValue() const { PIVariant CDType::variantValue() const {
if (type_.isEmpty()) return PIVariant(value()); if (type_.isEmpty()) return PIVariant(value());
switch (type_[0].toAscii()) { switch (type_[0].toAscii()) {
case 'b': return PIVariant(toBool()); break; case 'b': return PIVariant(toBool()); break;
case 'n': return PIVariant(toInt()); break; case 'n': return PIVariant(toInt()); break;
case 'f': return PIVariant(toDouble()); break; case 'f': return PIVariant(toDouble()); break;
case 'c': return PIVariant(PIVariantTypes::Color(toInt())); break; case 'c': return PIVariant(PIVariantTypes::Color(toInt())); break;
case 'e': { case 'e': {
PIVariantTypes::Enum e = enum_values; PIVariantTypes::Enum e = enum_values;
e.selectValue(toInt()); e.selectValue(toInt());
return PIVariant(e); return PIVariant(e);
break; break;
} }
default: break; default: break;
} }
return PIVariant(value()); return PIVariant(value());
} }
void CDType::setValue(const PIString & value_) { void CDType::setValue(const PIString & value_) {
formula_ = value_; formula_ = value_;
value_d = formula_.toDouble(); value_d = formula_.toDouble();
value_i = formula_.toInt(); value_i = formula_.toInt();
value_b = formula_.toBool(); value_b = formula_.toBool();
} }
void CDType::setVariantValue(const PIVariant & value_) { void CDType::setVariantValue(const PIVariant & value_) {
setValue(PIString::fromNumber(value_.toDouble())); setValue(PIString::fromNumber(value_.toDouble()));
} }
void CDType::setFormula(const PIString & f) { void CDType::setFormula(const PIString & f) {
formula_ = f; formula_ = f;
calculated = false; calculated = false;
//PIEvaluator e; //PIEvaluator e;
//calculate(&e); //calculate(&e);
} }
PIStringList CDType::pathString() const { PIStringList CDType::pathString() const {
PIStringList ret; PIStringList ret;
CDSection * ps = CDCore::instance()->root(cd_type_); CDSection * ps = CDCore::instance()->root(cd_type_);
if (!ps) return ret; if (!ps) return ret;
for (int i = 0; i < path_.size_s() - 1; ++i) { for (int i = 0; i < path_.size_s() - 1; ++i) {
ps = &(ps->section(path_[i])); ps = &(ps->section(path_[i]));
if (!ps->alias.isEmpty()) ret << ps->alias; if (!ps->alias.isEmpty()) ret << ps->alias;
else ret << PIString::fromNumber(path_[i]); else ret << PIString::fromNumber(path_[i]);
} }
if (!name_.isEmpty()) ret << name_; if (!name_.isEmpty()) ret << name_;
else ret << PIString::fromNumber(index_); else ret << PIString::fromNumber(index_);
return ret; return ret;
} }
void CDType::readX(PIByteArray & ba) { void CDType::readX(PIByteArray & ba) {
if (ba.size() < 5) return; if (ba.size() < 5) return;
uchar t(0); ba >> t; uchar t(0); ba >> t;
rmode_ = (XMode)t; rmode_ = (XMode)t;
switch (rmode_) { switch (rmode_) {
case X_Current: case X_Current:
ba >> value_d; ba >> value_d;
break; break;
case X_All_Avg: { case X_All_Avg: {
PIVector<double> ah; PIVector<double> ah;
ba >> ah; ba >> ah;
history << ah; history << ah;
if (!history.isEmpty()) if (!history.isEmpty())
value_d = history.back(); value_d = history.back();
} break; } break;
default: break; default: break;
} }
value_i = value_d; value_i = value_d;
value_b = value_d > 0.; value_b = value_d > 0.;
} }
void CDType::writeX(PIByteArray & ba) { void CDType::writeX(PIByteArray & ba) {
ba << uchar(mode_); ba << uchar(mode_);
switch (mode_) { switch (mode_) {
case X_Current: case X_Current:
ba << value_d; ba << value_d;
break; break;
case X_All_Avg: case X_All_Avg:
ba << history; ba << history;
history.clear(); history.clear();
break; break;
default: break; default: break;
} }
} }
bool CDType::calculate(PIEvaluator * e, PIVector<const CDType * > stack) { bool CDType::calculate(PIEvaluator * e, PIVector<const CDType * > stack) {
if (stack.contains(this)) { if (stack.contains(this)) {
error_ = "Circular dependencies: "; error_ = "Circular dependencies: ";
piForeachC (CDType * k, stack) piForeachC (CDType * k, stack)
error_ << k->name() << " -> "; error_ << k->name() << " -> ";
error_ << name(); error_ << name();
//piCout << error_; //piCout << error_;
return false; return false;
} }
stack << this; stack << this;
if (calculated) return true; if (calculated) return true;
calculated = true; calculated = true;
error_.clear(); error_.clear();
if (!parent) return true; if (!parent) return true;
//piCout << "calc" << name_ << (parent ? parent->alias : "root"); //piCout << "calc" << name_ << (parent ? parent->alias : "root");
value_s = formula_.trimmed(); value_s = formula_.trimmed();
for (;;) { for (;;) {
int ki = value_s.find("K["); int ki = value_s.find("K[");
if (ki < 0) break; if (ki < 0) break;
int ke = value_s.find("]", ki + 2); int ke = value_s.find("]", ki + 2);
if (ke < 0) break; if (ke < 0) break;
PIString kp = value_s.mid(ki + 2, ke - ki - 2); PIString kp = value_s.mid(ki + 2, ke - ki - 2);
//piCout << kp; //piCout << kp;
CDType & k((*parent)[kp]); CDType & k((*parent)[kp]);
k.calculate(e, stack); k.calculate(e, stack);
value_s.replace(ki, ke - ki + 1, PIString::fromNumber(k.value_d)); value_s.replace(ki, ke - ki + 1, PIString::fromNumber(k.value_d));
} }
value_d = formula_.toDouble(); value_d = formula_.toDouble();
value_i = formula_.toInt(); value_i = formula_.toInt();
value_b = formula_.toBool(); value_b = formula_.toBool();
double ev = 0.; double ev = 0.;
if (!e->check(value_s) && value_d == 0. && value_i == 0 && !value_b) { if (!e->check(value_s) && value_d == 0. && value_i == 0 && !value_b) {
PIString f = formula_.trimmed().toLowerCase(); PIString f = formula_.trimmed().toLowerCase();
if (f != "off" && f != "false" && f != "no" && !value_b) { if (f != "off" && f != "false" && f != "no" && !value_b) {
error_ = e->error(); error_ = e->error();
return false; return false;
} }
} else } else
if (e->isCorrect()) if (e->isCorrect())
ev = e->evaluate().real(); ev = e->evaluate().real();
//piCout << value_s << value_i << value_d << ev; //piCout << value_s << value_i << value_d << ev;
//if ((value_d == 0.) || (piAbsd(value_d) < piAbsd(ev))) value_d = ev; //if ((value_d == 0.) || (piAbsd(value_d) < piAbsd(ev))) value_d = ev;
//if ((value_i == 0) || (piAbsd(value_i) < piAbsd(ev))) value_i = int(ev); //if ((value_i == 0) || (piAbsd(value_i) < piAbsd(ev))) value_i = int(ev);
if ((value_d == 0.) || (ev != 0.)) value_d = ev; if ((value_d == 0.) || (ev != 0.)) value_d = ev;
if ((value_i == 0) || (ev != 0.)) value_i = int(ev); if ((value_i == 0) || (ev != 0.)) value_i = int(ev);
value_b = value_b || (ev > 0.); value_b = value_b || (ev > 0.);
if (value_i != 0) { if (value_i != 0) {
if (value_d == 0.) value_d = value_i; if (value_d == 0.) value_d = value_i;
value_b = value_i > 0; value_b = value_i > 0;
} }
if (value_d != 0.) { if (value_d != 0.) {
if (value_i == 0) value_i = value_d; if (value_i == 0) value_i = value_d;
value_b = value_d > 0.; value_b = value_d > 0.;
} }
if (value_b) { if (value_b) {
if (value_d == 0.) value_d = 1.; if (value_d == 0.) value_d = 1.;
if (value_i == 0) value_i = 1; if (value_i == 0) value_i = 1;
} }
value_s = PIString::fromNumber(value_d); value_s = PIString::fromNumber(value_d);
return true; return true;
} }
PIVariantTypes::Enum CDType::parseEnumComment(PIString c) { PIVariantTypes::Enum CDType::parseEnumComment(PIString c) {
PIVariantTypes::Enum ret; PIVariantTypes::Enum ret;
if (c.isEmpty()) return ret; if (c.isEmpty()) return ret;
if (type_ == "e") { if (type_ == "e") {
PIStringList sl = c.inBrackets('{', '}').split(","); PIStringList sl = c.inBrackets('{', '}').split(",");
int cval = 0; int cval = 0;
piForeach (PIString & s, sl) { piForeach (PIString & s, sl) {
s.trim(); s.trim();
if (s.isEmpty()) continue; if (s.isEmpty()) continue;
if (s[0].isDigit()) { if (s[0].isDigit()) {
int ind = s.find("-"); int ind = s.find("-");
if (ind > 0) { if (ind > 0) {
cval = s.left(ind).toInt(); cval = s.left(ind).toInt();
s.cutLeft(ind + 1).trim(); s.cutLeft(ind + 1).trim();
} }
} }
ret << PIVariantTypes::Enumerator(cval, s); ret << PIVariantTypes::Enumerator(cval, s);
++cval; ++cval;
} }
} }
//piCout << c << "=" << ret; //piCout << c << "=" << ret;
return ret; return ret;
} }
//CDType::CDType(const CDType &cdt) { //CDType::CDType(const CDType &cdt) {
// index_ = cdt.index_; // index_ = cdt.index_;
// name_ = cdt.name_; // name_ = cdt.name_;
// type_ = cdt.type_; // type_ = cdt.type_;
// value_s = cdt.value_s; // value_s = cdt.value_s;
// formula_ = cdt.formula_; // formula_ = cdt.formula_;
// comment_ = cdt.comment_; // comment_ = cdt.comment_;
// value_d = cdt.value_d; // value_d = cdt.value_d;
// value_i = cdt.value_i; // value_i = cdt.value_i;
// value_b = cdt.value_b; // value_b = cdt.value_b;
// cd_type_ = cdt.cd_type_; // cd_type_ = cdt.cd_type_;
// debug_cnt = cdtype_debug_cnt; // debug_cnt = cdtype_debug_cnt;
// cdtype_debug_cnt++; // cdtype_debug_cnt++;
// piCout << "[CDType] copy" << debug_cnt << "->" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] copy" << debug_cnt << "->" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
//} //}
//CDType &CDType::operator =(const CDType &cdt) { //CDType &CDType::operator =(const CDType &cdt) {
// index_ = cdt.index_; // index_ = cdt.index_;
// name_ = cdt.name_; // name_ = cdt.name_;
// type_ = cdt.type_; // type_ = cdt.type_;
// value_s = cdt.value_s; // value_s = cdt.value_s;
// formula_ = cdt.formula_; // formula_ = cdt.formula_;
// comment_ = cdt.comment_; // comment_ = cdt.comment_;
// value_d = cdt.value_d; // value_d = cdt.value_d;
// value_i = cdt.value_i; // value_i = cdt.value_i;
// value_b = cdt.value_b; // value_b = cdt.value_b;
// cd_type_ = cdt.cd_type_; // cd_type_ = cdt.cd_type_;
// piCout << "[CDType] assign" << debug_cnt << "=" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] assign" << debug_cnt << "=" << cdt.debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
// //debug_cnt = cdt.debug_cnt; // //debug_cnt = cdt.debug_cnt;
// return *this; // return *this;
//} //}
//CDType::~CDType() { //CDType::~CDType() {
// piCout << "[CDType] delete" << debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK); // piCout << "[CDType] delete" << debug_cnt << index_ << ":" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
//} //}
CDSection::CDSection(CDType::cdT type_) { CDSection::CDSection(CDType::cdT type_) {
cd_type_ = type_; cd_type_ = type_;
null.cd_type_ = type_; null.cd_type_ = type_;
} }
CDSection & CDSection::section(int v) { CDSection & CDSection::section(int v) {
CDSection & ret(s[v]); CDSection & ret(s[v]);
ret.cd_type_ = cd_type_; ret.cd_type_ = cd_type_;
return ret; return ret;
} }
const CDSection CDSection::section(int v) const { const CDSection CDSection::section(int v) const {
CDSection & ret(s[v]); CDSection & ret(s[v]);
ret.cd_type_ = cd_type_; ret.cd_type_ = cd_type_;
return s[v]; return s[v];
} }
bool CDSection::exists(PIDeque<int> path) const { bool CDSection::exists(PIDeque<int> path) const {
if (path.isEmpty()) return false; if (path.isEmpty()) return false;
if (path.size_s() == 1) return cd.contains(path[0]); if (path.size_s() == 1) return cd.contains(path[0]);
int si = path[0]; int si = path[0];
if (!s.contains(si)) return false; if (!s.contains(si)) return false;
path.remove(0, 1); path.remove(0, 1);
return s[si].exists(path); return s[si].exists(path);
} }
int CDSection::count(bool recursive) const { int CDSection::count(bool recursive) const {
int ret = cd.size_s(); int ret = cd.size_s();
if (recursive) { if (recursive) {
PIMap<int, CDSection>::const_iterator i; PIMap<int, CDSection>::const_iterator i;
for (i = s.constBegin(); i != s.constEnd(); ++i) for (i = s.constBegin(); i != s.constEnd(); ++i)
ret += i->second.count(recursive); ret += i->second.count(recursive);
} }
return ret; return ret;
} }
int CDSection::sectionsCount() const { int CDSection::sectionsCount() const {
return s.size(); return s.size();
} }
PIStringList CDSection::index_names() const { PIStringList CDSection::index_names() const {
PIStringList ret; PIStringList ret;
auto i = cd.makeIterator(); PIMap<int, CDType>::const_iterator i;
while (i.next()) for (i = cd.begin(); i != cd.end(); ++i)
ret << i.value().name(); ret << i->second.name();
return ret; return ret;
} }
void CDSection::calculate() { void CDSection::calculate() {
prepareCalculate(); prepareCalculate();
if (cd_type_ != CDType::cdK) return; if (cd_type_ != CDType::cdK) return;
PIEvaluator e; PIEvaluator e;
calculateRecursive(&e); calculateRecursive(&e);
} }
CDType & CDSection::getByName(const PIString & name_) { CDType & CDSection::getByName(const PIString & name_) {
PIStringList np = name_.split("."); PIStringList np = name_.split(".");
if (np.isEmpty()) return null; if (np.isEmpty()) return null;
//piCout << np; //piCout << np;
CDSection * cs = this, * ns = 0; CDSection * cs = this, * ns = 0;
if (np.front().isEmpty()) { if (np.front().isEmpty()) {
if (np.size_s() < 2) return null; if (np.size_s() < 2) return null;
cs = CDCore::instance()->root(cd_type_); cs = CDCore::instance()->root(cd_type_);
np.pop_front(); np.pop_front();
} }
for (int i = 0; i < np.size_s() - 1; ++i) { for (int i = 0; i < np.size_s() - 1; ++i) {
if (np[i].isEmpty()) return null; if (np[i].isEmpty()) return null;
bool isd = np[i][0].isDigit() || (np[i][0] == '-'); bool isd = np[i][0].isDigit() || (np[i][0] == '-');
int dv = 0; int dv = 0;
if (isd) dv = np[i].toInt(); if (isd) dv = np[i].toInt();
ns = 0; ns = 0;
auto it = cs->s.makeIterator(); PIMap<int, CDSection>::iterator it;
while (it.next()) { //piCout << np[i] << isd << dv;
bool f = false; for (it = cs->s.begin(); it != cs->s.end(); ++it) {
if (isd) f = (dv == it.key()); bool f = false;
else f = (np[i] == it.value().alias); if (isd) f = (dv == it.key());
//piCout << "s..." << it.key() << it.value().alias << f; else f = (np[i] == it.value().alias);
if (f) { //piCout << "s..." << it.key() << it.value().alias << f;
ns = &(it.valueRef()); if (f) {
break; ns = &(it.value());
} break;
} }
//piCout << ns; }
if (!ns) return null; //piCout << ns;
cs = ns; if (!ns) return null;
} cs = ns;
if (np.back().isEmpty()) return null; }
bool isd = np.back()[0].isDigit() || (np.back()[0] == '-'); PIMap<int, CDType>::iterator it;
int dv = 0; if (np.back().isEmpty()) return null;
if (isd) dv = np.back().toInt(); bool isd = np.back()[0].isDigit() || (np.back()[0] == '-');
//piCout << np.back() << isd << dv; int dv = 0;
auto it = cs->cd.makeIterator(); if (isd) dv = np.back().toInt();
while (it.next()) { //piCout << np.back() << isd << dv;
bool f = false; for (it = cs->cd.begin(); it != cs->cd.end(); ++it) {
if (isd) f = (dv == it.key()); bool f = false;
else f = (np.back() == it.value().name()); if (isd) f = (dv == it.key());
//piCout << "k..." << it.key() << it.value().name() << f; else f = (np.back() == it.value().name());
if (f) //piCout << "k..." << it.key() << it.value().name() << f;
return cs->cd[it.key()]; if (f)
} return cs->cd[it.key()];
return null; }
} return null;
}
CDType & CDSection::getByPath(const PIDeque<int> & path_) {
if (path_.isEmpty()) return null; CDType & CDSection::getByPath(const PIDeque<int> & path_) {
CDSection * s = this; if (path_.isEmpty()) return null;
for (int i = 0; i < path_.size_s() - 1; ++i) CDSection * s = this;
s = &(s->section(path_[i])); for (int i = 0; i < path_.size_s() - 1; ++i)
if (!s) return null; s = &(s->section(path_[i]));
return (*s)[path_.back()]; if (!s) return null;
} return (*s)[path_.back()];
}
void CDSection::write(PIIODevice * d, const PIString & prefix) {
if (!d) return; void CDSection::write(PIIODevice * d, const PIString & prefix) {
if (cd.isEmpty() && s.isEmpty()) return; if (!d) return;
// piCout << "[CDSection] write start"; if (cd.isEmpty() && s.isEmpty()) return;
PIString l; // piCout << "[CDSection] write start";
PIStringList cdtl; PIString l;
cdtl << "null" << "k" << "x" << "c" << "m"; PIStringList cdtl;
if (prefix.isEmpty()) l = "[" + cdtl[cd_type_] + "]"; cdtl << "null" << "k" << "x" << "c" << "m";
else l = "[" + prefix + "." + cdtl[cd_type_] + "]"; if (prefix.isEmpty()) l = "[" + cdtl[cd_type_] + "]";
l += "\n"; else l = "[" + prefix + "." + cdtl[cd_type_] + "]";
d->write(l.toUTF8()); l += "\n";
l = "name = " + name + " \n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l = "name = " + name + " \n";
l = "alias = " + alias + " \n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l = "alias = " + alias + " \n";
auto i = cd.makeIterator(); d->write(l.toUTF8());
while (i.next()) { PIMap<int, CDType>::iterator i;
const CDType & ck(i.value()); for (i = cd.begin(); i != cd.end(); ++i) {
if (ck.cd_type() != cd_type_) continue; CDType & ck(i.value());
switch (cd_type_) { if (ck.cd_type() != cd_type_) continue;
case CDType::cdNull: break; switch (cd_type_) {
case CDType::cdK: case CDType::cdNull: break;
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n"; case CDType::cdK:
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
if (!ck.enumValues().enum_list.isEmpty()) { d->write(l.toUTF8());
l.clear(); l << ck.index() << ".ev = {"; if (!ck.enumValues().enum_list.isEmpty()) {
//PIVector<CDType::Enumerator> el = ck.enumValues(); l.clear(); l << ck.index() << ".ev = {";
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list) //PIVector<CDType::Enumerator> el = ck.enumValues();
l << e.value << " - " << e.name << ", "; piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
l.cutRight(2); l << e.value << " - " << e.name << ", ";
l << "} \n"; l.cutRight(2);
d->write(l.toUTF8()); l << "} \n";
} d->write(l.toUTF8());
break; }
case CDType::cdX: break;
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n"; case CDType::cdX:
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
l.clear(); l << ck.index() << ".mode = " << ck.xmode() << " #e (0 - cur, 1 - all_avg) " << "\n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".mode = " << ck.xmode() << " #e (0 - cur, 1 - all_avg) " << "\n";
l.clear(); l << ck.index() << ".avg = " << ck.avg() << " #n " << "\n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".avg = " << ck.avg() << " #n " << "\n";
l.clear(); l << ck.index() << ".sel = " << (ck.isSelectedX() ? "1" : "0") << " #n " << "\n"; d->write(l.toUTF8());
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".sel = " << (ck.isSelectedX() ? "1" : "0") << " #n " << "\n";
break; d->write(l.toUTF8());
case CDType::cdC: break;
case CDType::cdM: case CDType::cdC:
l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n"; case CDType::cdM:
d->write(l.toUTF8()); l.clear(); l << ck.index() << ".name = " << ck.name() << " #s " << ck.comment() << " \n";
break; d->write(l.toUTF8());
} break;
} }
if (!s.isEmpty()) { }
if (prefix.isEmpty()) l = "s"; if (!s.isEmpty()) {
else l = prefix + ".s"; if (prefix.isEmpty()) l = "s";
auto j = s.makeIterator(); else l = prefix + ".s";
while (j.next()) { PIMap<int, CDSection>::iterator j;
j.valueRef().write(d, l + "." + PIString::fromNumber(j.key())); for (j = s.begin(); j != s.end(); ++j) {
} j.value().write(d, l + "." + PIString::fromNumber(j.key()));
} }
if (prefix.isEmpty()) { }
l = "[]\n"; if (prefix.isEmpty()) {
d->write(l.toUTF8()); l = "[]\n";
} d->write(l.toUTF8());
// piCout << "[CDSection] write end"; }
} // piCout << "[CDSection] write end";
}
void CDSection::read(const void * ep) {
// piCout << "[CDSection] read start"; void CDSection::read(const void * ep) {
PIStringList cdtl; // piCout << "[CDSection] read start";
cdtl << "null" << "k" << "x" << "c" << "m"; PIStringList cdtl;
cd.clear(); cdtl << "null" << "k" << "x" << "c" << "m";
s.clear(); cd.clear();
PIConfig::Entry & e(*(PIConfig::Entry*)ep); s.clear();
name = e.getValue(cdtl[cd_type_] + ".name").value(); PIConfig::Entry & e(*(PIConfig::Entry*)ep);
alias = e.getValue(cdtl[cd_type_] + ".alias").value(); name = e.getValue(cdtl[cd_type_] + ".name").value();
PIConfig::Entry & cdl = e.getValue(cdtl[cd_type_]); alias = e.getValue(cdtl[cd_type_] + ".alias").value();
for (int i = 0; i < cdl.childCount(); ++i) { PIConfig::Entry & cdl = e.getValue(cdtl[cd_type_]);
const PIConfig::Entry * e(cdl.child(i)); for (int i = 0; i < cdl.childCount(); ++i) {
bool ok = false; const PIConfig::Entry * e(cdl.child(i));
int id = e->name().toInt(-1, &ok); bool ok = false;
// piCout << "[read]" << ke->name() << ke->value() << ok; int id = e->name().toInt(-1, &ok);
// PIString n = ke->getValue("v").comment(); // piCout << "[read]" << ke->name() << ke->value() << ok;
// PIString t = n.takeLeft(1); // PIString n = ke->getValue("v").comment();
if (ok) { // PIString t = n.takeLeft(1);
CDType c; if (ok) {
PIString ev; CDType c;
switch (cd_type_) { PIString ev;
case CDType::cdNull: break; switch (cd_type_) {
case CDType::cdK: case CDType::cdNull: break;
c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cd_type_); case CDType::cdK:
ev = e->getValue("ev", "").value(); c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cd_type_);
if (!ev.isEmpty()) ev = e->getValue("ev", "").value();
c.enum_values = c.parseEnumComment(ev); if (!ev.isEmpty())
break; c.enum_values = c.parseEnumComment(ev);
case CDType::cdX: break;
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_); case CDType::cdX:
c.setXMode((CDType::XMode)e->getValue("mode", int(CDType::X_Current)).value().toInt()); c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_);
c.setAvg((CDType::XMode)e->getValue("avg", 1).value().toInt()); c.setXMode((CDType::XMode)e->getValue("mode", int(CDType::X_Current)).value().toInt());
c.x_enabled = e->getValue("sel", false).value().toBool(); c.setAvg((CDType::XMode)e->getValue("avg", 1).value().toInt());
break; c.x_enabled = e->getValue("sel", false).value().toBool();
case CDType::cdC: break;
case CDType::cdM: case CDType::cdC:
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_); case CDType::cdM:
break; c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString() , e->getValue("name").comment(), cd_type_);
} break;
cd[id] = c; }
} cd[id] = c;
} }
PIConfig::Entry & sl = e.getValue("s"); }
for (int i = 0; i < sl.childCount(); ++i) { PIConfig::Entry & sl = e.getValue("s");
const PIConfig::Entry * se(sl.child(i)); for (int i = 0; i < sl.childCount(); ++i) {
int sid = se->name().toInt(); const PIConfig::Entry * se(sl.child(i));
CDSection & rs(s[sid]); int sid = se->name().toInt();
rs.cd_type_ = cd_type_; CDSection & rs(s[sid]);
rs.read(se); rs.cd_type_ = cd_type_;
} rs.read(se);
// piCout << "[CDSection] read end"; }
} // piCout << "[CDSection] read end";
}
void CDSection::update(CDSection & v, UpdateModeFlags mode) {
if (mode[SaveByIndex] && mode[SaveByName]) { void CDSection::update(CDSection & v, UpdateModeFlags mode) {
piCout << "[CDSection] update error: SaveByIndex | SaveByName mode is denied!"; if (mode[SaveByIndex] && mode[SaveByName]) {
return; piCout << "[CDSection] update error: SaveByIndex | SaveByName mode is denied!";
} return;
//piCout << "[CDSection] update start"; }
//piCout << "before" << k.size() << v.k.size(); //piCout << "[CDSection] update start";
//piCout << "before" << k.size() << v.k.size();
PIMap<int, PIString> prev_cd_f_bi;
PIMap<PIString, PIString> prev_cd_f_bn; PIMap<int, PIString> prev_cd_f_bi;
PIMap<int, CDType>::iterator i; PIMap<PIString, PIString> prev_cd_f_bn;
if (mode[SaveByIndex]) { PIMap<int, CDType>::iterator i;
for (i = cd.begin(); i != cd.end(); ++i) if (mode[SaveByIndex]) {
prev_cd_f_bi[i.key()] = i.value().formula(); for (i = cd.begin(); i != cd.end(); ++i)
} prev_cd_f_bi[i.key()] = i.value().formula();
if (mode[SaveByName]) { }
for (i = cd.begin(); i != cd.end(); ++i) if (mode[SaveByName]) {
prev_cd_f_bn[i.value().name_] = i.value().formula(); for (i = cd.begin(); i != cd.end(); ++i)
} prev_cd_f_bn[i.value().name_] = i.value().formula();
if (!mode[Merge]) }
cd.clear(); if (!mode[Merge])
for (i = v.cd.begin(); i != v.cd.end(); ++i) { cd.clear();
int id = i.key(); for (i = v.cd.begin(); i != v.cd.end(); ++i) {
PIString n = i.value().name(); int id = i.key();
cd[id] = i.value(); PIString n = i.value().name();
if (mode[SaveByIndex]) { cd[id] = i.value();
if (prev_cd_f_bi.contains(id)) if (mode[SaveByIndex]) {
cd[id].setFormula(prev_cd_f_bi[id]); if (prev_cd_f_bi.contains(id))
} cd[id].setFormula(prev_cd_f_bi[id]);
if (mode[SaveByName]) { }
if (prev_cd_f_bn.contains(n)) if (mode[SaveByName]) {
cd[id].setFormula(prev_cd_f_bn[n]); if (prev_cd_f_bn.contains(n))
} cd[id].setFormula(prev_cd_f_bn[n]);
} }
}
PIMap<int, CDSection> prev_s_bi;
PIMap<PIString, CDSection> prev_s_bn; PIMap<int, CDSection> prev_s_bi;
PIMap<int, CDSection>::iterator j; PIMap<PIString, CDSection> prev_s_bn;
if (mode[SaveByIndex]) { PIMap<int, CDSection>::iterator j;
for (j = s.begin(); j != s.end(); ++j) if (mode[SaveByIndex]) {
prev_s_bi[j.key()] = j.value(); for (j = s.begin(); j != s.end(); ++j)
} prev_s_bi[j.key()] = j.value();
if (mode[SaveByName]) { }
for (j = s.begin(); j != s.end(); ++j) if (mode[SaveByName]) {
prev_s_bn[j.value().alias] = j.value(); for (j = s.begin(); j != s.end(); ++j)
} prev_s_bn[j.value().alias] = j.value();
if (!mode[Merge]) }
s.clear(); if (!mode[Merge])
for (j = v.s.begin(); j != v.s.end(); ++j) { s.clear();
int id = j.key(); for (j = v.s.begin(); j != v.s.end(); ++j) {
PIString n = j.value().alias; int id = j.key();
s[id] = j.value(); PIString n = j.value().alias;
if (mode[SaveByIndex]) { s[id] = j.value();
if (prev_s_bi.contains(id)) if (mode[SaveByIndex]) {
s[id] = prev_s_bi[id]; if (prev_s_bi.contains(id))
} s[id] = prev_s_bi[id];
if (mode[SaveByName]) { }
if (prev_s_bn.contains(n)) if (mode[SaveByName]) {
s[id] = prev_s_bn[n]; if (prev_s_bn.contains(n))
} s[id] = prev_s_bn[n];
s[id].update(j.value(), mode); }
} s[id].update(j.value(), mode);
}
/*PISet<int> used;
for (i = k.begin(); i != k.end(); ++i) { /*PISet<int> used;
if (v.k.contains(i.key())) { for (i = k.begin(); i != k.end(); ++i) {
PIString f = k[i.key()].formula_; if (v.k.contains(i.key())) {
CDType & cdt = v.k[i.key()]; PIString f = k[i.key()].formula_;
cdt.formula_ = f; CDType & cdt = v.k[i.key()];
k[i.key()] = cdt; cdt.formula_ = f;
used << i.key(); k[i.key()] = cdt;
} used << i.key();
if (mode) { }
CDType & ck(k[i.key()]); if (mode) {
if (prev_k_f_bn.contains(ck.name_)) CDType & ck(k[i.key()]);
ck.setFormula(prev_k_f_bn[ck.name_]); if (prev_k_f_bn.contains(ck.name_))
} ck.setFormula(prev_k_f_bn[ck.name_]);
} }
//piCout << " after" << k.size(); }
for (i = v.k.begin(); i != v.k.end(); ++i) { //piCout << " after" << k.size();
if (!used.contains(i.key())) for (i = v.k.begin(); i != v.k.end(); ++i) {
k[i.key()] = i.value(); if (!used.contains(i.key()))
CDType & ck(k[i.key()]); k[i.key()] = i.value();
ck.setFormula(prev_k_f_bn.value(ck.name_)); CDType & ck(k[i.key()]);
} ck.setFormula(prev_k_f_bn.value(ck.name_));
used.clear(); }
PIMap<int, CDSection>::iterator j; used.clear();
for (j = s.begin(); j != s.end(); ++j) { PIMap<int, CDSection>::iterator j;
if (v.s.contains(j.key())) for (j = s.begin(); j != s.end(); ++j) {
j.value().update(v.s[j.key()], mode); if (v.s.contains(j.key()))
used << j.key(); j.value().update(v.s[j.key()], mode);
} used << j.key();
for (j = v.s.begin(); j != v.s.end(); ++j) { }
if (!used.contains(j.key())) for (j = v.s.begin(); j != v.s.end(); ++j) {
s[j.key()] = j.value(); if (!used.contains(j.key()))
}*/ s[j.key()] = j.value();
// piCout << "[CDSection] update end"; }*/
} // piCout << "[CDSection] update end";
}
bool CDSection::isSameStructure(CDSection & v) {
PIMap<PIString, int> cd_ids; bool CDSection::isSameStructure(CDSection & v) {
PIMap<int, CDType>::iterator i; PIMap<PIString, int> cd_ids;
for (i = cd.begin(); i != cd.end(); ++i) PIMap<int, CDType>::iterator i;
cd_ids[i.value().name()] = i.key(); for (i = cd.begin(); i != cd.end(); ++i)
for (i = v.cd.begin(); i != v.cd.end(); ++i) { cd_ids[i.value().name()] = i.key();
if (!cd_ids.contains(i.value().name())) continue; for (i = v.cd.begin(); i != v.cd.end(); ++i) {
//piCout << i.key() << k[i.key()].name() << i.value().name(); if (!cd_ids.contains(i.value().name())) continue;
if (cd[cd_ids[i.value().name()]].index() != i.key()) //piCout << i.key() << k[i.key()].name() << i.value().name();
return false; if (cd[cd_ids[i.value().name()]].index() != i.key())
} return false;
PIMap<int, CDSection>::iterator j; }
for (j = v.s.begin(); j != v.s.end(); ++j) { PIMap<int, CDSection>::iterator j;
if (!s.contains(j.key())) continue; for (j = v.s.begin(); j != v.s.end(); ++j) {
if (!s[j.key()].isSameStructure(j.value())) if (!s.contains(j.key())) continue;
return false; if (!s[j.key()].isSameStructure(j.value()))
} return false;
return true; }
} return true;
}
void CDSection::prepareCalculate() {
PIMap<int, CDType>::iterator i; void CDSection::prepareCalculate() {
for (i = cd.begin(); i != cd.end(); ++i) { PIMap<int, CDType>::iterator i;
i.value().parent = this; for (i = cd.begin(); i != cd.end(); ++i) {
i.value().calculated = false; i.value().parent = this;
} i.value().calculated = false;
PIMap<int, CDSection>::iterator j; }
for (j = s.begin(); j != s.end(); ++j) PIMap<int, CDSection>::iterator j;
j.value().prepareCalculate(); for (j = s.begin(); j != s.end(); ++j)
} j.value().prepareCalculate();
}
void CDSection::calculateRecursive(PIEvaluator * e) {
PIMap<int, CDType>::iterator i; void CDSection::calculateRecursive(PIEvaluator * e) {
for (i = cd.begin(); i != cd.end(); ++i) PIMap<int, CDType>::iterator i;
i.value().calculate(e); for (i = cd.begin(); i != cd.end(); ++i)
PIMap<int, CDSection>::iterator j; i.value().calculate(e);
for (j = s.begin(); j != s.end(); ++j) PIMap<int, CDSection>::iterator j;
j.value().calculateRecursive(e); for (j = s.begin(); j != s.end(); ++j)
} j.value().calculateRecursive(e);
}
void CDSection::setSelectedX(bool yes) {
PIMap<int, CDType>::iterator i; void CDSection::setSelectedX(bool yes) {
for (i = cd.begin(); i != cd.end(); ++i) PIMap<int, CDType>::iterator i;
i.value().x_enabled = yes; for (i = cd.begin(); i != cd.end(); ++i)
PIMap<int, CDSection>::iterator j; i.value().x_enabled = yes;
for (j = s.begin(); j != s.end(); ++j) PIMap<int, CDSection>::iterator j;
j.value().setSelectedX(yes); for (j = s.begin(); j != s.end(); ++j)
} j.value().setSelectedX(yes);
}
PIVector<PIDeque<int> > CDSection::collectX() const {
PIVector<PIDeque<int> > ret; PIVector<PIDeque<int> > CDSection::collectX() const {
PIMap<int, CDType>::const_iterator i; PIVector<PIDeque<int> > ret;
for (i = cd.begin(); i != cd.end(); ++i) { PIMap<int, CDType>::const_iterator i;
if (i.value().x_enabled) for (i = cd.begin(); i != cd.end(); ++i) {
ret << i.value().path(); if (i.value().x_enabled)
} ret << i.value().path();
PIMap<int, CDSection>::const_iterator j; }
for (j = s.constBegin(); j != s.constEnd(); ++j) PIMap<int, CDSection>::const_iterator j;
ret << j.value().collectX(); for (j = s.constBegin(); j != s.constEnd(); ++j)
return ret; ret << j.value().collectX();
} return ret;
}
void CDSection::makePath(PIDeque<int> p) {
PIDeque<int> tp; void CDSection::makePath(PIDeque<int> p) {
PIMap<int, CDType>::iterator i; PIDeque<int> tp;
for (i = cd.begin(); i != cd.end(); ++i) { PIMap<int, CDType>::iterator i;
tp = p; for (i = cd.begin(); i != cd.end(); ++i) {
tp << i.key(); tp = p;
i.value().path_ = tp; tp << i.key();
//piCout << "path for" << i.value().name() << tp; i.value().path_ = tp;
} //piCout << "path for" << i.value().name() << tp;
PIMap<int, CDSection>::iterator j; }
for (j = s.begin(); j != s.end(); ++j) { PIMap<int, CDSection>::iterator j;
tp = p; for (j = s.begin(); j != s.end(); ++j) {
tp << j.key(); tp = p;
j.value().makePath(tp); tp << j.key();
} j.value().makePath(tp);
} }
}
PIVector<CDType * > CDSection::children(bool recursive) const {
PIVector<CDType * > ret; PIVector<CDType * > CDSection::children(bool recursive) const {
PIMap<int, CDType>::const_iterator i; PIVector<CDType * > ret;
for (i = cd.begin(); i != cd.end(); ++i) PIMap<int, CDType>::const_iterator i;
ret << const_cast<CDType * >(&(i.value())); for (i = cd.begin(); i != cd.end(); ++i)
if (!recursive) return ret; ret << const_cast<CDType * >(&(i.value()));
PIMap<int, CDSection>::const_iterator j; if (!recursive) return ret;
for (j = s.constBegin(); j != s.constEnd(); ++j) PIMap<int, CDSection>::const_iterator j;
ret << j.value().children(true); for (j = s.constBegin(); j != s.constEnd(); ++j)
return ret; ret << j.value().children(true);
} return ret;
}
PIVariantTypes::Enum CDSection::enumValues() const {
PIVariantTypes::Enum ret; PIVariantTypes::Enum CDSection::enumValues() const {
PIMap<int, CDType>::const_iterator i; PIVariantTypes::Enum ret;
for (i = cd.constBegin(); i != cd.constEnd(); ++i) PIMap<int, CDType>::const_iterator i;
ret << PIVariantTypes::Enumerator(i.key(), i.value().name()); for (i = cd.constBegin(); i != cd.constEnd(); ++i)
return ret; ret << PIVariantTypes::Enumerator(i.key(), i.value().name());
} return ret;
}

View File

@@ -1,193 +1,192 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_TYPES_H #ifndef CDUTILS_TYPES_H
#define CDUTILS_TYPES_H #define CDUTILS_TYPES_H
#include "pistring.h" #include "pistring.h"
#include "pimap.h" #include "pimap.h"
#include "pivariant.h" #include "pivariant.h"
#include "cd_utils_export.h"
class PIIODevice;
class PIIODevice; class PIEvaluator;
class PIEvaluator; class CD_Pult;
class CD_Pult; class CDItem;
class CDItem; class CDItemModel;
class CDItemModel;
namespace CDUtils {
namespace CDUtils {
class CDSection;
class CDSection;
enum UpdateMode {
enum UpdateMode { SaveByIndex = 0x01,
SaveByIndex = 0x01, SaveByName = 0x02,
SaveByName = 0x02, Merge = 0x04
Merge = 0x04 };
};
enum MessageType {
enum MessageType { Log = 1,
Log = 1, MessageBox,
MessageBox, };
};
typedef PIFlags<UpdateMode> UpdateModeFlags;
typedef PIFlags<UpdateMode> UpdateModeFlags;
class CDType {
class CD_UTILS_EXPORT CDType { friend class CDSection;
friend class CDSection; friend class CDCore;
friend class CDCore; friend class Interface;
friend class Interface; friend class XInterface;
friend class XInterface; public:
public: enum cdT {cdNull, cdK, cdX, cdC, cdM};
enum cdT {cdNull, cdK, cdX, cdC, cdM}; enum XMode {X_Current, X_All_Avg};
enum XMode {X_Current, X_All_Avg};
CDType();
CDType(); CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
CDType & operator =(double x);
CDType & operator =(double x); int index() const {return index_;}
int index() const {return index_;} PIString name() const {return name_;}
PIString name() const {return name_;} PIString type() const;
PIString type() const; PIString value() const;
PIString value() const; PIVariant variantValue() const;
PIVariant variantValue() const; PIString formula() const {return formula_;}
PIString formula() const {return formula_;} PIString comment() const {return comment_;}
PIString comment() const {return comment_;} double toDouble() const {return value_d;}
double toDouble() const {return value_d;} int toInt() const {return value_i;}
int toInt() const {return value_i;} bool toBool() const {return value_b;}
bool toBool() const {return value_b;} cdT cd_type() const {return cd_type_;}
cdT cd_type() const {return cd_type_;} void setValue(const PIString & value_);
void setValue(const PIString & value_); void setVariantValue(const PIVariant & value_);
void setVariantValue(const PIVariant & value_); void setFormula(const PIString & formula);
void setFormula(const PIString & formula); void setComment(const PIString & comment) {comment_ = comment;}
void setComment(const PIString & comment) {comment_ = comment;} operator double() const {return value_d;}
operator double() const {return value_d;} const PIVariantTypes::Enum & enumValues() const {return enum_values;}
const PIVariantTypes::Enum & enumValues() const {return enum_values;} void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;}
void setEnumValues(const PIVariantTypes::Enum & ev) {enum_values = ev;} const PIString & errorString() const {return error_;}
const PIString & errorString() const {return error_;} PIDeque<int> path() const {return path_;}
PIDeque<int> path() const {return path_;} PIStringList pathString() const;
PIStringList pathString() const;
void setXMode(XMode mode) {mode_ = mode;}
void setXMode(XMode mode) {mode_ = mode;} void setAvg(int avg) {avg_size = avg;}
void setAvg(int avg) {avg_size = avg;} XMode xmode() const {return mode_;}
XMode xmode() const {return mode_;} XMode xmode_rec() const {return rmode_;}
XMode xmode_rec() const {return rmode_;} int avg() const {return avg_size;}
int avg() const {return avg_size;} bool isSelectedX() const {return x_enabled;}
bool isSelectedX() const {return x_enabled;} void readX(PIByteArray & ba);
void readX(PIByteArray & ba); void writeX(PIByteArray & ba);
void writeX(PIByteArray & ba);
PIVector<double> history;
PIVector<double> history;
protected:
protected: bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >()); PIVariantTypes::Enum parseEnumComment(PIString c);
PIVariantTypes::Enum parseEnumComment(PIString c); cdT cd_type_;
cdT cd_type_; int index_;
int index_; PIString name_, type_;
PIString name_, type_; PIString value_s, formula_, comment_, error_;
PIString value_s, formula_, comment_, error_; PIVariantTypes::Enum enum_values;
PIVariantTypes::Enum enum_values; CDSection * parent;
CDSection * parent; PIDeque<int> path_;
PIDeque<int> path_; double value_d;
double value_d; int value_i;
int value_i; bool value_b, calculated, x_enabled;
bool value_b, calculated, x_enabled; PIVector<double> avg_h;
PIVector<double> avg_h; int avg_size;
int avg_size; XMode mode_, rmode_;
XMode mode_, rmode_; };
};
class CDSection {
class CD_UTILS_EXPORT CDSection { friend class CDCore;
friend class CDCore; friend class Interface;
friend class Interface; friend class XInterface;
friend class XInterface; friend class ::CD_Pult;
friend class ::CD_Pult; friend class ::CDItem;
friend class ::CDItem; friend class ::CDItemModel;
friend class ::CDItemModel; public:
public:
CDSection(CDType::cdT type_ = CDType::cdNull);
CDSection(CDType::cdT type_ = CDType::cdNull);
bool test(int v) {return cd.value(v).toBool();}
bool test(int v) {return cd.value(v).toBool();} // CDType & operator [](int v) {if (!k.contains(v)) k[v].index_ = v; return k[v];}
// CDType & operator [](int v) {if (!k.contains(v)) k[v].index_ = v; return k[v];} CDType & operator [](int v) {return cd[v];}
CDType & operator [](int v) {return cd[v];} const CDType operator [](int v) const {return cd[v];}
const CDType operator [](int v) const {return cd[v];} CDType & operator [](const PIString & name_) {return getByName(name_);}
CDType & operator [](const PIString & name_) {return getByName(name_);} const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->getByName(name_);}
const CDType operator [](const PIString & name_) const {return const_cast<CDSection*>(this)->getByName(name_);} CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);}
CDType & operator [](const PIDeque<int> & path_) {return getByPath(path_);} const CDType operator [](const PIDeque<int> & path_) const {return const_cast<CDSection*>(this)->getByPath(path_);}
const CDType operator [](const PIDeque<int> & path_) const {return const_cast<CDSection*>(this)->getByPath(path_);} CDSection & section(int v);
CDSection & section(int v); const CDSection section(int v) const;
const CDSection section(int v) const;
bool isEmpty() const {return cd.isEmpty() && s.isEmpty();}
bool isEmpty() const {return cd.isEmpty() && s.isEmpty();} bool exists(PIDeque<int> path) const;
bool exists(PIDeque<int> path) const; int count(bool recursive = true) const;
int count(bool recursive = true) const; int sectionsCount() const;
int sectionsCount() const; PIVector<int> indexes() const {return cd.keys();}
PIVector<int> indexes() const {return cd.keys();} PIStringList index_names() const;
PIStringList index_names() const; void calculate();
void calculate(); void makePath(PIDeque<int> p = PIDeque<int>());
void makePath(PIDeque<int> p = PIDeque<int>()); PIVector<CDType * > children(bool recursive = true) const;
PIVector<CDType * > children(bool recursive = true) const; PIVariantTypes::Enum enumValues() const;
PIVariantTypes::Enum enumValues() const;
PIString name;
PIString name; PIString alias;
PIString alias;
protected:
protected: CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) { cd = k_;
cd = k_; s = s_;
s = s_; }
} CDType & getByName(const PIString & name_);
CDType & getByName(const PIString & name_); CDType & getByPath(const PIDeque<int> & path_);
CDType & getByPath(const PIDeque<int> & path_); void write(PIIODevice * d, const PIString & prefix = PIString());
void write(PIIODevice * d, const PIString & prefix = PIString()); void read(const void * ep);
void read(const void * ep); void update(CDSection & v, UpdateModeFlags mode = SaveByName);
void update(CDSection & v, UpdateModeFlags mode = SaveByName); bool isSameStructure(CDSection & v);
bool isSameStructure(CDSection & v); void prepareCalculate();
void prepareCalculate(); void calculateRecursive(PIEvaluator * e);
void calculateRecursive(PIEvaluator * e); void setSelectedX(bool yes);
void setSelectedX(bool yes); PIVector<PIDeque<int> > collectX() const;
PIVector<PIDeque<int> > collectX() const;
PIMap<int, CDType> cd;
PIMap<int, CDType> cd; mutable PIMap<int, CDSection> s;
mutable PIMap<int, CDSection> s; CDType null;
CDType null; CDType::cdT cd_type_;
CDType::cdT cd_type_; };
};
}
}
inline PICout operator <<(PICout s, const CDUtils::CDType & v) {
inline PICout operator <<(PICout s, const CDUtils::CDType & v) { s.space();
s.space(); s.setControl(0, true);
s.setControl(0, true); switch (v.cd_type()) {
switch (v.cd_type()) { case CDUtils::CDType::cdK : s << "K["; break;
case CDUtils::CDType::cdK : s << "K["; break; case CDUtils::CDType::cdX : s << "X["; break;
case CDUtils::CDType::cdX : s << "X["; break; case CDUtils::CDType::cdC : s << "C["; break;
case CDUtils::CDType::cdC : s << "C["; break; case CDUtils::CDType::cdM : s << "M["; break;
case CDUtils::CDType::cdM : s << "M["; break; default : s << "Null["; break;
default : s << "Null["; break; }
} s << v.name() << "(" << v.index() << ")] = " << v.value();
s << v.name() << "(" << v.index() << ")] = " << v.value(); s.restoreControl();
s.restoreControl(); return s;
return s; }
}
#endif // CDUTILS_TYPES_H
#endif // CDUTILS_TYPES_H

View File

@@ -1,55 +1,55 @@
#include "cdutils_x.h" #include "cdutils_x.h"
#include "cdutils_core.h" #include "cdutils_core.h"
using namespace CDUtils; using namespace CDUtils;
XInterface X; XInterface X;
XInterface::XInterface(): Interface(CDType::cdX) { XInterface::XInterface(): Interface(CDType::cdX) {
CONNECTU(core, X_ReceivedX, this, receivedX); CONNECTU(core, X_ReceivedX, this, receivedX);
} }
void XInterface::setEnabled(const CDType & x, bool en) { void XInterface::setEnabled(const CDType & x, bool en) {
core->x_mutex.lock(); core->x_mutex.lock();
CDType & t((*s)[x.path()]); CDType & t((*s)[x.path()]);
if (t.cd_type() != CDType::cdX) { if (t.cd_type() != CDType::cdX) {
core->x_mutex.unlock(); core->x_mutex.unlock();
return; return;
} }
t.x_enabled = en; t.x_enabled = en;
//piCout << t << "x_enabled" << en; //piCout << t << "x_enabled" << en;
core->need_rebuild_x = true; core->need_rebuild_x = true;
core->x_mutex.unlock(); core->x_mutex.unlock();
} }
PIVector<PIDeque<int> > XInterface::enabledList() const { PIVector<PIDeque<int> > XInterface::enabledList() const {
return CDCore::instance()->x_selected; return CDCore::instance()->x_selected;
} }
void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) { void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) {
CDCore::instance()->x_selected = l; CDCore::instance()->x_selected = l;
} }
void XInterface::lock() { void XInterface::lock() {
CDCore::instance()->x_mutex.lock(); CDCore::instance()->x_mutex.lock();
} }
void XInterface::unlock() { void XInterface::unlock() {
CDCore::instance()->x_mutex.unlock(); CDCore::instance()->x_mutex.unlock();
} }
void XInterface::start(double freq) { void XInterface::start(double freq) {
core->startX(freq); core->startX(freq);
} }
void XInterface::stop() { void XInterface::stop() {
core->stopX(); core->stopX();
} }

View File

@@ -1,57 +1,56 @@
/* /*
CD Utils - Control-Debug utilites CD Utils - Control-Debug utilites
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CDUTILS_X_H #ifndef CDUTILS_X_H
#define CDUTILS_X_H #define CDUTILS_X_H
#include "cdutils_interface.h" #include "cdutils_interface.h"
#include "cd_utils_export.h"
namespace CDUtils {
namespace CDUtils {
class XInterface: public Interface
class CD_UTILS_EXPORT XInterface: public Interface {
{ PIOBJECT_SUBCLASS(XInterface, Interface)
PIOBJECT_SUBCLASS(XInterface, Interface) public:
public: XInterface();
XInterface();
EVENT1(keepNamesRequest, bool*, xn)
EVENT1(keepNamesRequest, bool*, xn) EVENT1(receivedX, PIVector<PIDeque<int> >, pathes)
EVENT1(receivedX, PIVector<PIDeque<int> >, pathes)
void enable(const CDType & x) {setEnabled(x, true);}
void enable(const CDType & x) {setEnabled(x, true);} void disable(const CDType & x) {setEnabled(x, false);}
void disable(const CDType & x) {setEnabled(x, false);} void setEnabled(const CDType & x, bool en);
void setEnabled(const CDType & x, bool en); void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);}
void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);} PIVector<PIDeque<int> > enabledList() const;
PIVector<PIDeque<int> > enabledList() const; void setEnabledList(const PIVector<PIDeque<int> > & l);
void setEnabledList(const PIVector<PIDeque<int> > & l); void lock();
void lock(); void unlock();
void unlock();
void start(double freq = 20.);
void start(double freq = 20.); void stop();
void stop();
};
};
}
}
extern CDUtils::XInterface X;
extern CD_UTILS_EXPORT CDUtils::XInterface X;
#endif // CDUTILS_X_H
#endif // CDUTILS_X_H

View File

@@ -1,97 +1,97 @@
#include "cdutils_k.h" #include "cdutils_k.h"
#include "cdutils_x.h" #include "cdutils_x.h"
#include "cdutils_c.h" #include "cdutils_c.h"
#include "cdutils_m.h" #include "cdutils_m.h"
#include "cdutils_core.h" #include "cdutils_core.h"
#include "cdtest.h" #include "cdtest.h"
#include "pip.h" #include "pip.h"
#include "k_description.h" #include "k_description.h"
using namespace CDUtils; using namespace CDUtils;
class Core : public PIObject class Core : public PIObject
{ {
PIOBJECT(Core) PIOBJECT(Core)
public: public:
Core() { Core() {
CDCore::instance()->initApp(); CDCore::instance()->initApp();
// piCout << "testCore"; // piCout << "testCore";
CONNECTU(&timer, tickEvent, this, timerDone); CONNECTU(&timer, tickEvent, this, timerDone);
CONNECTU(&X, received, this, xrecv); CONNECTU(&X, received, this, xrecv);
CONNECTU(&C, received, this, crecv); CONNECTU(&C, received, this, crecv);
t = 0.; t = 0.;
} }
void load() { void load() {
rf.open("k.dat", PIIODevice::ReadWrite); rf.open("k.dat", PIIODevice::ReadWrite);
K.read(&rf); K.read(&rf);
rf.close(); rf.close();
} }
void save() { void save() {
rf.open("k_out.txt", PIIODevice::ReadWrite); rf.open("k_out.txt", PIIODevice::ReadWrite);
rf.resize(0); rf.resize(0);
K.write(&rf); K.write(&rf);
rf.close(); rf.close();
// rf.open("k_out.txt", PIIODevice::ReadWrite); // rf.open("k_out.txt", PIIODevice::ReadWrite);
// K.read(&rf); // K.read(&rf);
// rf.close(); // rf.close();
// rf.open("k_out2.txt", PIIODevice::ReadWrite); // rf.open("k_out2.txt", PIIODevice::ReadWrite);
// rf.resize(0); // rf.resize(0);
// K.write(&rf); // K.write(&rf);
// rf.close(); // rf.close();
// rf.open("k_out2.txt", PIIODevice::ReadWrite); // rf.open("k_out2.txt", PIIODevice::ReadWrite);
// K.read(&rf); // K.read(&rf);
// rf.close(); // rf.close();
// rf.open("k_out3.txt", PIIODevice::ReadWrite); // rf.open("k_out3.txt", PIIODevice::ReadWrite);
// rf.resize(0); // rf.resize(0);
// K.write(&rf); // K.write(&rf);
// rf.close(); // rf.close();
} }
void test() { void test() {
X.lock(); X.lock();
X[KD::Frequency] = 100; X[KD::Frequency] = 100;
X.section(KD::Spectrometer)[KD::Temperature_default] = sin(t); X.section(KD::Spectrometer)[KD::Temperature_default] = sin(t);
t += 0.01; t += 0.01;
X.unlock(); X.unlock();
/*piCout << "count" << K.count(); /*piCout << "count" << K.count();
piCout << K[First]; piCout << K[First];
piCout << K[Second];*/ piCout << K[Second];*/
} }
EVENT_HANDLER(void, ksend) {piCout << "sended k";} EVENT_HANDLER(void, ksend) {piCout << "sended k";}
EVENT_HANDLER(void, crecv) { EVENT_HANDLER(void, crecv) {
piCout << "received c"; piCout << "received c";
C.connect(C.section(KD::Logs).section(KD::Spec).section(KD::Formats)[KD::Binary], this, HANDLER(cmd)); C.connect(C.section(KD::Logs).section(KD::Spec).section(KD::Formats)[KD::Binary], this, HANDLER(cmd));
C.autoConnect(this); C.autoConnect(this);
} }
EVENT_HANDLER(void, xrecv) { EVENT_HANDLER(void, xrecv) {
piCout << "received x"; piCout << "received x";
if (!timer.isRunning()) timer.start(10); if (!timer.isRunning()) timer.start(10);
X.start(); X.start();
} }
EVENT_HANDLER(void, timerDone) {test();} EVENT_HANDLER(void, timerDone) {test();}
EVENT_HANDLER(void, cmd) {piCout << "command cmd";} EVENT_HANDLER(void, cmd) {piCout << "command cmd";}
EVENT_HANDLER(void, c_Pause) { EVENT_HANDLER(void, c_Pause) {
piCout << "command pause"; piCout << "command pause";
M[KD::Main] << "rec command" << C[KD::Pause]; M[KD::Main] << "rec command" << C[KD::Pause];
M.messageBox(M.root()[KD::Core], "init successfull"); M.messageBox(M.root()[KD::Core], "init successfull");
} }
EVENT_HANDLER(void, c_Spectrometer_Connection) {piCout << "command spec_conn";} EVENT_HANDLER(void, c_Spectrometer_Connection) {piCout << "command spec_conn";}
private: private:
PIFile rf; PIFile rf;
PITimer timer; PITimer timer;
double t; double t;
}; };
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
X.start(); X.start();
piSleep(1); piSleep(1);
//CDCore::instance()->destroy(); //CDCore::instance()->destroy();
piCout << "DELETED"; piCout << "DELETED";
return 0; return 0;
} }

0
cmake_android.sh Normal file → Executable file
View File

View File

@@ -3,14 +3,9 @@ FROM ${DOCKER_PREFIX}android
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
ENV ANDROID_HOME=/usr/lib/android-sdk
ENV ANDROID_NDK_HOME=${ANDROID_HOME}/ndk-bundle
ENV ANDROID_TOOLCHAIN=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
ENV NDK_PLATFORM="android-21"
WORKDIR /soft WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \

View File

@@ -3,10 +3,9 @@ FROM ${DOCKER_PREFIX}debian
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_debian WORKDIR /soft/libs_build_debian
RUN cmake -DICU=0 -DLIB=1 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ RUN cmake -DICU=0 -DLIB=1 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \

View File

@@ -3,10 +3,9 @@ FROM ${DOCKER_PREFIX}osx
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/soft/osxcross/target/bin:/opt/cmake/bin:$PATH
WORKDIR /soft WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \

View File

@@ -3,10 +3,9 @@ FROM ${DOCKER_PREFIX}pi
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \

View File

@@ -3,10 +3,9 @@ FROM ${DOCKER_PREFIX}windows
ARG LIBS_BUILD_NUMBER=9999 ARG LIBS_BUILD_NUMBER=9999
ARG JOBS_COUNT=4 ARG JOBS_COUNT=4
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /soft WORKDIR /soft
RUN git clone -b release --single-branch --depth 1 --recursive https://git.shs.tools/SHS/libs.git RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git
WORKDIR /soft/libs_build_host WORKDIR /soft/libs_build_host
RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ RUN cmake -DICU=0 -DCROSSTOOLS=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \

View File

@@ -1,76 +1,76 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(kx_utils) project(kx_utils)
if (POLICY CMP0017) if (POLICY CMP0017)
cmake_policy(SET CMP0017 NEW) cmake_policy(SET CMP0017 NEW)
endif() endif()
if (NOT LIBPROJECT) if (NOT LIBPROJECT)
find_package(PIP REQUIRED) find_package(PIP REQUIRED)
endif () endif ()
if (MINGW) if (MINGW)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
endif() endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PIP_INCLUDES})
set(KX_PULT_NAME "kx_pult") set(KX_PULT_NAME "kx_pult")
option(KX_PULT "Build ${KX_PULT_NAME}" 1) option(KX_PULT "Build ${KX_PULT_NAME}" 1)
option(LIB "System install" 1) option(LIB "System install" 1)
option(DEBUG "Build with -g3" 0) option(DEBUG "Build with -g3" 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
if (DEBUG) if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
endif() endif()
set(CPPS_UTILS "kx_coeffs.cpp" "piprotocol.cpp") set(CPPS_UTILS "kx_coeffs.cpp" "piprotocol.cpp")
set(HDRS_UTILS "kx_coeffs.h" "kx_protocol_x.h" "kx_protocol_c.h" "piprotocol.h") set(HDRS_UTILS "kx_coeffs.h" "kx_protocol_x.h" "kx_protocol_c.h" "piprotocol.h")
if (DEFINED ENV{QNX_HOST}) if (DEFINED ENV{QNX_HOST})
add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS}) add_library(${PROJECT_NAME} STATIC ${CPPS_UTILS})
else() else()
add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS}) add_library(${PROJECT_NAME} SHARED ${CPPS_UTILS})
endif() endif()
target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY}) target_link_libraries(${PROJECT_NAME} ${PIP_LIBRARY})
message(STATUS "Building ${PROJECT_NAME}") message(STATUS "Building ${PROJECT_NAME}")
if (NOT DEFINED ENV{QNX_HOST}) if (NOT DEFINED ENV{QNX_HOST})
if (KX_PULT) if (KX_PULT)
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
find_package(QAD REQUIRED) find_package(QAD REQUIRED)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${QT_INCLUDES} ${QAD_INCLUDES}) include_directories(${QT_INCLUDES} ${QAD_INCLUDES})
set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp") set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
set(MOCS "kx_pult.h") set(MOCS "kx_pult.h")
file(GLOB UIS "*.ui") file(GLOB UIS "*.ui")
file(GLOB RES "*.qrc") file(GLOB RES "*.qrc")
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw) qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
qt4_wrap_ui(CUIS ${UIS}) qt4_wrap_ui(CUIS ${UIS})
qt4_add_resources(RESS ${RES}) qt4_add_resources(RESS ${RES})
add_executable(${KX_PULT_NAME} WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS}) 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_graphic4 qad_utils4 qad_widgets4) set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${PIP_LIBRARY} qad_graphic4 qad_utils4 qad_widgets4)
target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME}) target_link_libraries(${KX_PULT_NAME} ${LIBS} ${PROJECT_NAME})
endif() endif()
endif() endif()
if (LIB) if (LIB)
list(APPEND _ALL_TARGETS ${PROJECT_NAME}) list(APPEND _ALL_TARGETS ${PROJECT_NAME})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
if (WIN32) if (WIN32)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE}) install(FILES ${HDRS_UTILS} DESTINATION ${MINGW_INCLUDE})
install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB}) install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_LIB})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN}) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
else() else()
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else() else()
set(CMAKE_INSTALL_PREFIX /usr/local) set(CMAKE_INSTALL_PREFIX /usr/local)
endif() endif()
install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) install(FILES ${HDRS_UTILS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else() else()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} DESTINATION lib) install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES ${HDRS_UTILS} DESTINATION include) install(FILES ${HDRS_UTILS} DESTINATION include)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif() endif()
if (NOT DEFINED ENV{QNX_HOST}) if (NOT DEFINED ENV{QNX_HOST})
if (KX_PULT) if (KX_PULT)
install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(TARGETS ${KX_PULT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif() endif()
endif() endif()

View File

@@ -1,848 +1,848 @@
#include <QScrollBar> #include <QScrollBar>
#include <QMessageBox> #include <QMessageBox>
#include <math.h> #include <math.h>
#include "kx_pult.h" #include "kx_pult.h"
#include "ui_kx_pult.h" #include "ui_kx_pult.h"
#include "piqt.h" #include "piqt.h"
#include "qpiconfig.h" #include "qpiconfig.h"
bool isNormalDouble(const double & v) { bool isNormalDouble(const double & v) {
#ifdef WINDOWS #ifdef WINDOWS
return true; return true;
#else #else
return !isnan(v) && !isinf(v); return !isnan(v) && !isinf(v);
#endif #endif
} }
XCheck::XCheck(int index): QWidget() { XCheck::XCheck(int index): QWidget() {
index_ = index; index_ = index;
setProperty("index", index); setProperty("index", index);
setMouseTracking(true); setMouseTracking(true);
check.setText(QString::number(index + 1) + " "); check.setText(QString::number(index + 1) + " ");
check.setAutoFillBackground(true); check.setAutoFillBackground(true);
spin.setMaximum(KX_X_COUNT - 1); spin.setMaximum(KX_X_COUNT - 1);
QBoxLayout * l = new QBoxLayout(QBoxLayout::LeftToRight); QBoxLayout * l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setMargin(0); l->setMargin(0);
l->setSpacing(2); l->setSpacing(2);
l->addWidget(&check); l->addWidget(&check);
l->addWidget(&spin); l->addWidget(&spin);
setLayout(l); setLayout(l);
//check.installEventFilter(this); //check.installEventFilter(this);
//spin.installEventFilter(this); //spin.installEventFilter(this);
connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int))); connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int)));
connect(&check, SIGNAL(toggled(bool)), this, SLOT(checkChanged_(bool))); connect(&check, SIGNAL(toggled(bool)), this, SLOT(checkChanged_(bool)));
} }
bool XCheck::eventFilter(QObject * o, QEvent * e) { bool XCheck::eventFilter(QObject * o, QEvent * e) {
if (e->type() == QEvent::Enter) if (e->type() == QEvent::Enter)
qApp->postEvent(this, new QEvent(e->type())); qApp->postEvent(this, new QEvent(e->type()));
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }
KX_Pult::KX_Pult(): QMainWindow(), config_("kx_pult.conf"), name_x("x"), name_c("c"), KX_Pult::KX_Pult(): QMainWindow(), config_("kx_pult.conf"), name_x("x"), name_c("c"),
config(piqt(config_), QIODevice::ReadWrite), coeffs(config_, "k", true) { config(piqt(config_), QIODevice::ReadWrite), coeffs(config_, "k", true) {
//cout << sizeof(coeffsK.k_protocol->to_k) << endl; //cout << sizeof(coeffsK.k_protocol->to_k) << endl;
ui = new Ui::KX_Pult(); ui = new Ui::KX_Pult();
ui->setupUi(this); ui->setupUi(this);
ui->configWidget->setQPIConfig(&config); ui->configWidget->setQPIConfig(&config);
ui->configWidget->expandAll(); ui->configWidget->expandAll();
ui->list->viewport()->installEventFilter(this); ui->list->viewport()->installEventFilter(this);
ui->treeK->viewport()->installEventFilter(this); ui->treeK->viewport()->installEventFilter(this);
ui->scrollArea->setAutoFillBackground(false); ui->scrollArea->setAutoFillBackground(false);
ui->scrollAreaWidgetContents->setAutoFillBackground(false); ui->scrollAreaWidgetContents->setAutoFillBackground(false);
ui->widget->setAutoFillBackground(false); ui->widget->setAutoFillBackground(false);
ui->label_17->setFixedSize(preferredIconSize(1.25, this)); ui->label_17->setFixedSize(preferredIconSize(1.25, this));
log_menu.addAction(ui->actionClear); log_menu.addAction(ui->actionClear);
prot_x = 0; prot_x = 0;
prot_c = 0; prot_c = 0;
show_x = config.getValue("show_x", true); show_x = config.getValue("show_x", true);
if (!show_x) if (!show_x)
ui->tabWidget->removeTab(1); ui->tabWidget->removeTab(1);
session.setFile("session_KX_Pult.conf"); session.setFile("session_KX_Pult.conf");
session.addEntry(this); session.addEntry(this);
session.addEntry(ui->tabWidget); session.addEntry(ui->tabWidget);
session.addEntry(ui->checkKHideEmpty); session.addEntry(ui->checkKHideEmpty);
session.addEntry(ui->checkKHideNormal); session.addEntry(ui->checkKHideNormal);
session.addEntry(ui->checkKHideExpressions); session.addEntry(ui->checkKHideExpressions);
session.addEntry(ui->checkKAutoCalculate); session.addEntry(ui->checkKAutoCalculate);
needWrite = isPause = false; needWrite = isPause = false;
timer = 0; timer = 0;
//x.resize(KX_X_PACKET_NUM); //x.resize(KX_X_PACKET_NUM);
//k.resize(K_NUM); //k.resize(K_NUM);
QPalette pal = palette(); QPalette pal = palette();
QColor col; QColor col;
ui->graphic->setGraphicsCount(0); ui->graphic->setGraphicsCount(0);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
XCheck * xc = new XCheck(i); XCheck * xc = new XCheck(i);
xc->installEventFilter(this); xc->installEventFilter(this);
connect(xc, SIGNAL(valueChanged(int, int)), this, SLOT(changedX(int,int))); connect(xc, SIGNAL(valueChanged(int, int)), this, SLOT(changedX(int,int)));
connect(xc, SIGNAL(checkChanged(int, bool)), this, SLOT(toggledX(int, bool))); connect(xc, SIGNAL(checkChanged(int, bool)), this, SLOT(toggledX(int, bool)));
col = QColor::fromHsv(360 / KX_X_PACKET_NUM * i, 255, 200); col = QColor::fromHsv(360 / KX_X_PACKET_NUM * i, 255, 200);
pal.setColor(QPalette::Button, col); pal.setColor(QPalette::Button, col);
pal.setColor(QPalette::Window, col); pal.setColor(QPalette::Window, col);
pal.setColor(QPalette::WindowText, invertColor(col)); pal.setColor(QPalette::WindowText, invertColor(col));
xc->check.setPalette(pal); xc->check.setPalette(pal);
ui->graphic->addGraphic(QString::number(i), col); ui->graphic->addGraphic(QString::number(i), col);
ui->graphic->setGraphicVisible(false, i); ui->graphic->setGraphicVisible(false, i);
checks << xc; checks << xc;
((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(xc, (i / 10) * 2, i % 10); ((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(xc, (i / 10) * 2, i % 10);
QLabel * lbl = new QLabel("0"); lbl->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); QLabel * lbl = new QLabel("0"); lbl->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
values << lbl; values << lbl;
((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(lbl, (i / 10) * 2 + 1, i % 10); ((QGridLayout * )(ui->widgetChecks->layout()))->addWidget(lbl, (i / 10) * 2 + 1, i % 10);
//xc->show(); //xc->show();
} }
renew(); renew();
icon_record = QIcon(":/icons/media-record.png"); icon_record = QIcon(":/icons/media-record.png");
icon_stop = QIcon(":/icons/media-playback-stop.png"); icon_stop = QIcon(":/icons/media-playback-stop.png");
outdir = dir.absolutePath(); outdir = dir.absolutePath();
if (!dir.exists()) dir.mkdir(outdir); if (!dir.exists()) dir.mkdir(outdir);
outdir += "/"; outdir += "/";
ui->treeK->setColumnWidth(0, 60); ui->treeK->setColumnWidth(0, 60);
ui->treeK->setColumnWidth(1, 250); ui->treeK->setColumnWidth(1, 250);
ui->treeK->setColumnWidth(3, 100); ui->treeK->setColumnWidth(3, 100);
ui->treeK->setColumnWidth(4, 100); ui->treeK->setColumnWidth(4, 100);
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
ui->spinSize->setValue(K.size_s()); ui->spinSize->setValue(K.size_s());
addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
CONNECT(void, &coeffs, sendFailed, this, pip_sendFailed); CONNECT(void, &coeffs, sendFailed, this, pip_sendFailed);
CONNECT(void, &coeffs, sendSucceed, this, pip_sendSucceed); CONNECT(void, &coeffs, sendSucceed, this, pip_sendSucceed);
CONNECT(void, &coeffs, receiveFailed, this, pip_receiveFailed); CONNECT(void, &coeffs, receiveFailed, this, pip_receiveFailed);
CONNECT(void, &coeffs, receiveSucceed, this, pip_receiveSucceed); CONNECT(void, &coeffs, receiveSucceed, this, pip_receiveSucceed);
connect(this, SIGNAL(q_k_sendFailed()), this, SLOT(k_sendFailed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_sendFailed()), this, SLOT(k_sendFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_sendSucceed()), this, SLOT(k_sendSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_sendSucceed()), this, SLOT(k_sendSucceed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_receiveFailed()), this, SLOT(k_receiveFailed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_receiveFailed()), this, SLOT(k_receiveFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(q_k_receiveSucceed()), this, SLOT(k_receiveSucceed()), Qt::QueuedConnection); connect(this, SIGNAL(q_k_receiveSucceed()), this, SLOT(k_receiveSucceed()), Qt::QueuedConnection);
connect(&timer_diag, SIGNAL(timeout()), this, SLOT(updateDiag())); connect(&timer_diag, SIGNAL(timeout()), this, SLOT(updateDiag()));
connect(&session, SIGNAL(loading(QPIConfig&)), this, SLOT(loading(QPIConfig&))); connect(&session, SIGNAL(loading(QPIConfig&)), this, SLOT(loading(QPIConfig&)));
connect(&session, SIGNAL(saving(QPIConfig&)), this, SLOT(saving(QPIConfig&))); connect(&session, SIGNAL(saving(QPIConfig&)), this, SLOT(saving(QPIConfig&)));
connect(ui->checkKHideEmpty, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideEmpty, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->checkKHideNormal, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideNormal, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->checkKHideExpressions, SIGNAL(toggled(bool)), this, SLOT(filterTree())); connect(ui->checkKHideExpressions, SIGNAL(toggled(bool)), this, SLOT(filterTree()));
connect(ui->lineKSearch, SIGNAL(textChanged(QString)), this, SLOT(filterTree())); connect(ui->lineKSearch, SIGNAL(textChanged(QString)), this, SLOT(filterTree()));
session.load(); session.load();
updateKDesc(); updateKDesc();
updateCDesc(); updateCDesc();
timer_diag.start(40); timer_diag.start(40);
timer_update = startTimer(25); timer_update = startTimer(25);
} }
KX_Pult::~KX_Pult() { KX_Pult::~KX_Pult() {
session.save(); session.save();
} }
void KX_Pult::loading(QPIConfig & conf) { void KX_Pult::loading(QPIConfig & conf) {
kdesc_file = conf.getValue("kdesc_file").stringValue(); kdesc_file = conf.getValue("kdesc_file").stringValue();
cdesc_file = conf.getValue("cdesc_file").stringValue(); cdesc_file = conf.getValue("cdesc_file").stringValue();
} }
void KX_Pult::saving(QPIConfig & conf) { void KX_Pult::saving(QPIConfig & conf) {
conf.setValue("kdesc_file", kdesc_file); conf.setValue("kdesc_file", kdesc_file);
conf.setValue("cdesc_file", cdesc_file); conf.setValue("cdesc_file", cdesc_file);
} }
bool KX_Pult::eventFilter(QObject * o, QEvent * e) { bool KX_Pult::eventFilter(QObject * o, QEvent * e) {
if (o == ui->list->viewport()) { if (o == ui->list->viewport()) {
if (e->type() == QEvent::ContextMenu) { if (e->type() == QEvent::ContextMenu) {
clear_target = 0; clear_target = 0;
log_menu.popup(((QContextMenuEvent*)e)->globalPos()); log_menu.popup(((QContextMenuEvent*)e)->globalPos());
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
if (o == ui->treeK->viewport()) { if (o == ui->treeK->viewport()) {
if (e->type() == QEvent::ContextMenu) { if (e->type() == QEvent::ContextMenu) {
clear_target = 1; clear_target = 1;
log_menu.popup(((QContextMenuEvent*)e)->globalPos()); log_menu.popup(((QContextMenuEvent*)e)->globalPos());
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
int ind = o->property("index").toInt(); int ind = o->property("index").toInt();
//qDebug() << "event" << i << e->type(); //qDebug() << "event" << i << e->type();
switch (e->type()) { switch (e->type()) {
case QEvent::Enter: case QEvent::Enter:
ui->graphic->setAutoUpdate(false); ui->graphic->setAutoUpdate(false);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
ui->graphic->setGraphicLineWidth(ind == i ? 3. : 1., i); ui->graphic->setGraphicLineWidth(ind == i ? 3. : 1., i);
ui->graphic->setAutoUpdate(true); ui->graphic->setAutoUpdate(true);
ui->graphic->update(); ui->graphic->update();
break; break;
case QEvent::Leave: case QEvent::Leave:
ui->graphic->setAutoUpdate(false); ui->graphic->setAutoUpdate(false);
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
ui->graphic->setGraphicLineWidth(1., i); ui->graphic->setGraphicLineWidth(1., i);
ui->graphic->setAutoUpdate(true); ui->graphic->setAutoUpdate(true);
ui->graphic->update(); ui->graphic->update();
break; break;
default: break; default: break;
} }
return QMainWindow::eventFilter(o, e); return QMainWindow::eventFilter(o, e);
} }
void KX_Pult::timerEvent(QTimerEvent * e) { void KX_Pult::timerEvent(QTimerEvent * e) {
if (e->timerId() == timer_update) { if (e->timerId() == timer_update) {
if (need_update) { if (need_update) {
need_update = false; need_update = false;
ui->graphic->updateGraphics(); ui->graphic->updateGraphics();
} }
} }
if (e->timerId() == timer) { if (e->timerId() == timer) {
static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14); static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14);
static int cnt = 0; static int cnt = 0;
int si = qMax<int>(cnt - 6, 0); int si = qMax<int>(cnt - 6, 0);
++cnt; ++cnt;
cnt %= 23; cnt %= 23;
ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed()); ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed());
if (!coeffs.isReady()) return; if (!coeffs.isReady()) return;
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
//ui->table->showK(); //ui->table->showK();
} }
} }
void KX_Pult::setControlsEnable(bool enable) { void KX_Pult::setControlsEnable(bool enable) {
foreach (XCheck * i, checks) foreach (XCheck * i, checks)
i->setEnabled(enable); i->setEnabled(enable);
ui->buttonShowAll->setEnabled(enable); ui->buttonShowAll->setEnabled(enable);
ui->buttonHideAll->setEnabled(enable); ui->buttonHideAll->setEnabled(enable);
} }
void KX_Pult::setX(const KX_X_Data & data) { void KX_Pult::setX(const KX_X_Data & data) {
if (!show_x) return; if (!show_x) return;
//ui->graphic->lock(); //ui->graphic->lock();
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
if (!isNormalDouble(data.x_data[i])) continue; if (!isNormalDouble(data.x_data[i])) continue;
ui->graphic->addPoint(data.x_data[i], i, false); ui->graphic->addPoint(data.x_data[i], i, false);
values[i]->setText(QString("(%1): %2").arg(data.x_num[i]).arg(data.x_data[i])); values[i]->setText(QString("(%1): %2").arg(data.x_num[i]).arg(data.x_data[i]));
} }
//ui->graphic->unlock(); //ui->graphic->unlock();
if (!isPause) { if (!isPause) {
need_update = true; need_update = true;
} }
if (!needWrite) return; if (!needWrite) return;
stream << QString::number(tm.elapsed() / 1000., 'f', 3) << " " << QTime::currentTime().toString("hh:mm:ss") << " " << wcnt++; stream << QString::number(tm.elapsed() / 1000., 'f', 3) << " " << QTime::currentTime().toString("hh:mm:ss") << " " << wcnt++;
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
stream << " " << QString::number(data.x_data[i], 'f', 4); stream << " " << QString::number(data.x_data[i], 'f', 4);
stream << "\n"; stream << "\n";
} }
void KX_Pult::addToList(const QString & s, const QColor & c) { void KX_Pult::addToList(const QString & s, const QColor & c) {
ui->list->addItem(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:ss - ") + s); ui->list->addItem(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:ss - ") + s);
ui->list->item(ui->list->count() - 1)->setTextColor(c); ui->list->item(ui->list->count() - 1)->setTextColor(c);
ui->list->scrollToBottom(); ui->list->scrollToBottom();
} }
void KX_Pult::on_buttonRecord_clicked() { void KX_Pult::on_buttonRecord_clicked() {
static bool isRec = false; static bool isRec = false;
int cinc = 0; int cinc = 0;
QString str; QString str;
isRec = !isRec; isRec = !isRec;
setControlsEnable(!isRec); setControlsEnable(!isRec);
if (isRec) { if (isRec) {
tm.restart(); tm.restart();
file.close(); file.close();
file.setFileName(outdir + getNewFileName(cinc)); file.setFileName(outdir + getNewFileName(cinc));
while (file.exists()) while (file.exists())
file.setFileName(outdir + getNewFileName(cinc++)); file.setFileName(outdir + getNewFileName(cinc++));
file.open(QIODevice::ReadWrite); file.open(QIODevice::ReadWrite);
stream.setDevice(&file); stream.setDevice(&file);
stream << "T V C"; stream << "T V C";
for (int i = 0; i < KX_X_PACKET_NUM; ++i) for (int i = 0; i < KX_X_PACKET_NUM; ++i)
stream << " X" + QString::number(checks[i]->spin.value()); stream << " X" + QString::number(checks[i]->spin.value());
stream << "\n"; stream << "\n";
wcnt = 0; wcnt = 0;
needWrite = true; needWrite = true;
ui->buttonRecord->setText(trUtf8("Finish record")); ui->buttonRecord->setText(trUtf8("Finish record"));
ui->buttonRecord->setIcon(icon_stop); ui->buttonRecord->setIcon(icon_stop);
emit recordStarted(QFileInfo(file).completeBaseName()); emit recordStarted(QFileInfo(file).completeBaseName());
} else { } else {
needWrite = false; needWrite = false;
stream.setDevice(0); stream.setDevice(0);
file.close(); file.close();
ui->buttonRecord->setText(trUtf8("Start record")); ui->buttonRecord->setText(trUtf8("Start record"));
ui->buttonRecord->setIcon(icon_record); ui->buttonRecord->setIcon(icon_record);
emit recordStopped(QFileInfo(file).completeBaseName()); emit recordStopped(QFileInfo(file).completeBaseName());
} }
} }
void KX_Pult::on_actionClear_triggered() { void KX_Pult::on_actionClear_triggered() {
switch (clear_target) { switch (clear_target) {
case 0: case 0:
ui->list->clear(); ui->list->clear();
break; break;
case 1: case 1:
clearSelected(); clearSelected();
break; break;
default: break; default: break;
} }
} }
void KX_Pult::clearSelected() { void KX_Pult::clearSelected() {
QList<QTreeWidgetItem * > si = ui->treeK->selectedItems(); QList<QTreeWidgetItem * > si = ui->treeK->selectedItems();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
ui->treeK->blockSignals(true); ui->treeK->blockSignals(true);
foreach (QTreeWidgetItem * i, si) { foreach (QTreeWidgetItem * i, si) {
int ki = i->text(0).toInt(); int ki = i->text(0).toInt();
i->setText(2, ""); i->setText(2, "");
coeffs.setFormula(ki, ""); coeffs.setFormula(ki, "");
} }
ui->treeK->blockSignals(false); ui->treeK->blockSignals(false);
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
if (ui->checkKAutoCalculate->isChecked()) { if (ui->checkKAutoCalculate->isChecked()) {
QApplication::processEvents(); QApplication::processEvents();
calculate(); calculate();
} }
} }
QString KX_Pult::typeName(const QString & n) const { QString KX_Pult::typeName(const QString & n) const {
if (n.isEmpty()) return ""; if (n.isEmpty()) return "";
switch (n[0].toLatin1()) { switch (n[0].toLatin1()) {
case 'l': return trUtf8("list"); break; case 'l': return trUtf8("list"); break;
case 'b': return trUtf8("bool"); break; case 'b': return trUtf8("bool"); break;
case 'n': return trUtf8("int"); break; case 'n': return trUtf8("int"); break;
case 'f': return trUtf8("double"); break; case 'f': return trUtf8("double"); break;
case 'c': return trUtf8("color"); break; case 'c': return trUtf8("color"); break;
case 'r': return trUtf8("rect"); break; case 'r': return trUtf8("rect"); break;
case 'a': return trUtf8("rect"); break; case 'a': return trUtf8("rect"); break;
case 'p': return trUtf8("point"); break; case 'p': return trUtf8("point"); break;
case 'v': return trUtf8("vector"); break; case 'v': return trUtf8("vector"); break;
case 'i': return trUtf8("IP"); break; case 'i': return trUtf8("IP"); break;
case 'e': return trUtf8("enum"); break; case 'e': return trUtf8("enum"); break;
case 'F': return trUtf8("file"); break; case 'F': return trUtf8("file"); break;
case 'D': return trUtf8("dir"); break; case 'D': return trUtf8("dir"); break;
} }
return ""; return "";
} }
void KX_Pult::received(bool ok) { void KX_Pult::received(bool ok) {
if (!ok) return; if (!ok) return;
setX(prot_x->from_x); setX(prot_x->from_x);
} }
void KX_Pult::on_treeK_itemClicked(QTreeWidgetItem * item, int column) { void KX_Pult::on_treeK_itemClicked(QTreeWidgetItem * item, int column) {
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if (column == 2) f |= Qt::ItemIsEditable; if (column == 2) f |= Qt::ItemIsEditable;
item->setFlags(f); item->setFlags(f);
} }
void KX_Pult::on_treeK_itemChanged(QTreeWidgetItem * item, int column) { void KX_Pult::on_treeK_itemChanged(QTreeWidgetItem * item, int column) {
if (column != 2) return; if (column != 2) return;
int ki = item->text(0).toInt(); int ki = item->text(0).toInt();
coeffs.setFormula(ki, piqt(item->text(column))); coeffs.setFormula(ki, piqt(item->text(column)));
if (ui->checkKAutoCalculate->isChecked()) if (ui->checkKAutoCalculate->isChecked())
calculate(); calculate();
} }
QString KX_Pult::getNewFileName(int inc) { QString KX_Pult::getNewFileName(int inc) {
dir.refresh(); dir.refresh();
dir.setNameFilters(QStringList("Experiment_*.txt")); dir.setNameFilters(QStringList("Experiment_*.txt"));
return "Experiment_" + QDateTime::currentDateTime().toString("dd_MM_yy__hh_mm_ss") + "__" + return "Experiment_" + QDateTime::currentDateTime().toString("dd_MM_yy__hh_mm_ss") + "__" +
QString::number(dir.entryList().count() + inc) + ".txt"; QString::number(dir.entryList().count() + inc) + ".txt";
} }
void KX_Pult::on_buttonSendK_clicked() { void KX_Pult::on_buttonSendK_clicked() {
on_buttonWrite_clicked(); on_buttonWrite_clicked();
coeffs.sendCoeffs(); coeffs.sendCoeffs();
if (timer != 0) killTimer(timer); if (timer != 0) killTimer(timer);
timer = startTimer(100); timer = startTimer(100);
} }
void KX_Pult::on_buttonReceiveK_clicked() { void KX_Pult::on_buttonReceiveK_clicked() {
coeffs.receiveCoeffs(); coeffs.receiveCoeffs();
if (timer != 0) killTimer(timer); if (timer != 0) killTimer(timer);
timer = startTimer(100); timer = startTimer(100);
} }
void KX_Pult::on_buttonShowAll_clicked() { void KX_Pult::on_buttonShowAll_clicked() {
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
checks[i]->check.setChecked(true); checks[i]->check.setChecked(true);
//ui->graphic->setGraphicVisible(true, i); //ui->graphic->setGraphicVisible(true, i);
} }
} }
void KX_Pult::on_buttonHideAll_clicked() { void KX_Pult::on_buttonHideAll_clicked() {
for (int i = 0; i < KX_X_PACKET_NUM; ++i) { for (int i = 0; i < KX_X_PACKET_NUM; ++i) {
checks[i]->check.setChecked(false); checks[i]->check.setChecked(false);
//ui->graphic->setGraphicVisible(false, i); //ui->graphic->setGraphicVisible(false, i);
} }
} }
void KX_Pult::on_buttonRead_clicked() { void KX_Pult::on_buttonRead_clicked() {
coeffs.readCoeffs(); coeffs.readCoeffs();
addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
updateTree(); updateTree();
} }
void KX_Pult::on_buttonWrite_clicked() { void KX_Pult::on_buttonWrite_clicked() {
coeffs.writeCoeffs(); coeffs.writeCoeffs();
addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
} }
void KX_Pult::on_buttonResize_clicked() { void KX_Pult::on_buttonResize_clicked() {
K.resize(ui->spinSize->value()); K.resize(ui->spinSize->value());
coeffs.formulas.resize(ui->spinSize->value()); coeffs.formulas.resize(ui->spinSize->value());
ui->spinSize->setStyleSheet(""); ui->spinSize->setStyleSheet("");
updateTree(); updateTree();
} }
void KX_Pult::on_buttonSetKDesc_clicked() { void KX_Pult::on_buttonSetKDesc_clicked() {
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)"); QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
if (ret.isEmpty()) return; if (ret.isEmpty()) return;
kdesc_file = QDir::current().relativeFilePath(ret); kdesc_file = QDir::current().relativeFilePath(ret);
updateKDesc(true); updateKDesc(true);
} }
void KX_Pult::on_buttonSetCDesc_clicked() { void KX_Pult::on_buttonSetCDesc_clicked() {
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with C description"), cdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)"); QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with C description"), cdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
if (ret.isEmpty()) return; if (ret.isEmpty()) return;
cdesc_file = QDir::current().relativeFilePath(ret); cdesc_file = QDir::current().relativeFilePath(ret);
updateCDesc(); updateCDesc();
} }
void KX_Pult::on_spinSize_valueChanged(int) { void KX_Pult::on_spinSize_valueChanged(int) {
ui->spinSize->setStyleSheet(""); ui->spinSize->setStyleSheet("");
} }
void KX_Pult::k_sendFailed() { void KX_Pult::k_sendFailed() {
stopWait(); stopWait();
addToList(trUtf8("K not sended"), Qt::darkRed); addToList(trUtf8("K not sended"), Qt::darkRed);
} }
void KX_Pult::k_sendSucceed() { void KX_Pult::k_sendSucceed() {
stopWait(); stopWait();
addToList(trUtf8("K sended"), Qt::darkGreen); addToList(trUtf8("K sended"), Qt::darkGreen);
} }
void KX_Pult::k_receiveFailed() { void KX_Pult::k_receiveFailed() {
stopWait(); stopWait();
addToList(trUtf8("K not received"), Qt::darkRed); addToList(trUtf8("K not received"), Qt::darkRed);
} }
void KX_Pult::k_receiveSucceed() { void KX_Pult::k_receiveSucceed() {
stopWait(); stopWait();
addToList(trUtf8("K received"), Qt::darkGreen); addToList(trUtf8("K received"), Qt::darkGreen);
addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); addToList(trUtf8("Write K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta);
ui->spinSize->setValue(K.size_s()); ui->spinSize->setValue(K.size_s());
updateTree(); updateTree();
//ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //ui->table->setK(coeffsK.k()->data(), coeffsK.count());
} }
void KX_Pult::on_spinBuffer_editingFinished() { void KX_Pult::on_spinBuffer_editingFinished() {
ui->graphic->setHistorySize(ui->spinBuffer->value()); ui->graphic->setHistorySize(ui->spinBuffer->value());
} }
void KX_Pult::stopWait() { void KX_Pult::stopWait() {
killTimer(timer); killTimer(timer);
timer = 0; timer = 0;
ui->labelWait->setText(" "); ui->labelWait->setText(" ");
} }
void KX_Pult::updateGraph() { void KX_Pult::updateGraph() {
ui->graphic->updateGraphics(); ui->graphic->updateGraphics();
} }
void KX_Pult::updateDiag() { void KX_Pult::updateDiag() {
ui->labelKReceiver->setText(piqt(coeffs.k_protocol->receiverDeviceName() + " - " + coeffs.k_protocol->receiverDeviceState())); ui->labelKReceiver->setText(piqt(coeffs.k_protocol->receiverDeviceName() + " - " + coeffs.k_protocol->receiverDeviceState()));
ui->labelKSender->setText(piqt(coeffs.k_protocol->senderDeviceName())); ui->labelKSender->setText(piqt(coeffs.k_protocol->senderDeviceName()));
ui->spinKSended->setValue(coeffs.k_protocol->sendCount()); ui->spinKSended->setValue(coeffs.k_protocol->sendCount());
ui->spinKReceived->setValue(coeffs.k_protocol->receiveCount()); ui->spinKReceived->setValue(coeffs.k_protocol->receiveCount());
ui->spinKWrong->setValue(coeffs.k_protocol->wrongCount()); ui->spinKWrong->setValue(coeffs.k_protocol->wrongCount());
ui->spinKMissed->setValue(coeffs.k_protocol->missedCount()); ui->spinKMissed->setValue(coeffs.k_protocol->missedCount());
ui->labelKType->setText("0x" + QString::number(coeffs.k_protocol->from_k.type, 16).toUpper().rightJustified(2, '0')); ui->labelKType->setText("0x" + QString::number(coeffs.k_protocol->from_k.type, 16).toUpper().rightJustified(2, '0'));
ui->labelKAddrPult->setText("0x" + QString::number(coeffs.k_protocol->from_k.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelKAddrPult->setText("0x" + QString::number(coeffs.k_protocol->from_k.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelKAddr->setText("0x" + QString::number(coeffs.k_protocol->to_k.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelKAddr->setText("0x" + QString::number(coeffs.k_protocol->to_k.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelXReceiver->setText(piqt(prot_x->receiverDeviceName() + " - " + prot_x->receiverDeviceState())); ui->labelXReceiver->setText(piqt(prot_x->receiverDeviceName() + " - " + prot_x->receiverDeviceState()));
ui->labelXSender->setText(piqt(prot_x->senderDeviceName())); ui->labelXSender->setText(piqt(prot_x->senderDeviceName()));
ui->spinXSended->setValue(prot_x->sendCount()); ui->spinXSended->setValue(prot_x->sendCount());
ui->spinXReceived->setValue(prot_x->receiveCount()); ui->spinXReceived->setValue(prot_x->receiveCount());
ui->spinXWrong->setValue(prot_x->wrongCount()); ui->spinXWrong->setValue(prot_x->wrongCount());
ui->spinXMissed->setValue(prot_x->missedCount()); ui->spinXMissed->setValue(prot_x->missedCount());
ui->labelXType->setText("0x" + QString::number(prot_x->from_x.type, 16).toUpper().rightJustified(2, '0')); ui->labelXType->setText("0x" + QString::number(prot_x->from_x.type, 16).toUpper().rightJustified(2, '0'));
ui->labelXAddrPult->setText("0x" + QString::number(prot_x->from_x.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelXAddrPult->setText("0x" + QString::number(prot_x->from_x.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelXAddr->setText("0x" + QString::number(prot_x->to_x.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelXAddr->setText("0x" + QString::number(prot_x->to_x.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelCReceiver->setText(piqt(prot_c->receiverDeviceName() + " - " + prot_c->receiverDeviceState())); ui->labelCReceiver->setText(piqt(prot_c->receiverDeviceName() + " - " + prot_c->receiverDeviceState()));
ui->labelCSender->setText(piqt(prot_c->senderDeviceName())); ui->labelCSender->setText(piqt(prot_c->senderDeviceName()));
ui->spinCSended->setValue(prot_c->sendCount()); ui->spinCSended->setValue(prot_c->sendCount());
ui->spinCReceived->setValue(prot_c->receiveCount()); ui->spinCReceived->setValue(prot_c->receiveCount());
ui->spinCWrong->setValue(prot_c->wrongCount()); ui->spinCWrong->setValue(prot_c->wrongCount());
ui->spinCMissed->setValue(prot_c->missedCount()); ui->spinCMissed->setValue(prot_c->missedCount());
ui->labelCType->setText("0x" + QString::number(prot_c->from_c.type, 16).toUpper().rightJustified(2, '0')); ui->labelCType->setText("0x" + QString::number(prot_c->from_c.type, 16).toUpper().rightJustified(2, '0'));
ui->labelCAddrPult->setText("0x" + QString::number(prot_c->from_c.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelCAddrPult->setText("0x" + QString::number(prot_c->from_c.addr_to, 16).toUpper().rightJustified(2, '0'));
ui->labelCAddr->setText("0x" + QString::number(prot_c->to_c.addr_to, 16).toUpper().rightJustified(2, '0')); ui->labelCAddr->setText("0x" + QString::number(prot_c->to_c.addr_to, 16).toUpper().rightJustified(2, '0'));
} }
int KX_Pult::parseHeader(const QString & file, QMap<int, KX_Pult::KDesc> & map) { int KX_Pult::parseHeader(const QString & file, QMap<int, KX_Pult::KDesc> & map) {
map.clear(); map.clear();
QFile f(file); QFile f(file);
if (!f.open(QIODevice::ReadOnly)) { if (!f.open(QIODevice::ReadOnly)) {
updateTree(); updateTree();
addToList(trUtf8("Update descriptions from \"%1\": error").arg(file), Qt::darkRed); addToList(trUtf8("Update descriptions from \"%1\": error").arg(file), Qt::darkRed);
return 0; return 0;
} }
addToList(trUtf8("Update descriptions from \"%1\"").arg(file), Qt::darkMagenta); addToList(trUtf8("Update descriptions from \"%1\"").arg(file), Qt::darkMagenta);
QTextStream s(&f); QTextStream s(&f);
int cind = -1; int cind = -1;
bool found = false; bool found = false;
//qDebug() << "\nparse" << file; //qDebug() << "\nparse" << file;
while (!s.atEnd()) { while (!s.atEnd()) {
QString line = s.readLine().trimmed(), num, name, type, comment; QString line = s.readLine().trimmed(), num, name, type, comment;
int i = line.indexOf("//"); int i = line.indexOf("//");
if (i >= 0) { if (i >= 0) {
comment = line.right(line.length() - i - 2); comment = line.right(line.length() - i - 2);
type = comment.left(1); type = comment.left(1);
comment = comment.right(comment.length() - 1).trimmed(); comment = comment.right(comment.length() - 1).trimmed();
line = line.left(i).trimmed(); line = line.left(i).trimmed();
} }
if (line.isEmpty()) continue; if (line.isEmpty()) continue;
if (line.contains("enum")) { if (line.contains("enum")) {
found = true; found = true;
continue; continue;
} }
if (!found) continue; if (!found) continue;
if (line.contains('}')) if (line.contains('}'))
break; break;
line.remove(',').remove(' ').remove('\t'); line.remove(',').remove(' ').remove('\t');
i = line.indexOf("="); i = line.indexOf("=");
if (i >= 0) { if (i >= 0) {
num = line.right(line.length() - i - 1).trimmed(); num = line.right(line.length() - i - 1).trimmed();
line = line.left(i).trimmed(); line = line.left(i).trimmed();
} }
name = line; name = line;
if (num.isEmpty()) if (num.isEmpty())
++cind; ++cind;
else else
cind = Q2PIString(num).toInt(); cind = Q2PIString(num).toInt();
KDesc kd; KDesc kd;
kd.index = cind; kd.index = cind;
kd.name = name; kd.name = name;
kd.type = type; kd.type = type;
kd.comment = comment; kd.comment = comment;
map[kd.index] = kd; map[kd.index] = kd;
//qDebug() << name << cind << type << comment; //qDebug() << name << cind << type << comment;
} }
cind++; cind++;
return cind; return cind;
} }
void KX_Pult::updateKDesc(bool ask_move) { void KX_Pult::updateKDesc(bool ask_move) {
int cind = parseHeader(kdesc_file, kdesc); int cind = parseHeader(kdesc_file, kdesc);
if (K.size_s() < cind) { if (K.size_s() < cind) {
ui->spinSize->setValue(cind); ui->spinSize->setValue(cind);
ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);"); ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);");
} }
bool move = false; bool move = false;
if (ask_move) if (ask_move)
move = (QMessageBox::question(this, "KX Pult", "Save values at associated names?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes); move = (QMessageBox::question(this, "KX Pult", "Save values at associated names?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes);
updateTree(move); updateTree(move);
} }
void KX_Pult::updateCDesc() { void KX_Pult::updateCDesc() {
parseHeader(cdesc_file, cdesc); parseHeader(cdesc_file, cdesc);
updateCommands(); updateCommands();
} }
bool stringComp(const QString & s1, const QString & s2) { bool stringComp(const QString & s1, const QString & s2) {
if (s1.size() != s2.size()) if (s1.size() != s2.size())
return s1.size() > s2.size(); return s1.size() > s2.size();
return s1 > s2; return s1 > s2;
} }
void KX_Pult::updateTree(bool move) { void KX_Pult::updateTree(bool move) {
int sp = ui->treeK->verticalScrollBar()->value(); int sp = ui->treeK->verticalScrollBar()->value();
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
//qDebug() << "fill tree ..."; //qDebug() << "fill tree ...";
QMap<QString, QString> prev_val; QMap<QString, QString> prev_val;
if (move) { if (move) {
for (int i = 0; i < ui->treeK->topLevelItemCount(); ++i) { for (int i = 0; i < ui->treeK->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
if (!ti->text(1).isEmpty()) if (!ti->text(1).isEmpty())
prev_val[ti->text(1)] = ti->text(2); prev_val[ti->text(1)] = ti->text(2);
} }
} }
ui->treeK->clear(); ui->treeK->clear();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
eval.clearCustomVariables(); eval.clearCustomVariables();
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
QTreeWidgetItem * ti = new QTreeWidgetItem(); QTreeWidgetItem * ti = new QTreeWidgetItem();
KDesc kd = kdesc[i]; KDesc kd = kdesc[i];
QString kn = QString("k%1").arg(i); QString kn = QString("k%1").arg(i);
knames[kn] = i; knames[kn] = i;
knames_sort << kn; knames_sort << kn;
if (eval.content.findVariable(kn) < 0) if (eval.content.findVariable(kn) < 0)
eval.content.addVariable(kn, 0., false); eval.content.addVariable(kn, 0., false);
if (!kd.name.isEmpty()) { if (!kd.name.isEmpty()) {
knames[kd.name] = i; knames[kd.name] = i;
knames_sort << kd.name; knames_sort << kd.name;
eval.content.addVariable(kd.name, 0., false); eval.content.addVariable(kd.name, 0., false);
} }
if (move && !kd.name.isEmpty()) { if (move && !kd.name.isEmpty()) {
if (prev_val.contains(kd.name)) if (prev_val.contains(kd.name))
coeffs.setFormula(i, Q2PIString(prev_val[kd.name])); coeffs.setFormula(i, Q2PIString(prev_val[kd.name]));
} }
ti->setText(0, QString::number(i)); ti->setText(0, QString::number(i));
ti->setText(1, kd.name); ti->setText(1, kd.name);
ti->setText(2, PI2QString(coeffs.formula(i))); ti->setText(2, PI2QString(coeffs.formula(i)));
ti->setText(3, QString::number(K[i])); ti->setText(3, QString::number(K[i]));
ti->setText(4, typeName(kd.type)); ti->setText(4, typeName(kd.type));
ti->setText(5, kd.comment); ti->setText(5, kd.comment);
ui->treeK->addTopLevelItem(ti); ui->treeK->addTopLevelItem(ti);
} }
eval.content.sortVariables(); eval.content.sortVariables();
//qDebug() << "fill tree ok"; //qDebug() << "fill tree ok";
//qDebug() << "sort ..."; //qDebug() << "sort ...";
qSort(knames_sort.begin(), knames_sort.end(), stringComp); qSort(knames_sort.begin(), knames_sort.end(), stringComp);
//qDebug() << "names" << knames_sort; //qDebug() << "names" << knames_sort;
//qDebug() << "sort ok"; //qDebug() << "sort ok";
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
ui->treeK->verticalScrollBar()->setValue(sp); ui->treeK->verticalScrollBar()->setValue(sp);
calculate(); calculate();
filterTree(); filterTree();
} }
void KX_Pult::updateCommands() { void KX_Pult::updateCommands() {
while (ui->layoutCommands->count() > 0) while (ui->layoutCommands->count() > 0)
delete ui->layoutCommands->itemAt(0)->widget(); delete ui->layoutCommands->itemAt(0)->widget();
QMapIterator<int, KDesc> it(cdesc); QMapIterator<int, KDesc> it(cdesc);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
KDesc kd = it.value(); KDesc kd = it.value();
QPushButton * b = new QPushButton(); QPushButton * b = new QPushButton();
QString text = kd.name; QString text = kd.name;
if (!kd.comment.isEmpty()) if (!kd.comment.isEmpty())
text += QString("\n(%1)").arg(kd.comment); text += QString("\n(%1)").arg(kd.comment);
b->setText(text); b->setText(text);
b->setProperty("_command", kd.index); b->setProperty("_command", kd.index);
connect(b, SIGNAL(clicked()), this, SLOT(commandClicked())); connect(b, SIGNAL(clicked()), this, SLOT(commandClicked()));
ui->layoutCommands->addWidget(b); ui->layoutCommands->addWidget(b);
} }
} }
void KX_Pult::filterTree() { void KX_Pult::filterTree() {
bool he = ui->checkKHideEmpty->isChecked(); bool he = ui->checkKHideEmpty->isChecked();
bool hn = ui->checkKHideNormal->isChecked(); bool hn = ui->checkKHideNormal->isChecked();
bool hs = ui->checkKHideExpressions->isChecked(); bool hs = ui->checkKHideExpressions->isChecked();
bool ok = false; bool ok = false;
QString fl = ui->lineKSearch->text(); QString fl = ui->lineKSearch->text();
int lc = ui->treeK->topLevelItemCount(); int lc = ui->treeK->topLevelItemCount();
for (int i = 0; i < lc; ++i) { for (int i = 0; i < lc; ++i) {
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
if (ti->text(1).isEmpty() && he) if (ti->text(1).isEmpty() && he)
ti->setHidden(true); ti->setHidden(true);
else else
if (fl.isEmpty()) if (fl.isEmpty())
ti->setHidden(false); ti->setHidden(false);
else else
ti->setHidden(!ti->text(0).contains(fl, Qt::CaseInsensitive) && ti->setHidden(!ti->text(0).contains(fl, Qt::CaseInsensitive) &&
!ti->text(1).contains(fl, Qt::CaseInsensitive) && !ti->text(1).contains(fl, Qt::CaseInsensitive) &&
!ti->text(2).contains(fl, Qt::CaseInsensitive) && !ti->text(2).contains(fl, Qt::CaseInsensitive) &&
!ti->text(3).contains(fl, Qt::CaseInsensitive) && !ti->text(3).contains(fl, Qt::CaseInsensitive) &&
!ti->text(4).contains(fl, Qt::CaseInsensitive)); !ti->text(4).contains(fl, Qt::CaseInsensitive));
if (hn) if (hn)
if (ti->data(0, Qt::UserRole).toBool()) if (ti->data(0, Qt::UserRole).toBool())
ti->setHidden(true); ti->setHidden(true);
if (hs) { if (hs) {
ti->data(2, Qt::DisplayRole).toDouble(&ok); ti->data(2, Qt::DisplayRole).toDouble(&ok);
if (!ok) if (!ok)
ti->setHidden(true); ti->setHidden(true);
} }
} }
} }
void KX_Pult::calculate() { void KX_Pult::calculate() {
calculated.clear(); calculated.clear();
ui->treeK->setUpdatesEnabled(false); ui->treeK->setUpdatesEnabled(false);
ui->treeK->blockSignals(true); ui->treeK->blockSignals(true);
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
progress(0, 100); progress(0, 100);
ui->buttonCalculate->setEnabled(false); ui->buttonCalculate->setEnabled(false);
QApplication::processEvents(); QApplication::processEvents();
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
ui->treeK->topLevelItem(i)->setToolTip(2, QString()); ui->treeK->topLevelItem(i)->setToolTip(2, QString());
ui->treeK->topLevelItem(i)->setToolTip(3, QString()); ui->treeK->topLevelItem(i)->setToolTip(3, QString());
} }
for (int i = 0; i < K.size_s(); ++i) { for (int i = 0; i < K.size_s(); ++i) {
progress(i, K.size_s()); progress(i, K.size_s());
calculateExpression(i, QVector<int>()); calculateExpression(i, QVector<int>());
} }
ui->buttonCalculate->setEnabled(true); ui->buttonCalculate->setEnabled(true);
ui->progress->setValue(100); ui->progress->setValue(100);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->treeK->blockSignals(false); ui->treeK->blockSignals(false);
ui->treeK->setUpdatesEnabled(true); ui->treeK->setUpdatesEnabled(true);
} }
bool KX_Pult::calculateExpression(int i, QVector<int> trace) { bool KX_Pult::calculateExpression(int i, QVector<int> trace) {
if (calculated.contains(i)) return true; if (calculated.contains(i)) return true;
trace << i; trace << i;
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i); QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
QString expr = ti->text(2); QString expr = ti->text(2);
if (expr.isEmpty() || expr == "0" || expr == "0,00000000" || expr == "0.00000000") { if (expr.isEmpty() || expr == "0" || expr == "0,00000000" || expr == "0.00000000") {
markNormal(ti); markNormal(ti);
calculated << i; calculated << i;
K[i] = 0.; K[i] = 0.;
ti->setText(3, "0"); ti->setText(3, "0");
return true; return true;
} }
//ti->setToolTip(2, QString()); //ti->setToolTip(2, QString());
if (!eval.check(expr)) { if (!eval.check(expr)) {
markError(ti, eval.error()); markError(ti, eval.error());
return false; return false;
} }
foreach (const QString & n, knames_sort) { foreach (const QString & n, knames_sort) {
if (expr.contains(n)) { if (expr.contains(n)) {
int ki = knames.value(n, -1); int ki = knames.value(n, -1);
if (trace.contains(ki)) { if (trace.contains(ki)) {
QString strace; QString strace;
trace << ki; trace << ki;
for (int j = 0; j < trace.size(); ++j) { for (int j = 0; j < trace.size(); ++j) {
//calculated << trace[j]; //calculated << trace[j];
if (j > 0) strace += " -> "; if (j > 0) strace += " -> ";
strace += "k" + QString::number(trace[j]); strace += "k" + QString::number(trace[j]);
} }
for (int j = 0; j < trace.size(); ++j) { for (int j = 0; j < trace.size(); ++j) {
QTreeWidgetItem * pti = ui->treeK->topLevelItem(trace[j]); QTreeWidgetItem * pti = ui->treeK->topLevelItem(trace[j]);
markError(pti, QString("Circular dependency: %1!").arg(strace)); markError(pti, QString("Circular dependency: %1!").arg(strace));
} }
return false; return false;
} }
if (ki < 0) { if (ki < 0) {
markError(ti); markError(ti);
return false; return false;
} }
if (calculated.contains(ki)) { if (calculated.contains(ki)) {
eval.setVariable(n, K[ki]); eval.setVariable(n, K[ki]);
} else { } else {
if (calculateExpression(ki, trace)) if (calculateExpression(ki, trace))
eval.setVariable(n, K[ki]); eval.setVariable(n, K[ki]);
else { else {
markError(ti); markError(ti);
return false; return false;
} }
} }
} }
} }
markNormal(ti); markNormal(ti);
calculated << i; calculated << i;
complexd ret = eval.evaluate(); complexd ret = eval.evaluate();
K[i] = ret.real(); K[i] = ret.real();
ti->setText(3, QString::number(K[i])); ti->setText(3, QString::number(K[i]));
return true; return true;
} }
void KX_Pult::markError(QTreeWidgetItem * item, const QString & tool_tip) { void KX_Pult::markError(QTreeWidgetItem * item, const QString & tool_tip) {
int cc = item->columnCount(); int cc = item->columnCount();
for (int i = 0; i < cc; ++i) for (int i = 0; i < cc; ++i)
item->setBackgroundColor(i, QColor(255, 200, 200)); item->setBackgroundColor(i, QColor(255, 200, 200));
if (item->toolTip(2).isEmpty()) if (item->toolTip(2).isEmpty())
item->setToolTip(2, tool_tip); item->setToolTip(2, tool_tip);
if (item->toolTip(3).isEmpty()) if (item->toolTip(3).isEmpty())
item->setToolTip(3, tool_tip); item->setToolTip(3, tool_tip);
item->setData(0, Qt::UserRole, false); item->setData(0, Qt::UserRole, false);
item->setText(3, "Error"); item->setText(3, "Error");
} }
void KX_Pult::markNormal(QTreeWidgetItem * item) { void KX_Pult::markNormal(QTreeWidgetItem * item) {
int cc = item->columnCount(); int cc = item->columnCount();
for (int i = 0; i < cc; ++i) for (int i = 0; i < cc; ++i)
item->setBackground(i, Qt::NoBrush); item->setBackground(i, Qt::NoBrush);
item->setToolTip(2, QString()); item->setToolTip(2, QString());
item->setToolTip(3, QString()); item->setToolTip(3, QString());
item->setData(0, Qt::UserRole, true); item->setData(0, Qt::UserRole, true);
} }
void KX_Pult::progress(int val, int max) { void KX_Pult::progress(int val, int max) {
if (ctm.elapsed() < 50) return; if (ctm.elapsed() < 50) return;
ctm.restart(); ctm.restart();
ui->progress->setValue(qRound(val * 100. / max)); ui->progress->setValue(qRound(val * 100. / max));
QApplication::processEvents(); QApplication::processEvents();
} }
void KX_Pult::renew(bool write) { void KX_Pult::renew(bool write) {
addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta); addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta);
dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue()); dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue());
setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult")); setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult"));
//if (write) ui->configWidget->write(); //if (write) ui->configWidget->write();
if (prot_x != 0) { if (prot_x != 0) {
prot_x->stop(); prot_x->stop();
delete prot_x; delete prot_x;
} }
if (prot_c != 0) { if (prot_c != 0) {
prot_c->stop(); prot_c->stop();
delete prot_c; delete prot_c;
} }
prot_x = new __KX_Protocol_X(config_, name_x); prot_x = new __KX_Protocol_X(config_, name_x);
prot_c = new __KX_Protocol_C(config_, name_c); prot_c = new __KX_Protocol_C(config_, name_c);
ui->graphic->setAutoXIncrement(prot_x->expectedFrequency() > 0. ? 1. / prot_x->expectedFrequency() : 1.); ui->graphic->setAutoXIncrement(prot_x->expectedFrequency() > 0. ? 1. / prot_x->expectedFrequency() : 1.);
coeffs.renew(); coeffs.renew();
CONNECT1(void, bool, prot_x, received, this, received); CONNECT1(void, bool, prot_x, received, this, received);
} }
void KX_Pult::toggledX(int index, bool on) { void KX_Pult::toggledX(int index, bool on) {
ui->graphic->setGraphicVisible(on, index); ui->graphic->setGraphicVisible(on, index);
} }
void KX_Pult::changedX(int index, int num) { void KX_Pult::changedX(int index, int num) {
prot_x->to_x.x_num[index] = num; prot_x->to_x.x_num[index] = num;
} }
void KX_Pult::commandClicked() { void KX_Pult::commandClicked() {
QPushButton * b = qobject_cast<QPushButton*>(sender()); QPushButton * b = qobject_cast<QPushButton*>(sender());
if (!b) return; if (!b) return;
prot_c->sendCommand(b->property("_command").toInt()); prot_c->sendCommand(b->property("_command").toInt());
} }

View File

@@ -1,170 +1,170 @@
#ifndef KX_PULT_H #ifndef KX_PULT_H
#define KX_PULT_H #define KX_PULT_H
#include <QDialog> #include <QDialog>
#include <QSpinBox> #include <QSpinBox>
#include <QFont> #include <QFont>
#include <QRect> #include <QRect>
#include <QFile> #include <QFile>
#include <QVector> #include <QVector>
#include <QDir> #include <QDir>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QBoxLayout> #include <QBoxLayout>
#include <QCheckBox> #include <QCheckBox>
#include <QMainWindow> #include <QMainWindow>
#include <QTimer> #include <QTimer>
#include <QTime> #include <QTime>
#include <QMenu> #include <QMenu>
#include <QMetaObject> #include <QMetaObject>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QLabel> #include <QLabel>
#include "kx_coeffs.h" #include "kx_coeffs.h"
#include "kx_protocol_x.h" #include "kx_protocol_x.h"
#include "kx_protocol_c.h" #include "kx_protocol_c.h"
#include "piqt.h" #include "piqt.h"
#include "session_manager.h" #include "session_manager.h"
#include "qpievaluator.h" #include "qpievaluator.h"
class XCheck: public QWidget { class XCheck: public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit XCheck(int index); explicit XCheck(int index);
QCheckBox check; QCheckBox check;
QSpinBox spin; QSpinBox spin;
private: private:
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
int index_; int index_;
private slots: private slots:
void spinChanged(int value) {check.setChecked(true); emit valueChanged(index_, value);} void spinChanged(int value) {check.setChecked(true); emit valueChanged(index_, value);}
void checkChanged_(bool value) {emit checkChanged(index_, value);} void checkChanged_(bool value) {emit checkChanged(index_, value);}
signals: signals:
void valueChanged(int index, int value); void valueChanged(int index, int value);
void checkChanged(int index, bool on); void checkChanged(int index, bool on);
}; };
namespace Ui { namespace Ui {
class KX_Pult; class KX_Pult;
}; };
class KX_Pult: public QMainWindow, public PIObject class KX_Pult: public QMainWindow, public PIObject
{ {
Q_OBJECT Q_OBJECT
PIOBJECT(KX_Pult) PIOBJECT(KX_Pult)
public: public:
KX_Pult(); KX_Pult();
~KX_Pult(); ~KX_Pult();
private: private:
struct KDesc { struct KDesc {
KDesc() {index = -1;} KDesc() {index = -1;}
int index; int index;
QString name; QString name;
QString type; QString type;
QString comment; QString comment;
QString value; QString value;
}; };
bool eventFilter(QObject * o, QEvent * e); bool eventFilter(QObject * o, QEvent * e);
void timerEvent(QTimerEvent * ); void timerEvent(QTimerEvent * );
void setControlsEnable(bool enable); void setControlsEnable(bool enable);
void setX(const KX_X_Data & data); void setX(const KX_X_Data & data);
void addToList(const QString & s, const QColor & c); void addToList(const QString & s, const QColor & c);
QString getNewFileName(int inc); QString getNewFileName(int inc);
QColor invertColor(QColor col) {return QColor(255 - col.red(), 255 - col.green(), 255 - col.blue());} QColor invertColor(QColor col) {return QColor(255 - col.red(), 255 - col.green(), 255 - col.blue());}
void stopWait(); void stopWait();
bool calculateExpression(int i, QVector<int> trace); bool calculateExpression(int i, QVector<int> trace);
void markError(QTreeWidgetItem * item, const QString & tool_tip = QString()); void markError(QTreeWidgetItem * item, const QString & tool_tip = QString());
void markNormal(QTreeWidgetItem * item); void markNormal(QTreeWidgetItem * item);
void progress(int val, int max); void progress(int val, int max);
void clearSelected(); void clearSelected();
QString typeName(const QString & n) const; QString typeName(const QString & n) const;
int parseHeader(const QString & file, QMap<int, KDesc> & map); int parseHeader(const QString & file, QMap<int, KDesc> & map);
EVENT_HANDLER1(void, received, bool, ok); EVENT_HANDLER1(void, received, bool, ok);
EVENT_HANDLER(void, pip_sendFailed) {emit q_k_sendFailed();} EVENT_HANDLER(void, pip_sendFailed) {emit q_k_sendFailed();}
EVENT_HANDLER(void, pip_sendSucceed) {emit q_k_sendSucceed();} EVENT_HANDLER(void, pip_sendSucceed) {emit q_k_sendSucceed();}
EVENT_HANDLER(void, pip_receiveFailed) {emit q_k_receiveFailed();} EVENT_HANDLER(void, pip_receiveFailed) {emit q_k_receiveFailed();}
EVENT_HANDLER(void, pip_receiveSucceed) {emit q_k_receiveSucceed();} EVENT_HANDLER(void, pip_receiveSucceed) {emit q_k_receiveSucceed();}
QVector<XCheck * > checks; QVector<XCheck * > checks;
QVector<QLabel * > values; QVector<QLabel * > values;
Ui::KX_Pult * ui; Ui::KX_Pult * ui;
PIString config_, name_x, name_c; PIString config_, name_x, name_c;
QDir dir; QDir dir;
QString outdir, kdesc_file, cdesc_file; QString outdir, kdesc_file, cdesc_file;
QFile file; QFile file;
QTime tm, ctm; QTime tm, ctm;
QIcon icon_record, icon_stop; QIcon icon_record, icon_stop;
QTextStream stream; QTextStream stream;
QTimer timer_diag; QTimer timer_diag;
QMap<int, KDesc> kdesc, cdesc; QMap<int, KDesc> kdesc, cdesc;
QMap<QString, int> knames; QMap<QString, int> knames;
QSet<int> calculated; QSet<int> calculated;
QStringList knames_sort; QStringList knames_sort;
QPIEvaluator eval; QPIEvaluator eval;
SessionManager session; SessionManager session;
QPIConfig config; QPIConfig config;
QMenu log_menu; QMenu log_menu;
//QVector<float> k, x; //QVector<float> k, x;
KX_Coefficients coeffs; KX_Coefficients coeffs;
__KX_Protocol_X * prot_x; __KX_Protocol_X * prot_x;
__KX_Protocol_C * prot_c; __KX_Protocol_C * prot_c;
int csize, wcnt, timer, timer_update, clear_target; int csize, wcnt, timer, timer_update, clear_target;
bool needWrite, isPause, need_update, show_x; bool needWrite, isPause, need_update, show_x;
private slots: private slots:
void loading(QPIConfig & conf); void loading(QPIConfig & conf);
void saving(QPIConfig & conf); void saving(QPIConfig & conf);
void updateGraph(); void updateGraph();
void updateDiag(); void updateDiag();
void updateKDesc(bool ask_move = false); void updateKDesc(bool ask_move = false);
void updateCDesc(); void updateCDesc();
void updateTree(bool move = false); void updateTree(bool move = false);
void updateCommands(); void updateCommands();
void filterTree(); void filterTree();
void calculate(); void calculate();
void renew(bool write = true); void renew(bool write = true);
void toggledX(int index, bool on); void toggledX(int index, bool on);
void changedX(int index, int num); void changedX(int index, int num);
void commandClicked(); void commandClicked();
void k_sendFailed(); void k_sendFailed();
void k_sendSucceed(); void k_sendSucceed();
void k_receiveFailed(); void k_receiveFailed();
void k_receiveSucceed(); void k_receiveSucceed();
void on_spinBuffer_editingFinished(); void on_spinBuffer_editingFinished();
void on_buttonSendK_clicked(); void on_buttonSendK_clicked();
void on_buttonReceiveK_clicked(); void on_buttonReceiveK_clicked();
void on_buttonShowAll_clicked(); void on_buttonShowAll_clicked();
void on_buttonHideAll_clicked(); void on_buttonHideAll_clicked();
void on_buttonRead_clicked(); void on_buttonRead_clicked();
void on_buttonWrite_clicked(); void on_buttonWrite_clicked();
void on_buttonResize_clicked(); void on_buttonResize_clicked();
void on_buttonSetKDesc_clicked(); void on_buttonSetKDesc_clicked();
void on_buttonReparseKDesc_clicked() {updateKDesc(true);} void on_buttonReparseKDesc_clicked() {updateKDesc(true);}
void on_buttonSetCDesc_clicked(); void on_buttonSetCDesc_clicked();
void on_buttonReparseCDesc_clicked() {updateCDesc();} void on_buttonReparseCDesc_clicked() {updateCDesc();}
void on_buttonCalculate_clicked() {calculate();} void on_buttonCalculate_clicked() {calculate();}
void on_buttonApply_clicked() {renew();} void on_buttonApply_clicked() {renew();}
void on_spinSize_valueChanged(int); void on_spinSize_valueChanged(int);
void on_buttonPause_toggled(bool on) {isPause = on;} void on_buttonPause_toggled(bool on) {isPause = on;}
void on_buttonRecord_clicked(); void on_buttonRecord_clicked();
void on_treeK_itemClicked(QTreeWidgetItem * item, int column); void on_treeK_itemClicked(QTreeWidgetItem * item, int column);
void on_treeK_itemChanged(QTreeWidgetItem * item, int column); void on_treeK_itemChanged(QTreeWidgetItem * item, int column);
void on_actionClear_triggered(); void on_actionClear_triggered();
signals: signals:
void q_k_sendFailed(); void q_k_sendFailed();
void q_k_sendSucceed(); void q_k_sendSucceed();
void q_k_receiveFailed(); void q_k_receiveFailed();
void q_k_receiveSucceed(); void q_k_receiveSucceed();
void recordStarted(const QString & fileName); void recordStarted(const QString & fileName);
void recordStopped(const QString & fileName); void recordStopped(const QString & fileName);
}; };
#endif // KX_PULT_H #endif // KX_PULT_H

View File

@@ -1,10 +1,10 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include "kx_pult.h" #include "kx_pult.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QApplication a(argc, argv); QApplication a(argc, argv);
KX_Pult w; KX_Pult w;
w.show(); w.show();
return a.exec(); return a.exec();
} }

0
make_libs.sh Normal file → Executable file
View File

2
pip

Submodule pip updated: a4b3edb3e1...5df43a45f2

View File

@@ -1,21 +1,49 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(piqt)
if(NOT LIBPROJECT)
macro(piqt_library NAME _MODULES _LIBS) find_package(PIP REQUIRED)
_qt_project(${NAME} FALSE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN}) option(LIB "System install" 0)
_qt_install(${NAME} FALSE "pip" "out_HDR" "out_QM") option(DEBUG "Build with -g3" 0)
endmacro() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
if(DEBUG)
macro(piqt_application NAME _MODULES _LIBS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
_qt_project(${NAME} TRUE "PIQt" "${_MODULES}" "pip;${_LIBS}" ${ARGN}) endif()
_qt_install(${NAME} TRUE "pip" "" "out_QM") endif()
endmacro() find_package(QAD REQUIRED)
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
include_directories(${PIP_INCLUDES}) include_directories(${PIP_INCLUDES} ${QAD_INCLUDES})
add_subdirectory(libs) file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
if (UTILS) find_qt(${QtVersions} Core Gui Positioning)
add_subdirectory(utils) qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
endif() qt_add_library(${PROJECT_NAME} SHARED out_CPP)
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets)
copy_to_parent(piqt_includes) message(STATUS "Building ${PROJECT_NAME}")
if(LIBPROJECT)
sdk_install("pip" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
else()
if(LIB)
if(WIN32)
install(FILES ${out_HDR} DESTINATION ${MINGW_INCLUDE}/pip)
if(NOT "x${out_QM}" STREQUAL "x")
qt_install(FILES ${out_QM} DESTINATION QtLang)
endif()
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION QtBin)
else()
install(FILES ${out_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(WIN32)
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif()
install(FILES ${out_HDR} DESTINATION include/pip)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif()
endif()

View File

@@ -1 +0,0 @@
add_directories_with_include("piqt_")

View File

@@ -1 +0,0 @@
piqt_library(piqt "Gui;Positioning" "qad_utils;qad_widgets")

View File

@@ -1 +0,0 @@
piqt_library(qcd_utils "Gui" "pip;qad_utils;qad_widgets;qad_graphic;cd_utils;piqt")

View File

@@ -1,9 +0,0 @@
include(PIPMacros)
pip_code_model(CCM "${ROOT_DIR}/pip/libs/main/io_devices/piiodevice.h" "${ROOT_DIR}/pip/libs/main/io_utils/pipacketextractor.h" OPTIONS "-DPIP_EXPORT" "-Es")
piqt_library(piqt_utils "Gui" "qad_utils;qad_widgets;qad_blockview;piqt" ${CCM})
foreach(_v ${_QT_VERSIONS_})
if (LOCAL_FOUND${_v})
add_dependencies(piqt_utils${_v} pip_cmg)
endif()
endforeach()

View File

@@ -106,7 +106,7 @@ const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v) {
const QAD::File PI2QADFile(const PIVariantTypes::File & v) { const QAD::File PI2QADFile(const PIVariantTypes::File & v) {
return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs, v.is_save); return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs);
} }
@@ -116,7 +116,7 @@ const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v) {
const PIVariantTypes::File QAD2PIFile(const QAD::File & v) { const PIVariantTypes::File QAD2PIFile(const QAD::File & v) {
return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs, v.is_save); return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs);
} }

View File

@@ -29,14 +29,13 @@
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
# include "pigeoposition.h" # include "pigeoposition.h"
#endif #endif
#include "piqt_export.h"
class QGeoCoordinate; class QGeoCoordinate;
PIQT_EXPORT const QVariant PI2QVariant(const PIVariant & v); const QVariant PI2QVariant(const PIVariant & v);
PIQT_EXPORT const PIVariant Q2PIVariant(const QVariant & v); const PIVariant Q2PIVariant(const QVariant & v);
//inline const QString PI2QString(const PIString & v) {return QString::fromLocal8Bit(v.data());} //inline const QString PI2QString(const PIString & v) {return QString::fromLocal8Bit(v.data());}
inline const QString PI2QString(const PIString & v) {return QString::fromUtf8(v.dataUTF8());} inline const QString PI2QString(const PIString & v) {return QString::fromUtf8(v.dataUTF8());}
@@ -125,20 +124,20 @@ inline PropertyStorage PI2QPropertyStorage(const PIPropertyStorage & props) {
} }
PIQT_EXPORT const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el); const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el);
PIQT_EXPORT const QAD::File PI2QADFile(const PIVariantTypes::File & v); const QAD::File PI2QADFile(const PIVariantTypes::File & v);
PIQT_EXPORT const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v); const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v);
PIQT_EXPORT const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v); const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v);
PIQT_EXPORT const PIVariantTypes::Enum QAD2PIEnum(const QAD::Enum & el); const PIVariantTypes::Enum QAD2PIEnum(const QAD::Enum & el);
PIQT_EXPORT const PIVariantTypes::File QAD2PIFile(const QAD::File & v); const PIVariantTypes::File QAD2PIFile(const QAD::File & v);
PIQT_EXPORT const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v); const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v);
PIQT_EXPORT const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevice & v); const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevice & v);
//inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));} //inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));}
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
PIQT_EXPORT const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v); const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v);
PIQT_EXPORT const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v); const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v);
#endif #endif
template <typename From> template <typename From>

View File

@@ -1 +0,0 @@
add_directories("piqt_")

View File

@@ -1,14 +0,0 @@
project(cd_pult)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "")
else()
set(APP_ICON "")
endif()
set(APP_INFO "CD Pult")
piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;qad_application;qcd_utils;piqt_utils")
if (Qt5_FOUND)
import_version(${PROJ_NAME}5 ${PROJECT_NAME})
deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release)
endif()

View File

@@ -1,16 +0,0 @@
<RCC>
<qresource prefix="/">
<file>../../../qad/icons/dialog-information.png</file>
<file>../../../qad/icons/dialog-cancel.png</file>
<file>../../../qad/icons/dialog-ok-apply.png</file>
<file>../../../qad/icons/document-revert.png</file>
<file>../../../qad/icons/view-refresh.png</file>
<file>../../../qad/icons/format-stroke-color.png</file>
<file>icons/db-export.png</file>
<file>icons/db-import.png</file>
<file>icons/timer.png</file>
<file>icons/flame.png</file>
<file>icons/Apps-accessories-calculator-icon.png</file>
<file>icons/accessories-text-editor.png</file>
</qresource>
</RCC>

View File

@@ -1,10 +0,0 @@
project(piconnedit)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "")
else()
set(APP_ICON "")
endif()
set(APP_INFO "PIConnection GUI editor")
piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_blockview;piqt_utils")

View File

@@ -1,10 +0,0 @@
project(pidumper)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "")
else()
set(APP_ICON "")
endif()
set(APP_INFO "PIConnection GUI editor")
piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;piqt_utils")

View File

@@ -1,13 +0,0 @@
project(piintrospector)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "")
else()
set(APP_ICON "")
endif()
set(APP_INFO "PIConnection GUI editor")
include(PIPMacros)
set(PII_ROOT "${ROOT_DIR}/pip/libs/main/introspection")
pip_code_model(CCM "${PII_ROOT}/piintrospection_server_p.h" "${PII_ROOT}/piintrospection_threads_p.h" OPTIONS "-DPIP_EXPORT" "-Es")
piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_application;piqt_utils" ${CCM})

View File

@@ -1,14 +0,0 @@
project(qpicalc)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "icons/qpicalculator.ico")
else()
set(APP_ICON "icons/qpicalculator.png")
endif()
set(APP_INFO "Small calculator ang grapher")
qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;pip;piqt")
if (Qt5_FOUND)
import_version(${PROJ_NAME}5 ${PROJECT_NAME})
deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release)
endif()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>icons/qpicalculator.png</file>
</qresource>
</RCC>

73
piqt_utils/CMakeLists.txt Normal file
View File

@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 3.0)
project(piqt_utils)
set(PIQT_UTILS_UTILS 1)
if(LIBPROJECT)
include(PIPMacros)
include(SDKMacros)
set(PIQT_UTILS_UTILS ${UTILS})
else()
find_package(PIP REQUIRED)
option(LIB "System install" 0)
option(DEBUG "Build with -g3" 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
if(DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
endif()
endif()
set(LIBTYPE SHARED)
if(DEFINED ENV{QNX_HOST})
set(LIBTYPE STATIC)
endif()
find_package(QAD REQUIRED)
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE)
include_directories(${PIP_INCLUDES} ${QAD_INCLUDES})
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
pip_code_model(CCM "../pip/lib/main/io_devices/piiodevice.h" "../pip/lib/main/io_utils/pipacketextractor.h" OPTIONS "-DPIP_EXPORT" "-Es")
find_qt(${QtVersions} Core Gui)
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
qt_add_library(${PROJECT_NAME} ${LIBTYPE} out_CPP CCM)
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets qad_blockview piqt)
message(STATUS "Building ${PROJECT_NAME}")
if (LIBPROJECT)
foreach(_v ${_QT_VERSIONS_})
if (LOCAL_FOUND${_v})
add_dependencies(piqt_utils${_v} pip_cmg)
endif()
endforeach()
endif()
if (NOT DEFINED ENV{QNX_HOST})
if (PIQT_UTILS_UTILS)
add_subdirectory(piconnedit)
add_subdirectory(pidumper)
add_subdirectory(piintrospector)
endif()
endif()
if(LIBPROJECT)
sdk_install("pip" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
else()
if(LIB)
if(WIN32)
install(FILES ${out_HDR} DESTINATION ${MINGW_INCLUDE}/pip)
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${MINGW_LIB})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${MINGW_BIN})
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION QtBin)
else()
install(FILES ${out_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(WIN32)
qt_install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
qt_install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib)
else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif()
install(FILES ${out_HDR} DESTINATION include/pip)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif()
endif()

165
piqt_utils/LICENSE.txt Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -0,0 +1,23 @@
project(piconnedit)
file(GLOB SRC "*.h" "*.cpp" "*.ui" "*.qrc" "lang/*.ts")
find_qt(${QtVersions} Core Gui)
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP)
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets piqt_utils)
qt_target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../")
message(STATUS "Building ${PROJECT_NAME}")
if(LIB)
if(WIN32)
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
else()
if (DEFINED ANDROID_PLATFORM)
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${ANDROID_SYSTEM_LIBRARY_PATH}/usr/bin)
else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION /usr/local/bin)
endif()
endif()
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION bin)
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
endif()

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Some files were not shown because too many files have changed in this diff Show More