diff --git a/src/build/.cmake/api/v1/reply/index-2023-04-06T19-30-51-0911.json b/src/build/.cmake/api/v1/reply/index-2023-04-06T21-06-58-0296.json similarity index 100% rename from src/build/.cmake/api/v1/reply/index-2023-04-06T19-30-51-0911.json rename to src/build/.cmake/api/v1/reply/index-2023-04-06T21-06-58-0296.json diff --git a/src/model/hardware/hw/extendables/Device.hpp b/src/model/hardware/hw/extendables/Device.hpp index c1cbe8f..217449c 100644 --- a/src/model/hardware/hw/extendables/Device.hpp +++ b/src/model/hardware/hw/extendables/Device.hpp @@ -9,7 +9,7 @@ class Device{ std::string _displayName; std::map* _commands = new std::map(); public: - std::atomic_bool enabled = true; + std::atomic_bool enabled = false; std::atomic_bool working = false; std::atomic_int workDelayMs = 60; inline Device(const std::string& tagidentifier) : _tagidentifier(tagidentifier){} diff --git a/src/model/hardware/hw/extendables/DeviceTree.cpp b/src/model/hardware/hw/extendables/DeviceTree.cpp index 0573712..7278ae1 100644 --- a/src/model/hardware/hw/extendables/DeviceTree.cpp +++ b/src/model/hardware/hw/extendables/DeviceTree.cpp @@ -48,8 +48,12 @@ void DeviceTree::build(){ if(back.find(kv.first) != std::string::npos){ std::cout << "uids matched! port assigned"<< std::endl; (*serialDevices)[kv.first]->serialPort = serialPort; + (*serialDevices)[kv.first]->enabled = true; assigned = true; std::cout << "assign done"<< std::endl; + }else{ + std::cout << "device sent back uid but no match, an extension may be missing"<< std::endl; + assigned = false; } } @@ -76,7 +80,7 @@ void DeviceTree::runDevice(SerialDevice* device){ while(device->enabled){ if(!device->working){ device->working = true; - device->doPortWork(); + device->runPort(); } std::this_thread::sleep_for(std::chrono::milliseconds(device->workDelayMs)); } diff --git a/src/model/hardware/hw/extendables/SerialDevice.hpp b/src/model/hardware/hw/extendables/SerialDevice.hpp index 22b418a..4a38bc1 100644 --- a/src/model/hardware/hw/extendables/SerialDevice.hpp +++ b/src/model/hardware/hw/extendables/SerialDevice.hpp @@ -23,10 +23,15 @@ class SerialDevice : public Device{ unsigned int _baudrate; std::string lastData; public: - mn::CppLinuxSerial::SerialPort* serialPort; + mn::CppLinuxSerial::SerialPort* serialPort = nullptr; DeviceCommand* ic; SerialDevice(const std::string& serialPort) : Device("blank"), _serialPort(serialPort){} void getID(); + void runPort(){ + if(enabled){ + doPortWork(); + } + } virtual void doPortWork() = 0; ~SerialDevice(){ delete ic; diff --git a/src/model/hardware/hw/inputKeys.hpp b/src/model/hardware/hw/inputKeys.hpp index 802a40f..92147e3 100644 --- a/src/model/hardware/hw/inputKeys.hpp +++ b/src/model/hardware/hw/inputKeys.hpp @@ -59,10 +59,10 @@ enum class KeyboardKeyCode: unsigned int { BACKSPACE = 8, TAB = 9, CAPS_LOCK = 20, - LEFT_ARROW = 37, - UP_ARROW = 38, - RIGHT_ARROW = 39, - DOWN_ARROW = 40, + LEFT_ARROW = 81, + UP_ARROW = 84, + RIGHT_ARROW = 83, + DOWN_ARROW = 82, INSERT = 45, DELETE_KEY = 46, HOME = 36, diff --git a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal index 6e3fc60..eb71548 100644 --- a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal +++ b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal @@ -325,6 +325,42 @@ model/windows/CMakeFiles/windows.dir/window.cpp.o /usr/include/GL/glu.h /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp /usr/include/c++/11/iostream + /home/kanken/code/AHRS_core/src/model/hardware/hw/inputManager.hpp + /usr/include/c++/11/thread + /usr/include/c++/11/bits/std_thread.h + /usr/include/c++/11/bits/this_thread_sleep.h + /home/kanken/code/AHRS_core/src/threadweaver/threadweaver.hpp + /usr/include/unistd.h + /usr/include/x86_64-linux-gnu/bits/posix_opt.h + /usr/include/x86_64-linux-gnu/bits/environments.h + /usr/include/x86_64-linux-gnu/bits/confname.h + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h + /usr/include/x86_64-linux-gnu/bits/getopt_core.h + /usr/include/x86_64-linux-gnu/bits/unistd_ext.h + /usr/include/linux/close_range.h + /usr/include/c++/11/filesystem + /usr/include/c++/11/bits/fs_fwd.h + /usr/include/c++/11/bits/fs_path.h + /usr/include/c++/11/locale + /usr/include/c++/11/bits/locale_facets_nonio.h + /usr/include/x86_64-linux-gnu/c++/11/bits/time_members.h + /usr/include/x86_64-linux-gnu/c++/11/bits/messages_members.h + /usr/include/libintl.h + /usr/include/c++/11/bits/codecvt.h + /usr/include/c++/11/bits/locale_facets_nonio.tcc + /usr/include/c++/11/bits/locale_conv.h + /usr/include/c++/11/iomanip + /usr/include/c++/11/bits/quoted_string.h + /usr/include/c++/11/codecvt + /usr/include/c++/11/bits/fs_dir.h + /usr/include/c++/11/bits/fs_ops.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp + /home/kanken/code/AHRS_core/src/model/patterns/observer/observable.hpp + /usr/include/c++/11/list + /usr/include/c++/11/bits/stl_list.h + /usr/include/c++/11/bits/list.tcc + /home/kanken/code/AHRS_core/src/model/patterns/observer/observer.hpp + /home/kanken/code/AHRS_core/src/model/hardware/hw/inputKeys.hpp model/windows/CMakeFiles/windows.dir/windowManager.cpp.o /home/kanken/code/AHRS_core/src/model/windows/windowManager.cpp diff --git a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make index 0f2782c..6cec8f5 100644 --- a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make +++ b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make @@ -323,7 +323,43 @@ model/windows/CMakeFiles/windows.dir/window.cpp.o: model/windows/window.cpp \ /usr/include/KHR/khrplatform.h \ /usr/include/GL/glu.h \ threadweaver/debugging.hpp \ - /usr/include/c++/11/iostream + /usr/include/c++/11/iostream \ + model/hardware/hw/inputManager.hpp \ + /usr/include/c++/11/thread \ + /usr/include/c++/11/bits/std_thread.h \ + /usr/include/c++/11/bits/this_thread_sleep.h \ + threadweaver/threadweaver.hpp \ + /usr/include/unistd.h \ + /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_posix.h \ + /usr/include/x86_64-linux-gnu/bits/getopt_core.h \ + /usr/include/x86_64-linux-gnu/bits/unistd_ext.h \ + /usr/include/linux/close_range.h \ + /usr/include/c++/11/filesystem \ + /usr/include/c++/11/bits/fs_fwd.h \ + /usr/include/c++/11/bits/fs_path.h \ + /usr/include/c++/11/locale \ + /usr/include/c++/11/bits/locale_facets_nonio.h \ + /usr/include/x86_64-linux-gnu/c++/11/bits/time_members.h \ + /usr/include/x86_64-linux-gnu/c++/11/bits/messages_members.h \ + /usr/include/libintl.h \ + /usr/include/c++/11/bits/codecvt.h \ + /usr/include/c++/11/bits/locale_facets_nonio.tcc \ + /usr/include/c++/11/bits/locale_conv.h \ + /usr/include/c++/11/iomanip \ + /usr/include/c++/11/bits/quoted_string.h \ + /usr/include/c++/11/codecvt \ + /usr/include/c++/11/bits/fs_dir.h \ + /usr/include/c++/11/bits/fs_ops.h \ + threadweaver/debugging.hpp \ + model/patterns/observer/observable.hpp \ + /usr/include/c++/11/list \ + /usr/include/c++/11/bits/stl_list.h \ + /usr/include/c++/11/bits/list.tcc \ + model/patterns/observer/observer.hpp \ + model/hardware/hw/inputKeys.hpp model/windows/CMakeFiles/windows.dir/windowManager.cpp.o: model/windows/windowManager.cpp \ /usr/include/stdc-predef.h \ @@ -656,6 +692,42 @@ model/windows/CMakeFiles/windows.dir/windowManager.cpp.o: model/windows/windowMa model/windows/windowManager.cpp: +model/patterns/observer/observer.hpp: + +/usr/include/c++/11/bits/list.tcc: + +/usr/include/c++/11/list: + +/usr/include/c++/11/bits/fs_ops.h: + +/usr/include/c++/11/bits/fs_dir.h: + +/usr/include/c++/11/bits/quoted_string.h: + +/usr/include/c++/11/bits/locale_conv.h: + +/usr/include/c++/11/bits/locale_facets_nonio.tcc: + +/usr/include/libintl.h: + +/usr/include/x86_64-linux-gnu/c++/11/bits/messages_members.h: + +/usr/include/x86_64-linux-gnu/c++/11/bits/time_members.h: + +/usr/include/c++/11/bits/locale_facets_nonio.h: + +/usr/include/c++/11/filesystem: + +/usr/include/x86_64-linux-gnu/bits/unistd_ext.h: + +/usr/include/x86_64-linux-gnu/bits/getopt_core.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +model/hardware/hw/inputManager.hpp: + threadweaver/debugging.hpp: /usr/include/GL/glu.h: @@ -776,6 +848,8 @@ model/windows/windowManager.hpp: /usr/include/x86_64-linux-gnu/bits/posix2_lim.h: +/usr/include/unistd.h: + /usr/include/c++/11/bits/stl_algobase.h: /usr/lib/gcc/x86_64-linux-gnu/11/include/stdint.h: @@ -860,6 +934,8 @@ model/windows/windowManager.hpp: /usr/include/c++/11/bits/std_function.h: +model/patterns/observer/observable.hpp: + /usr/include/c++/11/type_traits: /usr/include/x86_64-linux-gnu/sys/single_threaded.h: @@ -894,6 +970,8 @@ model/windows/windowManager.hpp: /usr/include/c++/11/limits: +/usr/include/c++/11/bits/fs_path.h: + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: /usr/include/x86_64-linux-gnu/bits/uintn-identity.h: @@ -904,6 +982,8 @@ model/windows/windowManager.hpp: /usr/local/include/opencv4/opencv2/core/cvdef.h: +/usr/include/linux/close_range.h: + model/windows/window.hpp: /usr/include/x86_64-linux-gnu/bits/types/timer_t.h: @@ -912,12 +992,16 @@ model/windows/window.hpp: /usr/local/include/opencv4/opencv2/core/core.hpp: +threadweaver/threadweaver.hpp: + /usr/lib/gcc/x86_64-linux-gnu/11/include/syslimits.h: /usr/include/c++/11/debug/debug.h: /usr/include/features-time64.h: +/usr/include/x86_64-linux-gnu/bits/environments.h: + /usr/include/c++/11/bits/exception_defines.h: /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h: @@ -1068,6 +1152,8 @@ model/windows/window.cpp: /usr/include/c++/11/unordered_map: +/usr/include/c++/11/iomanip: + /usr/include/c++/11/cctype: /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h: @@ -1100,6 +1186,8 @@ model/windows/window.cpp: /usr/local/include/opencv4/opencv2/core/cvstd.hpp: +/usr/include/c++/11/bits/codecvt.h: + /usr/include/c++/11/bits/basic_ios.tcc: /usr/include/c++/11/bits/enable_special_members.h: @@ -1134,10 +1222,14 @@ model/windows/window.cpp: /usr/include/c++/11/bits/vector.tcc: +/usr/include/c++/11/codecvt: + /usr/include/c++/11/bits/streambuf.tcc: /usr/include/string.h: +/usr/include/c++/11/locale: + /usr/include/ctype.h: /usr/include/x86_64-linux-gnu/bits/uio_lim.h: @@ -1192,12 +1284,16 @@ model/windows/window.cpp: /usr/include/x86_64-linux-gnu/bits/cpu-set.h: +/usr/include/x86_64-linux-gnu/bits/getopt_posix.h: + /usr/include/time.h: /usr/include/x86_64-linux-gnu/bits/setjmp.h: /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h: +/usr/include/c++/11/bits/fs_fwd.h: + /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h: /usr/include/c++/11/bits/stl_bvector.h: @@ -1264,6 +1360,8 @@ model/windows/window.cpp: /usr/include/x86_64-linux-gnu/bits/mathcalls-narrow.h: +/usr/include/c++/11/bits/stl_list.h: + /usr/include/x86_64-linux-gnu/bits/iscanonical.h: /usr/include/c++/11/bits/specfun.h: @@ -1276,6 +1374,8 @@ model/windows/window.cpp: /usr/include/c++/11/tr1/bessel_function.tcc: +model/hardware/hw/inputKeys.hpp: + /usr/include/c++/11/bits/atomic_lockfree_defines.h: /usr/include/c++/11/array: diff --git a/src/model/windows/window.cpp b/src/model/windows/window.cpp index f64d485..61520bc 100644 --- a/src/model/windows/window.cpp +++ b/src/model/windows/window.cpp @@ -1,5 +1,5 @@ #include "window.hpp" - +#include "../hardware/hw/inputManager.hpp" void glDrawTextureCallback(void* userdata) { cv::ogl::Texture2D* texObj = static_cast(userdata); @@ -35,7 +35,10 @@ void Window::draw(){ #else cv::imshow(this->myWindow, drawBuffer); #endif - cv::waitKey(1); + int key = cv::waitKey(1); + if (key >= 0) { + InputManager::GetInstance()->sendinput(key, InputTypes::KEYBOARD); + } } catch(...){ drawAccess.unlock(); diff --git a/src/pipeline/abstract/pipelineNode.hpp b/src/pipeline/abstract/pipelineNode.hpp index 721253e..438dc72 100644 --- a/src/pipeline/abstract/pipelineNode.hpp +++ b/src/pipeline/abstract/pipelineNode.hpp @@ -14,8 +14,10 @@ /// @brief this class represents an unthreaded sub-node of a given node of the graphcis pipeline class SubNode{ public: - virtual void processFrame(cv::UMat& input, cv::Point2d& cursorPos)=0; + void doWork(cv::UMat& input, cv::Point2d& cursorPos){if(enabled){processFrame(input,cursorPos);}} std::atomic_bool enabled = true; + protected: + virtual void processFrame(cv::UMat& input, cv::Point2d& cursorPos)=0; }; /// @brief this class represents a threaded node of the graphics pipeline diff --git a/src/pipeline/members/cameraPickerNode.cpp b/src/pipeline/members/cameraPickerNode.cpp index 3c4b85f..9186611 100644 --- a/src/pipeline/members/cameraPickerNode.cpp +++ b/src/pipeline/members/cameraPickerNode.cpp @@ -18,7 +18,7 @@ void cameraPickerNode::processFrame(){ _sourceManager->accessLocks[0]->unlock(); Point2d p(0,0); for (SubNode* sn : subNodes) - if(sn->enabled) sn->processFrame(output,p); + if(sn->enabled) sn->doWork(output,p); outputLock.unlock(); DEBUG_LOG("cameraPickerNode on thread " << localThread->get_id() << " is done picking its camera frame"); diff --git a/src/pipeline/members/pluginNode.cpp b/src/pipeline/members/pluginNode.cpp index c0b3ef0..e79b800 100644 --- a/src/pipeline/members/pluginNode.cpp +++ b/src/pipeline/members/pluginNode.cpp @@ -20,7 +20,7 @@ void PluginNode::processFrame() DEBUG_LOG("PluginNode on thread " << localThread->get_id() << " fetched camera frame"); Point2d p(0,0); for (SubNode* sn : subNodes) - if(sn->enabled) sn->processFrame(toProcess,p); + if(sn->enabled) sn->doWork(toProcess,p); DEBUG_LOG("PluginNode on thread " << localThread->get_id() << " processed camera frame"); outputLock.lock(); output = toProcess; // write the final image to the psvr UI buffer diff --git a/src/pipeline/members/uiDrawerNode.cpp b/src/pipeline/members/uiDrawerNode.cpp index f495df8..d30c6c0 100644 --- a/src/pipeline/members/uiDrawerNode.cpp +++ b/src/pipeline/members/uiDrawerNode.cpp @@ -59,7 +59,7 @@ void UiDrawerNode::processFrame() Point2d pc = Point2d(0,stackerIndex); cv::rectangle(MenuMat, cv::Rect2i(0, stackerIndex+5, wd, 1), Scalar(200, 0, 0), 3, 8, 0); for (SubNode* sn : subNodes) - if(sn->enabled) sn->processFrame(MenuMat,pc); + if(sn->enabled) sn->doWork(MenuMat,pc); outputLock.lock(); output = MenuMat; outputLock.unlock(); diff --git a/src/pipeline/members/uiMergerNode.cpp b/src/pipeline/members/uiMergerNode.cpp index 0b5f7a2..eda3ac5 100644 --- a/src/pipeline/members/uiMergerNode.cpp +++ b/src/pipeline/members/uiMergerNode.cpp @@ -19,7 +19,7 @@ void UiMergerNode::processFrame() Point2d p(0,0); for (SubNode* sn : subNodes) - if(sn->enabled) sn->processFrame(cameraFrame,p); + if(sn->enabled) sn->doWork(cameraFrame,p); cameraFrame = UiSupport::resizeIn(cameraFrame); // resize the frame to the standard format // Copy the frame in the center of the background diff --git a/src/pluginManagement/PluginManager.cpp b/src/pluginManagement/PluginManager.cpp index dd9bbfe..0988a8d 100644 --- a/src/pluginManagement/PluginManager.cpp +++ b/src/pluginManagement/PluginManager.cpp @@ -25,7 +25,7 @@ PluginManager::PluginManager(Pipeline& pi){ if(pl->loadNode != NULL){ std::cout << "loading plugin node\n"; SubNode* sn = pl->loadNode(); - sn->enabled = true; + sn->enabled = false; pi.getNodes().at(6)->addSubNode(sn); std::cout << "loaded plugin node\n"; } diff --git a/src/prog b/src/prog index d39a7b0..60052f4 100755 Binary files a/src/prog and b/src/prog differ