diff --git a/.gitignore b/.gitignore index 94dab4e2..b7b2e79c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,18 @@ +*.swp /*.user /build* .DS_Store CMakeFiles/ __/ + +# Ignoring autogenerated files +*.cmake +Makefile +qrc_*.cpp +*.qrc.depends +moc_*.cpp +moc_*.cpp_parameters +CMakeCache.txt +*.log +/HyperionConfig.h +/lib diff --git a/.travis/travis_build.sh b/.travis/travis_build.sh index e5f514eb..0c84cf20 100755 --- a/.travis/travis_build.sh +++ b/.travis/travis_build.sh @@ -1,32 +1,32 @@ #!/bin/bash # for executing in non travis environment -[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$( uname -s | tr '[:upper:]' '[:lower:]' )" +[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$(uname -s | tr 'A-Z' 'a-z')" -###################################### -## COMPILE HYPERION +# Detect number of processor cores -# compile hyperion on osx -if [[ $TRAVIS_OS_NAME == 'osx' ]] -then +if [[ $TRAVIS_OS_NAME == 'osx' || $TRAVIS_OS_NAME == 'darwin' ]]; then procs=$(sysctl -n hw.ncpu | xargs) - echo "Processes: $procs" - - mkdir build || exit 1 - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -Wno-dev .. || exit 2 - make -j$procs || exit 3 - # make -j$(nproc) package || exit 4 # currently osx(dmg) package creation not implemented +elif [[ $TRAVIS_OS_NAME == 'linux' ]]; then + procs=$(nproc) +else + # For most modern systems, including the pi, this is a sane default + procs=4 fi -# compile hyperion on linux -if [[ $TRAVIS_OS_NAME == 'linux' ]] -then - mkdir build || exit 1 - cd build - cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Release .. || exit 2 - make -j$(nproc) || exit 3 - make -j$(nproc) package || exit 4 + +# Compile hyperion + +mkdir build || exit 1 +cd build +cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Debug .. || exit 2 +make -j$(nproc) || exit 3 + + +# Build the package on Linux + +if [[ $TRAVIS_OS_NAME == 'linux' ]]; then + make -j$(nproc) package || exit 4 fi diff --git a/.travis/travis_install.sh b/.travis/travis_install.sh index ae7735b4..af198a6e 100755 --- a/.travis/travis_install.sh +++ b/.travis/travis_install.sh @@ -1,18 +1,26 @@ #!/bin/bash + +# for executing in non travis environment +[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$( uname -s | tr '[:upper:]' '[:lower:]' )" + # install osx deps for hyperion compile -if [[ $TRAVIS_OS_NAME == 'osx' ]]; then +if [[ $TRAVIS_OS_NAME == 'osx' || $TRAVIS_OS_NAME == 'darwin' ]] +then echo "Install OSX deps" time brew update time brew install qt5 || true time brew install libusb || true time brew install cmake || true time brew install doxygen || true -fi # install linux deps for hyperion compile -if [[ $TRAVIS_OS_NAME == 'linux' ]]; then +elif [[ $TRAVIS_OS_NAME == 'linux' ]] +then echo "Install linux deps" sudo apt-get -qq update sudo apt-get install -qq -y qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev doxygen +else + echo "Unsupported platform: $TRAVIS_OS_NAME" + exit 5 fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 956c91a0..46e35bf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,55 +30,58 @@ SET ( DEFAULT_USE_SHARED_AVAHI_LIBS OFF ) SET ( DEFAULT_USE_AVAHI_LIBS ON ) SET ( DEFAULT_TESTS OFF ) +if ( NOT DEFINED PLATFORM ) + if ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" ) + SET( PLATFORM "x86") + elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" ) + SET( PLATFORM "rpi") + EXEC_PROGRAM( "nproc" OUTPUT_VARIABLE SYSTEM_CPU_CORES ) + FILE( READ /proc/cpuinfo SYSTEM_CPUINFO ) + STRING ( TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO ) + if ( "${SYSTEM_CPUINFO}" MATCHES "amlogic" ) + SET( PLATFORM "wetek" ) + elseif( SYSTEM_CPU_CORES GREATER 1 AND "${SYSTEM_CPUINFO}" MATCHES "bcm" ) + SET( PLATFORM "rpi-pwm" ) + endif() + endif() + if ( PLATFORM ) + message( STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}") + else() + message( FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=") + endif() +endif() + +if ( "${PLATFORM}" STREQUAL "rpi" ) + SET ( DEFAULT_DISPMANX ON ) +elseif ( "${PLATFORM}" STREQUAL "rpi-pwm" ) + SET ( DEFAULT_DISPMANX ON ) + SET ( DEFAULT_WS2812BPWM ON ) + SET ( DEFAULT_WS281XPWM ON ) +elseif ( "${PLATFORM}" STREQUAL "wetek" ) + SET ( DEFAULT_AMLOGIC ON ) +elseif ( "${PLATFORM}" STREQUAL "x86" ) + SET ( DEFAULT_X11 ON ) + SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) +elseif ( "${PLATFORM}" STREQUAL "x86-dev" ) + SET ( DEFAULT_X11 ON ) + SET ( DEFAULT_AMLOGIC ON) + SET ( DEFAULT_WS281XPWM ON ) + SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) + SET ( DEFAULT_TESTS ON ) +elseif ( "${PLATFORM}" STREQUAL "imx6" ) + SET ( DEFAULT_FB ON ) +endif() + if (APPLE) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt5") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt5") + include_directories("/opt/X11/include/") SET ( DEFAULT_OSX ON ) - SET ( DEFAULT_V4L2 OFF ) + SET ( DEFAULT_V4L2 OFF ) SET ( DEFAULT_SPIDEV OFF ) SET ( DEFAULT_FB OFF ) - SET ( DEFAULT_USE_AVAHI_LIBS OFF ) -else () - if ( NOT DEFINED PLATFORM ) - if ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" ) - SET( PLATFORM "x86") - elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" ) - SET( PLATFORM "rpi") - EXEC_PROGRAM( "nproc" OUTPUT_VARIABLE SYSTEM_CPU_CORES ) - FILE( READ /proc/cpuinfo SYSTEM_CPUINFO ) - STRING ( TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO ) - if ( "${SYSTEM_CPUINFO}" MATCHES "amlogic" ) - SET( PLATFORM "wetek" ) - elseif( SYSTEM_CPU_CORES GREATER 1 AND "${SYSTEM_CPUINFO}" MATCHES "bcm" ) - SET( PLATFORM "rpi-pwm" ) - endif() - endif() - if ( PLATFORM ) - message( STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}") - else() - message( FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=") - endif() - endif() - - if ( "${PLATFORM}" STREQUAL "rpi" ) - SET ( DEFAULT_DISPMANX ON ) - elseif ( "${PLATFORM}" STREQUAL "rpi-pwm" ) - SET ( DEFAULT_DISPMANX ON ) - SET ( DEFAULT_WS2812BPWM ON ) - SET ( DEFAULT_WS281XPWM ON ) - elseif ( "${PLATFORM}" STREQUAL "wetek" ) - SET ( DEFAULT_AMLOGIC ON ) - elseif ( "${PLATFORM}" STREQUAL "x86" ) - SET ( DEFAULT_X11 ON ) - SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) - elseif ( "${PLATFORM}" STREQUAL "x86-dev" ) - SET ( DEFAULT_X11 ON ) - SET ( DEFAULT_AMLOGIC ON) - SET ( DEFAULT_WS281XPWM ON ) - SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) - SET ( DEFAULT_TESTS ON ) - elseif ( "${PLATFORM}" STREQUAL "imx6" ) - SET ( DEFAULT_FB ON ) - endif() + SET ( DEFAULT_WS281XPWM OFF ) + SET ( DEFAULT_USE_AVAHI_LIBS OFF ) + SET ( DEFAULT_USE_SHARED_AVAHI_LIBS OFF ) endif () # set the build options @@ -124,10 +127,6 @@ message(STATUS "ENABLE_PROFILER = " ${ENABLE_PROFILER}) SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto ) SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto ) -#if(ENABLE_QT5) -# TODO vs ENABLE_QT4? -#endif(ENABLE_QT5) - # Createt the configuration file # Add project specific cmake modules (find, etc) @@ -156,8 +155,18 @@ include_directories(${CMAKE_SOURCE_DIR}/include) #set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") # enable C++11 -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11 -Wall") +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +else() + message(STATUS "No support for C++11 detected. Compilation will most likely fail on your compiler") +endif() SET(QT_MIN_VERSION "5.2.0") find_package(Qt5 COMPONENTS Core Gui Network REQUIRED) diff --git a/CODING_STYLE.md b/CODING_STYLE.md index a22773c6..1a5d5f07 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -41,7 +41,7 @@ MyClass::MyClass() : myVarA(0), good: MyClass::MyClass() - : myVarA(0), + : myVarA(0) , myVarB("eee") , myVarC(true) { diff --git a/dependencies/LightberryHDUSBAPA1021.1/LightberryHDUSBAPA1021.1.ino b/assets/firmware/arduino/adalightapa102/LightberryHDUSBAPA1021.1.ino similarity index 100% rename from dependencies/LightberryHDUSBAPA1021.1/LightberryHDUSBAPA1021.1.ino rename to assets/firmware/arduino/adalightapa102/LightberryHDUSBAPA1021.1.ino diff --git a/assets/webconfig/css/bootstrap-colorpicker.css b/assets/webconfig/css/bootstrap-colorpicker.css deleted file mode 100644 index 74ed8970..00000000 --- a/assets/webconfig/css/bootstrap-colorpicker.css +++ /dev/null @@ -1,222 +0,0 @@ -/*! - * Bootstrap Colorpicker v2.3.3 - * http://mjolnic.github.io/bootstrap-colorpicker/ - * - * Originally written by (c) 2012 Stefan Petre - * Licensed under the Apache License v2.0 - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - */ -.colorpicker-saturation { - width: 100px; - height: 100px; - background-image: url("../img/bootstrap-colorpicker/saturation.png"); - cursor: crosshair; - float: left; -} -.colorpicker-saturation i { - display: block; - height: 5px; - width: 5px; - border: 1px solid #000; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; - position: absolute; - top: 0; - left: 0; - margin: -4px 0 0 -4px; -} -.colorpicker-saturation i b { - display: block; - height: 5px; - width: 5px; - border: 1px solid #fff; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} -.colorpicker-hue, -.colorpicker-alpha { - width: 15px; - height: 100px; - float: left; - cursor: row-resize; - margin-left: 4px; - margin-bottom: 4px; -} -.colorpicker-hue i, -.colorpicker-alpha i { - display: block; - height: 1px; - background: #000; - border-top: 1px solid #fff; - position: absolute; - top: 0; - left: 0; - width: 100%; - margin-top: -1px; -} -.colorpicker-hue { - background-image: url("../img/bootstrap-colorpicker/hue.png"); -} -.colorpicker-alpha { - background-image: url("../img/bootstrap-colorpicker/alpha.png"); - display: none; -} -.colorpicker-saturation, -.colorpicker-hue, -.colorpicker-alpha { - background-size: contain; -} -.colorpicker { - padding: 4px; - min-width: 130px; - margin-top: 1px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - z-index: 2500; -} -.colorpicker:before, -.colorpicker:after { - display: table; - content: ""; - line-height: 0; -} -.colorpicker:after { - clear: both; -} -.colorpicker:before { - content: ''; - display: inline-block; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 7px solid #ccc; - border-bottom-color: rgba(0, 0, 0, 0.2); - position: absolute; - top: -7px; - left: 6px; -} -.colorpicker:after { - content: ''; - display: inline-block; - border-left: 6px solid transparent; - border-right: 6px solid transparent; - border-bottom: 6px solid #ffffff; - position: absolute; - top: -6px; - left: 7px; -} -.colorpicker div { - position: relative; -} -.colorpicker.colorpicker-with-alpha { - min-width: 140px; -} -.colorpicker.colorpicker-with-alpha .colorpicker-alpha { - display: block; -} -.colorpicker-color { - height: 10px; - margin-top: 5px; - clear: both; - background-image: url("../img/bootstrap-colorpicker/alpha.png"); - background-position: 0 100%; -} -.colorpicker-color div { - height: 10px; -} -.colorpicker-selectors { - display: none; - height: 10px; - margin-top: 5px; - clear: both; -} -.colorpicker-selectors i { - cursor: pointer; - float: left; - height: 10px; - width: 10px; -} -.colorpicker-selectors i + i { - margin-left: 3px; -} -.colorpicker-element .input-group-addon i, -.colorpicker-element .add-on i { - display: inline-block; - cursor: pointer; - height: 16px; - vertical-align: text-top; - width: 16px; -} -.colorpicker.colorpicker-inline { - position: relative; - display: inline-block; - float: none; - z-index: auto; -} -.colorpicker.colorpicker-horizontal { - width: 110px; - min-width: 110px; - height: auto; -} -.colorpicker.colorpicker-horizontal .colorpicker-saturation { - margin-bottom: 4px; -} -.colorpicker.colorpicker-horizontal .colorpicker-color { - width: 100px; -} -.colorpicker.colorpicker-horizontal .colorpicker-hue, -.colorpicker.colorpicker-horizontal .colorpicker-alpha { - width: 100px; - height: 15px; - float: left; - cursor: col-resize; - margin-left: 0px; - margin-bottom: 4px; -} -.colorpicker.colorpicker-horizontal .colorpicker-hue i, -.colorpicker.colorpicker-horizontal .colorpicker-alpha i { - display: block; - height: 15px; - background: #ffffff; - position: absolute; - top: 0; - left: 0; - width: 1px; - border: none; - margin-top: 0px; -} -.colorpicker.colorpicker-horizontal .colorpicker-hue { - background-image: url("../img/bootstrap-colorpicker/hue-horizontal.png"); -} -.colorpicker.colorpicker-horizontal .colorpicker-alpha { - background-image: url("../img/bootstrap-colorpicker/alpha-horizontal.png"); -} -.colorpicker.colorpicker-hidden { - display: none; -} -.colorpicker.colorpicker-visible { - display: block; -} -.colorpicker-inline.colorpicker-visible { - display: inline-block; -} -.colorpicker-right:before { - left: auto; - right: 6px; -} -.colorpicker-right:after { - left: auto; - right: 7px; -} -.colorpicker-no-arrow:before { - border-right: 0; - border-left: 0; -} -.colorpicker-no-arrow:after { - border-right: 0; - border-left: 0; -} -/*# sourceMappingURL=bootstrap-colorpicker.css.map */ \ No newline at end of file diff --git a/assets/webconfig/css/bootstrap-colorpicker.min.css b/assets/webconfig/css/bootstrap-colorpicker.min.css new file mode 100644 index 00000000..22e5c37a --- /dev/null +++ b/assets/webconfig/css/bootstrap-colorpicker.min.css @@ -0,0 +1,10 @@ +/*! + * Bootstrap Colorpicker v2.3.3 + * http://mjolnic.github.io/bootstrap-colorpicker/ + * + * Originally written by (c) 2012 Stefan Petre + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + */.colorpicker-saturation{width:100px;height:100px;background-image:url(../img/bootstrap-colorpicker/saturation.png);cursor:crosshair;float:left}.colorpicker-saturation i{display:block;height:5px;width:5px;border:1px solid #000;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;position:absolute;top:0;left:0;margin:-4px 0 0 -4px}.colorpicker-saturation i b{display:block;height:5px;width:5px;border:1px solid #fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.colorpicker-alpha,.colorpicker-hue{width:15px;height:100px;float:left;cursor:row-resize;margin-left:4px;margin-bottom:4px}.colorpicker-alpha i,.colorpicker-hue i{display:block;height:1px;background:#000;border-top:1px solid #fff;position:absolute;top:0;left:0;width:100%;margin-top:-1px}.colorpicker-hue{background-image:url(../img/bootstrap-colorpicker/hue.png)}.colorpicker-alpha{background-image:url(../img/bootstrap-colorpicker/alpha.png);display:none}.colorpicker-alpha,.colorpicker-hue,.colorpicker-saturation{background-size:contain}.colorpicker{padding:4px;min-width:130px;margin-top:1px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;z-index:2500}.colorpicker:after,.colorpicker:before{display:table;content:"";line-height:0}.colorpicker:after{clear:both}.colorpicker:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0,0,0,.2);position:absolute;top:-7px;left:6px}.colorpicker:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;top:-6px;left:7px}.colorpicker div{position:relative}.colorpicker.colorpicker-with-alpha{min-width:140px}.colorpicker.colorpicker-with-alpha .colorpicker-alpha{display:block}.colorpicker-color{height:10px;margin-top:5px;clear:both;background-image:url(../img/bootstrap-colorpicker/alpha.png);background-position:0 100%}.colorpicker-color div{height:10px}.colorpicker-selectors{display:none;height:10px;margin-top:5px;clear:both}.colorpicker-selectors i{cursor:pointer;float:left;height:10px;width:10px}.colorpicker-selectors i+i{margin-left:3px}.colorpicker-element .add-on i,.colorpicker-element .input-group-addon i{display:inline-block;cursor:pointer;height:16px;vertical-align:text-top;width:16px}.colorpicker.colorpicker-inline{position:relative;display:inline-block;float:none;z-index:auto}.colorpicker.colorpicker-horizontal{width:110px;min-width:110px;height:auto}.colorpicker.colorpicker-horizontal .colorpicker-saturation{margin-bottom:4px}.colorpicker.colorpicker-horizontal .colorpicker-color{width:100px}.colorpicker.colorpicker-horizontal .colorpicker-alpha,.colorpicker.colorpicker-horizontal .colorpicker-hue{width:100px;height:15px;float:left;cursor:col-resize;margin-left:0;margin-bottom:4px}.colorpicker.colorpicker-horizontal .colorpicker-alpha i,.colorpicker.colorpicker-horizontal .colorpicker-hue i{display:block;height:15px;background:#fff;position:absolute;top:0;left:0;width:1px;border:none;margin-top:0}.colorpicker.colorpicker-horizontal .colorpicker-hue{background-image:url(../img/bootstrap-colorpicker/hue-horizontal.png)}.colorpicker.colorpicker-horizontal .colorpicker-alpha{background-image:url(../img/bootstrap-colorpicker/alpha-horizontal.png)}.colorpicker.colorpicker-hidden{display:none}.colorpicker.colorpicker-visible{display:block}.colorpicker-inline.colorpicker-visible{display:inline-block}.colorpicker-right:before{left:auto;right:6px}.colorpicker-right:after{left:auto;right:7px}.colorpicker-no-arrow:before{border-right:0;border-left:0}.colorpicker-no-arrow:after{border-right:0;border-left:0} +/*# sourceMappingURL=bootstrap-colorpicker.min.css.map */ \ No newline at end of file diff --git a/assets/webconfig/css/bootstrap-colorpicker.min.css.map b/assets/webconfig/css/bootstrap-colorpicker.min.css.map new file mode 100644 index 00000000..f61ccb3e --- /dev/null +++ b/assets/webconfig/css/bootstrap-colorpicker.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["src/less/colorpicker.less"],"names":[],"mappings":";;;;;;;;AAqBA,wBACE,MAAA,MACA,OAAA,MAXA,iBAAsB,iDAatB,OAAA,UACA,MAAA,KACA,0BACE,QAAA,MACA,OAAA,IACA,MAAA,IACA,OAAA,IAAA,MAAA,KAfF,sBAAA,IACA,mBAAA,IACA,cAAA,IAeE,SAAA,SACA,IAAA,EACA,KAAA,EACA,OAAA,KAAA,EAAA,EAAA,KACA,4BACE,QAAA,MACA,OAAA,IACA,MAAA,IACA,OAAA,IAAA,MAAA,KAzBJ,sBAAA,IACA,mBAAA,IACA,cAAA,IA8BF,mBADA,iBAEE,MAAA,KACA,OAAA,MACA,MAAA,KACA,OAAA,WACA,YAAA,IACA,cAAA,IAIiB,qBADF,mBAEf,QAAA,MACA,OAAA,IACA,WAAA,KACA,WAAA,IAAA,MAAA,KACA,SAAA,SACA,IAAA,EACA,KAAA,EACA,MAAA,KACA,WAAA,KAGF,iBA1DE,iBAAsB,0CA8DxB,mBA9DE,iBAAsB,4CAgEtB,QAAA,KAKF,mBADA,iBADA,wBAGE,gBAAA,QAGF,aACE,QAAA,IACA,UAAA,MACA,WAAA,IAxEA,sBAAA,IACA,mBAAA,IACA,cAAA,IAwEA,QAAA,KAIU,mBADA,oBAEV,QAAA,MACA,QAAA,GACA,YAAA,EAGU,mBACV,MAAA,KAGU,oBACV,QAAA,GACA,QAAA,aACA,YAAA,IAAA,MAAA,YACA,aAAA,IAAA,MAAA,YACA,cAAA,IAAA,MAAA,KACA,oBAAA,eACA,SAAA,SACA,IAAA,KACA,KAAA,IAGU,mBACV,QAAA,GACA,QAAA,aACA,YAAA,IAAA,MAAA,YACA,aAAA,IAAA,MAAA,YACA,cAAA,IAAA,MAAA,KACA,SAAA,SACA,IAAA,KACA,KAAA,IAGW,iBACX,SAAA,SAGU,oCACV,UAAA,MAGkC,uDAClC,QAAA,MAGF,mBACE,OAAA,KACA,WAAA,IACA,MAAA,KAlIA,iBAAsB,4CAoItB,oBAAA,EAAA,KAGiB,uBACjB,OAAA,KAGF,uBACE,QAAA,KACA,OAAA,KACA,WAAA,IACA,MAAA,KAGqB,yBACrB,OAAA,QACA,MAAA,KACA,OAAA,KACA,MAAA,KAGuB,2BACvB,YAAA,IAI2B,+BADW,0CAEtC,QAAA,aACA,OAAA,QACA,OAAA,KACA,eAAA,SACA,MAAA,KAGU,gCACV,SAAA,SACA,QAAA,aACA,MAAA,KACA,QAAA,KAGU,oCACV,MAAA,MACA,UAAA,MACA,OAAA,KAGkC,4DAClC,cAAA,IAGkC,uDAClC,MAAA,MAIkC,uDADA,qDAElC,MAAA,MACA,OAAA,KACA,MAAA,KACA,OAAA,WACA,YAAA,EACA,cAAA,IAIqD,yDADF,uDAEnD,QAAA,MACA,OAAA,KACA,WAAA,KACA,SAAA,SACA,IAAA,EACA,KAAA,EACA,MAAA,IACA,OAAA,KACA,WAAA,EAGkC,qDAlNlC,iBAAsB,qDAsNY,uDAtNlC,iBAAsB,uDA0NZ,gCACV,QAAA,KAGU,iCACV,QAAA,MAGiB,wCACjB,QAAA,aAGgB,0BAChB,KAAA,KACA,MAAA,IAGgB,yBAChB,KAAA,KACA,MAAA,IAGmB,6BACnB,aAAA,EACA,YAAA,EAGmB,4BACnB,aAAA,EACA,YAAA"} \ No newline at end of file diff --git a/assets/webconfig/css/hyperion.css b/assets/webconfig/css/hyperion.css index 5b8aeeae..064f8b54 100644 --- a/assets/webconfig/css/hyperion.css +++ b/assets/webconfig/css/hyperion.css @@ -5,8 +5,12 @@ url("../fonts/Roboto-Regular.ttf") format('ttf'); } body{font-family:Roboto,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px;} +/*remove padding on all col elements for mobile view*/ +@media (max-width: 767px){div[class*="col-"] {padding:0;}} /*icon spacing*/ .fa-fw{margin-right:5px;} +/*borderless table*/ +table.borderless td,table.borderless th{border: none !important;} /*Header*/ .navbar-brand{padding: 5px;height:90px;} diff --git a/assets/webconfig/index.html b/assets/webconfig/index.html index 17db80a2..6274caa6 100644 --- a/assets/webconfig/index.html +++ b/assets/webconfig/index.html @@ -12,20 +12,25 @@ Hyperion - WebUI - + + + + + + - + - - + + - - + + + - + - + - -
diff --git a/assets/webconfig/remote_components.html b/assets/webconfig/remote_components.html new file mode 100644 index 00000000..f362e550 --- /dev/null +++ b/assets/webconfig/remote_components.html @@ -0,0 +1,42 @@ +
+
+
+

Effects

+
+

The components remote enables you to disable and enable certain components of Hyperion during runtime. Keep in mind this persist just until the next reboot! To enable/disable components permament, use the configuration section.

+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/assets/webconfig/update.html b/assets/webconfig/update.html index b0bcb43d..78b7d6d3 100644 --- a/assets/webconfig/update.html +++ b/assets/webconfig/update.html @@ -18,7 +18,7 @@ $.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/ve var vlist = JSON.parse(data); for (key in vlist) { - $('#versionlist').append('
Hyperion V'+key+'

Type: '+ vlist[key].channel +'

Description: '+vlist[key].versiondesc+'


Full changelog
'); + $('#versionlist').append('
Hyperion V'+vlist[key].versionnr+'

Type: '+ vlist[key].channel +'

Description: '+vlist[key].versiondesc+'


Full changelog
'); } }); diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 00000000..7a132693 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +protoc diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 00000000..6830205c --- /dev/null +++ b/config/.gitignore @@ -0,0 +1 @@ +/*.json diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 07dc7af4..dce78257 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(build/getoptPlusPlus) add_subdirectory(build/hidapi) add_subdirectory(build/jsoncpp) add_subdirectory(build/tinkerforge) diff --git a/dependencies/LightberryHDUSBAPA1021.1.zip b/dependencies/LightberryHDUSBAPA1021.1.zip deleted file mode 100644 index af1527ae..00000000 Binary files a/dependencies/LightberryHDUSBAPA1021.1.zip and /dev/null differ diff --git a/dependencies/build/getoptPlusPlus/CMakeLists.txt b/dependencies/build/getoptPlusPlus/CMakeLists.txt deleted file mode 100644 index e19880da..00000000 --- a/dependencies/build/getoptPlusPlus/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(getoptPlusPlus) - -include_directories( - ../../include/getoptPlusPlus) - -add_library(getoptPlusPlus - ../../include/getoptPlusPlus/getoptpp.h - ../../include/getoptPlusPlus/parameter.include.cc - getoptpp.cc) diff --git a/dependencies/build/getoptPlusPlus/COPYING b/dependencies/build/getoptPlusPlus/COPYING deleted file mode 100644 index 641905ac..00000000 --- a/dependencies/build/getoptPlusPlus/COPYING +++ /dev/null @@ -1,66 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 3, 29 June 2007 - -Copyright © 2007 Free Software Foundation, Inc. - -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: - o 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. - o 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. - diff --git a/dependencies/build/getoptPlusPlus/Makefile b/dependencies/build/getoptPlusPlus/Makefile deleted file mode 100644 index d6be12e2..00000000 --- a/dependencies/build/getoptPlusPlus/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -SOURCES=getoptpp.cc test.cc -HEADERS=getoptpp.h -OBJECTS=$(SOURCES:.cc=.o) -LDFLAGS= -CXXFLAGS=-O0 -ggdb -Wall -CFLAGS=$(CXXFLAGS) -CC=g++ -TARGET=getopt-test - -all: $(TARGET) -$(TARGET): $(OBJECTS) - $(CXX) $(LDFLAGS) -o $(TARGET) $(OBJECTS) -$(SOURCES): $(HEADERS) - -clean: - rm -rf $(TARGET) $(OBJECTS) *~ diff --git a/dependencies/build/getoptPlusPlus/README b/dependencies/build/getoptPlusPlus/README deleted file mode 100644 index 0ef16591..00000000 --- a/dependencies/build/getoptPlusPlus/README +++ /dev/null @@ -1,8 +0,0 @@ -A very small class library that replaces getopt() and -getopt_long()-functionality with a more C++-friendly approach. - -Additionally, it does not rely on UNIX-specific code. - -See test.cc for a sample application and COPYING for license information. - - diff --git a/dependencies/build/getoptPlusPlus/config.doxygen b/dependencies/build/getoptPlusPlus/config.doxygen deleted file mode 100644 index 9ac6e568..00000000 --- a/dependencies/build/getoptPlusPlus/config.doxygen +++ /dev/null @@ -1,1630 +0,0 @@ -# Doxyfile 1.7.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans.ttf - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/dependencies/build/getoptPlusPlus/getoptpp.cc b/dependencies/build/getoptPlusPlus/getoptpp.cc deleted file mode 100644 index 37212901..00000000 --- a/dependencies/build/getoptPlusPlus/getoptpp.cc +++ /dev/null @@ -1,357 +0,0 @@ -/* (C) 2011 Viktor Lofgren - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "getoptpp.h" -#include -#include -#include -#include -#include - -using namespace std; - -namespace vlofgren { - -/* -* -* Class OptionsParser -* -* -*/ - - -OptionsParser::OptionsParser(const char* programDesc) : fprogramDesc(programDesc) {} -OptionsParser::~OptionsParser() {} - -ParameterSet& OptionsParser::getParameters() { - return parameters; -} - -void OptionsParser::parse(int argc, const char* argv[]) throw(runtime_error) -{ - argv0 = argv[0]; - - if(argc == 1) return; - - vector v(&argv[1], &argv[argc]); - - ParserState state(/* *this,*/ v); - - for(; !state.end(); state.advance()) { - - std::list::iterator i; - - for(i = parameters.parameters.begin(); - i != parameters.parameters.end(); i++) - { - int n = 0; - try - { - n = (*i)->receive(state); - } - catch(Parameter::ExpectedArgument &) - { - throw Parameter::ExpectedArgument(state.get() + ": expected an argument"); - } - catch(Parameter::UnexpectedArgument &) - { - throw Parameter::UnexpectedArgument(state.get() + ": did not expect an argument"); - } - catch(Switchable::SwitchingError &) - { - throw Parameter::ParameterRejected(state.get() + ": parameter already set"); - } - catch(Parameter::ParameterRejected & pr) { - std::string what = pr.what(); - if(what.length()) - { - throw Parameter::ParameterRejected(state.get() + ": " + what); - } - throw Parameter::ParameterRejected(state.get() + " (unspecified error)"); - } - - for (int j = 1; j < n; ++j) - { - state.advance(); - } - - if(n != 0) - { - break; - } - } - - if(i == parameters.parameters.end()) { - std::string file = state.get(); - if(file == "--") { - state.advance(); - break; - } - else if(file.at(0) == '-') - throw Parameter::ParameterRejected(string("Bad parameter: ") + file); - else files.push_back(state.get()); - } - } - - if(!state.end()) for(; !state.end(); state.advance()) { - files.push_back(state.get()); - } - -} - -void OptionsParser::usage() const { - cerr << fprogramDesc << endl; - cerr << "Build time: " << __DATE__ << " " << __TIME__ << endl << endl; - cerr << "Usage: " << programName() << " [OPTIONS]" << endl << endl; - - cerr << "Parameters: " << endl; - - int totalWidth = 80; - int usageWidth = 33; - - // read total width from the terminal - struct winsize w; - if (ioctl(0, TIOCGWINSZ, &w) == 0) - { - if (w.ws_col > totalWidth) - totalWidth = w.ws_col; - } - - std::list::const_iterator i; - for(i = parameters.parameters.begin(); - i != parameters.parameters.end(); i++) - { - cerr.width(usageWidth); - cerr << std::left << " " + (*i)->usageLine(); - - std::string description = (*i)->description(); - while (int(description.length()) > (totalWidth - usageWidth)) - { - size_t pos = description.find_last_of(' ', totalWidth - usageWidth); - cerr << description.substr(0, pos) << std::endl << std::string(usageWidth - 1, ' '); - description = description.substr(pos); - } - cerr << description << endl; - - } -} - -const vector& OptionsParser::getFiles() const { - return files; -} - -const string& OptionsParser::programName() const { - return argv0; -} - -/* -* Parameter set -* -* -*/ - -ParameterSet::ParameterSet(const ParameterSet& ps) { - throw new runtime_error("ParameterSet not copyable"); -} - -ParameterSet::~ParameterSet() { - for(std::list::iterator i = parameters.begin(); - i != parameters.end(); i++) - { - delete *i; - } - -} - -/* The typical use case for command line arguments makes linear searching completely -* acceptable here. -*/ - -Parameter& ParameterSet::operator[](char c) const { - for(std::list::const_iterator i = parameters.begin(); i!= parameters.end(); i++) { - if((*i)->shortOption() == c) return *(*i); - } - throw out_of_range("ParameterSet["+string(&c)+string("]")); -} - - -Parameter& ParameterSet::operator[](const string& param) const { - for(std::list::const_iterator i = parameters.begin(); i!= parameters.end(); i++) { - if((*i)->longOption() == param) return *(*i); - } - throw out_of_range("ParameterSet["+param+"]"); -} - - - -/* -* -* Class ParserState -* -* -*/ - - -ParserState::ParserState(/*OptionsParser &opts, */vector& args) : - /*opts(opts),*/ arguments(args), iterator(args.begin()) -{ - -} - -const string ParserState::peek() const { - vector::const_iterator next = iterator+1; - if(next != arguments.end()) return *next; - else return ""; - -} - -const string ParserState::get() const { - if(!end()) return *iterator; - else return ""; -} - -void ParserState::advance() { - iterator++; -} - -bool ParserState::end() const { - return iterator == arguments.end(); -} - - -/* -* -* Class Parameter -* -* -*/ - - - -Parameter::Parameter(char shortOption, const std::string & longOption, const std::string & description) : - fshortOption(shortOption), flongOption(longOption), fdescription(description) -{ - -} - -Parameter::~Parameter() {} - -const string& Parameter::description() const { return fdescription; } -const string& Parameter::longOption() const { return flongOption; } -bool Parameter::hasShortOption() const { return fshortOption != 0x0; } -char Parameter::shortOption() const { assert(hasShortOption()); return fshortOption; } - -/* -* -* Class Switchable -* -* -*/ - -bool Switchable::isSet() const { return fset; } -Switchable::~Switchable() {}; -Switchable::Switchable() : fset(false) {} - -void MultiSwitchable::set() throw (Switchable::SwitchingError) { fset = true; } -MultiSwitchable::~MultiSwitchable() {} - - -void UniquelySwitchable::set() throw (Switchable::SwitchingError) { - if(UniquelySwitchable::isSet()) throw Switchable::SwitchingError(); - fset = true; -} -UniquelySwitchable::~UniquelySwitchable() {} - - -PresettableUniquelySwitchable::~PresettableUniquelySwitchable() {} -bool PresettableUniquelySwitchable::isSet() const { - return UniquelySwitchable::isSet() || fpreset.isSet(); -} -void PresettableUniquelySwitchable::set() throw (Switchable::SwitchingError) -{ - UniquelySwitchable::set(); -} -void PresettableUniquelySwitchable::preset() { - fpreset.set(); -} - -/* -* -* PODParameter specializations -* -* -* -*/ - - -template<> -PODParameter::PODParameter(char shortOption, const char *longOption, - const char* description) : CommonParameter(shortOption, longOption, description) { -} - - -template<> -int PODParameter::validate(const string &s) throw(Parameter::ParameterRejected) -{ - // This is sadly necessary for strto*-functions to operate on - // const char*. The function doesn't write to the memory, though, - // so it's quite safe. - - char* cstr = const_cast(s.c_str()); - if(*cstr == '\0') throw ParameterRejected("No argument given"); - - long l = strtol(cstr, &cstr, 10); - if(*cstr != '\0') throw ParameterRejected("Expected int"); - - if(l > INT_MAX || l < INT_MIN) { - throw ParameterRejected("Expected int"); - } - - return l; -} - -template<> -long PODParameter::validate(const string &s) throw(Parameter::ParameterRejected) -{ - char* cstr = const_cast(s.c_str()); - if(*cstr == '\0') throw ParameterRejected("No argument given"); - - long l = strtol(cstr, &cstr, 10); - if(*cstr != '\0') throw ParameterRejected("Expected long"); - - return l; -} - -template<> -double PODParameter::validate(const string &s) throw(Parameter::ParameterRejected) -{ - char* cstr = const_cast(s.c_str()); - if(*cstr == '\0') throw ParameterRejected("No argument given"); - - double d = strtod(cstr, &cstr); - if(*cstr != '\0') throw ParameterRejected("Expected double"); - - return d; -} - -template<> -string PODParameter::validate(const string &s) throw(Parameter::ParameterRejected) -{ - return s; -} - - -} //namespace diff --git a/dependencies/build/getoptPlusPlus/test.cc b/dependencies/build/getoptPlusPlus/test.cc deleted file mode 100644 index adb34ff8..00000000 --- a/dependencies/build/getoptPlusPlus/test.cc +++ /dev/null @@ -1,196 +0,0 @@ - /* (C) 2011 Viktor Lofgren - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - - -#include "getoptpp.h" -#include -#include -#include -#include - -using namespace std; -using namespace vlofgren; - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -/* - * - * This is one way of adding new parameter types, - * inheriting existing types and adding new validation. - * - * In this case, StringParameter (which is a typedef of PODParameter gets - * a new validator that only accepts strings with only letters. - * - */ - - -class AlphabeticParameter : public StringParameter { -public: - AlphabeticParameter(char shortName, const char* longName, const char* description) : - StringParameter(shortName, longName, description) {} - virtual ~AlphabeticParameter() {} - - void receiveSwitch() throw(Parameter::ParameterRejected) { - throw Parameter::ParameterRejected(); - } - - - /* isalpha may be a macro */ - static bool isNotAlpha(char c) { return !isalpha(c); } - - virtual string validate(const string& arg) throw(Parameter::ParameterRejected) { - int nonalpha = count_if(arg.begin(), arg.end(), isNotAlpha); - - - if(nonalpha) throw Parameter::ParameterRejected("I only want numbers"); - else return arg; - } - -}; - -/* - * - * The other way is to specialize the PODParameter class - * - */ - -enum RockPaperScissor { ROCK, PAPER, SCISSOR } ; - -namespace vlofgren { - // needs to live in the vlofgren namespace for whatever reason - template<> enum RockPaperScissor - PODParameter::validate(const string &s) throw(Parameter::ParameterRejected) - { - if(s == "rock") - return ROCK; - else if(s == "paper") - return PAPER; - else if(s == "scissor") - return SCISSOR; - else { - throw ParameterRejected("Invalid argument"); - } - - } -} -typedef PODParameter RockPaperScissorParameter; - - -/* - * - * Dummy program - * - */ - - -int main(int argc, const char* argv[]) { - - // Create a parser - - OptionsParser optp("An example program (that also runs some tests)"); - ParameterSet& ps = optp.getParameters(); - - /* An alternative option is to simply extend the options parser and set all this up - * in the constructor. - */ - - ps.add('f', "foo", "Enable the foo system (no argument)"); - ps.add('b', "bar", "Enable the bar system (string argument)"); - ps.add >('z', "baz", "Enable the baz system (floating point argument"); - - PODParameter& i = ps.add >('i', "foobar", "Enable the foobar system (integer argument"); - i.setDefault(15); - - ps.add('a', "alpha", "Custom parameter that requires a string of letters"); - ps.add('r', "rps", "Takes the values rock, paper or scissor"); - ps.add('h', "help", "Display help screen"); - - - // Register the parameters with the parser - - try { - // Parse argv - optp.parse(argc, argv); - - // Test for the help flag - if(ps['h'].isSet()) { - optp.usage(); - return EXIT_SUCCESS; - } - - // Print out what values the parameters were given - - cout << "The following parameters were set:" << endl; - - cout << "foo: " << (ps['f'].isSet() ? "true" : "false") << endl; - cout << "bar: \"" << ps['b'].get() << "\""<< endl; - cout << "baz: "; - - if(ps['z'].isSet()) { - cout << ps['z'].get() << endl; - } else { - cout << "not set" << endl; - } - - /* You can also save the return value from ParserSet::add() if - * you feel the operator[].get() stuff is a bit much */ - cout << "foobar: "; - if(i.isSet()) { - cout << i.get() << endl; - } else { - cout << "not set" << endl; - } - cout << "alpha: "; - if(ps["alpha"].isSet()) { - cout << ps["alpha"].get() << endl; - } else { - cout << "not set" << endl; - } - - cout << "rps: "; - if(ps["rps"].isSet()) { - cout << ps["rps"].get() << endl; - } else { - cout << "not set" << endl; - } - - } catch(Parameter::ParameterRejected &p){ - // This will happen if the user has fed some malformed parameter to the program - cerr << p.what() << endl; - optp.usage(); - return EXIT_FAILURE; - } catch(runtime_error &e) { - // This will happen if you try to access a parameter that hasn't been set - cerr << e.what() << endl; - - return EXIT_FAILURE; - } - - - // List what non-parameter options were given (typically files) - cout << "The following file arguments were given:" << endl; - - vector files = optp.getFiles(); - for(vector::iterator i = files.begin(); i != files.end(); i++) { - cout << "\t" << *i << endl; - } - - - return EXIT_SUCCESS; -} - -#endif diff --git a/dependencies/getoptPlusPlus-master-20130810.zip b/dependencies/getoptPlusPlus-master-20130810.zip deleted file mode 100644 index fe332429..00000000 Binary files a/dependencies/getoptPlusPlus-master-20130810.zip and /dev/null differ diff --git a/dependencies/include/getoptPlusPlus/getoptpp.h b/dependencies/include/getoptPlusPlus/getoptpp.h deleted file mode 100644 index cfa9102f..00000000 --- a/dependencies/include/getoptPlusPlus/getoptpp.h +++ /dev/null @@ -1,398 +0,0 @@ - /* (C) 2011 Viktor Lofgren - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - /* - * Modifications: - * - * - Removed using namespace std from header - * - Changed Parameter container type from std::set to std::list to presume order - * - Changed arguments of Parameters to be a seperated arguments on the command line - * - Make the choice of receiving arguments or not in subclasses of CommonParameter - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef GETOPTPP_H -#define GETOPTPP_H - -namespace vlofgren { - -class Parameter; -class ParserState; - -class OptionsParser; - -/** Container for a set of parameters */ - -class ParameterSet { -public: - - /** Find a parameter by short option form */ - Parameter& operator[](char c) const; - - /** Find a parameter by long option form. */ - Parameter& operator[](const std::string &s) const; - - /** Factory method that adds a new parameter of - * type T to the set. - * - * This is just for convenience. It allows ParameterSet - * to manage the pointers, as well as (usually) making the - * code slightly easier to read. - * - * Do not try to add non-Parameter types lest you will invoke - * the wrath of gcc's template error messages. - * - * @returns The created parameter. The reference is valid - * as long as ParameterSet exists. - */ - template - T &add(char shortName, const char* longName, const char* description); - - ParameterSet() {} - ~ParameterSet(); -protected: - friend class OptionsParser; - std::list parameters; - -private: - ParameterSet(const ParameterSet& ps); -}; - -/** getopt()-style parser for command line arguments - * - * Matches each element in argv against given - * parameters, and collects non-parameter arguments - * (typically files) in a vector. - * - */ - -class OptionsParser { -public: - OptionsParser(const char *programDesc); - virtual ~OptionsParser(); - - ParameterSet& getParameters(); - - /** Parse command line arguments */ - void parse(int argc, const char* argv[]) throw(std::runtime_error); - - /** Generate a usage screen */ - void usage() const; - - /** Return the name of the program, as - * given by argv[0] - */ - const std::string& programName() const; - - /** Return a vector of each non-parameter */ - const std::vector& getFiles() const; -protected: - std::string argv0; - std::string fprogramDesc; - - ParameterSet parameters; - std::vector files; - - friend class ParserState; -}; - -/** - * Corresponds to the state of the parsing, basically just a wrapper - * for a const_iterator that handles nicer. - */ - -class ParserState { -public: - const std::string peek() const; - const std::string get() const; - void advance(); - bool end() const; -protected: - ParserState(/*OptionsParser &opts,*/ std::vector& args); -private: - friend class OptionsParser; - -// OptionsParser &opts; - const std::vector &arguments; - std::vector::const_iterator iterator; -}; - -/** - * - * Abstract base class of all parameters - * - */ - -class Parameter { -public: - - /** Generic exception thrown when a parameter is malformed - */ - class ParameterRejected : public std::runtime_error { - public: - ParameterRejected(const std::string& s) : std::runtime_error(s) {} - ParameterRejected() : runtime_error("") {} - }; - - /** Exception thrown when a parameter did not expect an argument */ - class UnexpectedArgument : public ParameterRejected { - public: - UnexpectedArgument(const std::string &s) : ParameterRejected(s) {} - UnexpectedArgument() {} - }; - - /** Exception thrown when a parameter expected an argument */ - class ExpectedArgument : public ParameterRejected { - public: - ExpectedArgument(const std::string &s) : ParameterRejected(s) {} - ExpectedArgument() {} - }; - - Parameter(char shortOption, const std::string & longOption, const std::string & description); - - virtual ~Parameter(); - - /** Test whether the parameter has been set */ - virtual bool isSet() const = 0; - - /** This parameter's line in OptionsParser::usage() */ - virtual std::string usageLine() const = 0; - - /** Description of the parameter (rightmost field in OptionsParser::usage()) */ - const std::string& description() const; - - /** The long name of this parameter (e.g. "--option"), without the dash. */ - const std::string& longOption() const; - - /** Check if this parameters has a short option */ - bool hasShortOption() const; - - /** The short name of this parameter (e.g. "-o"), without the dash. */ - char shortOption() const; - -protected: - - /** Receive a potential parameter from the parser (and determien if it's ours) - * - * The parser will pass each potential parameter through it's registered parameters' - * receive function. - * - * @throw ParameterRejected if the parameter belongs to us, but is malformed somehow. - * - * @param state Allows access to the current argument. This is a fairly powerful - * iterator that technically allows for more complex grammar than what is - * presently used. - */ - virtual int receive(ParserState& state) throw(ParameterRejected) = 0; - - friend class OptionsParser; - - char fshortOption; - const std::string flongOption; - const std::string fdescription; -private: - -}; - -/* - * - * Abstract base class of all parameters - * - */ - -class Switchable; - -/** Base class for most parameter implementations. - * - * It parses the argument in receive() and if it matches, - * calls receiveSwitch() or receiveArgument() which are implemented - * in child classes. - * - * The SwitchingBehavior mixin determines what happens if the argument - * is set multiple times. - */ - -template -class CommonParameter : public Parameter, protected SwitchingBehavior { -public: - - /** Test whether the parameter has been set */ - virtual bool isSet() const; - - CommonParameter(char shortOption, const char *longOption, - const char* description); - virtual ~CommonParameter(); - - virtual std::string usageLine() const; - -protected: - /** Parse the argument given by state, and dispatch either - * receiveSwitch() or receiveArgument() accordingly. - * - * @param state The current argument being parsed. - * @return The number of parameters taken from the input - */ - virtual int receive(ParserState& state) throw(ParameterRejected) = 0; -}; - -/** This class (used as a mixin) defines how a parameter - * behaves when switched on, specifically when switched on multiple times. - * - */ -class Switchable { -public: - class SwitchingError : public Parameter::ParameterRejected {}; - - /** Test whether the parameter has been set */ - virtual bool isSet() const; - - /** Set the parameter - * - */ - virtual void set() throw (SwitchingError) = 0; - - virtual ~Switchable(); - Switchable(); -protected: - bool fset; -}; - -/** Switching behavior that does not complain when set multiple times. */ -class MultiSwitchable : public Switchable { -public: - virtual ~MultiSwitchable(); - virtual void set() throw(SwitchingError); - -}; - -/** Switching behavior that allows switching only once. - * - * This is typically what you want if your parameter has an argument. - * - */ -class UniquelySwitchable : public Switchable { -public: - - virtual ~UniquelySwitchable(); - - /** Set the parameter - * - * @throw SwitchingError Thrown if the parameter is already set. - */ - virtual void set() throw (SwitchingError); -}; - -/** Switching behavior that makes possible allows presettable parameters, - * that is, it can either be set by the program, or by a command line argument, - * and the command-line part is UniquelySwitchable, but the program part - * is MultiSwitchable (and is set by preset()) - * - * - */ -class PresettableUniquelySwitchable : public UniquelySwitchable { -public: - - /** Test whether the parameter has been set OR preset */ - virtual bool isSet() const; - - /** Call if the parameter has been set. - * - * @throw SwitchingError thrown if the parameter is already set - * (doesn't care if it's been pre-set) - */ - virtual void set() throw (Switchable::SwitchingError); - - /** Call if the parameter has been preset */ - virtual void preset(); - - virtual ~PresettableUniquelySwitchable(); -private: - MultiSwitchable fpreset; -}; - -/* Parameter that does not take an argument, and throws an exception - * if an argument is given */ - -template -class SwitchParameter : public CommonParameter { -public: - SwitchParameter(char shortOption, const char *longOption, - const char* description); - virtual ~SwitchParameter(); - -protected: - virtual int receive(ParserState& state) throw(Parameter::ParameterRejected); -}; - -/** Plain-Old-Data parameter. Performs input validation. - * - * Currently only supports int, long and double, but extending - * it to other types (even non-POD) is as easy as partial template specialization. - * - * Specifically, you need to specialize validate(). - */ - -template -class PODParameter : public CommonParameter { -public: - PODParameter(char shortOption, const char *longOption, - const char* description); - virtual ~PODParameter(); - - /* Retreive the value of the argument. Throws an exception if - * the value hasn't been set (test with isSet()) - */ - T getValue() const; - - /** Type-casting operator, for convenience. */ - operator T() const; - - /** Set a default value for this parameter */ - virtual void setDefault(T value); - - std::string usageLine() const; -protected: - virtual int receive(ParserState& state) throw(Parameter::ParameterRejected); - - /** Validation function for the data type. - * - * @throw ParameterRejected if the argument does not conform to this data type. - * @return the value corresponding to the argument. - */ - virtual T validate(const std::string& s) throw (Parameter::ParameterRejected); - - T value; -}; - - -typedef PODParameter IntParameter; -typedef PODParameter LongParameter; -typedef PODParameter DoubleParameter; -typedef PODParameter StringParameter; - -#include "parameter.include.cc" - -} //namespace - -#endif diff --git a/dependencies/include/getoptPlusPlus/parameter.include.cc b/dependencies/include/getoptPlusPlus/parameter.include.cc deleted file mode 100644 index a1daf516..00000000 --- a/dependencies/include/getoptPlusPlus/parameter.include.cc +++ /dev/null @@ -1,177 +0,0 @@ - /* (C) 2011 Viktor Lofgren - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#ifdef GETOPTPP_H - - -/* This file contains template voodoo, and due to the unique way GCC handles - * templates, it needs to be included as a header (and it -is-). Do not attempt to - * compile this file directly! - */ - -template -T &ParameterSet::add(char shortName, const char* longName, const char* description) { - T* p = new T(shortName, longName, description); - parameters.push_back(p); - return *p; -} - -/* - * - * Class CommonParameter implementation - * - * - */ - -template -CommonParameter::~CommonParameter() {} - -template -CommonParameter::CommonParameter(char shortOption, const char *longOption, - const char* description) : Parameter(shortOption, longOption, description) {} - -template -bool CommonParameter::isSet() const{ - return SwitchingBehavior::isSet(); -} - -template -std::string CommonParameter::usageLine() const { - std::stringstream strstr; - - if (hasShortOption()) - { - strstr << "-" << shortOption() << ", "; - } - else - { - strstr << " "; - } - strstr.width(20); - strstr << std::left << "--" + longOption(); - - return strstr.str(); -} - -/* - * - * Class SwitchParameter - * - * - */ - -template -SwitchParameter::SwitchParameter(char shortOption, const char *longOption, - const char* description) : CommonParameter(shortOption, longOption, description) {} -template -SwitchParameter::~SwitchParameter() {} - -template -int SwitchParameter::receive(ParserState& state) throw(Parameter::ParameterRejected) { - - const std::string arg = state.get(); - - if(arg.at(0) != '-') return false; - - if ((arg.at(1) == '-' && arg.substr(2) == this->longOption()) || - (this->hasShortOption() && arg.at(1) == this->shortOption() && arg.length() == 2)) - { - this->set(); - return 1; - } - - return 0; -} - -/* - * PODParameter stuff - * - */ - - -template -PODParameter::PODParameter(char shortOption, const char *longOption, - const char* description) : CommonParameter(shortOption, longOption, description) {} - -template -PODParameter::~PODParameter() {} - -template -PODParameter::operator T() const { return getValue(); } - -template -void PODParameter::setDefault(T value) { - PresettableUniquelySwitchable::preset(); - this->value = value; -} - -template -T PODParameter::getValue() const { - if(!this->isSet()) { - throw std::runtime_error( - std::string("Attempting to retreive the argument of parameter") + this->longOption() + " but it hasn't been set!"); - } - return value; - -} - -template -std::string PODParameter::usageLine() const { - std::stringstream strstr; - - if (this->hasShortOption()) - { - strstr << "-" << this->shortOption() << ", "; - } - else - { - strstr << " "; - } - strstr.width(20); - strstr << std::left << "--" + this->longOption() + " "; - - return strstr.str(); -} - -template -int PODParameter::receive(ParserState& state) throw(Parameter::ParameterRejected) { - - const std::string arg = state.get(); - - if(arg.at(0) != '-') return false; - - if((arg.at(1) == '-' && arg.substr(2) == this->longOption()) || - (this->hasShortOption() && arg.at(1) == this->shortOption() && arg.length() == 2)) - { - // retrieve the argument - std::string arg1 = state.peek(); - if (arg1.length() == 0) - { - throw Parameter::ExpectedArgument(arg + ": expected an argument"); - return 1; - } - - this->set(); - value = this->validate(arg1); - - return 2; - } - - return 0; -} - -#endif diff --git a/dependencies/wjwwood-serial-master-20131105.zip b/dependencies/wjwwood-serial-master-20131105.zip deleted file mode 100644 index 098d7f9c..00000000 Binary files a/dependencies/wjwwood-serial-master-20131105.zip and /dev/null differ diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..0149c29b --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,3 @@ +/hyperion-build-doc.sh +/hyperion.doxygen +/html/ diff --git a/include/commandline/BooleanOption.h b/include/commandline/BooleanOption.h new file mode 100644 index 00000000..72e35eee --- /dev/null +++ b/include/commandline/BooleanOption.h @@ -0,0 +1,35 @@ +#ifndef HYPERION_BOOLEANOPTION_H +#define HYPERION_BOOLEANOPTION_H + + +#include +#include "Option.h" + +namespace commandline +{ + +class BooleanOption: public Option +{ +public: + BooleanOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(name, description, QString(), QString()) + {} + BooleanOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(names, description, QString(), QString()) + {} + BooleanOption(const QCommandLineOption &other) + : Option(other) + {} +}; + +} + +#endif //HYPERION_BOOLEANOPTION_H diff --git a/include/commandline/ColorOption.h b/include/commandline/ColorOption.h new file mode 100644 index 00000000..1814143c --- /dev/null +++ b/include/commandline/ColorOption.h @@ -0,0 +1,41 @@ +#ifndef HYPERION_COLOROPTION_H +#define HYPERION_COLOROPTION_H + +#include "Option.h" +#include +#include + +namespace commandline +{ + +class ColorOption: public Option +{ +protected: + QColor _color; +public: + ColorOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(name, description, valueName, defaultValue) + {} + ColorOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(names, description, valueName, defaultValue) + {} + ColorOption(const QCommandLineOption &other) + : Option(other) + {} + + virtual bool validate(Parser & parser, QString & value) override; + QColor getColor(Parser &parser) + { return _color; } +}; + +} + +#endif //HYPERION_COLOROPTION_H diff --git a/include/commandline/ColorsOption.h b/include/commandline/ColorsOption.h new file mode 100644 index 00000000..eafe1b07 --- /dev/null +++ b/include/commandline/ColorsOption.h @@ -0,0 +1,41 @@ +#ifndef HYPERION_COLORSOPTION_H +#define HYPERION_COLORSOPTION_H + +#include "Option.h" +#include +#include + +namespace commandline +{ + +class ColorsOption: public Option +{ +protected: + QList _colors; +public: + ColorsOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(name, description, valueName, defaultValue) + {} + ColorsOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(names, description, valueName, defaultValue) + {} + ColorsOption(const QCommandLineOption &other) + : Option(other) + {} + + virtual bool validate(Parser & parser, QString & value) override; + QList &getColors(Parser &parser) + { return _colors; } +}; + +} + +#endif //HYPERION_COLOROPTION_H diff --git a/include/commandline/DoubleOption.h b/include/commandline/DoubleOption.h new file mode 100644 index 00000000..9eb3f924 --- /dev/null +++ b/include/commandline/DoubleOption.h @@ -0,0 +1,40 @@ +#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H +#define HYPERION_DOUBLECOMMANDLINEOPTION_H + +#include +#include "ValidatorOption.h" + +namespace commandline +{ + +class DoubleOption: public ValidatorOption +{ +protected: + double _double; +public: + DoubleOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(name, description, valueName, defaultValue) + { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } + DoubleOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(names, description, valueName, defaultValue) + { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } + DoubleOption(const QCommandLineOption &other, + double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(other) + { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } + + double getDouble(Parser &parser, bool *ok = 0); + double *getDoublePtr(Parser &parser, bool *ok = 0); +}; + +} + +#endif //HYPERION_DOUBLECOMMANDLINEOPTION_H diff --git a/include/commandline/ImageOption.h b/include/commandline/ImageOption.h new file mode 100644 index 00000000..535d501e --- /dev/null +++ b/include/commandline/ImageOption.h @@ -0,0 +1,41 @@ +#ifndef HYPERION_IMAGEOPTION_H +#define HYPERION_IMAGEOPTION_H + +#include "Option.h" +#include +#include + +namespace commandline +{ + +class ImageOption: public Option +{ +protected: + QImage _image; +public: + ImageOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(name, description, valueName, defaultValue) + {} + ImageOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString() + ) + : Option(names, description, valueName, defaultValue) + {} + ImageOption(const QCommandLineOption &other) + : Option(other) + {} + + virtual bool validate(Parser & parser, QString & value) override; + QImage &getImage(Parser &parser) + { return _image; } +}; + +} + +#endif //HYPERION_IMAGEOPTION_H diff --git a/include/commandline/IntOption.h b/include/commandline/IntOption.h new file mode 100644 index 00000000..2f59fae3 --- /dev/null +++ b/include/commandline/IntOption.h @@ -0,0 +1,41 @@ +#ifndef HYPERION_INTCOMMANDLINEOPTION_H +#define HYPERION_INTCOMMANDLINEOPTION_H + +#include +#include +#include "ValidatorOption.h" + +namespace commandline +{ + +class IntOption: public ValidatorOption +{ +protected: + int _int; +public: + IntOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + int minimum = std::numeric_limits::min(), int maximum = std::numeric_limits::max()) + : ValidatorOption(name, description, valueName, defaultValue) + { setValidator(new QIntValidator(minimum, maximum)); } + IntOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + int minimum = std::numeric_limits::min(), int maximum = std::numeric_limits::max()) + : ValidatorOption(names, description, valueName, defaultValue) + { setValidator(new QIntValidator(minimum, maximum)); } + IntOption(const QCommandLineOption &other, + int minimum = std::numeric_limits::min(), int maximum = std::numeric_limits::max()) + : ValidatorOption(other) + { setValidator(new QIntValidator(minimum, maximum)); } + + int getInt(Parser &parser, bool *ok = 0, int base = 10); + int *getIntPtr(Parser &parser, bool *ok = 0, int base = 10); +}; + +} + +#endif //HYPERION_INTCOMMANDLINEOPTION_H diff --git a/include/commandline/Option.h b/include/commandline/Option.h new file mode 100644 index 00000000..d58bc4fe --- /dev/null +++ b/include/commandline/Option.h @@ -0,0 +1,49 @@ +#ifndef HYPERION_OPTION_H +#define HYPERION_OPTION_H + +#include +#include + +namespace commandline +{ + +class Parser; + +/* Note, this class and all it's derivatives store the validated results for caching. This means that unlike the + * regular QCommandLineOption it is _not_ idempotent! */ +class Option: public QCommandLineOption +{ +protected: + QString _error; +public: + Option(const QString &name, + const QString &description = QString(), + const QString &valueName = QString::null, + const QString &defaultValue = QString() + ) + : QCommandLineOption(name, description, valueName, defaultValue) + {} + Option(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString::null, + const QString &defaultValue = QString() + ) + : QCommandLineOption(names, description, valueName, defaultValue) + {} + Option(const QCommandLineOption &other) + : QCommandLineOption(other) + {} + + virtual bool validate(Parser &parser, QString &value); + QString name() + { return this->names().last();} + QString getError() + { return this->_error; } + QString value(Parser &parser); + std::string getStdString(Parser &parser); + std::wstring getStdWString(Parser &parser); +}; + +} + +#endif //HYPERION_OPTION_H diff --git a/include/commandline/Parser.h b/include/commandline/Parser.h new file mode 100644 index 00000000..a9876e87 --- /dev/null +++ b/include/commandline/Parser.h @@ -0,0 +1,120 @@ +#ifndef HYPERION_COMMANDLINEPARSER_H +#define HYPERION_COMMANDLINEPARSER_H + +#include +#include +#include "ColorOption.h" +#include "ColorsOption.h" +#include "DoubleOption.h" +#include "ImageOption.h" +#include "IntOption.h" +#include "Option.h" +#include "RegularExpressionOption.h" +#include "SwitchOption.h" +#include "ValidatorOption.h" +#include "BooleanOption.h" + +namespace commandline +{ + +class Parser : public QObject +{ +protected: + QHash _options; + QString _errorText; + /* No public inheritance because we need to modify a few methods */ + QCommandLineParser _parser; + + QStringList _getNames(const char shortOption, const QString longOption); + QString _getDescription(const QString description, const QString default_=QString()); + +public: + bool parse(const QStringList &arguments); + void process(const QStringList &arguments); + void process(const QCoreApplication &app); + QString errorText() const; + + template + OptionT &add( + const char shortOption, + const QString longOption, + const QString description, + const QString default_, + Args ... args) + { + OptionT * option = new OptionT( + _getNames(shortOption, longOption), + _getDescription(description, default_), + longOption, + default_, + args...); + addOption(option); + return *option; + } + + /* gcc does not support default arguments for variadic templates which + * makes this method necessary */ + template + OptionT &add( + const char shortOption, + const QString longOption, + const QString description, + const QString default_ = QString()) + { + OptionT * option = new OptionT( + _getNames(shortOption, longOption), + _getDescription(description, default_), + longOption, + default_); + addOption(option); + return *option; + } + + Parser(QString description=QString()) + {if(description.size())setApplicationDescription(description);}; + QCommandLineOption addHelpOption() + { return _parser.addHelpOption(); } + bool addOption(Option &option); + bool addOption(Option *option); + void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString()) + { _parser.addPositionalArgument(name, description, syntax); } + QCommandLineOption addVersionOption() + { return _parser.addVersionOption(); } + QString applicationDescription() const + { return _parser.applicationDescription(); } + void clearPositionalArguments() + { _parser.clearPositionalArguments(); } + QString helpText() const + { return _parser.helpText(); } + bool isSet(const QString &name) const + { return _parser.isSet(name); } + bool isSet(const Option &option) const + { return _parser.isSet(option); } + bool isSet(const Option *option) const + { return _parser.isSet(*option); } + QStringList optionNames() const + { return _parser.optionNames(); } + QStringList positionalArguments() const + { return _parser.positionalArguments(); } + void setApplicationDescription(const QString &description) + { _parser.setApplicationDescription(description); } + void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode) + { _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); } + void showHelp(int exitCode = 0) + { _parser.showHelp(exitCode); } + QStringList unknownOptionNames() const + { return _parser.unknownOptionNames(); } + QString value(const QString &optionName) const + { return _parser.value(optionName); } + QString value(const Option &option) const + { return _parser.value(option); } + QStringList values(const QString &optionName) const + { return _parser.values(optionName); } + QStringList values(const Option &option) const + { return _parser.values(option); } + +}; + +} + +#endif //HYPERION_COMMANDLINEPARSER_H diff --git a/include/commandline/RegularExpressionOption.h b/include/commandline/RegularExpressionOption.h new file mode 100644 index 00000000..36094754 --- /dev/null +++ b/include/commandline/RegularExpressionOption.h @@ -0,0 +1,71 @@ +#ifndef HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H +#define HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H + +#include +#include +#include "ValidatorOption.h" + +namespace commandline +{ + +class RegularExpressionOption: public ValidatorOption +{ +public: + RegularExpressionOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString()) + : ValidatorOption(name, description, valueName, defaultValue) + {} + RegularExpressionOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString()) + : ValidatorOption(names, description, valueName, defaultValue) + {} + RegularExpressionOption(const QCommandLineOption &other) + : ValidatorOption(other) + {} + + RegularExpressionOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QRegularExpression &expression = QRegularExpression()) + : ValidatorOption(name, description, valueName, defaultValue) + { setValidator(new QRegularExpressionValidator(expression)); } + RegularExpressionOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QRegularExpression &expression = QRegularExpression()) + : ValidatorOption(names, description, valueName, defaultValue) + { setValidator(new QRegularExpressionValidator(expression)); } + RegularExpressionOption(const QCommandLineOption &other, + const QRegularExpression &expression = QRegularExpression()) + : ValidatorOption(other) + { setValidator(new QRegularExpressionValidator(expression)); } + + RegularExpressionOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QString &expression = QString()) + : ValidatorOption(name, description, valueName, defaultValue) + { setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); } + RegularExpressionOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QString &expression = QString()) + : ValidatorOption(names, description, valueName, defaultValue) + { setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); } + RegularExpressionOption(const QCommandLineOption &other, + const QString &expression = QString()) + : ValidatorOption(other) + { setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); } +}; + +} + +#endif //HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H diff --git a/include/commandline/SwitchOption.h b/include/commandline/SwitchOption.h new file mode 100644 index 00000000..06763661 --- /dev/null +++ b/include/commandline/SwitchOption.h @@ -0,0 +1,45 @@ +#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H +#define HYPERION_SWITCHCOMMANDLINEOPTION_H + +#include +#include "Option.h" + +namespace commandline +{ + +template +class SwitchOption: public Option +{ +protected: + QMap _switches; +public: + SwitchOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QMap &switches=QMap()) + : Option(name, description, valueName, defaultValue), _switches(switches) + {} + SwitchOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QMap &switches=QMap()) + : Option(names, description, valueName, defaultValue), _switches(switches) + {} + SwitchOption(const QCommandLineOption &other, const QMap &switches) + : Option(other), _switches(switches) + {} + + const QMap &getSwitches() const{return _switches;}; + virtual bool validate(Parser &parser, QString &switch_) override{return hasSwitch(switch_);} + bool hasSwitch(const QString &switch_){return _switches.contains(switch_.toLower());} + void setSwitches(const QMap &_switches){this->_switches = _switches;} + void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;} + void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());} + T & switchValue(Parser & parser){return _switches[value(parser).toLower()];} +}; + +} + +#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H diff --git a/include/commandline/ValidatorOption.h b/include/commandline/ValidatorOption.h new file mode 100644 index 00000000..c7349ccf --- /dev/null +++ b/include/commandline/ValidatorOption.h @@ -0,0 +1,42 @@ +#ifndef HYPERION_COMMANDLINEOPTION_H +#define HYPERION_COMMANDLINEOPTION_H + +#include +#include +#include + +namespace commandline +{ + +class ValidatorOption: public Option +{ +protected: + const QValidator *validator; + virtual void setValidator(const QValidator *validator); +public: + ValidatorOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QValidator *validator = nullptr) + : Option(name, description, valueName, defaultValue), validator(validator) + {} + ValidatorOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + const QValidator *validator = nullptr) + : Option(names, description, valueName, defaultValue), validator(validator) + {} + ValidatorOption(const QCommandLineOption &other, + const QValidator *validator = nullptr) + : Option(other), validator(validator) + {} + + virtual const QValidator *getValidator() const; + virtual bool validate(Parser & parser, QString &value) override; +}; + +} + +#endif //HYPERION_COMMANDLINEOPTION_H diff --git a/include/grabber/X11Grabber.h b/include/grabber/X11Grabber.h index 1aafe1f8..e026bab2 100755 --- a/include/grabber/X11Grabber.h +++ b/include/grabber/X11Grabber.h @@ -72,6 +72,10 @@ private: XRenderPictureAttributes _pictAttr; Picture _srcPicture; Picture _dstPicture; + + XTransform _transform; + int _horizontalDecimation; + int _verticalDecimation; unsigned _screenWidth; unsigned _screenHeight; diff --git a/include/leddevice/LedDevice.h b/include/leddevice/LedDevice.h index f40e809f..f253591c 100644 --- a/include/leddevice/LedDevice.h +++ b/include/leddevice/LedDevice.h @@ -2,14 +2,21 @@ // STL incldues #include - #include +#include // Utility includes #include #include #include #include +#include +#include + +class LedDevice; + +typedef LedDevice* ( *LedDeviceCreateFuncType ) ( const Json::Value& ); +typedef std::map LedDeviceRegistry; /// /// Interface (pure virtual base class) for LedDevices. @@ -44,6 +51,10 @@ public: /// virtual int open(); + static int addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr); + static const LedDeviceRegistry& getDeviceMap(); + static void setActiveDevice(std::string dev); + static std::string activeDevice() { return _activeDevice; }; protected: /// The common Logger instance for all LedDevices Logger * _log; @@ -53,4 +64,6 @@ protected: /// The buffer containing the packed RGB values std::vector _ledBuffer; + static std::string _activeDevice; + static LedDeviceRegistry _ledDeviceMap; }; diff --git a/include/protoserver/ProtoConnectionWrapper.h b/include/protoserver/ProtoConnectionWrapper.h index 2f423291..1f4e1bb5 100644 --- a/include/protoserver/ProtoConnectionWrapper.h +++ b/include/protoserver/ProtoConnectionWrapper.h @@ -16,7 +16,7 @@ class ProtoConnectionWrapper : public QObject Q_OBJECT public: - ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply); + ProtoConnectionWrapper(const QString &address, int priority, int duration_ms, bool skipProtoReply); virtual ~ProtoConnectionWrapper(); signals: diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index a40681f6..f6b0d9a7 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -4,6 +4,7 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc) add_subdirectory(hyperion) +add_subdirectory(commandline) add_subdirectory(blackborder) add_subdirectory(jsonserver) add_subdirectory(protoserver) diff --git a/libsrc/commandline/BooleanOption.cpp b/libsrc/commandline/BooleanOption.cpp new file mode 100644 index 00000000..d92c5192 --- /dev/null +++ b/libsrc/commandline/BooleanOption.cpp @@ -0,0 +1,3 @@ +#include "commandline/BooleanOption.h" + +using namespace commandline; diff --git a/libsrc/commandline/CMakeLists.txt b/libsrc/commandline/CMakeLists.txt new file mode 100644 index 00000000..51fa4161 --- /dev/null +++ b/libsrc/commandline/CMakeLists.txt @@ -0,0 +1,42 @@ +# Define the current source locations +set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/commandline) +set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/commandline) + +set(Parser_HEADERS + ${CURRENT_HEADER_DIR}/ColorOption.h + ${CURRENT_HEADER_DIR}/ColorsOption.h + ${CURRENT_HEADER_DIR}/DoubleOption.h + ${CURRENT_HEADER_DIR}/ImageOption.h + ${CURRENT_HEADER_DIR}/IntOption.h + ${CURRENT_HEADER_DIR}/Option.h + ${CURRENT_HEADER_DIR}/Parser.h + ${CURRENT_HEADER_DIR}/RegularExpressionOption.h + ${CURRENT_HEADER_DIR}/SwitchOption.h + ${CURRENT_HEADER_DIR}/ValidatorOption.h + ${CURRENT_HEADER_DIR}/BooleanOption.h +) + +set(Parser_SOURCES + ${CURRENT_SOURCE_DIR}/ColorOption.cpp + ${CURRENT_SOURCE_DIR}/ColorsOption.cpp + ${CURRENT_SOURCE_DIR}/DoubleOption.cpp + ${CURRENT_SOURCE_DIR}/ImageOption.cpp + ${CURRENT_SOURCE_DIR}/IntOption.cpp + ${CURRENT_SOURCE_DIR}/Option.cpp + ${CURRENT_SOURCE_DIR}/Parser.cpp + ${CURRENT_SOURCE_DIR}/RegularExpressionOption.cpp + ${CURRENT_SOURCE_DIR}/SwitchOption.cpp + ${CURRENT_SOURCE_DIR}/ValidatorOption.cpp + ${CURRENT_SOURCE_DIR}/BooleanOption.cpp +) + +add_library(commandline + ${Parser_HEADERS} + ${Parser_SOURCES} +) + +qt5_use_modules(commandline Gui) + +target_link_libraries(commandline + hyperion +) diff --git a/libsrc/commandline/ColorOption.cpp b/libsrc/commandline/ColorOption.cpp new file mode 100644 index 00000000..32863fad --- /dev/null +++ b/libsrc/commandline/ColorOption.cpp @@ -0,0 +1,30 @@ +#include +#include "commandline/ColorOption.h" +#include "commandline/Parser.h" + +using namespace commandline; + +bool ColorOption::validate(Parser & parser, QString & value) +{ + // Check if we can create the color by name + _color = QColor(value); + if (_color.isValid()) { + return true; + } + + // check if we can create the color by hex RRGGBB getColors + _color = QColor(QString("#%1").arg(value)); + if (_color.isValid()) { + return true; + } + + if(!parser.isSet(*this)){ + // Return true if no value is available + return true; + } + + QStringList error; + _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); + + return false; +} diff --git a/libsrc/commandline/ColorsOption.cpp b/libsrc/commandline/ColorsOption.cpp new file mode 100644 index 00000000..b7f81bd7 --- /dev/null +++ b/libsrc/commandline/ColorsOption.cpp @@ -0,0 +1,37 @@ +#include +#include "commandline/ColorsOption.h" +#include "commandline/Parser.h" + +using namespace commandline; + +bool ColorsOption::validate(Parser & parser, QString & value) +{ + // Clear any old results + _colors.clear(); + + // Check if we can create the color by name + QColor color(value); + if (color.isValid()) { + _colors.push_back(color); + return true; + } + + // check if we can create the color by hex RRGGBB getColors + QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch match = hexRe.match(value); + if(match.hasMatch()) { + Q_FOREACH(const QString m, match.capturedTexts()){ + _colors.push_back(QColor(QString("#%1").arg(m))); + } + return true; + } + + if(!parser.isSet(*this)){ + // Return true if no value is available + return true; + } + + _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); + + return false; +} diff --git a/libsrc/commandline/DoubleOption.cpp b/libsrc/commandline/DoubleOption.cpp new file mode 100644 index 00000000..532df096 --- /dev/null +++ b/libsrc/commandline/DoubleOption.cpp @@ -0,0 +1,20 @@ +#include "commandline/DoubleOption.h" +#include "commandline/Parser.h" + +using namespace commandline; + +double DoubleOption::getDouble(Parser &parser, bool *ok) +{ + _double = value(parser).toDouble(ok); + return _double; +} + +double *DoubleOption::getDoublePtr(Parser &parser, bool *ok) +{ + if (parser.isSet(this)) { + getDouble(parser, ok); + return &_double; + } else { + return nullptr; + } +} diff --git a/libsrc/commandline/ImageOption.cpp b/libsrc/commandline/ImageOption.cpp new file mode 100644 index 00000000..77933176 --- /dev/null +++ b/libsrc/commandline/ImageOption.cpp @@ -0,0 +1,18 @@ +#include "commandline/ImageOption.h" + +using namespace commandline; + +bool ImageOption::validate(Parser & parser, QString & value) +{ + if(value.size()){ + _image = QImage(value); + + if (_image.isNull()) + { + _error = QString("File %1 could not be opened as image").arg(value); + return false; + } + } + + return true; +} diff --git a/libsrc/commandline/IntOption.cpp b/libsrc/commandline/IntOption.cpp new file mode 100644 index 00000000..e034fb0c --- /dev/null +++ b/libsrc/commandline/IntOption.cpp @@ -0,0 +1,20 @@ +#include "commandline/IntOption.h" +#include "commandline/Parser.h" + +using namespace commandline; + +int IntOption::getInt(Parser &parser, bool *ok, int base) +{ + _int = value(parser).toInt(ok, base); + return _int; +} + +int *IntOption::getIntPtr(Parser &parser, bool *ok, int base) +{ + if (parser.isSet(this)) { + getInt(parser, ok, base); + return &_int; + } else { + return nullptr; + } +} diff --git a/libsrc/commandline/Option.cpp b/libsrc/commandline/Option.cpp new file mode 100644 index 00000000..d8e733e8 --- /dev/null +++ b/libsrc/commandline/Option.cpp @@ -0,0 +1,26 @@ +#include "commandline/Option.h" +#include "commandline/Parser.h" + +using namespace commandline; + +bool Option::validate(Parser & parser, QString &value) +{ + /* By default everything is accepted */ + return true; +} + +QString Option::value(Parser &parser) +{ + return parser.value(*this); +} + +std::string Option::getStdString(Parser &parser) +{ + return value(parser).toStdString(); +} + +std::wstring Option::getStdWString(Parser &parser) +{ + return value(parser).toStdWString(); +} + diff --git a/libsrc/commandline/Parser.cpp b/libsrc/commandline/Parser.cpp new file mode 100644 index 00000000..c09c3449 --- /dev/null +++ b/libsrc/commandline/Parser.cpp @@ -0,0 +1,90 @@ +#include +#include +#include "commandline/Parser.h" + +using namespace commandline; + +bool Parser::parse(const QStringList &arguments) +{ + if (!_parser.parse(arguments)) { + return false; + } + + Q_FOREACH(Option * option, _options) { + QString value = this->value(*option); + if (!option->validate(*this, value)) { + const QString error = option->getError(); + if (error.size()) { + _errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error); + } + else { + _errorText = tr("%1 is not a valid option for %2").arg(value, option->name()); + } + return false; + } + } + return true; +} + +void Parser::process(const QStringList &arguments) +{ + _parser.process(arguments); + if (!parse(arguments)) { + + fprintf(stdout, "%s", qPrintable(tr("Error: %1").arg(_errorText))); + showHelp(EXIT_FAILURE); + } +} + +void Parser::process(const QCoreApplication &app) +{ + Q_UNUSED(app); + process(QCoreApplication::arguments()); +} + +QString Parser::errorText() const +{ + if (_errorText.size()) { + return _errorText; + } + else { + return _parser.errorText(); + } +} + +bool Parser::addOption(Option &option) +{ + return addOption(&option); +} + +bool Parser::addOption(Option * const option) +{ + _options[option->name()] = option; + return _parser.addOption(*option); +} +QStringList Parser::_getNames(const char shortOption, const QString longOption) +{ + QStringList names; + if (shortOption != 0x0) { + names << QString(shortOption); + } + if (longOption.size()) { + names << longOption; + } + return names; +} +QString Parser::_getDescription(const QString description, const QString default_) +{ + /* Add the translations if available */ + QString formattedDescription(tr(qPrintable(description))); + + /* Fill in the default if needed */ + if (default_.size()) { + if(!formattedDescription.contains("%1")){ + formattedDescription += " [default: %1]"; + } + formattedDescription = formattedDescription.arg(default_); + } + return formattedDescription; +} + diff --git a/libsrc/commandline/RegularExpressionOption.cpp b/libsrc/commandline/RegularExpressionOption.cpp new file mode 100644 index 00000000..7b16f264 --- /dev/null +++ b/libsrc/commandline/RegularExpressionOption.cpp @@ -0,0 +1,4 @@ +#include "commandline/RegularExpressionOption.h" + +using namespace commandline; + diff --git a/libsrc/commandline/SwitchOption.cpp b/libsrc/commandline/SwitchOption.cpp new file mode 100644 index 00000000..05d5bc1c --- /dev/null +++ b/libsrc/commandline/SwitchOption.cpp @@ -0,0 +1,5 @@ +#include "commandline/SwitchOption.h" + +using namespace commandline; + + diff --git a/libsrc/commandline/ValidatorOption.cpp b/libsrc/commandline/ValidatorOption.cpp new file mode 100644 index 00000000..9dfc9fca --- /dev/null +++ b/libsrc/commandline/ValidatorOption.cpp @@ -0,0 +1,25 @@ +#include "commandline/ValidatorOption.h" +#include "commandline/Parser.h" + +using namespace commandline; + +bool ValidatorOption::validate(Parser & parser, QString & value) +{ + if (parser.isSet(*this) || !defaultValues().empty()) { + int pos = 0; + validator->fixup(value); + return validator->validate(value, pos) == QValidator::Acceptable; + } else { + return true; + } +} + +const QValidator *ValidatorOption::getValidator() const +{ + return validator; +} +void ValidatorOption::setValidator(const QValidator *validator) +{ + ValidatorOption::validator = validator; +} + diff --git a/libsrc/grabber/x11/X11Grabber.cpp b/libsrc/grabber/x11/X11Grabber.cpp index 8fea47b0..feae804b 100755 --- a/libsrc/grabber/x11/X11Grabber.cpp +++ b/libsrc/grabber/x11/X11Grabber.cpp @@ -6,29 +6,29 @@ // X11Grabber includes #include -X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) : - _imageResampler(), - _useXGetImage(useXGetImage), - _cropLeft(cropLeft), - _cropRight(cropRight), - _cropTop(cropTop), - _cropBottom(cropBottom), - _x11Display(nullptr), - _pixmap(None), - _srcFormat(nullptr), - _dstFormat(nullptr), - _srcPicture(None), - _dstPicture(None), - _screenWidth(0), - _screenHeight(0), - _croppedWidth(0), - _croppedHeight(0), - _image(0,0), - _log(Logger::getInstance("X11GRABBER")) +X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) + : _imageResampler() + , _useXGetImage(useXGetImage) + , _cropLeft(cropLeft) + , _cropRight(cropRight) + , _cropTop(cropTop) + , _cropBottom(cropBottom) + , _x11Display(nullptr) + , _pixmap(None) + , _srcFormat(nullptr) + , _dstFormat(nullptr) + , _srcPicture(None) + , _dstPicture(None) + , _horizontalDecimation(horizontalPixelDecimation) + , _verticalDecimation(verticalPixelDecimation) + , _screenWidth(0) + , _screenHeight(0) + , _croppedWidth(0) + , _croppedHeight(0) + , _image(0,0) + , _log(Logger::getInstance("X11GRABBER")) { - _imageResampler.setHorizontalPixelDecimation(horizontalPixelDecimation); - _imageResampler.setVerticalPixelDecimation(verticalPixelDecimation); - _imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XShmGetImage or XGetImage + _imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage memset(&_pictAttr, 0, sizeof(_pictAttr)); _pictAttr.repeat = RepeatNone; } @@ -51,12 +51,14 @@ void X11Grabber::freeResources() { // Cleanup allocated resources of the X11 grab XDestroyImage(_xImage); - if(_XShmAvailable && !_useXGetImage) { + if(_XShmAvailable && !_useXGetImage) + { XShmDetach(_x11Display, &_shminfo); shmdt(_shminfo.shmaddr); shmctl(_shminfo.shmid, IPC_RMID, 0); } - if (_XRenderAvailable && !_useXGetImage) { + if (_XRenderAvailable && !_useXGetImage) + { XRenderFreePicture(_x11Display, _srcPicture); XRenderFreePicture(_x11Display, _dstPicture); XFreePixmap(_x11Display, _pixmap); @@ -65,29 +67,32 @@ void X11Grabber::freeResources() void X11Grabber::setupResources() { - if(_XShmAvailable && !_useXGetImage) { + if(_XShmAvailable && !_useXGetImage) + { _xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, _croppedWidth, _croppedHeight); - _shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777); _xImage->data = (char*)shmat(_shminfo.shmid,0,0); _shminfo.shmaddr = _xImage->data; _shminfo.readOnly = False; - - XShmAttach(_x11Display, &_shminfo); + XShmAttach(_x11Display, &_shminfo); } - if (_XRenderAvailable && !_useXGetImage) { - if(_XShmPixmapAvailable) { + if (_XRenderAvailable && !_useXGetImage) + { + if(_XShmPixmapAvailable) + { _pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth); - } else { + } + else + { _pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth); } _srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); _dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); _srcPicture = XRenderCreatePicture(_x11Display, _window, _srcFormat, CPRepeat, &_pictAttr); _dstPicture = XRenderCreatePicture(_x11Display, _pixmap, _dstFormat, CPRepeat, &_pictAttr); - XRenderSetPictureFilter(_x11Display, _srcPicture, "bilinear", NULL, 0); + XRenderSetPictureFilter(_x11Display, _srcPicture, FilterBilinear, NULL, 0); } } @@ -97,9 +102,12 @@ bool X11Grabber::Setup() if (_x11Display == nullptr) { Error(_log, "Unable to open display"); - if (getenv("DISPLAY")) { + if (getenv("DISPLAY")) + { Error(_log, "%s",getenv("DISPLAY")); - } else { + } + else + { Error(_log, "DISPLAY environment variable not set"); } return false; @@ -113,6 +121,10 @@ bool X11Grabber::Setup() _XShmAvailable = XShmQueryExtension(_x11Display); XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported); _XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap; + + // Image scaling is performed by XRender when available, otherwise by ImageResampler + _imageResampler.setHorizontalPixelDecimation(_XRenderAvailable ? 1 : _horizontalDecimation); + _imageResampler.setVerticalPixelDecimation(_XRenderAvailable ? 1 : _verticalDecimation); return true; } @@ -121,32 +133,67 @@ Image & X11Grabber::grab() { updateScreenDimensions(); - if (_XRenderAvailable && !_useXGetImage) { - XRenderComposite( _x11Display, // *dpy, - PictOpSrc, // op, - _srcPicture, // src - None, // mask - _dstPicture, // dst - _cropLeft, // src_x - _cropTop, // src_y - 0, // mask_x - 0, // mask_y - 0, // dst_x - 0, // dst_y - _croppedWidth, // width - _croppedHeight); // height - + if (_XRenderAvailable && !_useXGetImage) + { + double scale_x = static_cast(_windowAttr.width / _horizontalDecimation) / static_cast(_windowAttr.width); + double scale_y = static_cast(_windowAttr.height / _verticalDecimation) / static_cast(_windowAttr.height); + double scale = std::min(scale_y, scale_x); + + _transform = + { + { + { + XDoubleToFixed(1), + XDoubleToFixed(0), + XDoubleToFixed(0) + }, + { + XDoubleToFixed(0), + XDoubleToFixed(1), + XDoubleToFixed(0) + }, + { + XDoubleToFixed(0), + XDoubleToFixed(0), + XDoubleToFixed(scale) + } + } + }; + + XRenderSetPictureTransform (_x11Display, _srcPicture, &_transform); + + XRenderComposite( _x11Display, // dpy + PictOpSrc, // op + _srcPicture, // src + None, // mask + _dstPicture, // dst + _cropLeft / _horizontalDecimation, // src_x _cropLeft + _cropTop / _verticalDecimation, // src_y _cropTop + 0, // mask_x + 0, // mask_y + 0, // dst_x + 0, // dst_y + _croppedWidth, // width + _croppedHeight); // height + XSync(_x11Display, False); - - if (_XShmAvailable) { + + if (_XShmAvailable) + { XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes); - } else { + } + else + { _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); } - } else { + } + else + { if (_XShmAvailable && !_useXGetImage) { XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes); - } else { + } + else + { _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); } } @@ -164,32 +211,67 @@ Image & X11Grabber::grab() int X11Grabber::grabFrame(Image & image) { - if (_XRenderAvailable && !_useXGetImage) { - XRenderComposite( _x11Display, // *dpy, - PictOpSrc, // op, - _srcPicture, // src - None, // mask - _dstPicture, // dst - _cropLeft, // src_x - _cropTop, // src_y - 0, // mask_x - 0, // mask_y - 0, // dst_x - 0, // dst_y - _croppedWidth, // width - _croppedHeight); // height - + if (_XRenderAvailable && !_useXGetImage) + { + double scale_x = static_cast(_windowAttr.width / _horizontalDecimation) / static_cast(_windowAttr.width); + double scale_y = static_cast(_windowAttr.height / _verticalDecimation) / static_cast(_windowAttr.height); + double scale = std::min(scale_y, scale_x); + + _transform = + { + { + { + XDoubleToFixed(1), + XDoubleToFixed(0), + XDoubleToFixed(0) + }, + { + XDoubleToFixed(0), + XDoubleToFixed(1), + XDoubleToFixed(0) + }, + { + XDoubleToFixed(0), + XDoubleToFixed(0), + XDoubleToFixed(scale) + } + } + }; + + XRenderSetPictureTransform (_x11Display, _srcPicture, &_transform); + + XRenderComposite( _x11Display, // dpy + PictOpSrc, // op + _srcPicture, // src + None, // mask + _dstPicture, // dst + _cropLeft / _horizontalDecimation, // src_x _cropLeft + _cropTop / _verticalDecimation, // src_y _cropTop + 0, // mask_x + 0, // mask_y + 0, // dst_x + 0, // dst_y + _croppedWidth, // width + _croppedHeight); // height + XSync(_x11Display, False); - - if (_XShmAvailable) { + + if (_XShmAvailable) + { XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes); - } else { + } + else + { _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); } - } else { + } + else + { if (_XShmAvailable && !_useXGetImage) { XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes); - } else { + } + else + { _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); } } @@ -220,7 +302,8 @@ int X11Grabber::updateScreenDimensions() return 0; } - if (_screenWidth || _screenHeight) { + if (_screenWidth || _screenHeight) + { freeResources(); } @@ -228,20 +311,33 @@ int X11Grabber::updateScreenDimensions() _screenWidth = _windowAttr.width; _screenHeight = _windowAttr.height; - _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight)) - ? (_screenWidth - _cropLeft - _cropRight) - : _screenWidth; - - _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom)) - ? (_screenHeight - _cropTop - _cropBottom) - : _screenHeight; - - if (_XRenderAvailable && !_useXGetImage) { + // Image scaling is performed by XRender when available, otherwise by ImageResampler + if (_XRenderAvailable && !_useXGetImage) + { + _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight)) + ? ((_screenWidth - _cropLeft - _cropRight) / _horizontalDecimation) + : _screenWidth / _horizontalDecimation; + + _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom)) + ? ((_screenHeight - _cropTop - _cropBottom) / _verticalDecimation) + : _screenHeight / _verticalDecimation; + Info(_log, "Using XRender for grabbing"); - } else { + } + else + { + _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight)) + ? (_screenWidth - _cropLeft - _cropRight) + : _screenWidth; + + _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom)) + ? (_screenHeight - _cropTop - _cropBottom) + : _screenHeight; + Info(_log, "Using XGetImage for grabbing"); } + _image.resize(_croppedWidth, _croppedHeight); setupResources(); return 1; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index aa4cae2a..9cbaf376 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -565,7 +565,6 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) , _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])) , _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])) , _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"])) - , _device(LedDeviceFactory::construct(jsonConfig["device"])) , _effectEngine(nullptr) , _messageForwarder(createMessageForwarder(jsonConfig["forwarder"])) , _jsonConfig(jsonConfig) @@ -575,6 +574,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) , _hwLedCount(_ledString.leds().size()) , _sourceAutoSelectEnabled(true) { + _device = LedDeviceFactory::construct(jsonConfig["device"]); registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY); if (!_raw2ledAdjustment->verifyAdjustments()) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index ab497bd4..527aaa34 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -561,13 +562,16 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &, const st const std::list & activeEffectsDefinitions = _hyperion->getActiveEffects(); for (const ActiveEffectDefinition & activeEffectDefinition : activeEffectsDefinitions) { - Json::Value activeEffect; - activeEffect["script"] = activeEffectDefinition.script; - activeEffect["priority"] = activeEffectDefinition.priority; - activeEffect["timeout"] = activeEffectDefinition.timeout; - activeEffect["args"] = activeEffectDefinition.args; - - activeEffects.append(activeEffect); + if (activeEffectDefinition.priority != PriorityMuxer::LOWEST_PRIORITY -1) + { + Json::Value activeEffect; + activeEffect["script"] = activeEffectDefinition.script; + activeEffect["priority"] = activeEffectDefinition.priority; + activeEffect["timeout"] = activeEffectDefinition.timeout; + activeEffect["args"] = activeEffectDefinition.args; + + activeEffects.append(activeEffect); + } } //////////////////////////////////// @@ -624,21 +628,31 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &, const st << std::hex << unsigned(priorityInfo.ledColors.begin()->blue); LEDcolor["HEX Value"].append(hex.str()); - + activeLedColors.append(LEDcolor); } } } + // get available led devices + info["ledDevices"]["active"] = LedDevice::activeDevice(); + info["ledDevices"]["available"] = Json::Value(Json::arrayValue); + for ( auto dev: LedDevice::getDeviceMap()) + { + info["ledDevices"]["available"].append(dev.first); + } + + // Add Hyperion Version, build time - Json::Value & version = info["hyperion"] = Json::Value(Json::arrayValue); + //Json::Value & version = + info["hyperion"] = Json::Value(Json::arrayValue); Json::Value ver; ver["jsonrpc_version"] = HYPERION_JSON_VERSION; ver["version"] = HYPERION_VERSION; - ver["build"] = HYPERION_BUILD_ID; - ver["time"] = __DATE__ " " __TIME__; + ver["build"] = HYPERION_BUILD_ID; + ver["time"] = __DATE__ " " __TIME__; - version.append(ver); + info["hyperion"].append(ver); // send the result sendMessage(result); @@ -941,7 +955,7 @@ void JsonClientConnection::handleConfigSetCommand(const Json::Value &message, co sendSuccessReply(command, tan); } } else - sendErrorReply("Error while parsing json: Message size " + message.size(), command, tan); + sendErrorReply("Error while parsing json: Message size " + std::to_string(message.size()), command, tan); } void JsonClientConnection::handleComponentStateCommand(const Json::Value& message, const std::string &command, const int tan) diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 2efcca56..4816ccd7 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -15,12 +15,12 @@ include_directories( # Group the headers that go through the MOC compiler SET(Leddevice_QT_HEADERS ${CURRENT_HEADER_DIR}/LedDevice.h - ${CURRENT_SOURCE_DIR}/LedRs232Device.h + ${CURRENT_SOURCE_DIR}/ProviderRs232.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h - ${CURRENT_SOURCE_DIR}/LedHIDDevice.h + ${CURRENT_SOURCE_DIR}/ProviderHID.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ) @@ -34,13 +34,12 @@ SET(Leddevice_HEADERS ${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h ${CURRENT_SOURCE_DIR}/LedDeviceSedu.h ${CURRENT_SOURCE_DIR}/LedDeviceFile.h - ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h - ${CURRENT_SOURCE_DIR}/LedDeviceUdp.h ${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.h ${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.h - ${CURRENT_SOURCE_DIR}/LedUdpDevice.h + ${CURRENT_SOURCE_DIR}/ProviderUdp.h ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.h + ${CURRENT_SOURCE_DIR}/LedDeviceTpm2net.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmo.h ) @@ -48,8 +47,8 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDevice.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp - ${CURRENT_SOURCE_DIR}/LedRs232Device.cpp - ${CURRENT_SOURCE_DIR}/LedHIDDevice.cpp + ${CURRENT_SOURCE_DIR}/ProviderRs232.cpp + ${CURRENT_SOURCE_DIR}/ProviderHID.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp @@ -62,20 +61,20 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp - ${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.cpp - ${CURRENT_SOURCE_DIR}/LedUdpDevice.cpp + ${CURRENT_SOURCE_DIR}/ProviderUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.cpp ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceTpm2net.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAtmo.cpp ) if(ENABLE_SPIDEV) SET(Leddevice_HEADERS ${Leddevice_HEADERS} - ${CURRENT_SOURCE_DIR}/LedSpiDevice.h + ${CURRENT_SOURCE_DIR}/ProviderSpi.h ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.h ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.h ${CURRENT_SOURCE_DIR}/LedDeviceP9813.h @@ -86,7 +85,7 @@ if(ENABLE_SPIDEV) ) SET(Leddevice_SOURCES ${Leddevice_SOURCES} - ${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp + ${CURRENT_SOURCE_DIR}/ProviderSpi.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.cpp ${CURRENT_SOURCE_DIR}/LedDeviceP9813.cpp @@ -131,7 +130,13 @@ if(ENABLE_TINKERFORGE) ) endif() +set(LedDevice_RESOURCES + ${CURRENT_SOURCE_DIR}/LedDeviceSchemas.qrc +) + QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS}) +qt5_add_resources(LedDevice_RESOURCES_RCC ${LedDevice_RESOURCES} OPTIONS "-no-compress") + add_library(leddevice @@ -139,13 +144,14 @@ add_library(leddevice ${Leddevice_QT_HEADERS} ${Leddevice_HEADERS_MOC} ${Leddevice_SOURCES} + ${LedDevice_RESOURCES} + ${LedDevice_RESOURCES_RCC} ) qt5_use_modules(leddevice Network SerialPort) target_link_libraries(leddevice hyperion-utils -# serialport ${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev ${CMAKE_THREAD_LIBS_INIT} ${QT_LIBRARIES} diff --git a/libsrc/leddevice/LedDevice.cpp b/libsrc/leddevice/LedDevice.cpp index 11381238..e38a7d81 100644 --- a/libsrc/leddevice/LedDevice.cpp +++ b/libsrc/leddevice/LedDevice.cpp @@ -1,5 +1,8 @@ #include +LedDeviceRegistry LedDevice::_ledDeviceMap = LedDeviceRegistry(); +std::string LedDevice::_activeDevice = ""; + LedDevice::LedDevice() : QObject() , _log(Logger::getInstance("LedDevice")) @@ -9,8 +12,24 @@ LedDevice::LedDevice() { } +// dummy implemention int LedDevice::open() { - //dummy implemention return 0; } + +int LedDevice::addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr) +{ + _ledDeviceMap.emplace(name,funcPtr); + return 0; +} + +const LedDeviceRegistry& LedDevice::getDeviceMap() +{ + return _ledDeviceMap; +} + +void LedDevice::setActiveDevice(std::string dev) +{ + _activeDevice = dev; +} \ No newline at end of file diff --git a/libsrc/leddevice/LedDeviceAPA102.cpp b/libsrc/leddevice/LedDeviceAPA102.cpp index 0b2bb1b1..b2314b85 100644 --- a/libsrc/leddevice/LedDeviceAPA102.cpp +++ b/libsrc/leddevice/LedDeviceAPA102.cpp @@ -12,9 +12,15 @@ // hyperion local includes #include "LedDeviceAPA102.h" -LedDeviceAPA102::LedDeviceAPA102(const std::string& outputDevice, const unsigned baudrate) - : LedSpiDevice(outputDevice, baudrate, 500000) +LedDeviceAPA102::LedDeviceAPA102(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) { + _latchTime_ns = 500000; +} + +LedDevice* LedDeviceAPA102::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceAPA102(deviceConfig); } int LedDeviceAPA102::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceAPA102.h b/libsrc/leddevice/LedDeviceAPA102.h index 5eb00514..d7411429 100644 --- a/libsrc/leddevice/LedDeviceAPA102.h +++ b/libsrc/leddevice/LedDeviceAPA102.h @@ -4,23 +4,24 @@ #include // hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" +#include /// /// Implementation of the LedDevice interface for writing to APA102 led device. /// -/// APA102 is -/// -class LedDeviceAPA102 : public LedSpiDevice +class LedDeviceAPA102 : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type APA102 + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/dev/spidev.0.0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceAPA102(const std::string& outputDevice, const unsigned baudrate ); + LedDeviceAPA102(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// diff --git a/libsrc/leddevice/LedDeviceAdalight.cpp b/libsrc/leddevice/LedDeviceAdalight.cpp index 880f6690..a2c6ad71 100644 --- a/libsrc/leddevice/LedDeviceAdalight.cpp +++ b/libsrc/leddevice/LedDeviceAdalight.cpp @@ -10,9 +10,10 @@ // hyperion local includes #include "LedDeviceAdalight.h" +#include -LedDeviceAdalight::LedDeviceAdalight(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) - : LedRs232Device(outputDevice, baudrate, delayAfterConnect_ms) +LedDeviceAdalight::LedDeviceAdalight(const Json::Value &deviceConfig) + : ProviderRs232(deviceConfig) , _timer() { // setup the timer @@ -24,6 +25,11 @@ LedDeviceAdalight::LedDeviceAdalight(const std::string& outputDevice, const unsi _timer.start(); } +LedDevice* LedDeviceAdalight::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceAdalight(deviceConfig); +} + int LedDeviceAdalight::write(const std::vector & ledValues) { if (_ledBuffer.size() == 0) diff --git a/libsrc/leddevice/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h index 2f8aab60..35a9f4af 100644 --- a/libsrc/leddevice/LedDeviceAdalight.h +++ b/libsrc/leddevice/LedDeviceAdalight.h @@ -7,23 +7,25 @@ #include // hyperion include -#include "LedRs232Device.h" +#include "ProviderRs232.h" /// /// Implementation of the LedDevice interface for writing to an Adalight led device. /// -class LedDeviceAdalight : public LedRs232Device +class LedDeviceAdalight : public ProviderRs232 { Q_OBJECT public: /// - /// Constructs the LedDevice for attached Adalight device + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/dev/ttyS0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceAdalight(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms); + LedDeviceAdalight(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device @@ -46,3 +48,4 @@ protected: /// every 15 seconds QTimer _timer; }; + diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.cpp b/libsrc/leddevice/LedDeviceAdalightApa102.cpp index c72cbc3b..ccc273a2 100644 --- a/libsrc/leddevice/LedDeviceAdalightApa102.cpp +++ b/libsrc/leddevice/LedDeviceAdalightApa102.cpp @@ -11,11 +11,17 @@ // hyperion local includes #include "LedDeviceAdalightApa102.h" -LedDeviceAdalightApa102::LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) - : LedDeviceAdalight(outputDevice, baudrate, delayAfterConnect_ms) +LedDeviceAdalightApa102::LedDeviceAdalightApa102(const Json::Value &deviceConfig) + : LedDeviceAdalight(deviceConfig) { } +LedDevice* LedDeviceAdalightApa102::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceAdalightApa102(deviceConfig); +} + + //comparing to ws2801 adalight, the following changes were needed: // 1- differnt data frame (4 bytes instead of 3) // 2 - in order to accomodate point 1 above, number of leds sent to adalight is increased by 1/3rd diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.h b/libsrc/leddevice/LedDeviceAdalightApa102.h index dfdd99c2..d452d771 100644 --- a/libsrc/leddevice/LedDeviceAdalightApa102.h +++ b/libsrc/leddevice/LedDeviceAdalightApa102.h @@ -20,7 +20,10 @@ public: /// @param outputDevice The name of the output device (eg '/dev/ttyS0') /// @param baudrate The used baudrate for writing to the output device /// - LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms); + LedDeviceAdalightApa102(const Json::Value &deviceConfig); + + /// create leddevice when type in config is set to this type + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device @@ -33,3 +36,4 @@ public: /// Switch the leds off virtual int switchOff(); }; + diff --git a/libsrc/leddevice/LedDeviceAtmo.cpp b/libsrc/leddevice/LedDeviceAtmo.cpp index 74d7f044..b4467a8d 100644 --- a/libsrc/leddevice/LedDeviceAtmo.cpp +++ b/libsrc/leddevice/LedDeviceAtmo.cpp @@ -1,8 +1,8 @@ // hyperion local includes #include "LedDeviceAtmo.h" -LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate) - : LedRs232Device(outputDevice, baudrate) +LedDeviceAtmo::LedDeviceAtmo(const Json::Value &deviceConfig) + : ProviderRs232(deviceConfig) { _ledBuffer.resize(4 + 5*3); // 4-byte header, 5 RGB values _ledBuffer[0] = 0xFF; // Startbyte @@ -11,6 +11,12 @@ LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned bau _ledBuffer[3] = 0x0F; // Number of Databytes send (always! 15) } +LedDevice* LedDeviceAtmo::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceAtmo(deviceConfig); +} + + int LedDeviceAtmo::write(const std::vector &ledValues) { // The protocol is shomehow limited. we always need to send exactly 5 channels + header diff --git a/libsrc/leddevice/LedDeviceAtmo.h b/libsrc/leddevice/LedDeviceAtmo.h index 85f05c6e..8bb54cdf 100644 --- a/libsrc/leddevice/LedDeviceAtmo.h +++ b/libsrc/leddevice/LedDeviceAtmo.h @@ -4,22 +4,23 @@ #include // hyperion incluse -#include "LedRs232Device.h" +#include "ProviderRs232.h" /// /// Implementation of the LedDevice interface for writing to serial device using tpm2 protocol. /// -class LedDeviceAtmo : public LedRs232Device +class LedDeviceAtmo : public ProviderRs232 { public: /// - /// Constructs the LedDevice for attached serial device using supporting tpm2 protocol - /// All LEDs in the stripe are handled as one frame + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/dev/ttyAMA0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate); + LedDeviceAtmo(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp index 28fc48d1..79c339a1 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.cpp +++ b/libsrc/leddevice/LedDeviceAtmoOrb.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -15,23 +16,10 @@ AtmoOrbLight::AtmoOrbLight(unsigned int id) { // Not implemented } -LedDeviceAtmoOrb::LedDeviceAtmoOrb( - const std::string &output, - bool useOrbSmoothing, - int transitiontime, - int skipSmoothingDiff, - int port, - int numLeds, - std::vector orbIds) +LedDeviceAtmoOrb::LedDeviceAtmoOrb(const Json::Value &deviceConfig) : LedDevice() - , _multicastGroup(output.c_str()) - , _useOrbSmoothing(useOrbSmoothing) - , _transitiontime(transitiontime) - , _skipSmoothingDiff(skipSmoothingDiff) - , _multiCastGroupPort(port) - , _numLeds(numLeds) - , _orbIds(orbIds) { + setConfig(deviceConfig); _manager = new QNetworkAccessManager(); _groupAddress = QHostAddress(_multicastGroup); @@ -41,6 +29,44 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb( joinedMulticastgroup = _udpSocket->joinMulticastGroup(_groupAddress); } +bool LedDeviceAtmoOrb::setConfig(const Json::Value &deviceConfig) +{ + _multicastGroup = deviceConfig["output"].asString().c_str(); + _useOrbSmoothing = deviceConfig.get("useOrbSmoothing", false).asBool(); + _transitiontime = deviceConfig.get("transitiontime", 0).asInt(); + _skipSmoothingDiff = deviceConfig.get("skipSmoothingDiff", 0).asInt(); + _multiCastGroupPort = deviceConfig.get("port", 49692).asInt(); + _numLeds = deviceConfig.get("numLeds", 24).asInt(); + + const std::string orbId = deviceConfig["orbIds"].asString(); + _orbIds.clear(); + + // If we find multiple Orb ids separate them and add to list + const std::string separator (","); + if (orbId.find(separator) != std::string::npos) + { + std::stringstream ss(orbId); + std::vector output; + unsigned int i; + while (ss >> i) + { + _orbIds.push_back(i); + if (ss.peek() == ',' || ss.peek() == ' ') ss.ignore(); + } + } + else + { + _orbIds.push_back(atoi(orbId.c_str())); + } + + return true; +} + +LedDevice* LedDeviceAtmoOrb::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceAtmoOrb(deviceConfig); +} + int LedDeviceAtmoOrb::write(const std::vector &ledValues) { // If not in multicast group return diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.h b/libsrc/leddevice/LedDeviceAtmoOrb.h index d11127f1..e76fe067 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.h +++ b/libsrc/leddevice/LedDeviceAtmoOrb.h @@ -45,20 +45,21 @@ public: bool joinedMulticastgroup; /// - /// Constructs the device. + /// Constructs specific LedDevice /// - /// @param output is the multicast address of Orbs - /// @param transitiontime is optional and not used at the moment - /// @param useOrbSmoothing use Orbs own (external) smoothing algorithm (default: false) - /// @param skipSmoothingDiff minimal color (0-255) difference to override smoothing so that if current and previously received colors are higher than set dif we override smoothing - /// @param port is the multicast port. - /// @param numLeds is the total amount of leds per Orb - /// @param array containing orb ids + /// @param deviceConfig json device config /// - LedDeviceAtmoOrb(const std::string &output, bool useOrbSmoothing = - false, int transitiontime = 0, int skipSmoothingDiff = 0, int port = 49692, int numLeds = 24, - std::vector orbIds = std::vector()); + LedDeviceAtmoOrb(const Json::Value &deviceConfig); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Destructor of this device /// diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index cb733a44..b4baa439 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // Build configuration #include @@ -10,6 +11,7 @@ // Leddevice includes #include #include +#include // Local Leddevice includes #ifdef ENABLE_SPIDEV @@ -35,7 +37,7 @@ #include "LedDeviceSedu.h" #include "LedDeviceFile.h" #include "LedDeviceFadeCandy.h" -#include "LedDeviceUdp.h" +#include "LedDeviceTpm2net.h" #include "LedDeviceUdpRaw.h" #include "LedDeviceUdpE131.h" #include "LedDeviceHyperionUsbasp.h" @@ -63,281 +65,81 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) std::string type = deviceConfig.get("type", "UNSPECIFIED").asString(); std::transform(type.begin(), type.end(), type.begin(), ::tolower); + // rs232 devices + LedDevice::addToDeviceMap("adalight" , LedDeviceAdalight::construct); + LedDevice::addToDeviceMap("adalightapa102", LedDeviceAdalightApa102::construct); + LedDevice::addToDeviceMap("sedu" , LedDeviceSedu::construct); + LedDevice::addToDeviceMap("tpm2" , LedDeviceTpm2::construct); + LedDevice::addToDeviceMap("atmo" , LedDeviceAtmo::construct); + LedDevice::addToDeviceMap("fadecandy" , LedDeviceFadeCandy::construct); + + // spi devices + #ifdef ENABLE_SPIDEV + LedDevice::addToDeviceMap("apa102" , LedDeviceAPA102::construct); + LedDevice::addToDeviceMap("lpd6803" , LedDeviceLpd6803::construct); + LedDevice::addToDeviceMap("lpd8806" , LedDeviceLpd8806::construct); + LedDevice::addToDeviceMap("p9813" , LedDeviceP9813::construct); + LedDevice::addToDeviceMap("ws2801" , LedDeviceWs2801::construct); + LedDevice::addToDeviceMap("ws2812spi" , LedDeviceWs2812SPI::construct); + LedDevice::addToDeviceMap("sk6812rgbw-spi", LedDeviceSk6812SPI::construct); + #endif + + // pwm devices + #ifdef ENABLE_WS2812BPWM + LedDevice::addToDeviceMap("ws2812b", LedDeviceWS2812b::construct); + #endif + #ifdef ENABLE_WS281XPWM + LedDevice::addToDeviceMap("ws281x", LedDeviceWS281x::construct); + #endif + + // network lights + LedDevice::addToDeviceMap("tmp2net", LedDeviceTpm2net::construct); + LedDevice::addToDeviceMap("udpraw", LedDeviceUdpRaw::construct); + LedDevice::addToDeviceMap("e131", LedDeviceUdpE131::construct); + #ifdef ENABLE_TINKERFORGE + LedDevice::addToDeviceMap("tinkerforge", LedDeviceTinkerforge::construct); + #endif + LedDevice::addToDeviceMap("philipshue", LedDevicePhilipsHue::construct); + LedDevice::addToDeviceMap("atmoorb", LedDeviceAtmoOrb::construct); + + // direct usb + LedDevice::addToDeviceMap("hyperion-usbasp", LedDeviceHyperionUsbasp::construct); + LedDevice::addToDeviceMap("rawhid", LedDeviceRawHID::construct); + LedDevice::addToDeviceMap("paintpack", LedDevicePaintpack::construct); + LedDevice::addToDeviceMap("lightpack", LedDeviceLightpack::construct); + LedDevice::addToDeviceMap("multi-lightpack", LedDeviceMultiLightpack::construct); + + // other + LedDevice::addToDeviceMap("file", LedDeviceFile::construct); + LedDevice::addToDeviceMap("piblaster", LedDevicePiBlaster::construct); + + const LedDeviceRegistry& devList = LedDevice::getDeviceMap(); LedDevice* device = nullptr; try { - if (false) {} - else if (type == "adalight") + for ( auto dev: devList) { - device = new LedDeviceAdalight( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt(), - deviceConfig.get("delayAfterConnect",500).asInt() - ); - } - else if (type == "adalightapa102") - { - device = new LedDeviceAdalightApa102( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt(), - deviceConfig.get("delayAfterConnect",500).asInt() - ); - } - #ifdef ENABLE_SPIDEV - else if (type == "lpd6803" || type == "ldp6803") - { - device = new LedDeviceLpd6803( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "lpd8806" || type == "ldp8806") - { - device = new LedDeviceLpd8806( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "p9813") - { - device = new LedDeviceP9813( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "apa102") - { - device = new LedDeviceAPA102( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "ws2801" || type == "lightberry") - { - device = new LedDeviceWs2801( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt(), - deviceConfig.get("latchtime",500000).asInt(), - deviceConfig.get("spimode",0).asInt(), - deviceConfig.get("invert",false).asBool() - ); - } - else if (type == "ws2812spi") - { - device = new LedDeviceWs2812SPI( - deviceConfig["output"].asString(), - deviceConfig.get("rate",2857143).asInt(), - deviceConfig.get("spimode",0).asInt(), - deviceConfig.get("invert",false).asBool() - ); - } - else if (type == "sk6812rgbw-spi") - { - device = new LedDeviceSk6812SPI( - deviceConfig["output"].asString(), - deviceConfig.get("rate",2857143).asInt(), - deviceConfig.get("white_algorithm","").asString(), - deviceConfig.get("spimode",0).asInt(), - deviceConfig.get("invert",false).asBool() - ); - } - #endif - #ifdef ENABLE_TINKERFORGE - else if (type=="tinkerforge") - { - device = new LedDeviceTinkerforge( - deviceConfig.get("output", "127.0.0.1").asString(), - deviceConfig.get("port", 4223).asInt(), - deviceConfig["uid"].asString(), - deviceConfig["rate"].asInt() - ); - - } - #endif - else if (type == "rawhid") - { - const int delay_ms = deviceConfig["delayAfterConnect"].asInt(); - auto VendorIdString = deviceConfig.get("VID", "0x2341").asString(); - auto ProductIdString = deviceConfig.get("PID", "0x8036").asString(); - - // Convert HEX values to integer - auto VendorId = std::stoul(VendorIdString, nullptr, 16); - auto ProductId = std::stoul(ProductIdString, nullptr, 16); - - device = new LedDeviceRawHID(VendorId, ProductId, delay_ms); - } - else if (type == "lightpack") - { - device = new LedDeviceLightpack( - deviceConfig.get("output", "").asString() - ); - } - else if (type == "multi-lightpack") - { - device = new LedDeviceMultiLightpack(); - } - else if (type == "paintpack") - { - const int delay_ms = deviceConfig["delayAfterConnect"].asInt(); - auto VendorIdString = deviceConfig.get("VID", "0x0EBF").asString(); - auto ProductIdString = deviceConfig.get("PID", "0x0025").asString(); - - // Convert HEX values to integer - auto VendorId = std::stoul(VendorIdString, nullptr, 16); - auto ProductId = std::stoul(ProductIdString, nullptr, 16); - - device = new LedDevicePaintpack(VendorId, ProductId, delay_ms); - } - else if (type == "piblaster") - { - const std::string output = deviceConfig.get("output", "").asString(); - const std::string assignment = deviceConfig.get("assignment", "").asString(); - const Json::Value gpioMapping = deviceConfig.get("gpiomap", Json::nullValue); - - if (! assignment.empty()) + if (dev.first == type) { - throw std::runtime_error("Piblaster: The piblaster configuration syntax has changed in this version."); + device = dev.second(deviceConfig); + LedDevice::setActiveDevice(dev.first); + Info(log,"LedDevice '%s' configured.", dev.first.c_str()); + break; } - if (gpioMapping.isNull()) - { - throw std::runtime_error("Piblaster: no gpiomap defined."); - } - device = new LedDevicePiBlaster(output, gpioMapping); } - else if (type == "sedu") - { - device = new LedDeviceSedu( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "hyperion-usbasp-ws2801") - { - device = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2801); - } - else if (type == "hyperion-usbasp-ws2812") - { - device = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2812); - } - else if (type == "philipshue") - { - const std::string output = deviceConfig["output"].asString(); - const std::string username = deviceConfig.get("username", "newdeveloper").asString(); - const bool switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool(); - const int transitiontime = deviceConfig.get("transitiontime", 1).asInt(); - std::vector lightIds; - for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) { - lightIds.push_back(deviceConfig["lightIds"][i].asInt()); - } - device = new LedDevicePhilipsHue(output, username, switchOffOnBlack, transitiontime, lightIds); - } - else if (type == "atmoorb") - { - const std::string output = deviceConfig["output"].asString(); - const bool useOrbSmoothing = deviceConfig.get("useOrbSmoothing", false).asBool(); - const int transitiontime = deviceConfig.get("transitiontime", 1).asInt(); - const int skipSmoothingDiff = deviceConfig.get("skipSmoothingDiff", 0).asInt(); - const int port = deviceConfig.get("port", 1).asInt(); - const int numLeds = deviceConfig.get("numLeds", 1).asInt(); - const std::string orbId = deviceConfig["orbIds"].asString(); - std::vector orbIds; - - // If we find multiple Orb ids separate them and add to list - const std::string separator (","); - if (orbId.find(separator) != std::string::npos) { - std::stringstream ss(orbId); - std::vector output; - unsigned int i; - while (ss >> i) { - orbIds.push_back(i); - if (ss.peek() == ',' || ss.peek() == ' ') - ss.ignore(); - } - } - else - { - orbIds.push_back(atoi(orbId.c_str())); - } - - device = new LedDeviceAtmoOrb(output, useOrbSmoothing, transitiontime, skipSmoothingDiff, port, numLeds, orbIds); - } - else if (type == "fadecandy") - { - device = new LedDeviceFadeCandy(deviceConfig); - } - else if (type == "udp") - { - device = new LedDeviceUdp( - deviceConfig["output"].asString(), - deviceConfig["protocol"].asInt(), - deviceConfig["maxpacket"].asInt() - ); - } - else if (type == "udpraw") - { - device = new LedDeviceUdpRaw( - deviceConfig["output"].asString(), - deviceConfig.get("latchtime",500000).asInt() - ); - } - else if (type == "e131") - { - device = new LedDeviceUdpE131( - deviceConfig["output"].asString(), - deviceConfig.get("latchtime",500000).asInt(), - deviceConfig.get("universe",1).asInt() - ); - } - else if (type == "tpm2") - { - device = new LedDeviceTpm2( - deviceConfig["output"].asString(), - deviceConfig["rate"].asInt() - ); - } - else if (type == "atmo") - { - device = new LedDeviceAtmo( - deviceConfig["output"].asString(), - 38400 - ); - } - #ifdef ENABLE_WS2812BPWM - else if (type == "ws2812b") - { - device = new LedDeviceWS2812b(); - } - #endif - #ifdef ENABLE_WS281XPWM - else if (type == "ws281x") - { - device = new LedDeviceWS281x( - deviceConfig.get("gpio", 18).asInt(), - deviceConfig.get("leds", 256).asInt(), - deviceConfig.get("freq", (Json::UInt)800000ul).asInt(), - deviceConfig.get("dmanum", 5).asInt(), - deviceConfig.get("pwmchannel", 0).asInt(), - deviceConfig.get("invert", 0).asInt(), - deviceConfig.get("rgbw", 0).asInt(), - deviceConfig.get("white_algorithm","").asString() - ); - } - #endif - else if (type == "file") - { - device = new LedDeviceFile( deviceConfig.get("output", "/dev/null").asString() ); - } - else + + if (device == nullptr) { Error(log, "Dummy device used, because configured device '%s' is unknown", type.c_str() ); throw std::runtime_error("unknown device"); } } - catch(std::exception e) + catch(std::exception& e) { Error(log, "Dummy device used, because configured device '%s' throws error '%s'", type.c_str(), e.what()); - device = new LedDeviceFile( "/dev/null" ); + const Json::Value dummyDeviceConfig; + device = LedDeviceFile::construct(Json::nullValue); } device->open(); diff --git a/libsrc/leddevice/LedDeviceFadeCandy.cpp b/libsrc/leddevice/LedDeviceFadeCandy.cpp index f71d02c9..671bde35 100644 --- a/libsrc/leddevice/LedDeviceFadeCandy.cpp +++ b/libsrc/leddevice/LedDeviceFadeCandy.cpp @@ -1,6 +1,6 @@ #include "LedDeviceFadeCandy.h" -static const signed MAX_NUM_LEDS = 10000; // OPC can handle 21845 leds - in theory, fadecandy device should handle 10000 leds +static const signed MAX_NUM_LEDS = 10000; // OPC can handle 21845 leds - in theory, fadecandy device should handle 10000 leds static const unsigned OPC_SET_PIXELS = 0; // OPC command codes static const unsigned OPC_SYS_EX = 255; // OPC command codes static const unsigned OPC_HEADER_SIZE = 4; // OPC header size @@ -10,13 +10,6 @@ LedDeviceFadeCandy::LedDeviceFadeCandy(const Json::Value &deviceConfig) : LedDevice() { setConfig(deviceConfig); - _opc_data.resize( OPC_HEADER_SIZE ); - _opc_data[0] = _channel; - _opc_data[1] = OPC_SET_PIXELS; - _opc_data[2] = 0; - _opc_data[3] = 0; - - } @@ -25,8 +18,16 @@ LedDeviceFadeCandy::~LedDeviceFadeCandy() _client.close(); } +LedDevice* LedDeviceFadeCandy::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceFadeCandy(deviceConfig); +} + + bool LedDeviceFadeCandy::setConfig(const Json::Value &deviceConfig) { + _client.close(); + _host = deviceConfig.get("output", "127.0.0.1").asString(); _port = deviceConfig.get("port", 7890).asInt(); _channel = deviceConfig.get("channel", 0).asInt(); @@ -49,6 +50,12 @@ bool LedDeviceFadeCandy::setConfig(const Json::Value &deviceConfig) _whitePoint_b = whitePointConfig[2].asDouble(); } + _opc_data.resize( OPC_HEADER_SIZE ); + _opc_data[0] = _channel; + _opc_data[1] = OPC_SET_PIXELS; + _opc_data[2] = 0; + _opc_data[3] = 0; + return true; } diff --git a/libsrc/leddevice/LedDeviceFadeCandy.h b/libsrc/leddevice/LedDeviceFadeCandy.h index 7a534cee..cd55958c 100644 --- a/libsrc/leddevice/LedDeviceFadeCandy.h +++ b/libsrc/leddevice/LedDeviceFadeCandy.h @@ -7,7 +7,6 @@ // Leddevice includes #include -#include /// /// Implementation of the LedDevice interface for sending to @@ -48,6 +47,9 @@ public: /// virtual ~LedDeviceFadeCandy(); + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// /// Sets configuration /// @@ -66,7 +68,6 @@ public: /// Switch the leds off virtual int switchOff(); - private: QTcpSocket _client; std::string _host; @@ -115,3 +116,4 @@ private: void sendFadeCandyConfiguration(); }; + diff --git a/libsrc/leddevice/LedDeviceFile.cpp b/libsrc/leddevice/LedDeviceFile.cpp index 3f60b40b..93ad3022 100644 --- a/libsrc/leddevice/LedDeviceFile.cpp +++ b/libsrc/leddevice/LedDeviceFile.cpp @@ -2,16 +2,32 @@ // Local-Hyperion includes #include "LedDeviceFile.h" -LedDeviceFile::LedDeviceFile(const std::string& output) +LedDeviceFile::LedDeviceFile(const Json::Value &deviceConfig) : LedDevice() - , _ofs( output.empty() ? "/dev/null" : output.c_str()) { - // empty + setConfig(deviceConfig); } LedDeviceFile::~LedDeviceFile() { - // empty +} + +LedDevice* LedDeviceFile::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceFile(deviceConfig); +} + +bool LedDeviceFile::setConfig(const Json::Value &deviceConfig) +{ + if ( _ofs.is_open() ) + { + _ofs.close(); + } + + std::string fileName = deviceConfig.get("output","/dev/null").asString(); + _ofs.open( fileName.c_str() ); + + return true; } int LedDeviceFile::write(const std::vector & ledValues) diff --git a/libsrc/leddevice/LedDeviceFile.h b/libsrc/leddevice/LedDeviceFile.h index ef7a54f7..282a7110 100644 --- a/libsrc/leddevice/LedDeviceFile.h +++ b/libsrc/leddevice/LedDeviceFile.h @@ -14,15 +14,27 @@ class LedDeviceFile : public LedDevice { public: /// - /// Constructs the test-device, which opens an output stream to the file + /// Constructs specific LedDevice /// - LedDeviceFile(const std::string& output); + /// @param deviceConfig json device config + /// + LedDeviceFile(const Json::Value &deviceConfig); /// /// Destructor of this test-device /// virtual ~LedDeviceFile(); + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + virtual bool setConfig(const Json::Value &deviceConfig); + /// /// Writes the given led-color values to the output stream /// diff --git a/libsrc/leddevice/LedDeviceHyperionUsbasp.cpp b/libsrc/leddevice/LedDeviceHyperionUsbasp.cpp index add361a9..f3aa6aaa 100644 --- a/libsrc/leddevice/LedDeviceHyperionUsbasp.cpp +++ b/libsrc/leddevice/LedDeviceHyperionUsbasp.cpp @@ -11,12 +11,12 @@ uint16_t LedDeviceHyperionUsbasp::_usbProductId = 0x05dc; std::string LedDeviceHyperionUsbasp::_usbProductDescription = "Hyperion led controller"; -LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(uint8_t writeLedsCommand) +LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(const Json::Value &deviceConfig) : LedDevice() - , _writeLedsCommand(writeLedsCommand) , _libusbContext(nullptr) , _deviceHandle(nullptr) { + setConfig(deviceConfig); } LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp() @@ -37,6 +37,25 @@ LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp() } } +bool LedDeviceHyperionUsbasp::setConfig(const Json::Value &deviceConfig) +{ + std::string ledType = deviceConfig.get("output", "ws2801").asString(); + if (ledType != "ws2801" && ledType != "ws2812") + { + throw std::runtime_error("HyperionUsbasp: invalid output; must be 'ws2801' or 'ws2812'."); + } + + _writeLedsCommand = (ledType == "ws2801") ? CMD_WRITE_WS2801 : CMD_WRITE_WS2812; + + return true; +} + +LedDevice* LedDeviceHyperionUsbasp::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceHyperionUsbasp(deviceConfig); +} + + int LedDeviceHyperionUsbasp::open() { int error; diff --git a/libsrc/leddevice/LedDeviceHyperionUsbasp.h b/libsrc/leddevice/LedDeviceHyperionUsbasp.h index 1471f1bd..7e9d0da2 100644 --- a/libsrc/leddevice/LedDeviceHyperionUsbasp.h +++ b/libsrc/leddevice/LedDeviceHyperionUsbasp.h @@ -24,9 +24,21 @@ public: }; /// - /// Constructs the LedDeviceLightpack + /// Constructs specific LedDevice /// - LedDeviceHyperionUsbasp(uint8_t writeLedsCommand); + /// @param deviceConfig json device config + /// + LedDeviceHyperionUsbasp(const Json::Value &deviceConfig); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open @@ -70,7 +82,7 @@ private: private: /// command to write the leds - const uint8_t _writeLedsCommand; + uint8_t _writeLedsCommand; /// libusb context libusb_context * _libusbContext; diff --git a/libsrc/leddevice/LedDeviceLightpack.cpp b/libsrc/leddevice/LedDeviceLightpack.cpp index 43fc6fd3..80677244 100644 --- a/libsrc/leddevice/LedDeviceLightpack.cpp +++ b/libsrc/leddevice/LedDeviceLightpack.cpp @@ -45,6 +45,12 @@ LedDeviceLightpack::LedDeviceLightpack(const std::string & serialNumber) _ledCount = -1; } +LedDeviceLightpack::LedDeviceLightpack(const Json::Value &deviceConfig) + : LedDeviceLightpack() +{ + setConfig(deviceConfig); +} + LedDeviceLightpack::~LedDeviceLightpack() { if (_deviceHandle != nullptr) @@ -63,6 +69,18 @@ LedDeviceLightpack::~LedDeviceLightpack() } } +bool LedDeviceLightpack::setConfig(const Json::Value &deviceConfig) +{ + _serialNumber = deviceConfig.get("output", "").asString(); + + return true; +} + +LedDevice* LedDeviceLightpack::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceLightpack(deviceConfig); +} + int LedDeviceLightpack::open() { int error; diff --git a/libsrc/leddevice/LedDeviceLightpack.h b/libsrc/leddevice/LedDeviceLightpack.h index 9c2f48b6..8c530094 100644 --- a/libsrc/leddevice/LedDeviceLightpack.h +++ b/libsrc/leddevice/LedDeviceLightpack.h @@ -23,6 +23,22 @@ public: /// @param serialNumber serial output device /// LedDeviceLightpack(const std::string & serialNumber = ""); + /// + /// Constructs specific LedDevice + /// + /// @param deviceConfig json device config + /// + LedDeviceLightpack(const Json::Value &deviceConfig); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open diff --git a/libsrc/leddevice/LedDeviceLpd6803.cpp b/libsrc/leddevice/LedDeviceLpd6803.cpp index 53f26950..37559ef7 100644 --- a/libsrc/leddevice/LedDeviceLpd6803.cpp +++ b/libsrc/leddevice/LedDeviceLpd6803.cpp @@ -10,11 +10,16 @@ // hyperion local includes #include "LedDeviceLpd6803.h" -LedDeviceLpd6803::LedDeviceLpd6803(const std::string& outputDevice, const unsigned baudrate) - : LedSpiDevice(outputDevice, baudrate) +LedDeviceLpd6803::LedDeviceLpd6803(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) { } +LedDevice* LedDeviceLpd6803::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceLpd6803(deviceConfig); +} + int LedDeviceLpd6803::write(const std::vector &ledValues) { unsigned messageLength = 4 + 2*ledValues.size() + ledValues.size()/8 + 1; diff --git a/libsrc/leddevice/LedDeviceLpd6803.h b/libsrc/leddevice/LedDeviceLpd6803.h index 3ec28ed5..ff228912 100644 --- a/libsrc/leddevice/LedDeviceLpd6803.h +++ b/libsrc/leddevice/LedDeviceLpd6803.h @@ -1,7 +1,7 @@ #pragma once // Local hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to LDP6803 led device. @@ -14,16 +14,18 @@ /// (R, G and B in the above illustration) making 16 bits per led. Total bytes = 4 + (2 x number of /// leds) /// -class LedDeviceLpd6803 : public LedSpiDevice +class LedDeviceLpd6803 : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type LDP6803 + /// Constructs specific LedDevice /// - /// @param[in] outputDevice The name of the output device (eg '/dev/spidev0.0') - /// @param[in] baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceLpd6803(const std::string& outputDevice, const unsigned baudrate); + LedDeviceLpd6803(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceLpd8806.cpp b/libsrc/leddevice/LedDeviceLpd8806.cpp index 62cc8e36..1c95d752 100644 --- a/libsrc/leddevice/LedDeviceLpd8806.cpp +++ b/libsrc/leddevice/LedDeviceLpd8806.cpp @@ -10,10 +10,14 @@ // hyperion local includes #include "LedDeviceLpd8806.h" -LedDeviceLpd8806::LedDeviceLpd8806(const std::string& outputDevice, const unsigned baudrate) - : LedSpiDevice(outputDevice, baudrate) +LedDeviceLpd8806::LedDeviceLpd8806(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) { - // empty +} + +LedDevice* LedDeviceLpd8806::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceLpd8806(deviceConfig); } int LedDeviceLpd8806::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceLpd8806.h b/libsrc/leddevice/LedDeviceLpd8806.h index 114747b3..e4b7803a 100644 --- a/libsrc/leddevice/LedDeviceLpd8806.h +++ b/libsrc/leddevice/LedDeviceLpd8806.h @@ -1,7 +1,7 @@ #pragma once // Local hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to LPD8806 led device. @@ -75,16 +75,18 @@ /// /// The number of zeroes in the 'clear data' is (#led/32 + 1)bytes (or *8 for bits) /// -class LedDeviceLpd8806 : public LedSpiDevice +class LedDeviceLpd8806 : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type LPD8806 + /// Constructs specific LedDevice /// - /// @param[in] outputDevice The name of the output device (eg '/dev/spidev0.0') - /// @param[in] baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceLpd8806(const std::string& outputDevice, const unsigned baudrate); + LedDeviceLpd8806(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceMultiLightpack.cpp b/libsrc/leddevice/LedDeviceMultiLightpack.cpp index 1104f5bf..2092bcb1 100644 --- a/libsrc/leddevice/LedDeviceMultiLightpack.cpp +++ b/libsrc/leddevice/LedDeviceMultiLightpack.cpp @@ -17,7 +17,7 @@ bool compareLightpacks(LedDeviceLightpack * lhs, LedDeviceLightpack * rhs) return lhs->getSerialNumber() < rhs->getSerialNumber(); } -LedDeviceMultiLightpack::LedDeviceMultiLightpack() +LedDeviceMultiLightpack::LedDeviceMultiLightpack(const Json::Value &) : LedDevice() , _lightpacks() { @@ -31,6 +31,11 @@ LedDeviceMultiLightpack::~LedDeviceMultiLightpack() } } +LedDevice* LedDeviceMultiLightpack::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceMultiLightpack(deviceConfig); +} + int LedDeviceMultiLightpack::open() { // retrieve a list with Lightpack serials diff --git a/libsrc/leddevice/LedDeviceMultiLightpack.h b/libsrc/leddevice/LedDeviceMultiLightpack.h index 65e0d1d6..858e9cd9 100644 --- a/libsrc/leddevice/LedDeviceMultiLightpack.h +++ b/libsrc/leddevice/LedDeviceMultiLightpack.h @@ -20,15 +20,20 @@ class LedDeviceMultiLightpack : public LedDevice { public: /// - /// Constructs the LedDeviceMultiLightpack + /// Constructs specific LedDevice /// - LedDeviceMultiLightpack(); + /// @param deviceConfig json device config + /// + LedDeviceMultiLightpack(const Json::Value &); /// /// Destructor of the LedDevice; closes the output device if it is open /// virtual ~LedDeviceMultiLightpack(); + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// /// Opens and configures the output device7 /// diff --git a/libsrc/leddevice/LedDeviceP9813.cpp b/libsrc/leddevice/LedDeviceP9813.cpp index d3142465..1305aa09 100644 --- a/libsrc/leddevice/LedDeviceP9813.cpp +++ b/libsrc/leddevice/LedDeviceP9813.cpp @@ -11,10 +11,14 @@ // hyperion local includes #include "LedDeviceP9813.h" -LedDeviceP9813::LedDeviceP9813(const std::string& outputDevice, const unsigned baudrate) - : LedSpiDevice(outputDevice, baudrate, 0) +LedDeviceP9813::LedDeviceP9813(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) { - // empty +} + +LedDevice* LedDeviceP9813::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceP9813(deviceConfig); } int LedDeviceP9813::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceP9813.h b/libsrc/leddevice/LedDeviceP9813.h index 97fba0e0..06b01b4d 100644 --- a/libsrc/leddevice/LedDeviceP9813.h +++ b/libsrc/leddevice/LedDeviceP9813.h @@ -4,21 +4,23 @@ #include // hyperion include -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to P9813 led device. /// -class LedDeviceP9813 : public LedSpiDevice +class LedDeviceP9813 : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type P9813 + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/etc/SpiDev.0.0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceP9813(const std::string& outputDevice, const unsigned baudrate); + LedDeviceP9813(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDevicePaintpack.cpp b/libsrc/leddevice/LedDevicePaintpack.cpp index b97665e8..15ed5c05 100644 --- a/libsrc/leddevice/LedDevicePaintpack.cpp +++ b/libsrc/leddevice/LedDevicePaintpack.cpp @@ -3,12 +3,16 @@ #include "LedDevicePaintpack.h" // Use out report HID device -LedDevicePaintpack::LedDevicePaintpack(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms) - : LedHIDDevice(VendorId, ProductId, delayAfterConnect_ms, false) +LedDevicePaintpack::LedDevicePaintpack(const Json::Value &deviceConfig) + : ProviderHID(deviceConfig) { - // empty + _useFeature = false; } +LedDevice* LedDevicePaintpack::construct(const Json::Value &deviceConfig) +{ + return new LedDevicePaintpack(deviceConfig); +} int LedDevicePaintpack::write(const std::vector & ledValues) { diff --git a/libsrc/leddevice/LedDevicePaintpack.h b/libsrc/leddevice/LedDevicePaintpack.h index d535c262..8a0c54fa 100644 --- a/libsrc/leddevice/LedDevicePaintpack.h +++ b/libsrc/leddevice/LedDevicePaintpack.h @@ -4,18 +4,23 @@ #include // Hyperion includes -#include "LedHIDDevice.h" +#include "ProviderHID.h" /// /// LedDevice implementation for a paintpack device () /// -class LedDevicePaintpack : public LedHIDDevice +class LedDevicePaintpack : public ProviderHID { public: - /** - * Constructs the paintpack device - */ - LedDevicePaintpack(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms); + /// + /// Constructs specific LedDevice + /// + /// @param deviceConfig json device config + /// + LedDevicePaintpack(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the RGB-Color values to the leds. diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index c5db336b..66652946 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -164,14 +164,11 @@ CiColor PhilipsHueLight::rgbToCiColor(float red, float green, float blue) return xy; } -LedDevicePhilipsHue::LedDevicePhilipsHue(const std::string& output, const std::string& username, bool switchOffOnBlack, int transitiontime, std::vector lightIds) +LedDevicePhilipsHue::LedDevicePhilipsHue(const Json::Value &deviceConfig) : LedDevice() - , host(output.c_str()) - , username(username.c_str()) - , switchOffOnBlack(switchOffOnBlack) - , transitiontime(transitiontime) - , lightIds(lightIds) { + setConfig(deviceConfig); + manager = new QNetworkAccessManager(); timer.setInterval(3000); timer.setSingleShot(true); @@ -183,6 +180,26 @@ LedDevicePhilipsHue::~LedDevicePhilipsHue() delete manager; } +bool LedDevicePhilipsHue::setConfig(const Json::Value &deviceConfig) +{ + host = deviceConfig["output"].asString().c_str(); + username = deviceConfig.get("username", "newdeveloper").asString().c_str(); + switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool(); + transitiontime = deviceConfig.get("transitiontime", 1).asInt(); + lightIds.clear(); + for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) + { + lightIds.push_back(deviceConfig["lightIds"][i].asInt()); + } + + return true; +} + +LedDevice* LedDevicePhilipsHue::construct(const Json::Value &deviceConfig) +{ + return new LedDevicePhilipsHue(deviceConfig); +} + int LedDevicePhilipsHue::write(const std::vector & ledValues) { // Save light states if not done before. diff --git a/libsrc/leddevice/LedDevicePhilipsHue.h b/libsrc/leddevice/LedDevicePhilipsHue.h index 3b60bb69..5d374a24 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.h +++ b/libsrc/leddevice/LedDevicePhilipsHue.h @@ -115,22 +115,27 @@ class LedDevicePhilipsHue: public LedDevice { public: /// - /// Constructs the device. + /// Constructs specific LedDevice /// - /// @param output the ip address of the bridge - /// @param username username of the hue bridge (default: newdeveloper) - /// @param switchOffOnBlack kill lights for black (default: false) - /// @param transitiontime the time duration a light change takes in multiples of 100 ms (default: 400 ms). - /// @param lightIds light ids of the lights to control if not starting at one in ascending order. + /// @param deviceConfig json device config /// - LedDevicePhilipsHue(const std::string& output, const std::string& username = "newdeveloper", bool switchOffOnBlack = - false, int transitiontime = 1, std::vector lightIds = std::vector()); + LedDevicePhilipsHue(const Json::Value &deviceConfig); /// /// Destructor of this device /// virtual ~LedDevicePhilipsHue(); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// /// Sends the given led-color values via put request to the hue system /// diff --git a/libsrc/leddevice/LedDevicePiBlaster.cpp b/libsrc/leddevice/LedDevicePiBlaster.cpp index 072a5be8..b4775ee0 100644 --- a/libsrc/leddevice/LedDevicePiBlaster.cpp +++ b/libsrc/leddevice/LedDevicePiBlaster.cpp @@ -13,11 +13,9 @@ // Local LedDevice includes #include "LedDevicePiBlaster.h" -LedDevicePiBlaster::LedDevicePiBlaster(const std::string & deviceName, const Json::Value & gpioMapping) - : _deviceName(deviceName) - , _fid(nullptr) +LedDevicePiBlaster::LedDevicePiBlaster(const Json::Value &deviceConfig) + : _fid(nullptr) { - signal(SIGPIPE, SIG_IGN); // initialise the mapping tables @@ -32,7 +30,31 @@ LedDevicePiBlaster::LedDevicePiBlaster(const std::string & deviceName, const Jso _gpio_to_color[i] = 'z'; } -// walk through the json config and populate the mapping tables + setConfig(deviceConfig); +} + +LedDevicePiBlaster::~LedDevicePiBlaster() +{ + // Close the device (if it is opened) + if (_fid != nullptr) + { + fclose(_fid); + _fid = nullptr; + } +} + + +bool LedDevicePiBlaster::setConfig(const Json::Value &deviceConfig) +{ + _deviceName = deviceConfig.get("output", "").asString(); + Json::Value gpioMapping = deviceConfig.get("gpiomap", Json::nullValue); + + if (gpioMapping.isNull()) + { + throw std::runtime_error("Piblaster: no gpiomap defined."); + } + + // walk through the json config and populate the mapping tables for (const Json::Value& gpioMap : gpioMapping) { const int gpio = gpioMap.get("gpio",-1).asInt(); @@ -47,16 +69,12 @@ LedDevicePiBlaster::LedDevicePiBlaster(const std::string & deviceName, const Jso Warning( _log, "IGNORING gpio %d ledindex %d color %c", gpio,ledindex, ledcolor[0]); } } + return true; } -LedDevicePiBlaster::~LedDevicePiBlaster() +LedDevice* LedDevicePiBlaster::construct(const Json::Value &deviceConfig) { - // Close the device (if it is opened) - if (_fid != nullptr) - { - fclose(_fid); - _fid = nullptr; - } + return new LedDevicePiBlaster(deviceConfig); } int LedDevicePiBlaster::open() diff --git a/libsrc/leddevice/LedDevicePiBlaster.h b/libsrc/leddevice/LedDevicePiBlaster.h index b61bc0b3..d1189e5b 100644 --- a/libsrc/leddevice/LedDevicePiBlaster.h +++ b/libsrc/leddevice/LedDevicePiBlaster.h @@ -14,15 +14,24 @@ class LedDevicePiBlaster : public LedDevice { public: /// - /// Constructs the PiBlaster device which writes to the indicated device and for the assigned - /// channels - /// @param deviceName The name of the output device - /// @param gpioMapping The RGB-Channel assignment json object + /// Constructs specific LedDevice /// - LedDevicePiBlaster(const std::string & deviceName, const Json::Value & gpioMapping); + /// @param deviceConfig json device config + /// + LedDevicePiBlaster(const Json::Value &deviceConfig); virtual ~LedDevicePiBlaster(); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// /// Attempts to open the piblaster-device. This will only succeed if the device is not yet open /// and the device is available. @@ -50,7 +59,7 @@ public: private: /// The name of the output device (very likely '/dev/pi-blaster') - const std::string _deviceName; + std::string _deviceName; int _gpio_to_led[64]; char _gpio_to_color[64]; diff --git a/libsrc/leddevice/LedDeviceRawHID.cpp b/libsrc/leddevice/LedDeviceRawHID.cpp index 5fd1b5ba..3ea3cc37 100644 --- a/libsrc/leddevice/LedDeviceRawHID.cpp +++ b/libsrc/leddevice/LedDeviceRawHID.cpp @@ -12,10 +12,12 @@ #include "LedDeviceRawHID.h" // Use feature report HID device -LedDeviceRawHID::LedDeviceRawHID(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms) - : LedHIDDevice(VendorId, ProductId, delayAfterConnect_ms, true) +LedDeviceRawHID::LedDeviceRawHID(const Json::Value &deviceConfig) + : ProviderHID(deviceConfig) , _timer() { + _useFeature = true; + // setup the timer _timer.setSingleShot(false); _timer.setInterval(5000); @@ -25,6 +27,11 @@ LedDeviceRawHID::LedDeviceRawHID(const unsigned short VendorId, const unsigned s _timer.start(); } +LedDevice* LedDeviceRawHID::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceRawHID(deviceConfig); +} + int LedDeviceRawHID::write(const std::vector & ledValues) { // Resize buffer if required diff --git a/libsrc/leddevice/LedDeviceRawHID.h b/libsrc/leddevice/LedDeviceRawHID.h index d0a8e04c..53a3569f 100644 --- a/libsrc/leddevice/LedDeviceRawHID.h +++ b/libsrc/leddevice/LedDeviceRawHID.h @@ -7,20 +7,25 @@ #include // hyperion include -#include "LedHIDDevice.h" +#include "ProviderHID.h" /// /// Implementation of the LedDevice interface for writing to an RawHID led device. /// -class LedDeviceRawHID : public LedHIDDevice +class LedDeviceRawHID : public ProviderHID { Q_OBJECT public: /// - /// Constructs the LedDevice for attached RawHID device + /// Constructs specific LedDevice /// - LedDeviceRawHID(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms); + /// @param deviceConfig json device config + /// + LedDeviceRawHID(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceSchemas.qrc b/libsrc/leddevice/LedDeviceSchemas.qrc new file mode 100644 index 00000000..4e7f956d --- /dev/null +++ b/libsrc/leddevice/LedDeviceSchemas.qrc @@ -0,0 +1,31 @@ + + + schemas/schema-adalightapa102.json + schemas/schema-adalight.json + schemas/schema-apa102.json + schemas/schema-atmo.json + schemas/schema-atmoorb.json + schemas/schema-e131.json + schemas/schema-fadecandy.json + schemas/schema-file.json + schemas/schema-hyperion-usbasp.json + schemas/schema-lightpack.json + schemas/schema-lpd6803.json + schemas/schema-lpd8806.json + schemas/schema-multi-lightpack.json + schemas/schema-p9813.json + schemas/schema-paintpack.json + schemas/schema-philipshue.json + schemas/schema-piblaster.json + schemas/schema-rawhid.json + schemas/schema-sedu.json + schemas/schema-sk6812rgbw-spi.json + schemas/schema-tinkerforge.json + schemas/schema-tmp2net.json + schemas/schema-tpm2.json + schemas/schema-udpraw.json + schemas/schema-ws2801.json + schemas/schema-ws2812spi.json + schemas/schema-ws281x.json + + diff --git a/libsrc/leddevice/LedDeviceSedu.cpp b/libsrc/leddevice/LedDeviceSedu.cpp index 7293dd27..6bdc70c4 100644 --- a/libsrc/leddevice/LedDeviceSedu.cpp +++ b/libsrc/leddevice/LedDeviceSedu.cpp @@ -17,12 +17,17 @@ struct FrameSpec size_t size; }; -LedDeviceSedu::LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate) - : LedRs232Device(outputDevice, baudrate) +LedDeviceSedu::LedDeviceSedu(const Json::Value &deviceConfig) + : ProviderRs232(deviceConfig) { // empty } +LedDevice* LedDeviceSedu::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceSedu(deviceConfig); +} + int LedDeviceSedu::write(const std::vector &ledValues) { if (_ledBuffer.size() == 0) diff --git a/libsrc/leddevice/LedDeviceSedu.h b/libsrc/leddevice/LedDeviceSedu.h index dda0a58d..9a67f1de 100644 --- a/libsrc/leddevice/LedDeviceSedu.h +++ b/libsrc/leddevice/LedDeviceSedu.h @@ -4,21 +4,23 @@ #include // hyperion incluse -#include "LedRs232Device.h" +#include "ProviderRs232.h" /// /// Implementation of the LedDevice interface for writing to SEDU led device. /// -class LedDeviceSedu : public LedRs232Device +class LedDeviceSedu : public ProviderRs232 { public: /// - /// Constructs the LedDevice for attached via SEDU device + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/dev/ttyS0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceSedu(const std::string& outputDevice, const unsigned baudrate); + LedDeviceSedu(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceSk6812SPI.cpp b/libsrc/leddevice/LedDeviceSk6812SPI.cpp index 0c5dc3c2..cb6cf412 100644 --- a/libsrc/leddevice/LedDeviceSk6812SPI.cpp +++ b/libsrc/leddevice/LedDeviceSk6812SPI.cpp @@ -11,10 +11,8 @@ // hyperion local includes #include "LedDeviceSk6812SPI.h" -LedDeviceSk6812SPI::LedDeviceSk6812SPI(const std::string& outputDevice, const unsigned baudrate, const std::string& whiteAlgorithm, - const int spiMode, const bool spiDataInvert) - : LedSpiDevice(outputDevice, baudrate, 0, spiMode, spiDataInvert) - , _whiteAlgorithm(whiteAlgorithm) +LedDeviceSk6812SPI::LedDeviceSk6812SPI(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) , bitpair_to_byte { 0b10001000, 0b10001100, @@ -23,7 +21,21 @@ LedDeviceSk6812SPI::LedDeviceSk6812SPI(const std::string& outputDevice, const un } { - Debug( _log, "whiteAlgorithm : %s", whiteAlgorithm.c_str()); + setConfig(deviceConfig); + Debug( _log, "whiteAlgorithm : %s", _whiteAlgorithm.c_str()); +} + +LedDevice* LedDeviceSk6812SPI::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceSk6812SPI(deviceConfig); +} + +bool LedDeviceSk6812SPI::setConfig(const Json::Value &deviceConfig) +{ + ProviderSpi::setConfig(deviceConfig); + _whiteAlgorithm = deviceConfig.get("white_algorithm","").asString(); + + return true; } int LedDeviceSk6812SPI::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceSk6812SPI.h b/libsrc/leddevice/LedDeviceSk6812SPI.h index d547d367..29ab4772 100644 --- a/libsrc/leddevice/LedDeviceSk6812SPI.h +++ b/libsrc/leddevice/LedDeviceSk6812SPI.h @@ -4,24 +4,31 @@ #include // hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to Sk6801 led device. /// -class LedDeviceSk6812SPI : public LedSpiDevice +class LedDeviceSk6812SPI : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type Sk6812SPI + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/etc/SpiDev.0.0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// + LedDeviceSk6812SPI(const Json::Value &deviceConfig); - LedDeviceSk6812SPI(const std::string& outputDevice, const unsigned baudrate, - const std::string& whiteAlgorithm, const int spiMode, const bool spiDataInvert); + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + /// /// Writes the led color values to the led-device /// diff --git a/libsrc/leddevice/LedDeviceTinkerforge.cpp b/libsrc/leddevice/LedDeviceTinkerforge.cpp index 972762eb..59ffaf37 100644 --- a/libsrc/leddevice/LedDeviceTinkerforge.cpp +++ b/libsrc/leddevice/LedDeviceTinkerforge.cpp @@ -9,17 +9,13 @@ static const unsigned MAX_NUM_LEDS = 320; static const unsigned MAX_NUM_LEDS_SETTABLE = 16; -LedDeviceTinkerforge::LedDeviceTinkerforge(const std::string & host, uint16_t port, const std::string & uid, const unsigned interval) +LedDeviceTinkerforge::LedDeviceTinkerforge(const Json::Value &deviceConfig) : LedDevice() - , _host(host) - , _port(port) - , _uid(uid) - , _interval(interval) , _ipConnection(nullptr) , _ledStrip(nullptr) , _colorChannelSize(0) { - // empty + setConfig(deviceConfig); } LedDeviceTinkerforge::~LedDeviceTinkerforge() @@ -35,6 +31,21 @@ LedDeviceTinkerforge::~LedDeviceTinkerforge() delete _ledStrip; } +bool LedDeviceTinkerforge::setConfig(const Json::Value &deviceConfig) +{ + _host = deviceConfig.get("output", "127.0.0.1").asString(); + _port = deviceConfig.get("port", 4223).asInt(); + _uid = deviceConfig["uid"].asString(); + _interval = deviceConfig["rate"].asInt(); + + return true; +} + +LedDevice* LedDeviceTinkerforge::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceTinkerforge(deviceConfig); +} + int LedDeviceTinkerforge::open() { // Check if connection is already createds diff --git a/libsrc/leddevice/LedDeviceTinkerforge.h b/libsrc/leddevice/LedDeviceTinkerforge.h index 95f43332..4f3c6dc7 100644 --- a/libsrc/leddevice/LedDeviceTinkerforge.h +++ b/libsrc/leddevice/LedDeviceTinkerforge.h @@ -16,11 +16,25 @@ extern "C" { class LedDeviceTinkerforge : public LedDevice { public: - - LedDeviceTinkerforge(const std::string &host, uint16_t port, const std::string &uid, const unsigned interval); + /// + /// Constructs specific LedDevice + /// + /// @param deviceConfig json device config + /// + LedDeviceTinkerforge(const Json::Value &deviceConfig); virtual ~LedDeviceTinkerforge(); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + /// /// Attempts to open a connection to the master bricklet and the led strip bricklet. /// @@ -50,16 +64,16 @@ private: int transferLedData(LEDStrip *ledstrip, unsigned int index, unsigned int length, uint8_t *redChannel, uint8_t *greenChannel, uint8_t *blueChannel); /// The host of the master brick - const std::string _host; + std::string _host; /// The port of the master brick - const uint16_t _port; + uint16_t _port; /// The uid of the led strip bricklet - const std::string _uid; + std::string _uid; /// The interval/rate - const unsigned _interval; + unsigned _interval; /// ip connection handle IPConnection *_ipConnection; diff --git a/libsrc/leddevice/LedDeviceTpm2.cpp b/libsrc/leddevice/LedDeviceTpm2.cpp index bf816a5c..e15045c4 100644 --- a/libsrc/leddevice/LedDeviceTpm2.cpp +++ b/libsrc/leddevice/LedDeviceTpm2.cpp @@ -6,11 +6,16 @@ // hyperion local includes #include "LedDeviceTpm2.h" +#include -LedDeviceTpm2::LedDeviceTpm2(const std::string& outputDevice, const unsigned baudrate) - : LedRs232Device(outputDevice, baudrate) +LedDeviceTpm2::LedDeviceTpm2(const Json::Value &deviceConfig) + : ProviderRs232(deviceConfig) { - // empty +} + +LedDevice* LedDeviceTpm2::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceTpm2(deviceConfig); } int LedDeviceTpm2::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceTpm2.h b/libsrc/leddevice/LedDeviceTpm2.h index f6ff7340..39e0a3ae 100644 --- a/libsrc/leddevice/LedDeviceTpm2.h +++ b/libsrc/leddevice/LedDeviceTpm2.h @@ -4,22 +4,23 @@ #include // hyperion incluse -#include "LedRs232Device.h" +#include "ProviderRs232.h" /// /// Implementation of the LedDevice interface for writing to serial device using tpm2 protocol. /// -class LedDeviceTpm2 : public LedRs232Device +class LedDeviceTpm2 : public ProviderRs232 { public: /// - /// Constructs the LedDevice for attached serial device using supporting tpm2 protocol - /// All LEDs in the stripe are handled as one frame + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/dev/ttyAMA0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceTpm2(const std::string& outputDevice, const unsigned baudrate); + LedDeviceTpm2(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceTpm2net.cpp b/libsrc/leddevice/LedDeviceTpm2net.cpp new file mode 100644 index 00000000..5075f188 --- /dev/null +++ b/libsrc/leddevice/LedDeviceTpm2net.cpp @@ -0,0 +1,63 @@ +// STL includes +#include +#include +#include +#include + +// Local-Hyperion includes +#include "LedDeviceTpm2net.h" + + +LedDeviceTpm2net::LedDeviceTpm2net(const Json::Value &deviceConfig) + : LedDevice() + , _socket(this) +{ + setConfig(deviceConfig); +} + +LedDeviceTpm2net::~LedDeviceTpm2net() +{ +} + +bool LedDeviceTpm2net::setConfig(const Json::Value &deviceConfig) +{ + _host = QHostAddress(QString::fromStdString(deviceConfig.get("output", "127.0.0.1").asString())); + _port = deviceConfig.get("port", 65506).asInt(); + + return true; +} + +LedDevice* LedDeviceTpm2net::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceTpm2net(deviceConfig); +} + +int LedDeviceTpm2net::write(const std::vector & ledValues) +{ + if (_ledBuffer.size() == 0) + { + _ledBuffer.resize(7 + 3*ledValues.size()); + _ledBuffer[0] = 0x9c; // block-start byte TPM.NET + _ledBuffer[1] = 0xDA; + _ledBuffer[2] = ((3 * ledValues.size()) >> 8) & 0xFF; // frame size high byte + _ledBuffer[3] = (3 * ledValues.size()) & 0xFF; // frame size low byte + _ledBuffer[4] = 1; // packets number + _ledBuffer[5] = 1; // Number of packets + _ledBuffer[(int)(7 + 3*ledValues.size()-1)] = 0x36; // block-end byte + } + + // write data + memcpy(6 + _ledBuffer.data(), ledValues.data() /*Max 1,490 bytes*/, ledValues.size() * 3); + + _socket.connectToHost(_host, _port); + _socket.write((const char *)_ledBuffer.data()); + _socket.close(); + + return 0; +} + +int LedDeviceTpm2net::switchOff() +{ + memset(6 + _ledBuffer.data(), 0, _ledBuffer.size() - 5); + return 0; +} diff --git a/libsrc/leddevice/LedDeviceTpm2net.h b/libsrc/leddevice/LedDeviceTpm2net.h new file mode 100644 index 00000000..1f3ec05f --- /dev/null +++ b/libsrc/leddevice/LedDeviceTpm2net.h @@ -0,0 +1,53 @@ +#pragma once + +// STL includes +#include +#include +#include +#include +// Leddevice includes +#include + +/// +class LedDeviceTpm2net : public LedDevice +{ +public: + /// + /// Constructs specific LedDevice + /// + /// @param deviceConfig json device config + /// + LedDeviceTpm2net(const Json::Value &deviceConfig); + + virtual ~LedDeviceTpm2net(); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); + + /// + /// Writes the given led-color values to the output stream + /// + /// @param ledValues The color-value per led + /// + /// @return Zero on success else negative + /// + virtual int write(const std::vector & ledValues); + + /// Switch the leds off + virtual int switchOff(); + +private: + /// The host of the master brick + QHostAddress _host; + + /// The port of the master brick + uint16_t _port; + QUdpSocket _socket; +}; diff --git a/libsrc/leddevice/LedDeviceUdpE131.cpp b/libsrc/leddevice/LedDeviceUdpE131.cpp index dbd6744b..1e93b732 100644 --- a/libsrc/leddevice/LedDeviceUdpE131.cpp +++ b/libsrc/leddevice/LedDeviceUdpE131.cpp @@ -9,66 +9,124 @@ #include #include +#include +#include + // hyperion local includes #include "LedDeviceUdpE131.h" -LedDeviceUdpE131::LedDeviceUdpE131(const std::string& outputDevice, const unsigned latchTime, const unsigned universe) - : LedUdpDevice(outputDevice, latchTime) - , _e131_universe(universe) +LedDeviceUdpE131::LedDeviceUdpE131(const Json::Value &deviceConfig) + : ProviderUdp(deviceConfig) { - // empty + setConfig(deviceConfig); } -#define CID "hyperion!\0" -#define SOURCE_NAME "hyperion on hostname\0" - -int LedDeviceUdpE131::write(const std::vector &ledValues) +bool LedDeviceUdpE131::setConfig(const Json::Value &deviceConfig) { - _ledCount = ledValues.size(); - int _dmxChannelCount = 3 * std::min(_ledCount,170); // DMX512 has max 512 channels == 170 RGB leds + ProviderUdp::setConfig(deviceConfig); + _LatchTime_ns = deviceConfig.get("latchtime",104000).asInt(); + _e131_universe = deviceConfig.get("universe",1).asInt(); + _e131_source_name = deviceConfig.get("source-name","hyperion on "+QHostInfo::localHostName().toStdString()).asString(); + QString _json_cid = QString::fromStdString(deviceConfig.get("cid","").asString()); + if (_json_cid.isEmpty()) + { + _e131_cid = QUuid::createUuid(); + Debug( _log, "e131 no cid found, generated %s", _e131_cid.toString().toStdString().c_str()); + } else { + _e131_cid = QUuid(_json_cid); + Debug( _log, "e131 cid found, using %s", _e131_cid.toString().toStdString().c_str()); + } + + return true; +} + +LedDevice* LedDeviceUdpE131::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceUdpE131(deviceConfig); +} + + +// populates the headers +void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this_dmxChannelCount) +{ memset(e131_packet.raw, 0, sizeof(e131_packet.raw)); /* Root Layer */ e131_packet.preamble_size = htons(16); e131_packet.postamble_size = 0; memcpy (e131_packet.acn_id, _acn_id, 12); - e131_packet.root_flength = htons(0x7000 | (110+_dmxChannelCount) ); + e131_packet.root_flength = htons(0x7000 | (110+this_dmxChannelCount) ); e131_packet.root_vector = htonl(VECTOR_ROOT_E131_DATA); - memcpy (e131_packet.cid, CID, sizeof(CID) ); + memcpy (e131_packet.cid, _e131_cid.toRfc4122().constData() , sizeof(e131_packet.cid) ); /* Frame Layer */ - e131_packet.frame_flength = htons(0x7000 | (88+_dmxChannelCount)); + e131_packet.frame_flength = htons(0x7000 | (88+this_dmxChannelCount)); e131_packet.frame_vector = htonl(VECTOR_E131_DATA_PACKET); - memcpy (e131_packet.source_name, SOURCE_NAME, sizeof(SOURCE_NAME)); + snprintf (e131_packet.source_name, sizeof(e131_packet.source_name), "%s", _e131_source_name.c_str() ); e131_packet.priority = 100; e131_packet.reserved = htons(0); - e131_packet.sequence_number = _e131_seq++; e131_packet.options = 0; // Bit 7 = Preview_Data // Bit 6 = Stream_Terminated // Bit 5 = Force_Synchronization - e131_packet.universe = htons(_e131_universe); - + e131_packet.universe = htons(this_universe); /* DMX Layer */ - e131_packet.dmp_flength = htons(0x7000 | (11+_dmxChannelCount)); + e131_packet.dmp_flength = htons(0x7000 | (11+this_dmxChannelCount)); e131_packet.dmp_vector = VECTOR_DMP_SET_PROPERTY; e131_packet.type = 0xa1; e131_packet.first_address = htons(0); e131_packet.address_increment = htons(1); - e131_packet.property_value_count = htons(1+_dmxChannelCount); + e131_packet.property_value_count = htons(1+this_dmxChannelCount); - int led_idx=0; e131_packet.property_values[0] = 0; // start code - for (int _dmxIdx=1; _dmxIdx <= _dmxChannelCount; ) +} + +int LedDeviceUdpE131::write(const std::vector &ledValues) +{ + int retVal = 0; + + int _thisChannelCount = 0; + + _e131_seq++; + + const uint8_t * rawdata = reinterpret_cast(ledValues.data()); + + _ledCount = ledValues.size(); + + int _dmxChannelCount = 3 * _ledCount; + + for (int rawIdx = 0; rawIdx < _dmxChannelCount; rawIdx++) { - e131_packet.property_values[_dmxIdx++] = ledValues[led_idx].red; - e131_packet.property_values[_dmxIdx++] = ledValues[led_idx].green; - e131_packet.property_values[_dmxIdx++] = ledValues[led_idx].blue; - led_idx ++; + if (rawIdx % DMX_MAX == 0) // start of new packet + { + _thisChannelCount = (_dmxChannelCount - rawIdx < DMX_MAX) ? _dmxChannelCount % DMX_MAX : DMX_MAX; +// is this the last packet? ? ^^ last packet : ^^ earlier packets + + prepare(_e131_universe + rawIdx / DMX_MAX, _thisChannelCount); + e131_packet.sequence_number = _e131_seq; + } + + e131_packet.property_values[1 + rawIdx%DMX_MAX] = rawdata[rawIdx]; + +// is this the last byte of last packet || last byte of other packets + if ( (rawIdx == _dmxChannelCount-1) || (rawIdx %DMX_MAX == DMX_MAX-1) ) + { +#undef e131debug +#if e131debug + printf ( "send packet: rawidx %d dmxchannelcount %d universe: %d, packetsz %d\n" + , rawIdx + , _dmxChannelCount + , _e131_universe + rawIdx / DMX_MAX + , E131_DMP_DATA + 1 + _thisChannelCount + ); +#endif + retVal &= writeBytes(E131_DMP_DATA + 1 + _thisChannelCount, e131_packet.raw); + } } - return writeBytes(E131_DMP_DATA + 1 + _dmxChannelCount, e131_packet.raw); + + return retVal; } int LedDeviceUdpE131::switchOff() diff --git a/libsrc/leddevice/LedDeviceUdpE131.h b/libsrc/leddevice/LedDeviceUdpE131.h index 783cb76d..5fc62bff 100644 --- a/libsrc/leddevice/LedDeviceUdpE131.h +++ b/libsrc/leddevice/LedDeviceUdpE131.h @@ -4,7 +4,9 @@ #include // hyperion includes -#include "LedUdpDevice.h" +#include "ProviderUdp.h" + +#include /* * @@ -55,12 +57,12 @@ typedef union { uint8_t acn_id[12]; uint16_t root_flength; uint32_t root_vector; - uint8_t cid[16]; + char cid[16]; /* Frame Layer */ uint16_t frame_flength; uint32_t frame_vector; - uint8_t source_name[64]; + char source_name[64]; uint8_t priority; uint16_t reserved; uint8_t sequence_number; @@ -91,22 +93,30 @@ typedef union { #define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds #define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds #define E131_DISCOVERY_UNIVERSE 64214 - +#define DMX_MAX 512 // 512 usable slots /// /// Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets /// -class LedDeviceUdpE131 : public LedUdpDevice +class LedDeviceUdpE131 : public ProviderUdp { public: /// - /// Constructs the LedDevice for sending led colors via udp + /// Constructs specific LedDevice /// - /// @param outputDevice hostname:port - /// @param latchTime + /// @param deviceConfig json device config /// + LedDeviceUdpE131(const Json::Value &deviceConfig); - LedDeviceUdpE131(const std::string& outputDevice, const unsigned latchTime, const unsigned universe); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// @@ -121,8 +131,12 @@ public: virtual int switchOff(); private: + void prepare(const unsigned this_universe, const unsigned this_dmxChannelCount); + e131_packet_t e131_packet; uint8_t _e131_seq = 0; uint8_t _e131_universe = 1; uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 }; + std::string _e131_source_name; + QUuid _e131_cid; }; diff --git a/libsrc/leddevice/LedDeviceUdpRaw.cpp b/libsrc/leddevice/LedDeviceUdpRaw.cpp index 3fcb1a64..81cf892f 100644 --- a/libsrc/leddevice/LedDeviceUdpRaw.cpp +++ b/libsrc/leddevice/LedDeviceUdpRaw.cpp @@ -11,10 +11,23 @@ // hyperion local includes #include "LedDeviceUdpRaw.h" -LedDeviceUdpRaw::LedDeviceUdpRaw(const std::string& outputDevice, const unsigned latchTime) - : LedUdpDevice(outputDevice, latchTime) +LedDeviceUdpRaw::LedDeviceUdpRaw(const Json::Value &deviceConfig) + : ProviderUdp(deviceConfig) { - // empty + setConfig(deviceConfig); +} + +bool LedDeviceUdpRaw::setConfig(const Json::Value &deviceConfig) +{ + ProviderUdp::setConfig(deviceConfig); + _LatchTime_ns = deviceConfig.get("latchtime",500000).asInt(); + + return true; +} + +LedDevice* LedDeviceUdpRaw::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceUdpRaw(deviceConfig); } int LedDeviceUdpRaw::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceUdpRaw.h b/libsrc/leddevice/LedDeviceUdpRaw.h index f56aac01..980c414c 100644 --- a/libsrc/leddevice/LedDeviceUdpRaw.h +++ b/libsrc/leddevice/LedDeviceUdpRaw.h @@ -4,22 +4,30 @@ #include // hyperion incluse -#include "LedUdpDevice.h" +#include "ProviderUdp.h" /// /// Implementation of the LedDevice interface for sending led colors via udp. /// -class LedDeviceUdpRaw : public LedUdpDevice +class LedDeviceUdpRaw : public ProviderUdp { public: /// - /// Constructs the LedDevice for sending led colors via udp + /// Constructs specific LedDevice /// - /// @param outputDevice hostname:port - /// @param latchTime + /// @param deviceConfig json device config /// + LedDeviceUdpRaw(const Json::Value &deviceConfig); - LedDeviceUdpRaw(const std::string& outputDevice, const unsigned latchTime); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceWS2812b.cpp b/libsrc/leddevice/LedDeviceWS2812b.cpp index ca7b8ffa..8df215bf 100644 --- a/libsrc/leddevice/LedDeviceWS2812b.cpp +++ b/libsrc/leddevice/LedDeviceWS2812b.cpp @@ -258,6 +258,11 @@ LedDeviceWS2812b::LedDeviceWS2812b() printf("WS2812b init finished \n"); } +LedDevice* LedDeviceWS2812b::construct(const Json::Value &) +{ + return new LedDeviceWS2812b(); +} + #ifdef WS2812_ASM_OPTI // rotate register, used to move the 1 around :-) diff --git a/libsrc/leddevice/LedDeviceWS2812b.h b/libsrc/leddevice/LedDeviceWS2812b.h index c477296d..041a58e3 100644 --- a/libsrc/leddevice/LedDeviceWS2812b.h +++ b/libsrc/leddevice/LedDeviceWS2812b.h @@ -133,10 +133,24 @@ class LedDeviceWS2812b : public LedDevice { public: /// - /// Constructs the LedDevice for a string containing leds of the type WS2812 + /// Constructs specific LedDevice + /// + /// @param deviceConfig json device config + /// LedDeviceWS2812b(); ~LedDeviceWS2812b(); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value&) {}; + + /// constructs leddevice + static LedDevice* construct(const Json::Value &); + /// /// Writes the led color values to the led-device /// diff --git a/libsrc/leddevice/LedDeviceWS281x.cpp b/libsrc/leddevice/LedDeviceWS281x.cpp index 7e49ff39..98e03e11 100644 --- a/libsrc/leddevice/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/LedDeviceWS281x.cpp @@ -4,31 +4,13 @@ #include "LedDeviceWS281x.h" // Constructor -LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel, const int invert, const int rgbw, const std::string& whiteAlgorithm) +LedDeviceWS281x::LedDeviceWS281x(const Json::Value &deviceConfig) : LedDevice() - , _channel(pwmchannel) , _initialized(false) - , _whiteAlgorithm(whiteAlgorithm) { - Debug( _log, "whiteAlgorithm : %s", whiteAlgorithm.c_str()); + setConfig(deviceConfig); + Debug( _log, "whiteAlgorithm : %s", _whiteAlgorithm.c_str()); - _led_string.freq = freq; - _led_string.dmanum = dmanum; - if (pwmchannel != 0 && pwmchannel != 1) - { - throw std::runtime_error("WS281x: invalid PWM channel; must be 0 or 1."); - } - _led_string.channel[_channel].gpionum = gpio; - _led_string.channel[_channel].invert = invert; - _led_string.channel[_channel].count = leds; - _led_string.channel[_channel].brightness = 255; - _led_string.channel[_channel].strip_type = ((rgbw == 1) ? SK6812_STRIP_GRBW : WS2811_STRIP_RGB); - - _led_string.channel[!_channel].gpionum = 0; - _led_string.channel[!_channel].invert = invert; - _led_string.channel[!_channel].count = 0; - _led_string.channel[!_channel].brightness = 0; - _led_string.channel[!_channel].strip_type = WS2811_STRIP_RGB; if (ws2811_init(&_led_string) < 0) { throw std::runtime_error("Unable to initialize ws281x library."); @@ -36,6 +18,38 @@ LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t _initialized = true; } +bool LedDeviceWS281x::setConfig(const Json::Value &deviceConfig) +{ + _whiteAlgorithm = deviceConfig.get("white_algorithm","").asString(); + _channel = deviceConfig.get("pwmchannel", 0).asInt(); + if (_channel != 0 && _channel != 1) + { + throw std::runtime_error("WS281x: invalid PWM channel; must be 0 or 1."); + } + + _led_string.freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt(); + _led_string.dmanum = deviceConfig.get("dmanum", 5).asInt(); + _led_string.channel[_channel].gpionum = deviceConfig.get("gpio", 18).asInt(); + _led_string.channel[_channel].count = deviceConfig.get("leds", 256).asInt(); + _led_string.channel[_channel].invert = deviceConfig.get("invert", 0).asInt(); + _led_string.channel[_channel].strip_type = ((deviceConfig.get("rgbw", 0).asInt() == 1) ? SK6812_STRIP_GRBW : WS2811_STRIP_RGB); + _led_string.channel[_channel].brightness = 255; + + _led_string.channel[!_channel].gpionum = 0; + _led_string.channel[!_channel].invert = _led_string.channel[_channel].invert; + _led_string.channel[!_channel].count = 0; + _led_string.channel[!_channel].brightness = 0; + _led_string.channel[!_channel].strip_type = WS2811_STRIP_RGB; + + return true; +} + +LedDevice* LedDeviceWS281x::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceWS281x(deviceConfig); +} + + // Send new values down the LED chain int LedDeviceWS281x::write(const std::vector &ledValues) { diff --git a/libsrc/leddevice/LedDeviceWS281x.h b/libsrc/leddevice/LedDeviceWS281x.h index 4cb9a0d2..b622981b 100644 --- a/libsrc/leddevice/LedDeviceWS281x.h +++ b/libsrc/leddevice/LedDeviceWS281x.h @@ -7,24 +7,26 @@ class LedDeviceWS281x : public LedDevice { public: /// - /// Constructs the LedDevice for WS281x (one wire 800kHz) + /// Constructs specific LedDevice /// - /// @param gpio The gpio pin to use (BCM chip counting, default is 18) - /// @param leds The number of leds attached to the gpio pin - /// @param freq The target frequency for the data line, default is 800000 - /// @param dmanum The DMA channel to use, default is 5 - /// @param pwmchannel The pwm channel to use - /// @param invert Invert the output line to support an inverting level shifter - /// @param rgbw Send 32 bit rgbw colour data for sk6812 - + /// @param deviceConfig json device config /// - LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel, int invert, - int rgbw, const std::string& whiteAlgorithm); + LedDeviceWS281x(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice, waits for DMA to complete and then cleans up /// ~LedDeviceWS281x(); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceWs2801.cpp b/libsrc/leddevice/LedDeviceWs2801.cpp index 41f2d661..b3d5e81a 100644 --- a/libsrc/leddevice/LedDeviceWs2801.cpp +++ b/libsrc/leddevice/LedDeviceWs2801.cpp @@ -11,11 +11,14 @@ // hyperion local includes #include "LedDeviceWs2801.h" -LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned baudrate, const unsigned latchTime, - const int spiMode, const bool spiDataInvert) - : LedSpiDevice(outputDevice, baudrate, latchTime, spiMode, spiDataInvert) +LedDeviceWs2801::LedDeviceWs2801(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) { - // empty +} + +LedDevice* LedDeviceWs2801::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceWs2801(deviceConfig); } int LedDeviceWs2801::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceWs2801.h b/libsrc/leddevice/LedDeviceWs2801.h index 0703bdf7..7961fea3 100644 --- a/libsrc/leddevice/LedDeviceWs2801.h +++ b/libsrc/leddevice/LedDeviceWs2801.h @@ -4,26 +4,23 @@ #include // hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to Ws2801 led device. /// -class LedDeviceWs2801 : public LedSpiDevice +class LedDeviceWs2801 : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type Ws2801 + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/etc/SpiDev.0.0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// + LedDeviceWs2801(const Json::Value &deviceConfig); - LedDeviceWs2801(const std::string& outputDevice, - const unsigned baudrate, - const unsigned latchTime, - const int spiMode, - const bool spiDataInvert); + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedDeviceWs2812SPI.cpp b/libsrc/leddevice/LedDeviceWs2812SPI.cpp index 3b3751e3..abef4d0e 100644 --- a/libsrc/leddevice/LedDeviceWs2812SPI.cpp +++ b/libsrc/leddevice/LedDeviceWs2812SPI.cpp @@ -11,8 +11,8 @@ // hyperion local includes #include "LedDeviceWs2812SPI.h" -LedDeviceWs2812SPI::LedDeviceWs2812SPI(const std::string& outputDevice, const unsigned baudrate, const int spiMode, const bool spiDataInvert) - : LedSpiDevice(outputDevice, baudrate, 0, spiMode, spiDataInvert) +LedDeviceWs2812SPI::LedDeviceWs2812SPI(const Json::Value &deviceConfig) + : ProviderSpi(deviceConfig) , bitpair_to_byte { 0b10001000, 0b10001100, @@ -20,7 +20,11 @@ LedDeviceWs2812SPI::LedDeviceWs2812SPI(const std::string& outputDevice, const un 0b11001100, } { - // empty +} + +LedDevice* LedDeviceWs2812SPI::construct(const Json::Value &deviceConfig) +{ + return new LedDeviceWs2812SPI(deviceConfig); } int LedDeviceWs2812SPI::write(const std::vector &ledValues) diff --git a/libsrc/leddevice/LedDeviceWs2812SPI.h b/libsrc/leddevice/LedDeviceWs2812SPI.h index eed65c3e..aaeb18b3 100644 --- a/libsrc/leddevice/LedDeviceWs2812SPI.h +++ b/libsrc/leddevice/LedDeviceWs2812SPI.h @@ -4,22 +4,23 @@ #include // hyperion incluse -#include "LedSpiDevice.h" +#include "ProviderSpi.h" /// /// Implementation of the LedDevice interface for writing to Ws2801 led device. /// -class LedDeviceWs2812SPI : public LedSpiDevice +class LedDeviceWs2812SPI : public ProviderSpi { public: /// - /// Constructs the LedDevice for a string containing leds of the type Ws2812SPI + /// Constructs specific LedDevice /// - /// @param outputDevice The name of the output device (eg '/etc/SpiDev.0.0') - /// @param baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedDeviceWs2812SPI(const std::string& outputDevice, const unsigned baudrate, - const int spiMode, const bool spiDataInvert); + LedDeviceWs2812SPI(const Json::Value &deviceConfig); + + /// constructs leddevice + static LedDevice* construct(const Json::Value &deviceConfig); /// /// Writes the led color values to the led-device diff --git a/libsrc/leddevice/LedUdpDevice.cpp b/libsrc/leddevice/LedUdpDevice.cpp deleted file mode 100644 index da7a9528..00000000 --- a/libsrc/leddevice/LedUdpDevice.cpp +++ /dev/null @@ -1,74 +0,0 @@ - -// STL includes -#include -#include -#include -#include -// Linux includes -#include -#include - -#include -#include -#include - -// Local Hyperion includes -#include "LedUdpDevice.h" - -LedUdpDevice::LedUdpDevice(const std::string& output, const int latchTime_ns) - : _target(output) - , _LatchTime_ns(latchTime_ns) -{ - _udpSocket = new QUdpSocket(); - QString str = QString::fromStdString(_target); - QStringList str_splitted = str.split(":"); - if (str_splitted.size() != 2) - { - throw("Error parsing hostname:port"); - } - QHostInfo info = QHostInfo::fromName(str_splitted.at(0)); - if (!info.addresses().isEmpty()) - { - // use the first IP address - _address = info.addresses().first(); - } - _port = str_splitted.at(1).toInt(); -} - -LedUdpDevice::~LedUdpDevice() -{ - _udpSocket->close(); -} - -int LedUdpDevice::open() -{ - QHostAddress localAddress = QHostAddress::Any; - quint16 localPort = 0; - - WarningIf( !_udpSocket->bind(localAddress, localPort), _log, "Couldnt bind local address: %s", strerror(errno)); - - return 0; -} - -int LedUdpDevice::writeBytes(const unsigned size, const uint8_t * data) -{ - - qint64 retVal = _udpSocket->writeDatagram((const char *)data,size,_address,_port); - - if (retVal >= 0 && _LatchTime_ns > 0) - { - // The 'latch' time for latching the shifted-value into the leds - timespec latchTime; - latchTime.tv_sec = 0; - latchTime.tv_nsec = _LatchTime_ns; - - // Sleep to latch the leds (only if write succesfull) - nanosleep(&latchTime, NULL); - } - else - { - Warning( _log, "Error sending: %s", strerror(errno)); - } - - return retVal; -} diff --git a/libsrc/leddevice/LedHIDDevice.cpp b/libsrc/leddevice/ProviderHID.cpp similarity index 80% rename from libsrc/leddevice/LedHIDDevice.cpp rename to libsrc/leddevice/ProviderHID.cpp index bd3a01bf..2149f165 100644 --- a/libsrc/leddevice/LedHIDDevice.cpp +++ b/libsrc/leddevice/ProviderHID.cpp @@ -7,20 +7,17 @@ #include // Local Hyperion includes -#include "LedHIDDevice.h" +#include "ProviderHID.h" -LedHIDDevice::LedHIDDevice(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms, const bool useFeature) - : _VendorId(VendorId) - , _ProductId(ProductId) - , _useFeature(useFeature) +ProviderHID::ProviderHID(const Json::Value &deviceConfig) + : _useFeature(false) , _deviceHandle(nullptr) - , _delayAfterConnect_ms(delayAfterConnect_ms) , _blockedForDelay(false) { - // empty + setConfig(deviceConfig); } -LedHIDDevice::~LedHIDDevice() +ProviderHID::~ProviderHID() { if (_deviceHandle != nullptr) { @@ -31,7 +28,20 @@ LedHIDDevice::~LedHIDDevice() hid_exit(); } -int LedHIDDevice::open() +bool ProviderHID::setConfig(const Json::Value &deviceConfig) +{ + _delayAfterConnect_ms = deviceConfig.get("delayAfterConnect", 0 ).asInt(); + auto VendorIdString = deviceConfig.get("VID", "0x2341").asString(); + auto ProductIdString = deviceConfig.get("PID", "0x8036").asString(); + + // Convert HEX values to integer + _VendorId = std::stoul(VendorIdString, nullptr, 16); + _ProductId = std::stoul(ProductIdString, nullptr, 16); + + return true; +} + +int ProviderHID::open() { // Initialize the usb context int error = hid_init(); @@ -87,7 +97,7 @@ int LedHIDDevice::open() } -int LedHIDDevice::writeBytes(const unsigned size, const uint8_t * data) +int ProviderHID::writeBytes(const unsigned size, const uint8_t * data) { if (_blockedForDelay) { return 0; @@ -146,7 +156,7 @@ int LedHIDDevice::writeBytes(const unsigned size, const uint8_t * data) return ret; } -void LedHIDDevice::unblockAfterDelay() +void ProviderHID::unblockAfterDelay() { Debug(_log,"Device unblocked"); _blockedForDelay = false; diff --git a/libsrc/leddevice/LedHIDDevice.h b/libsrc/leddevice/ProviderHID.h similarity index 59% rename from libsrc/leddevice/LedHIDDevice.h rename to libsrc/leddevice/ProviderHID.h index 65c2595e..4dbb9255 100644 --- a/libsrc/leddevice/LedHIDDevice.h +++ b/libsrc/leddevice/ProviderHID.h @@ -9,25 +9,31 @@ #include /// -/// The LedHIDDevice implements an abstract base-class for LedDevices using an HID-device. +/// The ProviderHID implements an abstract base-class for LedDevices using an HID-device. /// -class LedHIDDevice : public LedDevice +class ProviderHID : public LedDevice { Q_OBJECT public: /// - /// Constructs the LedDevice attached to an HID-device + /// Constructs specific LedDevice /// - /// @param[in] VendorId The USB VID of the output device - /// @param[in] ProductId The USB PID of the output device + /// @param deviceConfig json device config /// - LedHIDDevice(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms = 0, const bool useFeature = false); + ProviderHID(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open /// - virtual ~LedHIDDevice(); + virtual ~ProviderHID(); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + virtual bool setConfig(const Json::Value &deviceConfig); /// /// Opens and configures the output device @@ -46,21 +52,20 @@ protected: */ int writeBytes(const unsigned size, const uint8_t *data); -private slots: - /// Unblock the device after a connection delay - void unblockAfterDelay(); - -private: // HID VID and PID - const unsigned short _VendorId; - const unsigned short _ProductId; - const bool _useFeature; + unsigned short _VendorId; + unsigned short _ProductId; + bool _useFeature; /// libusb device handle hid_device * _deviceHandle; /// Sleep after the connect before continuing - const int _delayAfterConnect_ms; + int _delayAfterConnect_ms; bool _blockedForDelay; + +private slots: + /// Unblock the device after a connection delay + void unblockAfterDelay(); }; diff --git a/libsrc/leddevice/LedRs232Device.cpp b/libsrc/leddevice/ProviderRs232.cpp similarity index 83% rename from libsrc/leddevice/LedRs232Device.cpp rename to libsrc/leddevice/ProviderRs232.cpp index f55ee54b..819d6953 100644 --- a/libsrc/leddevice/LedRs232Device.cpp +++ b/libsrc/leddevice/ProviderRs232.cpp @@ -7,20 +7,28 @@ #include // Local Hyperion includes -#include "LedRs232Device.h" +#include "ProviderRs232.h" -LedRs232Device::LedRs232Device(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) - : _deviceName(outputDevice) - , _baudRate_Hz(baudrate) - , _delayAfterConnect_ms(delayAfterConnect_ms) - , _rs232Port(this) +ProviderRs232::ProviderRs232(const Json::Value &deviceConfig) + : _rs232Port(this) , _blockedForDelay(false) , _stateChanged(true) { + setConfig(deviceConfig); connect(&_rs232Port, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(error(QSerialPort::SerialPortError))); } -void LedRs232Device::error(QSerialPort::SerialPortError error) +bool ProviderRs232::setConfig(const Json::Value &deviceConfig) +{ + closeDevice(); + _deviceName = deviceConfig["output"].asString(); + _baudRate_Hz = deviceConfig["rate"].asInt(); + _delayAfterConnect_ms = deviceConfig.get("delayAfterConnect",250).asInt(); + + return true; +} + +void ProviderRs232::error(QSerialPort::SerialPortError error) { if ( error != QSerialPort::NoError ) { @@ -56,9 +64,14 @@ void LedRs232Device::error(QSerialPort::SerialPortError error) } } -LedRs232Device::~LedRs232Device() +ProviderRs232::~ProviderRs232() { disconnect(&_rs232Port, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(error(QSerialPort::SerialPortError))); + closeDevice(); +} + +void ProviderRs232::closeDevice() +{ if (_rs232Port.isOpen()) { _rs232Port.close(); @@ -66,8 +79,7 @@ LedRs232Device::~LedRs232Device() } } - -int LedRs232Device::open() +int ProviderRs232::open() { Info(_log, "Opening UART: %s", _deviceName.c_str()); _rs232Port.setPortName(_deviceName.c_str()); @@ -76,7 +88,7 @@ int LedRs232Device::open() } -bool LedRs232Device::tryOpen() +bool ProviderRs232::tryOpen() { if ( ! _rs232Port.isOpen() ) { @@ -104,7 +116,7 @@ bool LedRs232Device::tryOpen() } -int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data) +int ProviderRs232::writeBytes(const unsigned size, const uint8_t * data) { if (_blockedForDelay) { @@ -131,7 +143,7 @@ int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data) } -void LedRs232Device::unblockAfterDelay() +void ProviderRs232::unblockAfterDelay() { Debug(_log, "Device unblocked"); _blockedForDelay = false; diff --git a/libsrc/leddevice/LedRs232Device.h b/libsrc/leddevice/ProviderRs232.h similarity index 66% rename from libsrc/leddevice/LedRs232Device.h rename to libsrc/leddevice/ProviderRs232.h index 264c2829..4287aed9 100644 --- a/libsrc/leddevice/LedRs232Device.h +++ b/libsrc/leddevice/ProviderRs232.h @@ -7,25 +7,31 @@ #include /// -/// The LedRs232Device implements an abstract base-class for LedDevices using a RS232-device. +/// The ProviderRs232 implements an abstract base-class for LedDevices using a RS232-device. /// -class LedRs232Device : public LedDevice +class ProviderRs232 : public LedDevice { Q_OBJECT public: /// - /// Constructs the LedDevice attached to a RS232-device + /// Constructs specific LedDevice /// - /// @param[in] outputDevice The name of the output device (eg '/etc/ttyS0') - /// @param[in] baudrate The used baudrate for writing to the output device + /// @param deviceConfig json device config /// - LedRs232Device(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms = 0); + ProviderRs232(const Json::Value &deviceConfig); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + virtual bool setConfig(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open /// - virtual ~LedRs232Device(); + virtual ~ProviderRs232(); /// /// Opens and configures the output device @@ -45,6 +51,8 @@ protected: */ int writeBytes(const unsigned size, const uint8_t *data); + void closeDevice(); + private slots: /// Unblock the device after a connection delay void unblockAfterDelay(); @@ -55,10 +63,10 @@ private: bool tryOpen(); /// The name of the output device - const std::string _deviceName; + std::string _deviceName; /// The used baudrate of the output device - const qint32 _baudRate_Hz; + qint32 _baudRate_Hz; /// Sleep after the connect before continuing int _delayAfterConnect_ms; diff --git a/libsrc/leddevice/LedSpiDevice.cpp b/libsrc/leddevice/ProviderSpi.cpp similarity index 71% rename from libsrc/leddevice/LedSpiDevice.cpp rename to libsrc/leddevice/ProviderSpi.cpp index f0ed5b96..754f7b0a 100644 --- a/libsrc/leddevice/LedSpiDevice.cpp +++ b/libsrc/leddevice/ProviderSpi.cpp @@ -10,28 +10,36 @@ #include // Local Hyperion includes -#include "LedSpiDevice.h" +#include "ProviderSpi.h" #include -LedSpiDevice::LedSpiDevice(const std::string& outputDevice, const unsigned baudrate, const int latchTime_ns, const int spiMode, const bool spiDataInvert) - : _deviceName(outputDevice) - , _baudRate_Hz(baudrate) - , _latchTime_ns(latchTime_ns) +ProviderSpi::ProviderSpi(const Json::Value &deviceConfig) + : LedDevice() , _fid(-1) - , _spiMode(spiMode) - , _spiDataInvert(spiDataInvert) { + setConfig(deviceConfig); memset(&_spi, 0, sizeof(_spi)); Debug(_log, "_spiDataInvert %d, _spiMode %d", _spiDataInvert, _spiMode); } -LedSpiDevice::~LedSpiDevice() +ProviderSpi::~ProviderSpi() { // close(_fid); } -int LedSpiDevice::open() +bool ProviderSpi::setConfig(const Json::Value &deviceConfig) +{ + _deviceName = deviceConfig.get("output","/dev/spidev0.0").asString(); + _baudRate_Hz = deviceConfig.get("rate",1000000).asInt(); + _latchTime_ns = deviceConfig.get("latchtime",0).asInt(); + _spiMode = deviceConfig.get("spimode",SPI_MODE_0).asInt(); + _spiDataInvert = deviceConfig.get("invert",false).asBool(); + + return true; +} + +int ProviderSpi::open() { const int bitsPerWord = 8; @@ -61,7 +69,7 @@ int LedSpiDevice::open() return 0; } -int LedSpiDevice::writeBytes(const unsigned size, const uint8_t * data) +int ProviderSpi::writeBytes(const unsigned size, const uint8_t * data) { if (_fid < 0) { diff --git a/libsrc/leddevice/LedSpiDevice.h b/libsrc/leddevice/ProviderSpi.h similarity index 58% rename from libsrc/leddevice/LedSpiDevice.h rename to libsrc/leddevice/ProviderSpi.h index 8e27082b..9425b621 100644 --- a/libsrc/leddevice/LedSpiDevice.h +++ b/libsrc/leddevice/ProviderSpi.h @@ -7,27 +7,29 @@ #include /// -/// The LedSpiDevice implements an abstract base-class for LedDevices using the SPI-device. +/// The ProviderSpi implements an abstract base-class for LedDevices using the SPI-device. /// -class LedSpiDevice : public LedDevice +class ProviderSpi : public LedDevice { public: /// - /// Constructs the LedDevice attached to a SPI-device + /// Constructs specific LedDevice /// - /// @param[in] outputDevice The name of the output device (eg '/dev/spidev.0.0') - /// @param[in] baudrate The used baudrate for writing to the output device - /// @param[in] latchTime_ns The latch-time to latch in the values across the SPI-device (negative - /// means no latch required) [ns] + /// @param deviceConfig json device config /// - LedSpiDevice(const std::string& outputDevice, const unsigned baudrate, const int latchTime_ns = -1, - const int spiMode = SPI_MODE_0, const bool spiDataInvert = false); + ProviderSpi(const Json::Value &deviceConfig); + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + virtual bool setConfig(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open /// - virtual ~LedSpiDevice(); + virtual ~ProviderSpi(); /// /// Opens and configures the output device @@ -48,15 +50,14 @@ protected: /// int writeBytes(const unsigned size, const uint8_t *data); -private: /// The name of the output device - const std::string _deviceName; + std::string _deviceName; /// The used baudrate of the output device - const int _baudRate_Hz; + int _baudRate_Hz; /// The time which the device should be untouched after a write - const int _latchTime_ns; + int _latchTime_ns; /// The File Identifier of the opened output device (or -1 if not opened) int _fid; diff --git a/libsrc/leddevice/ProviderUdp.cpp b/libsrc/leddevice/ProviderUdp.cpp new file mode 100644 index 00000000..03ac61f0 --- /dev/null +++ b/libsrc/leddevice/ProviderUdp.cpp @@ -0,0 +1,86 @@ + +// STL includes +#include +#include +#include +#include +// Linux includes +#include +#include + +#include +#include +#include + +// Local Hyperion includes +#include "ProviderUdp.h" + +ProviderUdp::ProviderUdp(const Json::Value &deviceConfig) + : LedDevice() + , _LatchTime_ns(-1) +{ + setConfig(deviceConfig); + _udpSocket = new QUdpSocket(); +} + +ProviderUdp::~ProviderUdp() +{ + _udpSocket->close(); +} + +bool ProviderUdp::setConfig(const Json::Value &deviceConfig) +{ + if (_address.setAddress( QString::fromStdString(deviceConfig["host"].asString()) ) ) + { + Debug( _log, "Successfully parsed %s as an ip address.", deviceConfig["host"].asString().c_str()); + } + else + { + Debug( _log, "Failed to parse %s as an ip address.", deviceConfig["host"].asString().c_str()); + QHostInfo info = QHostInfo::fromName( QString::fromStdString(deviceConfig["host"].asString()) ); + if (info.addresses().isEmpty()) + { + Debug( _log, "Failed to parse %s as a hostname.", deviceConfig["host"].asString().c_str()); + throw std::runtime_error("invalid target address"); + } + Debug( _log, "Successfully parsed %s as a hostname.", deviceConfig["host"].asString().c_str()); + _address = info.addresses().first(); + } + _port = deviceConfig["port"].asUInt(); + Debug( _log, "UDP using %s:%d", _address.toString().toStdString().c_str() , _port ); + + return true; +} + +int ProviderUdp::open() +{ + QHostAddress localAddress = QHostAddress::Any; + quint16 localPort = 0; + + WarningIf( !_udpSocket->bind(localAddress, localPort), _log, "Could not bind local address: %s", strerror(errno)); + + return 0; +} + +int ProviderUdp::writeBytes(const unsigned size, const uint8_t * data) +{ + + qint64 retVal = _udpSocket->writeDatagram((const char *)data,size,_address,_port); + + if (retVal >= 0 && _LatchTime_ns > 0) + { + // The 'latch' time for latching the shifted-value into the leds + timespec latchTime; + latchTime.tv_sec = 0; + latchTime.tv_nsec = _LatchTime_ns; + + // Sleep to latch the leds (only if write succesfull) + nanosleep(&latchTime, NULL); + } + else + { + Warning( _log, "Error sending: %s", strerror(errno)); + } + + return retVal; +} diff --git a/libsrc/leddevice/LedUdpDevice.h b/libsrc/leddevice/ProviderUdp.h similarity index 59% rename from libsrc/leddevice/LedUdpDevice.h rename to libsrc/leddevice/ProviderUdp.h index 27ca481b..b5f9ec37 100644 --- a/libsrc/leddevice/LedUdpDevice.h +++ b/libsrc/leddevice/ProviderUdp.h @@ -7,24 +7,29 @@ #include /// -/// The LedUdpDevice implements an abstract base-class for LedDevices using the SPI-device. +/// The ProviderUdp implements an abstract base-class for LedDevices using the SPI-device. /// -class LedUdpDevice : public LedDevice +class ProviderUdp : public LedDevice { public: /// - /// Constructs the LedDevice sendig data via udp + /// Constructs specific LedDevice /// - /// @param[in] outputDevice string hostname:port - /// @param[in] latchTime_ns The latch-time to latch in the values across the SPI-device (negative - /// means no latch required) [ns] + /// @param deviceConfig json device config /// - LedUdpDevice(const std::string& outputDevice, const int latchTime_ns = -1); + ProviderUdp(const Json::Value &deviceConfig); /// /// Destructor of the LedDevice; closes the output device if it is open /// - virtual ~LedUdpDevice(); + virtual ~ProviderUdp(); + + /// + /// Sets configuration + /// + /// @param deviceConfig the json device config + /// @return true if success + bool setConfig(const Json::Value &deviceConfig); /// /// Opens and configures the output device @@ -45,12 +50,8 @@ protected: /// int writeBytes(const unsigned size, const uint8_t *data); -private: - /// The UDP destination as "host:port" - const std::string _target; - /// The time which the device should be untouched after a write - const int _LatchTime_ns; + int _LatchTime_ns; /// QUdpSocket * _udpSocket; diff --git a/libsrc/leddevice/schemas/schema-adalight.json b/libsrc/leddevice/schemas/schema-adalight.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-adalight.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-adalightapa102.json b/libsrc/leddevice/schemas/schema-adalightapa102.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-adalightapa102.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-apa102.json b/libsrc/leddevice/schemas/schema-apa102.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-apa102.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-atmo.json b/libsrc/leddevice/schemas/schema-atmo.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-atmo.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-atmoorb.json b/libsrc/leddevice/schemas/schema-atmoorb.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-atmoorb.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-e131.json b/libsrc/leddevice/schemas/schema-e131.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-e131.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-fadecandy.json b/libsrc/leddevice/schemas/schema-fadecandy.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-fadecandy.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-file.json b/libsrc/leddevice/schemas/schema-file.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-file.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-hyperion-usbasp.json b/libsrc/leddevice/schemas/schema-hyperion-usbasp.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-hyperion-usbasp.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-lightpack.json b/libsrc/leddevice/schemas/schema-lightpack.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-lightpack.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-lpd6803.json b/libsrc/leddevice/schemas/schema-lpd6803.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-lpd6803.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-lpd8806.json b/libsrc/leddevice/schemas/schema-lpd8806.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-lpd8806.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-multi-lightpack.json b/libsrc/leddevice/schemas/schema-multi-lightpack.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-multi-lightpack.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-p9813.json b/libsrc/leddevice/schemas/schema-p9813.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-p9813.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-paintpack.json b/libsrc/leddevice/schemas/schema-paintpack.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-paintpack.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-philipshue.json b/libsrc/leddevice/schemas/schema-philipshue.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-philipshue.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-piblaster.json b/libsrc/leddevice/schemas/schema-piblaster.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-piblaster.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-rawhid.json b/libsrc/leddevice/schemas/schema-rawhid.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-rawhid.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-sedu.json b/libsrc/leddevice/schemas/schema-sedu.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-sedu.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-sk6812rgbw-spi.json b/libsrc/leddevice/schemas/schema-sk6812rgbw-spi.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-sk6812rgbw-spi.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-tinkerforge.json b/libsrc/leddevice/schemas/schema-tinkerforge.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-tinkerforge.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-tmp2net.json b/libsrc/leddevice/schemas/schema-tmp2net.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-tmp2net.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-tpm2.json b/libsrc/leddevice/schemas/schema-tpm2.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-tpm2.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-udpraw.json b/libsrc/leddevice/schemas/schema-udpraw.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-udpraw.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-ws2801.json b/libsrc/leddevice/schemas/schema-ws2801.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-ws2801.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-ws2812spi.json b/libsrc/leddevice/schemas/schema-ws2812spi.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-ws2812spi.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/leddevice/schemas/schema-ws281x.json b/libsrc/leddevice/schemas/schema-ws281x.json new file mode 100644 index 00000000..0bce7984 --- /dev/null +++ b/libsrc/leddevice/schemas/schema-ws281x.json @@ -0,0 +1,7 @@ +{ + "type":"object", + "required":true, + "properties":{ + }, + "additionalProperties": true +} diff --git a/libsrc/protoserver/ProtoConnectionWrapper.cpp b/libsrc/protoserver/ProtoConnectionWrapper.cpp index e236e223..bc38e735 100644 --- a/libsrc/protoserver/ProtoConnectionWrapper.cpp +++ b/libsrc/protoserver/ProtoConnectionWrapper.cpp @@ -1,10 +1,13 @@ // protoserver includes #include "protoserver/ProtoConnectionWrapper.h" -ProtoConnectionWrapper::ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply) +ProtoConnectionWrapper::ProtoConnectionWrapper(const QString &address, + int priority, + int duration_ms, + bool skipProtoReply) : _priority(priority) , _duration_ms(duration_ms) - , _connection(address) + , _connection(address.toStdString()) { _connection.setSkipReply(skipProtoReply); connect(&_connection, SIGNAL(setGrabbingMode(GrabbingMode)), this, SIGNAL(setGrabbingMode(GrabbingMode))); diff --git a/libsrc/utils/ImageResampler.cpp b/libsrc/utils/ImageResampler.cpp index 0e17101c..d8df181c 100755 --- a/libsrc/utils/ImageResampler.cpp +++ b/libsrc/utils/ImageResampler.cpp @@ -1,14 +1,14 @@ #include "utils/ImageResampler.h" #include -ImageResampler::ImageResampler() : - _horizontalDecimation(1), - _verticalDecimation(1), - _cropLeft(0), - _cropRight(0), - _cropTop(0), - _cropBottom(0), - _videoMode(VIDEO_2D) +ImageResampler::ImageResampler() + : _horizontalDecimation(1) + , _verticalDecimation(1) + , _cropLeft(0) + , _cropRight(0) + , _cropTop(0) + , _cropBottom(0) + , _videoMode(VIDEO_2D) { } @@ -25,15 +25,15 @@ void ImageResampler::setHorizontalPixelDecimation(int decimator) void ImageResampler::setVerticalPixelDecimation(int decimator) { - _verticalDecimation = decimator; + _verticalDecimation = decimator; } void ImageResampler::setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom) { - _cropLeft = cropLeft; - _cropRight = cropRight; - _cropTop = cropTop; - _cropBottom = cropBottom; + _cropLeft = cropLeft; + _cropRight = cropRight; + _cropTop = cropTop; + _cropBottom = cropBottom; } void ImageResampler::set3D(VideoMode mode) @@ -62,70 +62,71 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i } // calculate the output size - int outputWidth = (width - cropLeft - cropRight - _horizontalDecimation/2 + _horizontalDecimation - 1) / _horizontalDecimation; - int outputHeight = (height - cropTop - cropBottom - _verticalDecimation/2 + _verticalDecimation - 1) / _verticalDecimation; - outputImage.resize(outputWidth, outputHeight); + int outputWidth = (width - cropLeft - cropRight - _horizontalDecimation/2 + _horizontalDecimation - 1) / _horizontalDecimation; + int outputHeight = (height - cropTop - cropBottom - _verticalDecimation/2 + _verticalDecimation - 1) / _verticalDecimation; + if ((outputImage.height() != unsigned(outputHeight)) && (outputImage.width() != unsigned(outputWidth))) + outputImage.resize(outputWidth, outputHeight); for (int yDest = 0, ySource = cropTop + _verticalDecimation/2; yDest < outputHeight; ySource += _verticalDecimation, ++yDest) { - for (int xDest = 0, xSource = cropLeft + _horizontalDecimation/2; xDest < outputWidth; xSource += _horizontalDecimation, ++xDest) + for (int xDest = 0, xSource = cropLeft + _horizontalDecimation/2; xDest < outputWidth; xSource += _horizontalDecimation, ++xDest) { ColorRgb & rgb = outputImage(xDest, yDest); - + switch (pixelFormat) { - case PIXELFORMAT_UYVY: + case PIXELFORMAT_UYVY: { - int index = lineLength * ySource + xSource * 2; + int index = lineLength * ySource + xSource * 2; uint8_t y = data[index+1]; uint8_t u = ((xSource&1) == 0) ? data[index ] : data[index-2]; uint8_t v = ((xSource&1) == 0) ? data[index+2] : data[index ]; yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue); } break; - case PIXELFORMAT_YUYV: + case PIXELFORMAT_YUYV: { - int index = lineLength * ySource + xSource * 2; + int index = lineLength * ySource + xSource * 2; uint8_t y = data[index]; uint8_t u = ((xSource&1) == 0) ? data[index+1] : data[index-1]; uint8_t v = ((xSource&1) == 0) ? data[index+3] : data[index+1]; yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue); } break; - case PIXELFORMAT_BGR16: - { - int index = lineLength * ySource + xSource * 2; - rgb.blue = (data[index] & 0x1f) << 3; - rgb.green = (((data[index+1] & 0x7) << 3) | (data[index] & 0xE0) >> 5) << 2; - rgb.red = (data[index+1] & 0xF8); - } - break; - case PIXELFORMAT_BGR24: - { - int index = lineLength * ySource + xSource * 3; - rgb.blue = data[index ]; - rgb.green = data[index+1]; - rgb.red = data[index+2]; - } - break; - case PIXELFORMAT_RGB32: - { - int index = lineLength * ySource + xSource * 4; - rgb.red = data[index ]; - rgb.green = data[index+1]; - rgb.blue = data[index+2]; - } - break; - case PIXELFORMAT_BGR32: - { - int index = lineLength * ySource + xSource * 4; - rgb.blue = data[index ]; - rgb.green = data[index+1]; - rgb.red = data[index+2]; - } - break; - case PIXELFORMAT_NO_CHANGE: - Error(Logger::getInstance("ImageResampler"), "Invalid pixel format given"); + case PIXELFORMAT_BGR16: + { + int index = lineLength * ySource + xSource * 2; + rgb.blue = (data[index] & 0x1f) << 3; + rgb.green = (((data[index+1] & 0x7) << 3) | (data[index] & 0xE0) >> 5) << 2; + rgb.red = (data[index+1] & 0xF8); + } + break; + case PIXELFORMAT_BGR24: + { + int index = lineLength * ySource + xSource * 3; + rgb.blue = data[index ]; + rgb.green = data[index+1]; + rgb.red = data[index+2]; + } + break; + case PIXELFORMAT_RGB32: + { + int index = lineLength * ySource + xSource * 4; + rgb.red = data[index ]; + rgb.green = data[index+1]; + rgb.blue = data[index+2]; + } + break; + case PIXELFORMAT_BGR32: + { + int index = lineLength * ySource + xSource * 4; + rgb.blue = data[index ]; + rgb.green = data[index+1]; + rgb.red = data[index+2]; + } + break; + case PIXELFORMAT_NO_CHANGE: + Error(Logger::getInstance("ImageResampler"), "Invalid pixel format given"); break; } } @@ -143,7 +144,7 @@ void ImageResampler::yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t &r, uint8_ int c = y - 16; int d = u - 128; int e = v - 128; - + r = clamp((298 * c + 409 * e + 128) >> 8); g = clamp((298 * c - 100 * d - 208 * e + 128) >> 8); b = clamp((298 * c + 516 * d + 128) >> 8); diff --git a/src/hyperion-aml/CMakeLists.txt b/src/hyperion-aml/CMakeLists.txt index 3493d3f3..0ee29a3d 100644 --- a/src/hyperion-aml/CMakeLists.txt +++ b/src/hyperion-aml/CMakeLists.txt @@ -30,7 +30,7 @@ add_executable(${PROJECT_NAME} ) target_link_libraries(${PROJECT_NAME} - getoptPlusPlus + commandline blackborder hyperion-utils protoserver diff --git a/src/hyperion-aml/hyperion-aml.cpp b/src/hyperion-aml/hyperion-aml.cpp index 191b871e..cc91a63e 100644 --- a/src/hyperion-aml/hyperion-aml.cpp +++ b/src/hyperion-aml/hyperion-aml.cpp @@ -4,20 +4,16 @@ #include #include -// getoptPlusPLus includes -#include - #include #include "AmlogicWrapper.h" #include "HyperionConfig.h" -#include +#include - -using namespace vlofgren; +using namespace commandline; // save the image as screenshot -void saveScreenshot(const char * filename, const Image & image) +void saveScreenshot(QString filename, const Image & image) { // store as PNG QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888); @@ -35,50 +31,30 @@ int main(int argc, char ** argv) try { - // create the option parser and initialize all parameters - OptionsParser optionParser("AmLogic capture application for Hyperion"); - ParameterSet & parameters = optionParser.getParameters(); + // create the option parser and initialize all parser + Parser parser("AmLogic capture application for Hyperion"); - IntParameter & argFps = parameters.add ('f', "framerate", "Capture frame rate [default: 10]"); - IntParameter & argWidth = parameters.add (0x0, "width", "Width of the captured image [default: 128]"); - IntParameter & argHeight = parameters.add (0x0, "height", "Height of the captured image [default: 128]"); - SwitchParameter<> & argScreenshot = parameters.add> (0x0, "screenshot", "Take a single screenshot, save it to file and quit"); - StringParameter & argAddress = parameters.add ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]"); - IntParameter & argPriority = parameters.add ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]"); - SwitchParameter<> & argSkipReply = parameters.add> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion"); - SwitchParameter<> & argHelp = parameters.add> ('h', "help", "Show this help message and exit"); - - // set defaults - argFps.setDefault(10); - argWidth.setDefault(160); - argHeight.setDefault(160); - argAddress.setDefault("127.0.0.1:19445"); - argPriority.setDefault(800); + IntOption & argFps = parser.add ('f', "framerate", "Capture frame rate [default: %1]", "10"); + IntOption & argWidth = parser.add (0x0, "width", "Width of the captured image [default: %1]", "160", 160, 4096); + IntOption & argHeight = parser.add (0x0, "height", "Height of the captured image [default: %1]", "160", 160, 4096); + BooleanOption & argScreenshot = parser.add (0x0, "screenshot", "Take a single screenshot, save it to file and quit"); + Option & argAddress = parser.add