commit c49c8f6e33a5ee199f34b932e552813d0d8db971 Author: Grant Terris Date: Sat Nov 9 15:02:46 2019 -0800 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2150658 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Cmake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +*_autogen + +# Qt +*.xml +*adaptor* + +# Executables +FaultFinder \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..fb92640 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/**", + "/usr/include/x86_64-linux-gnu/qt5/**", + "/usr/local/include/opencv4/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c11", + "cppStandard": "c++11", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..aab0671 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Build and Debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/FaultFinder", + "args": ["test"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "make", + "miDebuggerPath": "/usr/bin/gdb" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..82667a0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,61 @@ +{ + "files.associations": { + "iostream": "cpp", + "qudpsocket": "cpp", + "array": "cpp", + "atomic": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "map": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ratio": "cpp", + "set": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp", + "qdbusconnection": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e1e076c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "cmake", + "type": "shell", + "command": "cmake", + "args": [ + "." + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "make", + "type": "shell", + "command": "make", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": "cmake" + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..21b2f46 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8) +project( FaultFinder ) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +find_package( OpenCV REQUIRED ) +find_package( Ebus REQUIRED ) +find_package( Qt5 COMPONENTS Widgets Network DBus REQUIRED ) + +set(CMAKE_AUTOMOC ON) + +set(prog_SRCS DBus.xml) +qt5_generate_dbus_interface(ConfigManager.hpp + DBus.xml + OPTIONS -A + ) +qt5_add_dbus_adaptor(prog_SRCS + ${CMAKE_CURRENT_BINARY_DIR}/DBus.xml + ConfigManager.hpp + ConfigManager + ) + +include_directories( + ${OpenCV_INCLUDE_DIRS} + ${Ebus_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5Network_INCLUDE_DIRS} + ${Qt5DBus_INCLUDE_DIRS} +) + +add_executable( FaultFinder + FaultFinder.cpp + StreamManager.cpp + ImageManager.cpp + ConfigManager.cpp + FaultManager.cpp + ${prog_SRCS} +) + +target_link_libraries( FaultFinder + ${OpenCV_LIBS} + ${Ebus_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + ${Qt5Network_LIBRARIES} + ${Qt5DBus_LIBRARIES} + ) \ No newline at end of file diff --git a/ConfigManager.cpp b/ConfigManager.cpp new file mode 100644 index 0000000..2e4e7c9 --- /dev/null +++ b/ConfigManager.cpp @@ -0,0 +1,49 @@ +#include +#include + +#include "ConfigManager.hpp" +#include "dbusadaptor.h" + +ConfigManager::ConfigManager(QObject *parent) : QObject(parent) +{ + new ConfigManagerAdaptor(this); + + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject("/configuration", this); + dbus.registerService("com.infraredinspectionsystems.FaultFinder"); +} + +ConfigManager::~ConfigManager() +{ + +} + +bool ConfigManager::GetRecordingState() +{ + qDebug() << "ConfigManager::GetRecordingState"; + return this->recording; +} + +void ConfigManager::SetRecordingState(bool enable) +{ + qDebug() << "ConfigManager::SetRecordingState"; + if (this->recording != enable) { + this->recording = enable; + emit NewRecordingState(this->recording); + } +} + +double ConfigManager::GetEmissivity() +{ + qDebug() << "ConfigManager::GetEmissivity"; + return this->emissivity; +} + +void ConfigManager::SetEmissivity(double emissivity) +{ + qDebug() << "ConfigManager::SetEmissivity"; + if (this->emissivity != emissivity) { + this->emissivity = emissivity; + emit NewEmissivity(this->emissivity); + } +} \ No newline at end of file diff --git a/ConfigManager.hpp b/ConfigManager.hpp new file mode 100644 index 0000000..2afc42c --- /dev/null +++ b/ConfigManager.hpp @@ -0,0 +1,32 @@ +#ifndef CONFIG_MANAGER_H +#define CONFIG_MANAGER_H + +#include + +class ConfigManager: public QObject +{ + Q_OBJECT; + Q_PROPERTY(bool recording READ GetRecordingState WRITE SetRecordingState) + Q_PROPERTY(double emissivity READ GetEmissivity WRITE SetEmissivity) + +public: + ConfigManager(QObject *parent); + virtual ~ConfigManager(); + +public slots: + bool GetRecordingState(); + void SetRecordingState(bool enable); + double GetEmissivity(); + void SetEmissivity(double emissivity); + +signals: + void NewRecordingState(bool enable); + void NewEmissivity(double emissivity); + +private: + bool recording = false; + double emissivity = 0.7; + +}; + +#endif \ No newline at end of file diff --git a/FaultFinder.cpp b/FaultFinder.cpp new file mode 100644 index 0000000..1a60467 --- /dev/null +++ b/FaultFinder.cpp @@ -0,0 +1,20 @@ +#include + +#include "StreamManager.hpp" +#include "ImageManager.hpp" +#include "FaultManager.hpp" +#include "ConfigManager.hpp" + +using namespace std; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + //ImageManager image_mgr(&app); + //FaultManager fault_mgr(&app); + ConfigManager config_mgr(&app); + //StreamManager stream_mgr(&app); + + return app.exec(); +} \ No newline at end of file diff --git a/FaultManager.cpp b/FaultManager.cpp new file mode 100644 index 0000000..c69190a --- /dev/null +++ b/FaultManager.cpp @@ -0,0 +1,6 @@ +#include "FaultManager.hpp" + +FaultManager::FaultManager(QObject *parent) : QObject(parent) +{ + +} \ No newline at end of file diff --git a/FaultManager.hpp b/FaultManager.hpp new file mode 100644 index 0000000..c3e5328 --- /dev/null +++ b/FaultManager.hpp @@ -0,0 +1,18 @@ +#ifndef FAULT_MANAGER_H +#define FAULT_MANAGER_H + +#include + +class FaultManager: public QObject +{ + + Q_OBJECT; + +public: + + FaultManager(QObject *parent); + void Handle(); + +}; + +#endif \ No newline at end of file diff --git a/ImageManager.cpp b/ImageManager.cpp new file mode 100644 index 0000000..4d389d8 --- /dev/null +++ b/ImageManager.cpp @@ -0,0 +1,13 @@ +#include +#include + +#include "ImageManager.hpp" + +ImageManager::ImageManager(QObject *parent) : QObject(parent) +{ +} + +ImageManager::~ImageManager() +{ + +} \ No newline at end of file diff --git a/ImageManager.hpp b/ImageManager.hpp new file mode 100644 index 0000000..c4c0c9d --- /dev/null +++ b/ImageManager.hpp @@ -0,0 +1,18 @@ +#ifndef IMAGE_MANAGER_H +#define IMAGE_MANAGER_H + +#include + +class ImageManager: public QObject +{ + + Q_OBJECT; + +public: + + ImageManager(QObject *parent); + virtual ~ImageManager(); + +}; + +#endif \ No newline at end of file diff --git a/StreamManager.cpp b/StreamManager.cpp new file mode 100644 index 0000000..be01739 --- /dev/null +++ b/StreamManager.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +#include "StreamManager.hpp" +#include "ImageManager.hpp" + +StreamManager::StreamManager(QObject *parent) : QObject(parent) +{ + QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&StreamManager::Process)); + timer->start(1000); +} + +void StreamManager::Process() +{ + qInfo() << "TICK"; +} \ No newline at end of file diff --git a/StreamManager.hpp b/StreamManager.hpp new file mode 100644 index 0000000..8b688e1 --- /dev/null +++ b/StreamManager.hpp @@ -0,0 +1,18 @@ +#ifndef STREAM_MANAGER_H +#define STREAM_MANAGER_H + +#include + +class StreamManager : public QObject +{ + + Q_OBJECT; + +public: + + StreamManager(QObject *parent); + void Process(); + +}; + +#endif \ No newline at end of file diff --git a/cmake/FindEbus.cmake b/cmake/FindEbus.cmake new file mode 100644 index 0000000..6eddc52 --- /dev/null +++ b/cmake/FindEbus.cmake @@ -0,0 +1,151 @@ +# FindEbus.cmake - Find ebus sdk, version >= 4. +# quchao@seas.upenn.edu (Chao Qu) +# Modified from FindEigen.cmake by alexs.mac@gmail.com (Alex Stewart) +# +# This module defines the following variables: +# +# Ebus_FOUND: TRUE if ebus is found. +# Ebus_INCLUDE_DIRS: Include directories for ebus. +# Ebus_LIBRARIES: Libraries for all ebus component libraries +# and dependencies. +# +# Ebus_VERSION: Extracted from lib/PvBase.so.x.y.z +# Ebus_WORLD_VERSION: Equal to 4 if Ebus_VERSION = 4.0.5 +# Ebus_MAJOR_VERSION: Equal to 0 if Ebus_VERSION = 4.0.5 +# Ebus_MINOR_VERSION: Equal to 5 if Ebus_VERSION = 4.0.5 +# +# The following variables control the behaviour of this module: +# +# Ebus_INCLUDE_DIR_HINTS: List of additional directories in which to +# search for ebus includes, e.g: /foo/include. +# Ebus_LIBRARY_DIR_HINTS: List of additional directories in which to +# search for ebus libraries, e.g: /bar/lib. +# +# The following variables are also defined by this module, but in line with +# CMake recommended FindPackage() module style should NOT be referenced directly +# by callers (use the plural variables detailed above instead). These variables +# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which +# are NOT re-called (i.e. search for library is not repeated) if these variables +# are set with valid values _in the CMake cache_. This means that if these +# variables are set directly in the cache, either by the user in the CMake GUI, +# or by the user passing -DVAR=VALUE directives to CMake when called (which +# explicitly defines a cache variable), then they will be used verbatim, +# bypassing the HINTS variables and other hard-coded search locations. +# +# Ebus_INCLUDE_DIR: Include directory for ebus, not including the +# include directory of any dependencies. +# Ebus_LIBRARY: ebus library, not including the libraries of any +# dependencies. + +# Called if we failed to find ebus or any of it's required dependencies, +# unsets all public (designed to be used externally) variables and reports +# error message at priority depending upon [REQUIRED/QUIET/] argument. +macro(Ebus_REPORT_NOT_FOUND REASON_MSG) + unset(Ebus_FOUND) + unset(Ebus_INCLUDE_DIRS) + unset(Ebus_LIBRARIES) + unset(Ebus_WORLD_VERSION) + unset(Ebus_MAJOR_VERSION) + unset(Ebus_MINOR_VERSION) + # Make results of search visible in the CMake GUI if ebus has not + # been found so that user does not have to toggle to advanced view. + mark_as_advanced(CLEAR Ebus_INCLUDE_DIR) + # Note _FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() + # use the camelcase library name, not uppercase. + if(Ebus_FIND_QUIETLY) + message(STATUS "Failed to find ebus - " ${REASON_MSG} ${ARGN}) + elseif(Ebus_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find ebus - " ${REASON_MSG} ${ARGN}) + else() + # Neither QUIETLY nor REQUIRED, use no priority which emits a message + # but continues configuration and allows generation. + message("-- Failed to find ebus - " ${REASON_MSG} ${ARGN}) + endif() +endmacro(Ebus_REPORT_NOT_FOUND) + +# Search user-installed locations first, so that we prefer user installs +# to system installs where both exist. +list(APPEND Ebus_CHECK_INCLUDE_DIRS + /opt/pleora/ebus_sdk/Ubuntu-x86_64/include) +list(APPEND Ebus_CHECK_LIBRARY_DIRS + /opt/pleora/ebus_sdk/Ubuntu-x86_64/lib) + +# Check general hints +if(Ebus_HINTS AND EXISTS ${Ebus_HINTS}) + set(Ebus_INCLUDE_DIR_HINTS ${Ebus_HINTS}/include) + set(Ebus_LIBRARY_DIR_HINTS ${Ebus_HINTS}/lib) +endif() + +# Search supplied hint directories first if supplied. +# Find include directory for ebus +find_path(Ebus_INCLUDE_DIR + NAMES PvBase.h + PATHS ${Ebus_INCLUDE_DIR_HINTS} + ${Ebus_CHECK_INCLUDE_DIRS} + NO_DEFAULT_PATH) +if(NOT Ebus_INCLUDE_DIR OR NOT EXISTS ${Ebus_INCLUDE_DIR}) + Ebus_REPORT_NOT_FOUND( + "Could not find ebus include directory, set Ebus_INCLUDE_DIR to " + "path to ebus include directory," + "e.g. /opt/pleora/ebus_sdk/Ubuntu-x86_64/include.") +else() + #message(STATUS "ebus include dir found: " ${Ebus_INCLUDE_DIR}) +endif() + +# Find library directory for ebus +find_library(Ebus_LIBRARY + NAMES PvBase + PATHS ${Ebus_LIBRARY_DIR_HINTS} + ${Ebus_CHECK_LIBRARY_DIRS} + NO_DEFAULT_PATH) +if(NOT Ebus_LIBRARY OR NOT EXISTS ${Ebus_LIBRARY}) + Ebus_REPORT_NOT_FOUND( + "Could not find ebus library, set Ebus_LIBRARY " + "to full path to ebus library direcotory.") +else() + # TODO: need to fix this hacky solution for getting Ebus_LIBRARY_DIR + string(REGEX MATCH ".*/" Ebus_LIBRARY_DIR ${Ebus_LIBRARY}) +endif() + +# Mark internally as found, then verify. Ebus_REPORT_NOT_FOUND() unsets if +# called. +set(Ebus_FOUND TRUE) + +# Extract ebus version from ebus_sdk/Ubuntu-12.04-x86_64/lib/libPvBase.so.x.y.z +if(Ebus_LIBRARY_DIR) + file(GLOB Ebus_PVBASE + RELATIVE ${Ebus_LIBRARY_DIR} + ${Ebus_LIBRARY_DIR}/libPvBase.so.[0-9].[0-9].[0-9]) + # TODO: add version support + # string(REGEX MATCH "" + # Ebus_WORLD_VERSION ${Ebus_PVBASE}) + # message(STATUS "ebus world version: " ${Ebus_WORLD_VERSION}) +endif() + +# Catch case when caller has set Ebus_INCLUDE_DIR in the cache / GUI and +# thus FIND_[PATH/LIBRARY] are not called, but specified locations are +# invalid, otherwise we would report the library as found. +if(Ebus_INCLUDE_DIR AND NOT EXISTS ${Ebus_INCLUDE_DIR}/PvBase.h) + Ebus_REPORT_NOT_FOUND("Caller defined Ebus_INCLUDE_DIR: " + ${Ebus_INCLUDE_DIR} + " does not contain PvBase.h header.") +endif() + +# Set standard CMake FindPackage variables if found. +if(Ebus_FOUND) + set(Ebus_INCLUDE_DIRS ${Ebus_INCLUDE_DIR}) + file(GLOB Ebus_LIBRARIES ${Ebus_LIBRARY_DIR}libPv*.so) +endif() + +# Handle REQUIRED / QUIET optional arguments. +include(FindPackageHandleStandardArgs) +if(Ebus_FOUND) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ebus DEFAULT_MSG + Ebus_INCLUDE_DIRS Ebus_LIBRARIES) +endif() + +# Only mark internal variables as advanced if we found ebus, otherwise +# leave it visible in the standard GUI for the user to set manually. +if(Ebus_FOUND) + mark_as_advanced(FORCE Ebus_INCLUDE_DIR Ebus_LIBRARY) +endif()