├── .clang-format ├── .github └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── 3rdParty └── CMakeLists.txt ├── CANdevResources.qrc ├── CMakeLists.txt ├── Doxyfile ├── LICENSE ├── README.md ├── cmake ├── Modules │ ├── CodeCoverage.cmake │ ├── CompilerVersion.cmake │ └── FindLibnl.cmake └── osx_bundle.cmake ├── codecov.yml ├── doc └── CANBus_Styleguide.pdf ├── files ├── CANdevStudio.sh ├── css │ ├── darkStyle.css │ ├── lightStyle.css │ ├── toolBar_dark.css │ └── toolBar_light.css ├── images │ ├── dark │ │ ├── Angle-down-01.svg │ │ ├── Angle-up-01.svg │ │ ├── CANbus_icon_Add.svg │ │ ├── CANbus_icon_CascadeView.svg │ │ ├── CANbus_icon_CascadeView_disabled.svg │ │ ├── CANbus_icon_CheckBoxOff.svg │ │ ├── CANbus_icon_CheckBoxOff_disabled.svg │ │ ├── CANbus_icon_CheckBoxOn.svg │ │ ├── CANbus_icon_CheckBoxOn_disabled.svg │ │ ├── CANbus_icon_Clear.svg │ │ ├── CANbus_icon_Close.svg │ │ ├── CANbus_icon_CloseSim.svg │ │ ├── CANbus_icon_CloseSim_disabled.svg │ │ ├── CANbus_icon_Close_tab.svg │ │ ├── CANbus_icon_Close_tab_selected.svg │ │ ├── CANbus_icon_Combine.svg │ │ ├── CANbus_icon_Input.svg │ │ ├── CANbus_icon_InputOutput.svg │ │ ├── CANbus_icon_Lock.svg │ │ ├── CANbus_icon_NewProject.svg │ │ ├── CANbus_icon_OpenProject.svg │ │ ├── CANbus_icon_OpenSim.svg │ │ ├── CANbus_icon_OpenSim_disabled.svg │ │ ├── CANbus_icon_Output.svg │ │ ├── CANbus_icon_Remove.svg │ │ ├── CANbus_icon_SaveAsProject.svg │ │ ├── CANbus_icon_SaveAsProject_disabled.svg │ │ ├── CANbus_icon_SaveProject.svg │ │ ├── CANbus_icon_SaveProject_disabled.svg │ │ ├── CANbus_icon_Switch.svg │ │ ├── CANbus_icon_Switch_2.svg │ │ ├── CANbus_icon_TabsView.svg │ │ ├── CANbus_icon_TabsView_disabled.svg │ │ ├── CANbus_icon_Undock.svg │ │ ├── CANbus_icon_start_disabled.png │ │ ├── CANbus_icon_start_enabled.png │ │ ├── CANbus_icon_stop_disabled.png │ │ ├── CANbus_icon_stop_enabled.png │ │ ├── CANbus_logo.svg │ │ ├── about_screen.png │ │ └── start_screen.png │ ├── db_icon.svg │ └── light │ │ ├── Angle-down-01.svg │ │ ├── Angle-up-01.svg │ │ ├── CANbus_icon_Add.svg │ │ ├── CANbus_icon_CascadeView.svg │ │ ├── CANbus_icon_CascadeView_disabled.svg │ │ ├── CANbus_icon_CheckBoxOff.svg │ │ ├── CANbus_icon_CheckBoxOff_disable.svg │ │ ├── CANbus_icon_CheckBoxOn.svg │ │ ├── CANbus_icon_CheckBoxOn_disabled.svg │ │ ├── CANbus_icon_Clear.svg │ │ ├── CANbus_icon_Close.svg │ │ ├── CANbus_icon_CloseSim.svg │ │ ├── CANbus_icon_CloseSim_disabled.svg │ │ ├── CANbus_icon_Close_gray.svg │ │ ├── CANbus_icon_Close_tab.svg │ │ ├── CANbus_icon_Close_tab_selected.svg │ │ ├── CANbus_icon_Combine.svg │ │ ├── CANbus_icon_Input.svg │ │ ├── CANbus_icon_InputOutput.svg │ │ ├── CANbus_icon_Lock.svg │ │ ├── CANbus_icon_Log.svg │ │ ├── CANbus_icon_NewProject.svg │ │ ├── CANbus_icon_OpenProject.svg │ │ ├── CANbus_icon_OpenProject_Grey.svg │ │ ├── CANbus_icon_OpenSim.svg │ │ ├── CANbus_icon_OpenSim_disabled.svg │ │ ├── CANbus_icon_Output.svg │ │ ├── CANbus_icon_Remove.svg │ │ ├── CANbus_icon_SaveAsProject.svg │ │ ├── CANbus_icon_SaveAsProject_disabled.svg │ │ ├── CANbus_icon_SaveProject.svg │ │ ├── CANbus_icon_SaveProject_disabled.svg │ │ ├── CANbus_icon_Switch.svg │ │ ├── CANbus_icon_Switch_2.svg │ │ ├── CANbus_icon_Switch_dark.svg │ │ ├── CANbus_icon_TabsView.svg │ │ ├── CANbus_icon_TabsView_disabled.svg │ │ ├── CANbus_icon_Undock.svg │ │ ├── CANbus_icon_arrow_down.svg │ │ ├── CANbus_icon_arrow_up.svg │ │ ├── CANbus_icon_edit.svg │ │ ├── CANbus_icon_start_disabled.png │ │ ├── CANbus_icon_start_enabled.png │ │ ├── CANbus_icon_stop_disabled.png │ │ ├── CANbus_icon_stop_enabled.png │ │ ├── CANbus_logo.svg │ │ ├── about_screen.png │ │ ├── pattern_dark.png │ │ ├── pattern_white.png │ │ └── start_screen.png └── json │ ├── NodeEditorStyleDark.json │ ├── NodeEditorStyleLight.json │ └── projectConfigSchema.json ├── hooks └── pre-commit ├── packaging.cmake ├── src ├── common │ ├── CMakeLists.txt │ ├── bcastmsgs.h │ ├── candbhandler.cpp │ ├── candbhandler.h │ ├── candbpainter.cpp │ ├── candbpainter.h │ ├── componentinterface.h │ ├── componentmodel.h │ ├── confighelpers.h │ ├── context.h │ ├── datamodeltypes │ │ ├── canrawdata.h │ │ ├── cansignalmodel.h │ │ └── datadirection.h │ ├── enumiterator.h │ ├── guiinterface │ │ ├── checkboxinterface.h │ │ ├── lineeditinterface.h │ │ └── pushbuttoninterface.h │ ├── log.h │ ├── modelvisitor.h │ ├── nodepainter.h │ ├── plugin_type.h │ ├── pluginloader.h │ ├── plugins.hpp.in │ ├── propertyfields.h │ ├── sortenums.h │ ├── sortmodel.cpp │ ├── sortmodel.h │ ├── tests │ │ └── common_test.cpp │ ├── typestring.hh │ ├── version.h.in │ ├── visitablewith.h │ └── visitor.h ├── components │ ├── CMakeLists.txt │ ├── candevice │ │ ├── CMakeLists.txt │ │ ├── candevice.cpp │ │ ├── candevice.h │ │ ├── candevice_p.h │ │ ├── candeviceinterface.h │ │ ├── candevicemodel.cpp │ │ ├── candevicemodel.h │ │ ├── candeviceplugin.h │ │ ├── candeviceqt.h │ │ └── tests │ │ │ ├── candevice_test.cpp │ │ │ ├── candevicemodel_test.cpp │ │ │ └── candeviceqt_test.cpp │ ├── canload │ │ ├── CMakeLists.txt │ │ ├── canload.cpp │ │ ├── canload.h │ │ ├── canload_p.cpp │ │ ├── canload_p.h │ │ ├── canloadmodel.cpp │ │ ├── canloadmodel.h │ │ ├── canloadpainter.h │ │ ├── canloadplugin.h │ │ └── tests │ │ │ ├── canload_test.cpp │ │ │ └── canloadmodel_test.cpp │ ├── canrawfilter │ │ ├── CMakeLists.txt │ │ ├── canrawfilter.cpp │ │ ├── canrawfilter.h │ │ ├── canrawfilter_p.cpp │ │ ├── canrawfilter_p.h │ │ ├── canrawfiltermodel.cpp │ │ ├── canrawfiltermodel.h │ │ ├── canrawfilterplugin.h │ │ ├── gui │ │ │ ├── canrawfilter.ui │ │ │ ├── canrawfilterguiimpl.h │ │ │ └── canrawfilterguiint.h │ │ └── tests │ │ │ ├── canrawfilter_test.cpp │ │ │ └── canrawfiltermodel_test.cpp │ ├── canrawlogger │ │ ├── CMakeLists.txt │ │ ├── canrawlogger.cpp │ │ ├── canrawlogger.h │ │ ├── canrawlogger_p.cpp │ │ ├── canrawlogger_p.h │ │ ├── canrawloggermodel.cpp │ │ ├── canrawloggermodel.h │ │ ├── canrawloggerplugin.h │ │ └── tests │ │ │ ├── canrawlogger_test.cpp │ │ │ └── canrawloggermodel_test.cpp │ ├── canrawplayer │ │ ├── CMakeLists.txt │ │ ├── canrawplayer.cpp │ │ ├── canrawplayer.h │ │ ├── canrawplayer_p.cpp │ │ ├── canrawplayer_p.h │ │ ├── canrawplayermodel.cpp │ │ ├── canrawplayermodel.h │ │ ├── canrawplayerplugin.h │ │ └── tests │ │ │ ├── canrawplayer_test.cpp │ │ │ └── canrawplayermodel_test.cpp │ ├── canrawsender │ │ ├── CMakeLists.txt │ │ ├── canrawsender.cpp │ │ ├── canrawsender.h │ │ ├── canrawsender_p.cpp │ │ ├── canrawsender_p.h │ │ ├── canrawsendermodel.cpp │ │ ├── canrawsendermodel.h │ │ ├── canrawsenderplugin.h │ │ ├── gui │ │ │ ├── canrawsender.ui │ │ │ ├── crsgui.h │ │ │ ├── crsguiinterface.h │ │ │ ├── nlmcheckbox.h │ │ │ ├── nlmlineedit.h │ │ │ └── nlmpushbutton.h │ │ ├── newlinemanager.cpp │ │ ├── newlinemanager.h │ │ ├── nlmfactory.h │ │ ├── nlmfactoryinterface.h │ │ └── tests │ │ │ ├── canrawsender_test.cpp │ │ │ ├── canrawsendermodel_test.cpp │ │ │ ├── configfiles │ │ │ ├── canrawsenderconfig.cds │ │ │ ├── canrawsenderconfig_badData.cds │ │ │ ├── canrawsenderconfig_badId.cds │ │ │ ├── canrawsenderconfig_badInterval.cds │ │ │ └── canrawsenderconfig_badcolumns.cds │ │ │ └── newlinemanager_test.cpp │ ├── canrawview │ │ ├── CMakeLists.txt │ │ ├── canrawview.cpp │ │ ├── canrawview.h │ │ ├── canrawview_p.h │ │ ├── canrawviewmodel.cpp │ │ ├── canrawviewmodel.h │ │ ├── canrawviewplugin.h │ │ ├── gui │ │ │ ├── canrawview.ui │ │ │ ├── crvgui.h │ │ │ └── crvguiinterface.h │ │ └── tests │ │ │ ├── canrawview_test.cpp │ │ │ ├── canrawviewmodel_test.cpp │ │ │ └── configfiles │ │ │ ├── canrawviewconfig.cds │ │ │ ├── canrawviewconfig_columnluck.cds │ │ │ ├── canrawviewconfig_sortingformat.cds │ │ │ ├── canrawviewconfig_visualindexproblem.cds │ │ │ └── canrawviewconfig_widthproblem.cds │ ├── cansignaldata │ │ ├── CMakeLists.txt │ │ ├── cansignaldata.cpp │ │ ├── cansignaldata.h │ │ ├── cansignaldata_p.cpp │ │ ├── cansignaldata_p.h │ │ ├── cansignaldatamodel.cpp │ │ ├── cansignaldatamodel.h │ │ ├── cansignaldataplugin.h │ │ ├── gui │ │ │ ├── cansignaldata.ui │ │ │ ├── cansignaldataguiimpl.h │ │ │ └── cansignaldataguiint.h │ │ ├── searchmodel.cpp │ │ ├── searchmodel.h │ │ └── tests │ │ │ ├── cansignaldata_test.cpp │ │ │ ├── cansignaldatamodel_test.cpp │ │ │ └── dbc │ │ │ ├── project.cds │ │ │ └── tesla_can.dbc │ ├── cansignaldecoder │ │ ├── CMakeLists.txt │ │ ├── cansignaldecoder.cpp │ │ ├── cansignaldecoder.h │ │ ├── cansignaldecoder_p.cpp │ │ ├── cansignaldecoder_p.h │ │ ├── cansignaldecodermodel.cpp │ │ ├── cansignaldecodermodel.h │ │ ├── cansignaldecoderplugin.h │ │ └── tests │ │ │ ├── cansignaldecoder_test.cpp │ │ │ ├── cansignaldecodermodel_test.cpp │ │ │ └── dbc │ │ │ └── tesla_can.dbc │ ├── cansignalencoder │ │ ├── CMakeLists.txt │ │ ├── cansignalencoder.cpp │ │ ├── cansignalencoder.h │ │ ├── cansignalencoder_p.cpp │ │ ├── cansignalencoder_p.h │ │ ├── cansignalencodermodel.cpp │ │ ├── cansignalencodermodel.h │ │ ├── cansignalencoderplugin.h │ │ └── tests │ │ │ ├── cansignalencoder_test.cpp │ │ │ ├── cansignalencodermodel_test.cpp │ │ │ └── dbc │ │ │ └── tesla_can.dbc │ ├── cansignalsender │ │ ├── CMakeLists.txt │ │ ├── cansignalsender.cpp │ │ ├── cansignalsender.h │ │ ├── cansignalsender_p.cpp │ │ ├── cansignalsender_p.h │ │ ├── cansignalsendermodel.cpp │ │ ├── cansignalsendermodel.h │ │ ├── cansignalsenderplugin.h │ │ ├── cansignalsendertablemodel.cpp │ │ ├── cansignalsendertablemodel.h │ │ ├── gui │ │ │ ├── cansignalsender.ui │ │ │ ├── cansignalsenderguiimpl.h │ │ │ └── cansignalsenderguiint.h │ │ └── tests │ │ │ ├── cansignalsender_test.cpp │ │ │ └── cansignalsendermodel_test.cpp │ ├── cansignalviewer │ │ ├── CMakeLists.txt │ │ ├── cansignalviewer.cpp │ │ ├── cansignalviewer.h │ │ ├── cansignalviewer_p.cpp │ │ ├── cansignalviewer_p.h │ │ ├── cansignalviewermodel.cpp │ │ ├── cansignalviewermodel.h │ │ ├── cansignalviewerplugin.h │ │ ├── gui │ │ │ ├── cansignalviewer.ui │ │ │ ├── cansignalviewerguiimpl.h │ │ │ └── cansignalviewerguiint.h │ │ └── tests │ │ │ ├── cansignalviewer_test.cpp │ │ │ └── cansignalviewermodel_test.cpp │ └── qmlexecutor │ │ ├── CMakeLists.txt │ │ ├── canbusmodel.hpp │ │ ├── examples │ │ ├── sample.qml │ │ ├── simple_forwarder.qml │ │ └── simple_timer.qml │ │ ├── gui │ │ ├── qmlexecutor.ui │ │ ├── qmlexecutorguiimpl.h │ │ └── qmlexecutorguiint.h │ │ ├── qmlexecutor.cpp │ │ ├── qmlexecutor.h │ │ ├── qmlexecutor_p.cpp │ │ ├── qmlexecutor_p.h │ │ ├── qmlexecutormodel.cpp │ │ ├── qmlexecutormodel.h │ │ ├── qmlexecutorplugin.h │ │ └── tests │ │ ├── guimock.h │ │ ├── qmlexecutor_test.cpp │ │ └── qmlexecutormodel_test.cpp └── gui │ ├── CMakeLists.txt │ ├── aboutdialog.ui │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── projectconfig │ ├── CMakeLists.txt │ ├── dragwidget.cpp │ ├── dragwidget.h │ ├── flowviewwrapper.cpp │ ├── flowviewwrapper.h │ ├── iconlabel.h │ ├── modeltoolbutton.h │ ├── pcimpl.h │ ├── pcinterface.h │ ├── projectconfig.cpp │ ├── projectconfig.h │ ├── projectconfig.ui │ ├── projectconfig_p.h │ ├── projectconfigvalidator.cpp │ ├── projectconfigvalidator.h │ ├── propertyeditordialog.cpp │ ├── propertyeditordialog.h │ ├── propertyeditordialog.ui │ └── tests │ │ ├── configfiles │ │ ├── projectconfig.cds │ │ └── projectconfig_wrong.cds │ │ ├── projectconfig.ui │ │ ├── projectconfig_test.cpp │ │ └── projectconfig_test_noqrc.cpp │ ├── subwindow.h │ └── toolbar.ui └── tools ├── CMakeLists.txt └── templategen ├── CMakeLists.txt └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | build 3 | *.o 4 | *.user 5 | .vimrc 6 | .ycm_extra_conf.py 7 | .*.un~ 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rdParty/fakeit"] 2 | path = 3rdParty/fakeit 3 | url = https://github.com/eranpeer/FakeIt.git 4 | [submodule "3rdParty/spdlog"] 5 | path = 3rdParty/spdlog 6 | url = https://github.com/gabime/spdlog.git 7 | [submodule "3rdParty/nodeeditor"] 8 | path = 3rdParty/nodeeditor 9 | url = https://github.com/rkollataj/nodeeditor 10 | [submodule "3rdParty/rapidjson"] 11 | path = 3rdParty/rapidjson 12 | url = https://github.com/Tencent/rapidjson.git 13 | [submodule "3rdParty/qtCannelloniCanBus"] 14 | path = 3rdParty/qtCannelloniCanBus 15 | url = https://github.com/tuvok/qtCannelloniCanBus.git 16 | [submodule "3rdParty/readerwriterqueue"] 17 | path = 3rdParty/readerwriterqueue 18 | url = https://github.com/cameron314/readerwriterqueue 19 | [submodule "3rdParty/cxxopts"] 20 | path = 3rdParty/cxxopts 21 | url = https://github.com/jarro2783/cxxopts.git 22 | [submodule "3rdParty/CANdb"] 23 | path = 3rdParty/CANdb 24 | url = https://github.com/GENIVI/CANdb.git 25 | [submodule "3rdParty/catch"] 26 | path = 3rdParty/catch 27 | url = https://github.com/catchorg/Catch2 28 | -------------------------------------------------------------------------------- /3rdParty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(rapidjson INTERFACE) 3 | target_include_directories(rapidjson INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include) 4 | target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING=1 RAPIDJSON_HAS_CXX11_RVALUE_REFS=1) 5 | 6 | add_library(fakeit INTERFACE) 7 | target_include_directories(fakeit INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/fakeit/single_header/catch ${CMAKE_CURRENT_SOURCE_DIR}/fakeit/config/catch ${CMAKE_CURRENT_SOURCE_DIR}/catch/single_include/catch2) 8 | target_compile_options(fakeit INTERFACE $<$:-fno-devirtualize -Wno-cast-function-type>) 9 | 10 | add_library(rwqueue INTERFACE) 11 | target_include_directories(rwqueue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/readerwriterqueue) 12 | 13 | add_subdirectory(nodeeditor) 14 | 15 | 16 | add_subdirectory(CANdb EXCLUDE_FROM_ALL) 17 | 18 | if(UNIX AND NOT APPLE) 19 | add_subdirectory(qtCannelloniCanBus) 20 | 21 | install(PROGRAMS ${CMAKE_BINARY_DIR}/3rdParty/qtCannelloniCanBus/libqtCannelloniCanBusPlugin.so 22 | DESTINATION ${INSTALL_DEST_PLUG} 23 | ) 24 | endif() 25 | -------------------------------------------------------------------------------- /cmake/Modules/CompilerVersion.cmake: -------------------------------------------------------------------------------- 1 | set(GCC_MINIMAL_VERSION "5.3.0") 2 | set(CLANG_MINIMAL_VERSION "3.5.0") 3 | set(MSVC_MINIMAL_VERSION "19.0") 4 | 5 | set(selected_compiler_version "") 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | set(selected_compiler_version ${GCC_MINIMAL_VERSION}) 9 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 10 | set(selected_compiler_version ${CLANG_MINIMAL_VERSION}) 11 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 12 | set(selected_compiler_version ${MSVC_MINIMAL_VERSION}) 13 | endif() 14 | 15 | if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "${selected_compiler_version}") 16 | message(WARNING "\nWARNING: Compiler version may be too low. Minimal version of ${CMAKE_CXX_COMPILER_ID} is ${selected_compiler_version}\n") 17 | endif() 18 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibnl.cmake: -------------------------------------------------------------------------------- 1 | # - Find libnl 2 | # 3 | # This module defines 4 | # LIBNL_FOUND - whether the libnl library was found 5 | # LIBNL_LIBRARIES - the libnl library 6 | # LIBNL_INCLUDE_DIR - the include path of the libnl library 7 | 8 | find_library (LIBNL_LIBRARY nl-3) 9 | find_library (LIBNL_ROUTE_LIBRARY nl-route-3) 10 | 11 | set(LIBNL_LIBRARIES 12 | ${LIBNL_LIBRARY} 13 | ${LIBNL_ROUTE_LIBRARY} 14 | ) 15 | 16 | find_path (LIBNL_INCLUDE_DIR 17 | NAMES 18 | netlink/netlink.h 19 | PATH_SUFFIXES 20 | libnl3 21 | ) 22 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | ignore: 3 | - "src/components/canrawsender/gui" 4 | - "src/components/canrawview/gui" 5 | - "src/components/canrawfilter/gui" 6 | - "src/components/cansignaldata/gui" 7 | - "src/components/cansignalsender/gui" 8 | - "src/components/cansignalviewer/gui" 9 | - "src/components/canload/canloadpainter.h" 10 | - "src/components/qmlexecutor/gui" 11 | - "src/common/guiinterface" 12 | - "src/common/candbpainter.cpp" 13 | - "src/common/candbpainter.h" 14 | - "src/common/nodepainter.h" 15 | - "src/common/propertyfields.h" 16 | - "src/gui/main*" 17 | - "src/gui/subwindow.h" 18 | - "src/gui/projectconfig/flowviewwrapper.h" 19 | - "src/gui/projectconfig/flowviewwrapper.cpp" 20 | - "src/gui/projectconfig/dragwidget.h" 21 | - "src/gui/projectconfig/dragwidget.cpp" 22 | - "src/gui/projectconfig/canloadpainter.h" 23 | - "src/gui/projectconfig/pcinterface.h" 24 | - "src/gui/projectconfig/pcimpl.h" 25 | - ".*/tests/.*" 26 | - "tools" 27 | -------------------------------------------------------------------------------- /doc/CANBus_Styleguide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/doc/CANBus_Styleguide.pdf -------------------------------------------------------------------------------- /files/CANdevStudio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | appname=`basename $0 | sed s,\.sh$,,` 4 | 5 | dirname=`dirname $0` 6 | tmp="${dirname#?}" 7 | 8 | if [ "${dirname%$tmp}" != "/" ]; then 9 | dirname=$PWD/$dirname 10 | fi 11 | LD_LIBRARY_PATH=$dirname 12 | export LD_LIBRARY_PATH 13 | $dirname/$appname "$@" 14 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_CascadeView.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 12 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_CheckBoxOff.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Clear.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_CloseSim.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Close_tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Close_tab_selected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Combine.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Input.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 10 | 12 | 13 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_InputOutput.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_NewProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_OpenProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_OpenSim.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Output.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 10 | 12 | 13 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Remove.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 12 | 13 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_SaveAsProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_SaveProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Switch.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Switch_2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_TabsView.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_Undock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 12 | 13 | 14 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_start_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/CANbus_icon_start_disabled.png -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_start_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/CANbus_icon_start_enabled.png -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_stop_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/CANbus_icon_stop_disabled.png -------------------------------------------------------------------------------- /files/images/dark/CANbus_icon_stop_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/CANbus_icon_stop_enabled.png -------------------------------------------------------------------------------- /files/images/dark/about_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/about_screen.png -------------------------------------------------------------------------------- /files/images/dark/start_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/dark/start_screen.png -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_CascadeView.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 15 | 18 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Clear.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 11 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_CloseSim.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Close_gray.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Close_tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Close_tab_selected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Combine.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 11 | 13 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Input.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_InputOutput.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 15 | 18 | 19 | 20 | 23 | 24 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_NewProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_OpenProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_OpenSim.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Output.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Remove.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 15 | 16 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_SaveAsProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_SaveProject.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Switch.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Switch_2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_TabsView.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_Undock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 12 | 13 | 16 | 17 | 18 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_start_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/CANbus_icon_start_disabled.png -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_start_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/CANbus_icon_start_enabled.png -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_stop_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/CANbus_icon_stop_disabled.png -------------------------------------------------------------------------------- /files/images/light/CANbus_icon_stop_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/CANbus_icon_stop_enabled.png -------------------------------------------------------------------------------- /files/images/light/about_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/about_screen.png -------------------------------------------------------------------------------- /files/images/light/pattern_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/pattern_dark.png -------------------------------------------------------------------------------- /files/images/light/pattern_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/pattern_white.png -------------------------------------------------------------------------------- /files/images/light/start_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GENIVI/CANdevStudio/c7fb2a86d4a62da0bd467577fa7ce1475c9fcc08/files/images/light/start_screen.png -------------------------------------------------------------------------------- /files/json/NodeEditorStyleDark.json: -------------------------------------------------------------------------------- 1 | { 2 | "FlowViewStyle": { 3 | "BackgroundColor": [53, 53, 53], 4 | "FineGridColor": [30, 30, 30], 5 | "CoarseGridColor": [20, 20, 20] 6 | }, 7 | "ConnectionStyle": { 8 | "ConstructionColor": "gray", 9 | "NormalColor": [206, 206, 206], 10 | "SelectedColor": [130, 130, 130], 11 | "SelectedHaloColor": [20, 146, 202], 12 | "HoveredColor": [20, 146, 202], 13 | 14 | "LineWidth": 3.0, 15 | "ConstructionLineWidth": 2.0, 16 | "PointDiameter": 7.0, 17 | 18 | "UseDataDefinedColors": false 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /files/json/NodeEditorStyleLight.json: -------------------------------------------------------------------------------- 1 | { 2 | "FlowViewStyle": { 3 | "BackgroundColor": [53, 53, 53], 4 | "FineGridColor": [195, 195, 195], 5 | "CoarseGridColor": [187, 187, 187] 6 | }, 7 | "ConnectionStyle": { 8 | "ConstructionColor": "gray", 9 | "NormalColor": [110, 110, 110], 10 | "SelectedColor": [140, 140, 140], 11 | "SelectedHaloColor": [20, 146, 202], 12 | "HoveredColor": [20, 146, 202], 13 | 14 | "LineWidth": 3.0, 15 | "ConstructionLineWidth": 2.0, 16 | "PointDiameter": 7.0, 17 | 18 | "UseDataDefinedColors": false 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /hooks/pre-commit: -------------------------------------------------------------------------------- 1 | git diff --cached --name-only --diff-filter=ACMRT | grep -E "\.(c|cpp|h)$" | xargs -n1 clang-format -style=file -output-replacements-xml | grep "/dev/null 2 | if [ $? -ne 1 ] 3 | then 4 | echo "Commit did not match clang-format" 5 | exit 1; 6 | fi 7 | -------------------------------------------------------------------------------- /packaging.cmake: -------------------------------------------------------------------------------- 1 | # Package generation 2 | 3 | set(CPACK_PACKAGE_DESCRIPTION "CANDevStudio - CAN simulation software") 4 | set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") 5 | set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") 6 | set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}") 7 | 8 | set(VERSION_STRING "${VERSION_PATCH}") 9 | 10 | if(GIT_COMMIT_HASH) 11 | set(VERSION_STRING "${VERSION_PATCH}.${GIT_COMMIT_HASH}") 12 | endif() 13 | 14 | set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_STRING}-${CMAKE_SYSTEM_NAME}") 15 | 16 | if(STANDALONE) 17 | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-standalone") 18 | endif() 19 | 20 | set(CPACK_PACKAGE_VENDOR "Remigiusz Kołłątaj") 21 | set(CPACK_PACKAGE_CONTACT "remigiusz.kollataj@gmail.com") 22 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) 23 | 24 | if(APPLE) 25 | include("${CMAKE_SOURCE_DIR}/cmake/osx_bundle.cmake") 26 | endif() 27 | 28 | include(CPack) 29 | -------------------------------------------------------------------------------- /src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Threads REQUIRED) 2 | include_directories(${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/3rdParty/spdlog/include) 3 | 4 | set(SRC 5 | componentmodel.h 6 | propertyfields.h 7 | candbhandler.cpp 8 | candbpainter.cpp 9 | sortmodel.cpp 10 | ) 11 | 12 | add_library(cds-common STATIC ${SRC}) 13 | target_include_directories(cds-common INTERFACE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/3rdParty/spdlog/include) 14 | target_link_libraries(cds-common ${CMAKE_THREAD_LIBS_INIT} Qt5::SerialBus nodes CANdb Qt5::Svg) 15 | 16 | if(WITH_TESTS) 17 | add_executable(common_test tests/common_test.cpp) 18 | target_link_libraries(common_test Qt5::Test cds-common fakeit projectconfig) 19 | add_test(NAME common_test COMMAND common_test) 20 | endif() 21 | 22 | -------------------------------------------------------------------------------- /src/common/bcastmsgs.h: -------------------------------------------------------------------------------- 1 | #ifndef __BCASTMSGS_H 2 | #define __BCASTMSGS_H 3 | 4 | #include 5 | 6 | namespace BcastMsg { 7 | 8 | static const QString NodeCreated = "node_created"; 9 | static const QString RequestCanDb = "request_can_db"; 10 | static const QString ConfigChanged = "config_changed"; 11 | static const QString NodeDeleted = "node_deleted"; 12 | static const QString InitDone = "init_done"; 13 | static const QString CanDbUpdated = "can_db_updated"; 14 | static const QString GuiStyleSwitched = "gui_style_switched"; 15 | 16 | } 17 | 18 | #endif /* !__BCASTMSGS_H */ 19 | -------------------------------------------------------------------------------- /src/common/candbhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef __CANDBHANDLER_H 2 | #define __CANDBHANDLER_H 3 | 4 | #include "componentinterface.h" 5 | #include 6 | #include 7 | #include 8 | 9 | class QString; 10 | class QJsonObject; 11 | 12 | Q_DECLARE_METATYPE(CANmessages_t); 13 | 14 | class CanDbHandler : public QObject { 15 | Q_OBJECT 16 | 17 | public: 18 | CanDbHandler(ComponentInterface::PropertyContainer& props, const QString& dbProperty); 19 | void processBcast(const QJsonObject& msg, const QVariant& param); 20 | const CANmessages_t& getDb() const; 21 | const QString getName() const; 22 | void updateCurrentDbFromProps(); 23 | QWidget* createPropertyWidget(); 24 | 25 | signals: 26 | void sendCanDbRequest(const QJsonObject& msg, const QVariant = QVariant()); 27 | void requestRedraw(); 28 | void dbChanged(); 29 | 30 | private: 31 | void dbDeleted(const QUuid& id); 32 | 33 | private: 34 | ComponentInterface::PropertyContainer& _props; 35 | const QString& _dbProperty; 36 | std::map _dbNames; 37 | std::map _candb; 38 | std::map _dbColor; 39 | QUuid _currentDb; 40 | const CANmessages_t _emptyDb; 41 | }; 42 | 43 | #endif /* !__CANDBHANDLER_H */ 44 | -------------------------------------------------------------------------------- /src/common/candbpainter.h: -------------------------------------------------------------------------------- 1 | #ifndef __CANDBPAINTER_H 2 | #define __CANDBPAINTER_H 3 | 4 | #include "nodepainter.h" 5 | #include 6 | 7 | struct ComponentInterface; 8 | 9 | struct CanDbPainter : public NodePainter { 10 | 11 | CanDbPainter(const QColor& headerColor, const ComponentInterface* component, qreal size); 12 | 13 | virtual void paint(QPainter* painter, QtNodes::NodeGeometry const& geom, QtNodes::NodeDataModel const* model, 14 | QtNodes::NodeGraphicsObject const& graphicsObject) override; 15 | 16 | private: 17 | const ComponentInterface* _component; 18 | QColor _nodeColor; 19 | QColor _prevNodeColor; 20 | QSvgRenderer _svg; 21 | qreal _s; 22 | const QColor _lightColor; 23 | const QColor _darkColor; 24 | }; 25 | 26 | #endif /* !__CANDBPAINTER_H */ 27 | -------------------------------------------------------------------------------- /src/common/confighelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef SRC_COMMON_CONFIGHELPERS_H_ 2 | #define SRC_COMMON_CONFIGHELPERS_H_ 3 | 4 | #include "componentinterface.h" 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class configHelpers { 13 | 14 | public: 15 | static std::shared_ptr getQConfig( 16 | const ComponentInterface::ComponentProperties& sp, const std::map& properties) 17 | { 18 | std::shared_ptr q = std::make_shared(); 19 | 20 | QStringList props; 21 | for (auto& p : sp) { 22 | if (ComponentInterface::propertyEditability(p)) { 23 | // property editable 24 | const QString& propName = ComponentInterface::propertyName(p); 25 | props.push_back(propName); 26 | q->setProperty(propName.toStdString().c_str(), properties.at(propName)); 27 | 28 | auto&& fun = ComponentInterface::propertyField(p); 29 | QWidget* w; 30 | 31 | if (fun) { 32 | w = fun(); 33 | } else { 34 | w = new PropertyFieldText(); 35 | } 36 | 37 | w->setParent(q.get()); 38 | w->setObjectName(propName + "Widget"); 39 | } 40 | } 41 | 42 | q->setProperty("exposedProperties", props); 43 | 44 | return q; 45 | } 46 | 47 | static void setQConfig(const QWidget& qobject, const ComponentInterface::ComponentProperties& sp, 48 | std::map& properties) 49 | { 50 | for (auto& p : sp) { 51 | const QString& propName = ComponentInterface::propertyName(p); 52 | QVariant v = qobject.property(propName.toStdString().c_str()); 53 | if (v.isValid() && v.type() == ComponentInterface::propertyType(p)) { 54 | properties[propName] = v; 55 | } 56 | } 57 | } 58 | }; 59 | 60 | #endif /* SRC_COMMON_CONFIGHELPERS_H_ */ 61 | -------------------------------------------------------------------------------- /src/common/context.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONTEXT_H 2 | #define __CONTEXT_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * The class provides wrapper that enables to inject multiple dependencies 9 | * to one class. 10 | * 11 | * NOTE: Interfaces provided as template arguments must be unique 12 | */ 13 | template struct Context { 14 | /** 15 | * Used to construct the context and and initialize it with implementations. Class takes ownership over 16 | * implementations 17 | * 18 | * @param args pointers to implementation of Args interfaces 19 | */ 20 | Context(Args*... args) 21 | // need explicitely mark unique_ptr type as GCC 5 fails to deduce type 22 | : _implsPtr(std::unique_ptr(args)...) 23 | { 24 | } 25 | 26 | /** 27 | * Get implementation of interfaces passed as template parameter 28 | * 29 | * @return implementation of an interface 30 | */ 31 | template T& get() const 32 | { 33 | return *std::get>(_implsPtr).get(); 34 | } 35 | 36 | private: 37 | std::tuple...> _implsPtr; 38 | }; 39 | 40 | struct CanDeviceInterface; 41 | typedef Context CanDeviceCtx; 42 | 43 | struct CRSGuiInterface; 44 | struct NLMFactoryInterface; 45 | typedef Context CanRawSenderCtx; 46 | 47 | struct CRVGuiInterface; 48 | typedef Context CanRawViewCtx; 49 | 50 | #endif /* !__CONTEXT_H */ 51 | -------------------------------------------------------------------------------- /src/common/datamodeltypes/canrawdata.h: -------------------------------------------------------------------------------- 1 | #ifndef __CANRAWDATA_H 2 | #define __CANRAWDATA_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include "datadirection.h" 9 | 10 | /** 11 | * @brief The class describing data model used as output for CanDevice node 12 | */ 13 | class CanRawData : public QtNodes::NodeData { 14 | public: 15 | CanRawData(){}; 16 | CanRawData(QCanBusFrame const& frame, Direction const direction = Direction::TX, bool status = true) 17 | : _frame(frame) 18 | , _direction(direction) 19 | , _status(status) 20 | { 21 | } 22 | /** 23 | * @brief Used to get data type id and displayed text for ports 24 | * @return NodeDataType of rawview 25 | */ 26 | QtNodes::NodeDataType type() const override 27 | { 28 | return QtNodes::NodeDataType{ "rawframe", "RAW" }; 29 | } 30 | 31 | /** 32 | * @brief Used to get frame 33 | */ 34 | QCanBusFrame frame() const 35 | { 36 | return _frame; 37 | }; 38 | 39 | /** 40 | * @brief Used to get direction 41 | */ 42 | Direction direction() const 43 | { 44 | return _direction; 45 | }; 46 | 47 | /** 48 | * @brief Used to get status 49 | */ 50 | bool status() const 51 | { 52 | return _status; 53 | }; 54 | 55 | private: 56 | QCanBusFrame _frame; 57 | Direction _direction; 58 | bool _status; // used only for frameSent, ignored for frameReceived 59 | }; 60 | 61 | #endif /* !__CANRAWDATA_H */ 62 | -------------------------------------------------------------------------------- /src/common/datamodeltypes/cansignalmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALMODEL_H 2 | #define CANSIGNALMODEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "datadirection.h" 9 | 10 | class CanSignalModel : public QtNodes::NodeData { 11 | public: 12 | CanSignalModel(){}; 13 | CanSignalModel(const QString& sigName, const QVariant& value, const Direction& dir = Direction::TX) 14 | : _sigName(sigName) 15 | , _value(value) 16 | , _dir(dir) 17 | { 18 | } 19 | 20 | QtNodes::NodeDataType type() const override 21 | { 22 | return QtNodes::NodeDataType{ "signal", "SIG" }; 23 | } 24 | 25 | QVariant value() const 26 | { 27 | return _value; 28 | } 29 | 30 | QString name() const 31 | { 32 | return _sigName; 33 | } 34 | 35 | Direction direction() const 36 | { 37 | return _dir; 38 | } 39 | 40 | private: 41 | QString _sigName; 42 | QVariant _value; 43 | Direction _dir; 44 | }; 45 | 46 | #endif // CANSIGNALMODEL_H 47 | -------------------------------------------------------------------------------- /src/common/datamodeltypes/datadirection.h: -------------------------------------------------------------------------------- 1 | #ifndef __DATADIRECTION_H 2 | #define __DATADIRECTION_H 3 | 4 | /** 5 | * @brief The enum class describing frame direction 6 | */ 7 | enum class Direction { RX, TX, Uninitialized }; 8 | 9 | #endif /* !__DATADIRECTION_H */ 10 | -------------------------------------------------------------------------------- /src/common/guiinterface/checkboxinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKBOXINTERFACE_H 2 | #define CHECKBOXINTERFACE_H 3 | 4 | #include 5 | class QWidget; 6 | 7 | struct CheckBoxInterface { 8 | virtual ~CheckBoxInterface() 9 | { 10 | } 11 | 12 | typedef std::function toggled_t; 13 | virtual void toggledCbk(const toggled_t& cb) = 0; 14 | virtual QWidget* mainWidget() = 0; 15 | virtual bool getState() = 0; 16 | virtual void setState(bool state) = 0; 17 | virtual void setDisabled(bool state) = 0; 18 | }; 19 | #endif // CHECKBOXINTERFACE_H 20 | -------------------------------------------------------------------------------- /src/common/guiinterface/lineeditinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITINTERFACE_H 2 | #define LINEEDITINTERFACE_H 3 | 4 | #include 5 | #include 6 | class QWidget; 7 | 8 | struct LineEditInterface { 9 | virtual ~LineEditInterface() 10 | { 11 | } 12 | 13 | typedef std::function textChanged_t; 14 | virtual void editingFinishedCbk(const textChanged_t& cb) = 0; 15 | virtual void textChangedCbk(const textChanged_t& cb) = 0; 16 | virtual QWidget* mainWidget() = 0; 17 | virtual void init(const QString& placeholderText, QValidator* qValidator) = 0; 18 | virtual void setPlaceholderText(const QString& placeholderText) = 0; 19 | virtual void setDisabled(bool state) = 0; 20 | virtual int getTextLength() = 0; 21 | virtual const QString getText() = 0; 22 | virtual void setText(const QString& text) = 0; 23 | }; 24 | #endif // LINEEDITINTERFACE_H 25 | -------------------------------------------------------------------------------- /src/common/guiinterface/pushbuttoninterface.h: -------------------------------------------------------------------------------- 1 | #ifndef PUSHBUTTONINTERFACE_H 2 | #define PUSHBUTTONINTERFACE_H 3 | 4 | #include 5 | #include 6 | class QWidget; 7 | 8 | struct PushButtonInterface { 9 | virtual ~PushButtonInterface() 10 | { 11 | } 12 | 13 | typedef std::function pressed_t; 14 | virtual void pressedCbk(const pressed_t& cb) = 0; 15 | virtual QWidget* mainWidget() = 0; 16 | virtual void init(const QString& buttonName, bool isEnable) = 0; 17 | virtual void setDisabled(bool state) = 0; 18 | virtual bool isEnabled() = 0; 19 | virtual void setCheckable(bool checked) = 0; 20 | virtual bool checkable() = 0; 21 | virtual bool checked() = 0; 22 | virtual void setChecked(bool checked) = 0; 23 | }; 24 | #endif // PUSHBUTTONINTERFACE_H 25 | -------------------------------------------------------------------------------- /src/common/log.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | extern std::shared_ptr kDefaultLogger; 10 | 11 | #define __FILENAME__ (std::strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) 12 | 13 | #define cds_debug(fmt, ...) \ 14 | do { \ 15 | kDefaultLogger->debug("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \ 16 | } while (0) 17 | #define cds_warn(fmt, ...) \ 18 | do { \ 19 | kDefaultLogger->warn("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \ 20 | } while (0) 21 | #define cds_error(fmt, ...) \ 22 | do { \ 23 | kDefaultLogger->error("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \ 24 | } while (0) 25 | #define cds_info(fmt, ...) \ 26 | do { \ 27 | kDefaultLogger->info("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \ 28 | } while (0) 29 | -------------------------------------------------------------------------------- /src/common/modelvisitor.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MODELVISITOR_H 3 | #define MODELVISITOR_H 4 | 5 | #include // move, forward 6 | 7 | #include 8 | 9 | #include "visitor.h" // Visitor 10 | #include "visitablewith.h" // VisitableWith 11 | 12 | 13 | class CanRawViewModel; 14 | class CanRawSenderModel; 15 | class CanDeviceModel; 16 | 17 | /** 18 | * Example usage with @c VisitableWith: 19 | * 20 | * @code 21 | * auto m = node.nodeDataModel(); 22 | * 23 | * CanNodeDataModelVisitor v{ [this](CanRawViewModel& a) { } 24 | * , [this](CanRawSenderModel& a) { } }; 25 | * 26 | * assert(nullptr != m); 27 | * 28 | * apply_model_visitor(*m, std::move(v)); 29 | * // or apply_model_visitor(*m, std::move(std::ref(v))); 30 | * // or apply_model_visitor(*m, [](CanRawViewModel&) {}, [](CanRawSenderModel&) {}); 31 | * @endcode 32 | */ 33 | struct CanNodeDataModelVisitor 34 | : Visitor< 35 | CanNodeDataModelVisitor // tag, not visitable type! 36 | , CanRawViewModel 37 | , CanRawSenderModel 38 | , CanDeviceModel 39 | // , Other 40 | > 41 | { 42 | using Visitor::Visitor; 43 | }; 44 | 45 | 46 | /** @throws bad_cast if object under @c m is not visitable with @c v. */ 47 | inline void apply_model_visitor(QtNodes::NodeDataModel& m, CanNodeDataModelVisitor v) 48 | { 49 | // NOTE: Cannot use static_cast since NodeDataModel and VisitableWith 50 | // are not in direct inheritance relation, i.e. only type derived 51 | // from NodeDataModel derives from VisitableWith. 52 | 53 | dynamic_cast&>(m).visit(v); // throws! 54 | } 55 | 56 | /** @throws bad_cast if object under @c m is not visitable with @c v. */ 57 | template 58 | inline void apply_model_visitor(QtNodes::NodeDataModel& m, Actions&&... actions) 59 | { 60 | CanNodeDataModelVisitor v{std::forward(actions)...}; 61 | 62 | apply_model_visitor(m, std::move(v)); 63 | } 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/common/plugin_type.h: -------------------------------------------------------------------------------- 1 | #ifndef PLUGIN_TYPE_H_AGCRIYX2 2 | #define PLUGIN_TYPE_H_AGCRIYX2 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | template 9 | struct PluginBase { 10 | static const char* sectionName() 11 | { 12 | return Name::data(); 13 | } 14 | 15 | static QColor sectionColor() 16 | { 17 | return { Color }; 18 | } 19 | 20 | static int spacing() 21 | { 22 | return Space; 23 | } 24 | }; 25 | 26 | #endif /* end of include guard: PLUGIN_TYPE_H_AGCRIYX2 */ 27 | -------------------------------------------------------------------------------- /src/common/plugins.hpp.in: -------------------------------------------------------------------------------- 1 | #ifndef PLUGINS_HPP_IN_OH7O4FYA 2 | #define PLUGINS_HPP_IN_OH7O4FYA 3 | 4 | #include "pluginloader.h" 5 | @PLUGIN_INCLUDES@ 6 | 7 | using Plugins = PluginLoader, @PLUGINS_IMPL_STR@>; 8 | 9 | #endif /* end of include guard: PLUGINS_HPP_IN_OH7O4FYA */ 10 | -------------------------------------------------------------------------------- /src/common/sortenums.h: -------------------------------------------------------------------------------- 1 | enum class ColType { 2 | uint_type = 0, 3 | hex_type, 4 | double_type, 5 | str_type, 6 | int_type, 7 | }; 8 | 9 | Q_DECLARE_METATYPE(ColType) 10 | -------------------------------------------------------------------------------- /src/common/sortmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef SORTMODEL_H 2 | #define SORTMODEL_H 3 | 4 | #include 5 | 6 | class SortModel : public QSortFilterProxyModel { 7 | Q_OBJECT 8 | public: 9 | explicit SortModel(QObject* parent = 0); 10 | 11 | void setFilterActive(bool enabled); 12 | bool isFilterActive() const; 13 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; 14 | 15 | protected: 16 | /** 17 | * @brief Function compares two items while sorting table view 18 | * @param left index of first item to compare 19 | * @param right index of second item to compare 20 | * @return true if left item is smaller than right, false if otherwise 21 | */ 22 | bool lessThan(const QModelIndex& left, const QModelIndex& right) const override; 23 | 24 | private: 25 | int updatedSortNdx() const; 26 | 27 | int _currSortNdx; 28 | Qt::SortOrder _currSortOrder; 29 | bool _filterActive = false; 30 | }; 31 | #endif 32 | -------------------------------------------------------------------------------- /src/common/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef VERSION_H 2 | #define VERSION_H 3 | 4 | #define CDS_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" 5 | #define GIT_BRANCH "@GIT_BRANCH@" 6 | #define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/common/visitablewith.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VISITABLEWITH_H 3 | #define VISITABLEWITH_H 4 | 5 | /** 6 | * Example for two types that can be visited: A, B and visitor V. 7 | * 8 | * @code 9 | * struct V 10 | * { 11 | * void operator()(A&) { std::cout << "A\n"; } 12 | * void operator()(B&) { std::cout << "B\n"; } 13 | * }; 14 | * 15 | * struct A : VisitableWith 16 | * { 17 | * void visit(V& v) override { v(*this); } 18 | * virtual ~A() = default; 19 | * }; 20 | * 21 | * struct B : VisitableWith 22 | * { 23 | * void visit(V& v) override { v(*this); } 24 | * virtual ~B() = default; 25 | * }; 26 | * 27 | * int main() 28 | * { 29 | * A a; 30 | * B b; 31 | * V v; 32 | * 33 | * using W = VisitableWith; 34 | * 35 | * W& va = a; 36 | * W& vb = b; 37 | * 38 | * va.visit(v); 39 | * vb.visit(v); 40 | * } 41 | * @endcode 42 | * 43 | * gives 44 | * 45 | * A 46 | * B 47 | * 48 | */ 49 | template struct VisitableWith { 50 | virtual void visit(Visitor& visitor) = 0; 51 | 52 | virtual ~VisitableWith() = default; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/components/candevice/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME candevice) 2 | 3 | set(SRC 4 | candevice.cpp 5 | candevicemodel.cpp 6 | ) 7 | 8 | add_library(${COMPONENT_NAME} STATIC ${SRC}) 9 | target_link_libraries(${COMPONENT_NAME} cds-common rwqueue) 10 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 11 | 12 | if(WITH_TESTS) 13 | set(SRC tests/${COMPONENT_NAME}_test.cpp) 14 | 15 | if(UNIX AND NOT APPLE) 16 | list(APPEND SRC tests/candeviceqt_test.cpp) 17 | endif() 18 | 19 | add_executable(${COMPONENT_NAME}_test ${SRC}) 20 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 21 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 22 | 23 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 24 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 25 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 26 | endif() 27 | -------------------------------------------------------------------------------- /src/components/candevice/candeviceinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef CANDEVICEINTERFACE_H_DNXOI7PW 2 | #define CANDEVICEINTERFACE_H_DNXOI7PW 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct CanDeviceInterface { 9 | virtual ~CanDeviceInterface() {} 10 | 11 | typedef std::function framesWritten_t; 12 | typedef std::function framesReceived_t; 13 | typedef std::function errorOccurred_t; 14 | 15 | virtual void setFramesWrittenCbk(const framesWritten_t& cb) = 0; 16 | virtual void setFramesReceivedCbk(const framesReceived_t& cb) = 0; 17 | virtual void setErrorOccurredCbk(const errorOccurred_t& cb) = 0; 18 | 19 | virtual bool init(const QString& backend, const QString& iface) = 0; 20 | virtual bool writeFrame(const QCanBusFrame& frame) = 0; 21 | virtual bool connectDevice() = 0; 22 | virtual void disconnectDevice() = 0; 23 | virtual qint64 framesAvailable() = 0; 24 | virtual void clearCallbacks() = 0; 25 | virtual void setConfigurationParameter(int key, const QVariant& value) = 0; 26 | 27 | virtual QCanBusFrame readFrame() = 0; 28 | virtual void setParent(QObject* parent) = 0; 29 | }; 30 | 31 | #endif /* end of include guard: CANDEVICEINTERFACE_H_DNXOI7PW */ 32 | -------------------------------------------------------------------------------- /src/components/candevice/candeviceplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANDEVICEPLUGIN_H_R6ODXXIJ 2 | #define CANDEVICEPLUGIN_H_R6ODXXIJ 3 | 4 | #include "plugin_type.h" 5 | #include "candevicemodel.h" 6 | 7 | using DevicePlugin = PluginBase; 8 | 9 | struct CanDevicePlugin { 10 | using Model = CanDeviceModel; 11 | static constexpr const char* name = "CanDevice"; 12 | using PluginType = DevicePlugin; 13 | }; 14 | 15 | #endif /* end of include guard: CANDEVICEPLUGIN_H_R6ODXXIJ */ 16 | -------------------------------------------------------------------------------- /src/components/candevice/tests/candeviceqt_test.cpp: -------------------------------------------------------------------------------- 1 | #include "candeviceqt.h" 2 | #include 3 | #include 4 | #include 5 | 6 | TEST_CASE("Invalid parameters init fails", "[candeviceqt]") 7 | { 8 | CanDeviceQt dev; 9 | REQUIRE(dev.init("", "") == false); 10 | } 11 | 12 | TEST_CASE("Uninitialized device", "[candeviceqt]") 13 | { 14 | CanDeviceQt dev; 15 | QCanBusFrame frame; 16 | 17 | REQUIRE_THROWS(dev.setFramesWrittenCbk({})); 18 | REQUIRE_THROWS(dev.setFramesReceivedCbk({})); 19 | REQUIRE_THROWS(dev.setErrorOccurredCbk({})); 20 | REQUIRE_THROWS(dev.writeFrame(frame)); 21 | REQUIRE_THROWS(dev.connectDevice()); 22 | REQUIRE_THROWS(dev.readFrame()); 23 | REQUIRE_THROWS(dev.framesAvailable()); 24 | REQUIRE_THROWS(dev.disconnectDevice()); 25 | REQUIRE_THROWS(dev.clearCallbacks()); 26 | REQUIRE_THROWS(dev.setConfigurationParameter(0, 0)); 27 | } 28 | 29 | TEST_CASE("Correct init parameters", "[candeviceqt]") 30 | { 31 | CanDeviceQt dev; 32 | REQUIRE(dev.init("virtualcan", "can0") == true); 33 | } 34 | 35 | TEST_CASE("Initialized device", "[candeviceqt]") 36 | { 37 | CanDeviceQt dev; 38 | QCanBusFrame frame; 39 | 40 | REQUIRE(dev.init("virtualcan", "can0") == true); 41 | REQUIRE_NOTHROW(dev.connectDevice()); 42 | 43 | REQUIRE_NOTHROW(dev.writeFrame(frame)); 44 | REQUIRE_NOTHROW(dev.readFrame()); 45 | REQUIRE_NOTHROW(dev.framesAvailable()); 46 | REQUIRE_NOTHROW(dev.disconnectDevice()); 47 | REQUIRE_NOTHROW(dev.clearCallbacks()); 48 | REQUIRE_NOTHROW(dev.setConfigurationParameter(0, 0)); 49 | 50 | REQUIRE_NOTHROW(dev.setFramesWrittenCbk({})); 51 | REQUIRE_NOTHROW(dev.setFramesReceivedCbk({})); 52 | REQUIRE_NOTHROW(dev.setErrorOccurredCbk({})); 53 | } 54 | 55 | TEST_CASE("Thread", "[candeviceqt]") 56 | { 57 | CanDeviceQt dev; 58 | QEventLoop el; 59 | 60 | dev.setParent(&el); 61 | REQUIRE(dev.init("virtualcan", "can0") == true); 62 | } 63 | -------------------------------------------------------------------------------- /src/components/canload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canload) 2 | 3 | set(SRC 4 | canload.cpp 5 | canload_p.cpp 6 | canloadmodel.cpp 7 | ) 8 | 9 | add_library(${COMPONENT_NAME} ${SRC}) 10 | target_link_libraries(${COMPONENT_NAME} cds-common) 11 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | if(WITH_TESTS) 14 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 15 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 16 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 17 | 18 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 19 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 20 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 21 | endif() 22 | -------------------------------------------------------------------------------- /src/components/canload/canload.h: -------------------------------------------------------------------------------- 1 | #ifndef CANLOAD_H 2 | #define CANLOAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanLoadPrivate; 11 | class QWidget; 12 | class QCanBusFrame; 13 | typedef Context<> CanLoadCtx; 14 | 15 | class CanLoad : public QObject, public ComponentInterface { 16 | Q_OBJECT 17 | Q_DECLARE_PRIVATE(CanLoad) 18 | 19 | public: 20 | CanLoad(); 21 | explicit CanLoad(CanLoadCtx&& ctx); 22 | ~CanLoad(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void mainWidgetDockToggled(QWidget* widget) override; 35 | void currentLoad(uint8_t load); 36 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 37 | 38 | public slots: 39 | void stopSimulation() override; 40 | void startSimulation() override; 41 | void frameIn(const QCanBusFrame& frame); 42 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 43 | 44 | private: 45 | QScopedPointer d_ptr; 46 | }; 47 | 48 | #endif //CANLOAD_H 49 | -------------------------------------------------------------------------------- /src/components/canload/canload_p.cpp: -------------------------------------------------------------------------------- 1 | #include "canload_p.h" 2 | #include 3 | 4 | CanLoadPrivate::CanLoadPrivate(CanLoad* q, CanLoadCtx&& ctx) 5 | : _ctx(std::move(ctx)) 6 | , q_ptr(q) 7 | { 8 | initProps(); 9 | 10 | _bitrate = _props[_bitrateProperty].toInt(); 11 | _period = _props[_periodProperty].toInt(); 12 | 13 | connect(&_timer, &QTimer::timeout, [this] { 14 | if (_div) { 15 | uint8_t load = static_cast((_totalBits * 100) / _div); 16 | _totalBits = 0; 17 | emit q_ptr->currentLoad(load); 18 | } 19 | }); 20 | } 21 | 22 | void CanLoadPrivate::initProps() 23 | { 24 | for (const auto& p : _supportedProps) { 25 | _props[ComponentInterface::propertyName(p)]; 26 | } 27 | 28 | // Default value 29 | _props[_periodProperty] = "1000"; 30 | _props[_bitrateProperty] = "500000"; 31 | } 32 | 33 | ComponentInterface::ComponentProperties CanLoadPrivate::getSupportedProperties() const 34 | { 35 | return _supportedProps; 36 | } 37 | 38 | QJsonObject CanLoadPrivate::getSettings() 39 | { 40 | QJsonObject json; 41 | 42 | for (const auto& p : _props) { 43 | json[p.first] = QJsonValue::fromVariant(p.second); 44 | } 45 | 46 | return json; 47 | } 48 | 49 | void CanLoadPrivate::setSettings(const QJsonObject& json) 50 | { 51 | for (const auto& p : _supportedProps) { 52 | QString propName = ComponentInterface::propertyName(p); 53 | if (json.contains(propName)) 54 | _props[propName] = json[propName].toVariant(); 55 | } 56 | 57 | _bitrate = _props[_bitrateProperty].toInt(); 58 | _period = _props[_periodProperty].toInt(); 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/components/canload/canload_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANLOAD_P_H 2 | #define CANLOAD_P_H 3 | 4 | #include "canload.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanLoad; 11 | 12 | class CanLoadPrivate : public QObject { 13 | Q_OBJECT 14 | Q_DECLARE_PUBLIC(CanLoad) 15 | 16 | public: 17 | CanLoadPrivate(CanLoad* q, CanLoadCtx&& ctx = CanLoadCtx()); 18 | ComponentInterface::ComponentProperties getSupportedProperties() const; 19 | QJsonObject getSettings(); 20 | void setSettings(const QJsonObject& json); 21 | 22 | private: 23 | void initProps(); 24 | 25 | public: 26 | bool _simStarted{ false }; 27 | CanLoadCtx _ctx; 28 | std::map _props; 29 | const QString _nameProperty = "name"; 30 | const QString _periodProperty = "period [ms]"; 31 | const QString _bitrateProperty = "bitrate [bps]"; 32 | uint32_t _period = 0; 33 | uint32_t _bitrate = 0; 34 | uint32_t _div = 0; 35 | uint64_t _totalBits = 0; 36 | QTimer _timer; 37 | 38 | private: 39 | CanLoad* q_ptr; 40 | 41 | // workaround for clang 3.5 42 | using cf = ComponentInterface::CustomEditFieldCbk; 43 | 44 | // clang-format off 45 | ComponentInterface::ComponentProperties _supportedProps = { 46 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 47 | std::make_tuple(_bitrateProperty, QVariant::String, true, cf([] { return new PropertyFieldText(true); } )), 48 | std::make_tuple(_periodProperty, QVariant::String, true, cf([] { return new PropertyFieldText(true); } )) 49 | }; 50 | // clang-format on 51 | }; 52 | 53 | #endif // CANLOAD_P_H 54 | -------------------------------------------------------------------------------- /src/components/canload/canloadmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANLOADMODEL_H 2 | #define CANLOADMODEL_H 3 | 4 | #include "canload.h" 5 | #include "canloadpainter.h" 6 | #include "componentmodel.h" 7 | #include 8 | 9 | using QtNodes::NodeData; 10 | using QtNodes::NodeDataType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::PortType; 13 | 14 | enum class Direction; 15 | 16 | class CanLoadModel : public ComponentModel { 17 | Q_OBJECT 18 | 19 | public: 20 | CanLoadModel(); 21 | 22 | unsigned int nPorts(PortType portType) const override; 23 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 24 | std::shared_ptr outData(PortIndex port) override; 25 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 26 | QtNodes::NodePainterDelegate* painterDelegate() const override; 27 | 28 | public slots: 29 | void currentLoad(uint8_t load); 30 | 31 | signals: 32 | void frameIn(const QCanBusFrame& frame); 33 | void requestRedraw(); 34 | 35 | private: 36 | std::unique_ptr _painter; 37 | uint8_t _currentLoad = 0; 38 | }; 39 | 40 | #endif // CANLOADMODEL_H 41 | -------------------------------------------------------------------------------- /src/components/canload/canloadpainter.h: -------------------------------------------------------------------------------- 1 | #ifndef __CANLOADPAINTER_H 2 | #define __CANLOADPAINTER_H 3 | 4 | #include "nodepainter.h" 5 | 6 | struct CanLoadPainter : public NodePainter { 7 | 8 | CanLoadPainter(const QColor& headerColor, const uint8_t& load) 9 | : NodePainter(headerColor) 10 | , _load(load) 11 | { 12 | } 13 | 14 | virtual void paint(QPainter* painter, QtNodes::NodeGeometry const& geom, QtNodes::NodeDataModel const* model, 15 | QtNodes::NodeGraphicsObject const& graphicsObject) override 16 | { 17 | NodePainter::paint(painter, geom, model, graphicsObject); 18 | 19 | QtNodes::NodeStyle const& nodeStyle = model->nodeStyle(); 20 | int s = 15; 21 | 22 | painter->setPen(QPen(nodeStyle.FontColorFaded, 2)); 23 | painter->setBrush(Qt::NoBrush); 24 | 25 | QFont font({ "Arial", 8 }); 26 | font.setBold(true); 27 | painter->setFont(font); 28 | QString val = QString::number(_load) + "%"; 29 | QFontMetrics metrics(font); 30 | auto rect = metrics.boundingRect(val); 31 | 32 | QPoint p(geom.width() / 2, geom.height() / 2 + 12); 33 | painter->drawEllipse(p, s, s); 34 | 35 | painter->setPen(nodeStyle.FontColor); 36 | QPoint t(p.x() - rect.width() / 2 + 1, p.y() + 4); 37 | painter->drawText(t, val); 38 | } 39 | 40 | private: 41 | const uint8_t& _load; 42 | }; 43 | 44 | #endif /* !__CANLOADPAINTER_H */ 45 | -------------------------------------------------------------------------------- /src/components/canload/canloadplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANLOADPLUGIN_H_8T2GEZMW 2 | #define CANLOADPLUGIN_H_8T2GEZMW 3 | 4 | #include "plugin_type.h" 5 | #include "canloadmodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanLoadPlugin { 10 | using Model = CanLoadModel; 11 | static constexpr const char* name = "CanLoad"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | #endif /* end of include guard: CANLOADPLUGIN_H_8T2GEZMW */ 16 | -------------------------------------------------------------------------------- /src/components/canrawfilter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canrawfilter) 2 | 3 | set(SRC 4 | gui/canrawfilter.ui 5 | gui/canrawfilterguiimpl.h 6 | canrawfilter.cpp 7 | canrawfilter_p.cpp 8 | canrawfiltermodel.cpp 9 | ) 10 | 11 | add_library(${COMPONENT_NAME} ${SRC}) 12 | target_link_libraries(${COMPONENT_NAME} cds-common rwqueue) 13 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 14 | 15 | if(WITH_TESTS) 16 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 17 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 18 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 19 | 20 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 21 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 22 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 23 | endif() 24 | -------------------------------------------------------------------------------- /src/components/canrawfilter/canrawfilter.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWFILTER_H 2 | #define CANRAWFILTER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanRawFilterPrivate; 11 | class QWidget; 12 | class QCanBusFrame; 13 | struct CanRawFilterGuiInt; 14 | typedef Context CanRawFilterCtx; 15 | 16 | class CanRawFilter : public QObject, public ComponentInterface { 17 | Q_OBJECT 18 | Q_DECLARE_PRIVATE(CanRawFilter) 19 | 20 | public: 21 | CanRawFilter(); 22 | explicit CanRawFilter(CanRawFilterCtx&& ctx); 23 | ~CanRawFilter(); 24 | 25 | QWidget* mainWidget() override; 26 | void setConfig(const QJsonObject& json) override; 27 | void setConfig(const QWidget& qobject) override; 28 | QJsonObject getConfig() const override; 29 | std::shared_ptr getQConfig() const override; 30 | void configChanged() override; 31 | bool mainWidgetDocked() const override; 32 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 33 | 34 | signals: 35 | void mainWidgetDockToggled(QWidget* widget) override; 36 | void txFrameOut(const QCanBusFrame& frame); 37 | void rxFrameOut(const QCanBusFrame& frame); 38 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 39 | 40 | public slots: 41 | void txFrameIn(const QCanBusFrame& frame); 42 | void rxFrameIn(const QCanBusFrame& frame); 43 | void stopSimulation() override; 44 | void startSimulation() override; 45 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 46 | 47 | private: 48 | QScopedPointer d_ptr; 49 | }; 50 | 51 | #endif //CANRAWFILTER_H 52 | -------------------------------------------------------------------------------- /src/components/canrawfilter/canrawfilter_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWFILTER_P_H 2 | #define CANRAWFILTER_P_H 3 | 4 | #include "canrawfilter.h" 5 | #include "gui/canrawfilterguiimpl.h" 6 | #include 7 | #include 8 | 9 | class CanRawFilter; 10 | 11 | class CanRawFilterPrivate : public QObject { 12 | Q_OBJECT 13 | Q_DECLARE_PUBLIC(CanRawFilter) 14 | 15 | public: 16 | CanRawFilterPrivate(CanRawFilter* q, CanRawFilterCtx&& ctx = CanRawFilterCtx(new CanRawFilterGuiImpl)); 17 | ComponentInterface::ComponentProperties getSupportedProperties() const; 18 | QJsonObject getSettings(); 19 | void setSettings(const QJsonObject& json); 20 | bool acceptRxFrame(const QCanBusFrame& frame); 21 | bool acceptTxFrame(const QCanBusFrame& frame); 22 | 23 | private: 24 | void initProps(); 25 | bool acceptFrame(const CanRawFilterGuiInt::AcceptList_t& list, const QCanBusFrame& frame); 26 | CanRawFilterGuiInt::AcceptList_t getAcceptList(const QJsonObject& json, const QString& listName); 27 | 28 | public: 29 | bool _simStarted{ false }; 30 | CanRawFilterCtx _ctx; 31 | CanRawFilterGuiInt& _ui; 32 | bool _docked{ true }; 33 | std::map _props; 34 | 35 | private: 36 | CanRawFilterGuiInt::AcceptList_t _rxAcceptList; 37 | CanRawFilterGuiInt::AcceptList_t _txAcceptList; 38 | CanRawFilter* q_ptr; 39 | const QString _nameProperty = "name"; 40 | 41 | // workaround for clang 3.5 42 | using cf = ComponentInterface::CustomEditFieldCbk; 43 | 44 | // clang-format off 45 | ComponentInterface::ComponentProperties _supportedProps = { 46 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)) 47 | }; 48 | // clang-format on 49 | }; 50 | 51 | #endif // CANRAWFILTER_P_H 52 | -------------------------------------------------------------------------------- /src/components/canrawfilter/canrawfiltermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWFILTERMODEL_H 2 | #define CANRAWFILTERMODEL_H 3 | 4 | #include "canrawfilter.h" 5 | #include "componentmodel.h" 6 | #include "nodepainter.h" 7 | #include 8 | #include 9 | 10 | using QtNodes::NodeData; 11 | using QtNodes::NodeDataType; 12 | using QtNodes::PortIndex; 13 | using QtNodes::PortType; 14 | 15 | class QCanBusFrame; 16 | enum class Direction; 17 | 18 | class CanRawFilterModel : public ComponentModel { 19 | Q_OBJECT 20 | 21 | public: 22 | CanRawFilterModel(); 23 | 24 | unsigned int nPorts(PortType portType) const override; 25 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 26 | std::shared_ptr outData(PortIndex port) override; 27 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 28 | QtNodes::NodePainterDelegate* painterDelegate() const override; 29 | 30 | public slots: 31 | void filteredTx(const QCanBusFrame& frame); 32 | void filteredRx(const QCanBusFrame& frame); 33 | 34 | signals: 35 | void filterTx(const QCanBusFrame& frame); 36 | void filterRx(const QCanBusFrame& frame); 37 | void requestRedraw(); 38 | 39 | private: 40 | std::unique_ptr _painter; 41 | // 127 to use 4 blocks, 512 bytes each 42 | moodycamel::ReaderWriterQueue> _fwdQueue{ 127 }; 43 | }; 44 | 45 | #endif // CANRAWFILTERMODEL_H 46 | -------------------------------------------------------------------------------- /src/components/canrawfilter/canrawfilterplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWFILTERPLUGIN_H_MGJSE2A9 2 | #define CANRAWFILTERPLUGIN_H_MGJSE2A9 3 | 4 | #include "plugin_type.h" 5 | #include "canrawfiltermodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanRawFilterPlugin { 10 | using Model = CanRawFilterModel; 11 | static constexpr const char* name = "CanRawFilter"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | #endif /* end of include guard: CANRAWFILTERPLUGIN_H_MGJSE2A9 */ 16 | -------------------------------------------------------------------------------- /src/components/canrawfilter/gui/canrawfilterguiint.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWFILTERGUIINT_H 2 | #define CANRAWFILTERGUIINT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QWidget; 10 | 11 | struct CanRawFilterGuiInt { 12 | typedef std::tuple AcceptListItem_t; 13 | typedef std::vector AcceptList_t; 14 | typedef std::function ListUpdated_t; 15 | 16 | virtual ~CanRawFilterGuiInt() {} 17 | 18 | virtual QWidget* mainWidget() = 0; 19 | virtual void setTxListCbk(const ListUpdated_t& cb) = 0; 20 | virtual void setRxListCbk(const ListUpdated_t& cb) = 0; 21 | virtual void setListRx(const AcceptList_t& list) = 0; 22 | virtual void setListTx(const AcceptList_t& list) = 0; 23 | }; 24 | 25 | #endif // CANRAWFILTERGUIINT_H 26 | -------------------------------------------------------------------------------- /src/components/canrawlogger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canrawlogger) 2 | 3 | set(SRC 4 | canrawlogger.cpp 5 | canrawlogger_p.cpp 6 | canrawloggermodel.cpp 7 | ) 8 | 9 | add_library(${COMPONENT_NAME} ${SRC}) 10 | target_link_libraries(${COMPONENT_NAME} cds-common) 11 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | if(WITH_TESTS) 14 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 15 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 16 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 17 | 18 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 19 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 20 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 21 | endif() 22 | -------------------------------------------------------------------------------- /src/components/canrawlogger/canrawlogger.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWLOGGER_H 2 | #define CANRAWLOGGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class QCanBusFrame; 11 | class CanRawLoggerPrivate; 12 | class QWidget; 13 | typedef Context<> CanRawLoggerCtx; 14 | 15 | class CanRawLogger : public QObject, public ComponentInterface { 16 | Q_OBJECT 17 | Q_DECLARE_PRIVATE(CanRawLogger) 18 | 19 | public: 20 | CanRawLogger(); 21 | explicit CanRawLogger(CanRawLoggerCtx&& ctx); 22 | ~CanRawLogger(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void mainWidgetDockToggled(QWidget* widget) override; 35 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 36 | 37 | public slots: 38 | void stopSimulation() override; 39 | void startSimulation() override; 40 | void frameReceived(const QCanBusFrame& frame); 41 | void frameSent(bool status, const QCanBusFrame& frame); 42 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 43 | 44 | private: 45 | QScopedPointer d_ptr; 46 | }; 47 | 48 | #endif //CANRAWLOGGER_H 49 | -------------------------------------------------------------------------------- /src/components/canrawlogger/canrawlogger_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWLOGGER_P_H 2 | #define CANRAWLOGGER_P_H 3 | 4 | #include "canrawlogger.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class CanRawLogger; 12 | 13 | class CanRawLoggerPrivate : public QObject { 14 | Q_OBJECT 15 | Q_DECLARE_PUBLIC(CanRawLogger) 16 | 17 | public: 18 | CanRawLoggerPrivate(CanRawLogger* q, CanRawLoggerCtx&& ctx = CanRawLoggerCtx()); 19 | ComponentInterface::ComponentProperties getSupportedProperties() const; 20 | QJsonObject getSettings(); 21 | void setSettings(const QJsonObject& json); 22 | void logFrame(const QCanBusFrame& frame, const QString& dir); 23 | 24 | private: 25 | void initProps(); 26 | 27 | public: 28 | bool _simStarted{ false }; 29 | CanRawLoggerCtx _ctx; 30 | std::map _props; 31 | QString _filename; 32 | QFile _file; 33 | QElapsedTimer _timer; 34 | 35 | private: 36 | CanRawLogger* q_ptr; 37 | const QString _nameProperty = "name"; 38 | const QString _dirProperty = "directory"; 39 | 40 | // workaround for clang 3.5 41 | using cf = ComponentInterface::CustomEditFieldCbk; 42 | 43 | // clang-format off 44 | ComponentInterface::ComponentProperties _supportedProps = { 45 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 46 | std::make_tuple(_dirProperty, QVariant::String, true, cf([] { return new PropertyFieldPath(true); } )) 47 | }; 48 | // clang-format on 49 | }; 50 | 51 | #endif // CANRAWLOGGER_P_H 52 | -------------------------------------------------------------------------------- /src/components/canrawlogger/canrawloggermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWLOGGERMODEL_H 2 | #define CANRAWLOGGERMODEL_H 3 | 4 | #include "canrawlogger.h" 5 | #include "componentmodel.h" 6 | #include "nodepainter.h" 7 | #include 8 | 9 | using QtNodes::NodeData; 10 | using QtNodes::NodeDataType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::PortType; 13 | 14 | class QCanBusFrame; 15 | enum class Direction; 16 | 17 | class CanRawLoggerModel : public ComponentModel { 18 | Q_OBJECT 19 | 20 | public: 21 | CanRawLoggerModel(); 22 | 23 | unsigned int nPorts(PortType portType) const override; 24 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 25 | std::shared_ptr outData(PortIndex port) override; 26 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 27 | QtNodes::NodePainterDelegate* painterDelegate() const override; 28 | 29 | public slots: 30 | 31 | signals: 32 | void frameReceived(const QCanBusFrame& frame); 33 | void frameSent(bool status, const QCanBusFrame& frame); 34 | void requestRedraw(); 35 | 36 | private: 37 | std::unique_ptr _painter; 38 | }; 39 | 40 | #endif // CANRAWLOGGERMODEL_H 41 | -------------------------------------------------------------------------------- /src/components/canrawlogger/canrawloggerplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWLOGGERPLUGIN_H_QKYDNCFC 2 | #define CANRAWLOGGERPLUGIN_H_QKYDNCFC 3 | 4 | #include "plugin_type.h" 5 | #include "canrawloggermodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanRawLoggerPlugin { 10 | using Model = CanRawLoggerModel; 11 | static constexpr const char* name = "CanRawLogger"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | #endif /* end of include guard: CANRAWLOGGERPLUGIN_H_QKYDNCFC */ 16 | -------------------------------------------------------------------------------- /src/components/canrawplayer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canrawplayer) 2 | 3 | set(SRC 4 | canrawplayer.cpp 5 | canrawplayer_p.cpp 6 | canrawplayermodel.cpp 7 | ) 8 | 9 | add_library(${COMPONENT_NAME} ${SRC}) 10 | target_link_libraries(${COMPONENT_NAME} cds-common rwqueue) 11 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | if(WITH_TESTS) 14 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 15 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 16 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 17 | 18 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 19 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 20 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 21 | endif() 22 | -------------------------------------------------------------------------------- /src/components/canrawplayer/canrawplayer.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWPLAYER_H 2 | #define CANRAWPLAYER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanRawPlayerPrivate; 11 | class QCanBusFrame; 12 | class QWidget; 13 | typedef Context<> CanRawPlayerCtx; 14 | 15 | class CanRawPlayer : public QObject, public ComponentInterface { 16 | Q_OBJECT 17 | Q_DECLARE_PRIVATE(CanRawPlayer) 18 | 19 | public: 20 | CanRawPlayer(); 21 | explicit CanRawPlayer(CanRawPlayerCtx&& ctx); 22 | ~CanRawPlayer(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void sendFrame(const QCanBusFrame& frame); 35 | void mainWidgetDockToggled(QWidget* widget) override; 36 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 37 | 38 | public slots: 39 | void stopSimulation() override; 40 | void startSimulation() override; 41 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 42 | 43 | private: 44 | QScopedPointer d_ptr; 45 | }; 46 | 47 | #endif //CANRAWPLAYER_H 48 | -------------------------------------------------------------------------------- /src/components/canrawplayer/canrawplayer_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWPLAYER_P_H 2 | #define CANRAWPLAYER_P_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "canrawplayer.h" 9 | #include 10 | 11 | class CanRawPlayer; 12 | 13 | class CanRawPlayerPrivate : public QObject { 14 | Q_OBJECT 15 | Q_DECLARE_PUBLIC(CanRawPlayer) 16 | 17 | public: 18 | CanRawPlayerPrivate(CanRawPlayer* q, CanRawPlayerCtx&& ctx = CanRawPlayerCtx()); 19 | ComponentInterface::ComponentProperties getSupportedProperties() const; 20 | QJsonObject getSettings(); 21 | void setSettings(const QJsonObject& json); 22 | void loadTraceFile(const QString& filename); 23 | void startPlayback(); 24 | void stopPlayback(); 25 | 26 | private: 27 | void initProps(); 28 | 29 | 30 | private slots: 31 | void timeout(); 32 | 33 | public: 34 | bool _simStarted{ false }; 35 | CanRawPlayerCtx _ctx; 36 | std::map _props; 37 | uint32_t _tick{ 10 }; 38 | const QString _nameProperty = "name"; 39 | const QString _fileProperty = "file"; 40 | const QString _tickProperty = "timer tick [ms]"; 41 | 42 | private: 43 | CanRawPlayer* q_ptr; 44 | std::vector> _frames; 45 | uint32_t _frameNdx; 46 | uint32_t _ticks; 47 | QTimer _timer; 48 | 49 | // workaround for clang 3.5 50 | using cf = ComponentInterface::CustomEditFieldCbk; 51 | 52 | // clang-format off 53 | ComponentInterface::ComponentProperties _supportedProps = { 54 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 55 | std::make_tuple(_fileProperty, QVariant::String, true, cf([] { return new PropertyFieldPath; } )), 56 | std::make_tuple(_tickProperty, QVariant::String, true, cf([] { return new PropertyFieldText(true); } )) 57 | }; 58 | // clang-format on 59 | }; 60 | 61 | #endif // CANRAWPLAYER_P_H 62 | -------------------------------------------------------------------------------- /src/components/canrawplayer/canrawplayermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWPLAYERMODEL_H 2 | #define CANRAWPLAYERMODEL_H 3 | 4 | #include "canrawplayer.h" 5 | #include "componentmodel.h" 6 | #include "nodepainter.h" 7 | #include 8 | #include 9 | #include 10 | 11 | using QtNodes::NodeData; 12 | using QtNodes::NodeDataType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::PortType; 15 | 16 | enum class Direction; 17 | 18 | class CanRawPlayerModel : public ComponentModel { 19 | Q_OBJECT 20 | 21 | public: 22 | CanRawPlayerModel(); 23 | 24 | unsigned int nPorts(PortType portType) const override; 25 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 26 | std::shared_ptr outData(PortIndex port) override; 27 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 28 | QtNodes::NodePainterDelegate* painterDelegate() const override; 29 | 30 | virtual bool hasSeparateThread() const override 31 | { 32 | return true; 33 | } 34 | 35 | public slots: 36 | 37 | /** 38 | * @brief Callback, called when CanRawSender emits signal sendFrame, sends frame 39 | * @param received frame 40 | */ 41 | void sendFrame(const QCanBusFrame& frame); 42 | 43 | signals: 44 | void requestRedraw(); 45 | 46 | private: 47 | std::unique_ptr _painter; 48 | moodycamel::ReaderWriterQueue> _msgQueue{ 127 }; 49 | }; 50 | 51 | #endif // CANRAWPLAYERMODEL_H 52 | -------------------------------------------------------------------------------- /src/components/canrawplayer/canrawplayerplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWPLAYERPLUGIN_H_G8RLJWGO 2 | #define CANRAWPLAYERPLUGIN_H_G8RLJWGO 3 | 4 | #include "plugin_type.h" 5 | #include "canrawplayermodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanRawPlayerPlugin { 10 | using Model = CanRawPlayerModel; 11 | static constexpr const char* name = "CanRawPlayer"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | 16 | #endif /* end of include guard: CANRAWPLAYERPLUGIN_H_G8RLJWGO */ 17 | -------------------------------------------------------------------------------- /src/components/canrawsender/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canrawsender) 2 | 3 | set(SRC 4 | gui/canrawsender.ui 5 | gui/crsgui.h 6 | canrawsender.cpp 7 | canrawsender_p.cpp 8 | newlinemanager.cpp 9 | canrawsendermodel.cpp 10 | ) 11 | 12 | add_library(${COMPONENT_NAME} STATIC ${SRC}) 13 | target_link_libraries(${COMPONENT_NAME} cds-common) 14 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 15 | 16 | if(WITH_TESTS) 17 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp tests/newlinemanager_test.cpp) 18 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 19 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 20 | 21 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 22 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 23 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 24 | 25 | add_definitions(-DCRS_TEST_CONFIG_FILES="${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles") 26 | endif() 27 | -------------------------------------------------------------------------------- /src/components/canrawsender/canrawsendermodel.cpp: -------------------------------------------------------------------------------- 1 | #include "canrawsendermodel.h" 2 | #include 3 | #include "canrawsenderplugin.h" 4 | 5 | CanRawSenderModel::CanRawSenderModel() 6 | : ComponentModel("CanRawSender") 7 | , _painter(std::make_unique(CanRawSenderPlugin::PluginType::sectionColor())) 8 | { 9 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 10 | _label->setFixedSize(75, 25); 11 | _label->setAttribute(Qt::WA_TranslucentBackground); 12 | 13 | connect(&_component, &CanRawSender::sendFrame, this, &CanRawSenderModel::sendFrame); 14 | 15 | QWidget* crsWidget = _component.mainWidget(); 16 | crsWidget->setWindowTitle(_caption); 17 | } 18 | 19 | QtNodes::NodePainterDelegate* CanRawSenderModel::painterDelegate() const 20 | { 21 | return _painter.get(); 22 | } 23 | 24 | NodeDataType CanRawSenderModel::dataType(PortType, PortIndex) const 25 | { 26 | return CanRawData().type(); 27 | } 28 | 29 | std::shared_ptr CanRawSenderModel::outData(PortIndex) 30 | { 31 | return std::make_shared(_frame); 32 | } 33 | 34 | void CanRawSenderModel::sendFrame(const QCanBusFrame& frame) 35 | { 36 | // TODO: Check if we don't need queue here. If different threads will operate on _frame we may loose data 37 | _frame = frame; 38 | emit dataUpdated(0); // Data ready on port 0 39 | } 40 | 41 | unsigned int CanRawSenderModel::nPorts(PortType portType) const 42 | { 43 | return (PortType::Out == portType) ? 1 : 0; 44 | } 45 | -------------------------------------------------------------------------------- /src/components/canrawsender/canrawsenderplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWSENDERPLUGIN_H_M78FS6IV 2 | #define CANRAWSENDERPLUGIN_H_M78FS6IV 3 | 4 | #include "plugin_type.h" 5 | #include "canrawsendermodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanRawSenderPlugin { 10 | using Model = CanRawSenderModel; 11 | static constexpr const char* name = "CanRawSender"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | 16 | #endif /* end of include guard: CANRAWSENDERPLUGIN_H_M78FS6IV */ 17 | -------------------------------------------------------------------------------- /src/components/canrawsender/gui/crsgui.h: -------------------------------------------------------------------------------- 1 | #ifndef CRSGUI_H 2 | #define CRSGUI_H 3 | 4 | #include "crsguiinterface.h" 5 | #include "ui_canrawsender.h" 6 | #include 7 | 8 | namespace Ui { 9 | class CanRawSenderPrivate; 10 | } 11 | 12 | struct CRSGui : public CRSGuiInterface { 13 | CRSGui() 14 | : ui(new Ui::CanRawSenderPrivate) 15 | , widget(new QWidget) 16 | { 17 | ui->setupUi(widget); 18 | widget->setMinimumSize(ui->tv->minimumSize()); 19 | } 20 | 21 | void setAddCbk(const add_t& cb) override 22 | { 23 | QObject::connect(ui->pbAdd, &QPushButton::pressed, cb); 24 | } 25 | 26 | void setRemoveCbk(const remove_t& cb) override 27 | { 28 | QObject::connect(ui->pbRemove, &QPushButton::pressed, cb); 29 | } 30 | 31 | void setDockUndockCbk(const dockUndock_t& cb) override 32 | { 33 | QObject::connect(ui->pbDockUndock, &QPushButton::toggled, cb); 34 | } 35 | 36 | QWidget* mainWidget() override 37 | { 38 | return widget; 39 | } 40 | 41 | void initTableView(QAbstractItemModel& _tvModel) override 42 | { 43 | 44 | ui->tv->setModel(&_tvModel); 45 | ui->tv->setSelectionBehavior(QAbstractItemView::SelectRows); 46 | ui->tv->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); 47 | } 48 | 49 | QModelIndexList getSelectedRows() override 50 | { 51 | return ui->tv->selectionModel()->selectedRows(); 52 | } 53 | 54 | void setIndexWidget(const QModelIndex& index, QWidget* widget) override 55 | { 56 | ui->tv->setIndexWidget(index, widget); 57 | } 58 | 59 | private: 60 | Ui::CanRawSenderPrivate* ui; 61 | QWidget* widget; 62 | }; 63 | #endif // CRSGUI_H 64 | -------------------------------------------------------------------------------- /src/components/canrawsender/gui/crsguiinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef CRSGUIINTERFACE_H 2 | #define CRSGUIINTERFACE_H 3 | 4 | #include 5 | #include 6 | #include 7 | class QWidget; 8 | class QAbstractItemModel; 9 | class CanRawSender; 10 | class NewLineManager; 11 | 12 | struct CRSGuiInterface { 13 | virtual ~CRSGuiInterface() 14 | { 15 | } 16 | 17 | typedef std::function add_t; 18 | typedef std::function remove_t; 19 | typedef std::function dockUndock_t; 20 | virtual void setAddCbk(const add_t& cb) = 0; 21 | virtual void setRemoveCbk(const remove_t& cb) = 0; 22 | virtual void setDockUndockCbk(const dockUndock_t& cb) = 0; 23 | 24 | virtual QWidget* mainWidget() = 0; 25 | virtual void initTableView(QAbstractItemModel& _tvModel) = 0; 26 | virtual QModelIndexList getSelectedRows() = 0; 27 | virtual void setIndexWidget(const QModelIndex& index, QWidget* widget) = 0; 28 | }; 29 | #endif // CRSGUIINTERFACE_H 30 | -------------------------------------------------------------------------------- /src/components/canrawsender/gui/nlmcheckbox.h: -------------------------------------------------------------------------------- 1 | #ifndef NLMCHECKBOX_H 2 | #define NLMCHECKBOX_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct NLMCheckBox : public CheckBoxInterface { 10 | 11 | NLMCheckBox() 12 | : qWidget(new QWidget) 13 | , qCheckBox(new QCheckBox) 14 | , qLayout(nullptr) 15 | { 16 | init(); 17 | qCheckBox->setProperty("type", "nlmItem"); 18 | } 19 | 20 | void toggledCbk(const toggled_t& cb) override 21 | { 22 | QObject::connect(qCheckBox, &QCheckBox::toggled, cb); 23 | } 24 | 25 | QWidget* mainWidget() override 26 | { 27 | return qWidget; 28 | } 29 | 30 | bool getState() override 31 | { 32 | return qCheckBox->isChecked(); 33 | } 34 | 35 | void init() 36 | { 37 | qLayout = new QHBoxLayout(qWidget); 38 | qLayout->addWidget(qCheckBox); 39 | qLayout->setAlignment(Qt::AlignCenter); 40 | qLayout->setContentsMargins(0, 0, 0, 0); 41 | qWidget->setLayout(qLayout); 42 | } 43 | 44 | void setState(bool state) override 45 | { 46 | if (qCheckBox->isChecked() != state) { 47 | qCheckBox->setChecked(state); 48 | emit qCheckBox->released(); 49 | } 50 | } 51 | 52 | void setDisabled(bool state) override 53 | { 54 | qCheckBox->setDisabled(state); 55 | } 56 | 57 | 58 | private: 59 | QWidget* qWidget; 60 | QCheckBox* qCheckBox; 61 | QHBoxLayout* qLayout; 62 | }; 63 | 64 | #endif // NLMCHECKBOX_H 65 | -------------------------------------------------------------------------------- /src/components/canrawsender/gui/nlmlineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef NLMLINEEDIT_H 2 | #define NLMLINEEDIT_H 3 | 4 | #include 5 | #include 6 | 7 | struct NLMLineEdit : public LineEditInterface { 8 | 9 | NLMLineEdit() 10 | : qLineEdit(new QLineEdit) 11 | { 12 | qLineEdit->setProperty("type", "nlmItem"); 13 | } 14 | 15 | void editingFinishedCbk(const textChanged_t& cb) override 16 | { 17 | QObject::connect(qLineEdit, &QLineEdit::editingFinished, cb); 18 | } 19 | 20 | void textChangedCbk(const textChanged_t& cb) override 21 | { 22 | QObject::connect(qLineEdit, &QLineEdit::textEdited, cb); 23 | } 24 | 25 | QWidget* mainWidget() override 26 | { 27 | return qLineEdit; 28 | } 29 | 30 | void init(const QString& placeholderText, QValidator* qValidator) override 31 | { 32 | qLineEdit->setFrame(false); 33 | qLineEdit->setAlignment(Qt::AlignHCenter); 34 | qLineEdit->setPlaceholderText(placeholderText); 35 | if (qValidator != nullptr) { 36 | qLineEdit->setValidator(qValidator); 37 | } 38 | } 39 | 40 | void setPlaceholderText(const QString& placeholderText) override 41 | { 42 | qLineEdit->setPlaceholderText(placeholderText); 43 | } 44 | 45 | void setDisabled(bool state) override 46 | { 47 | qLineEdit->setDisabled(state); 48 | } 49 | 50 | int getTextLength() override 51 | { 52 | return qLineEdit->text().length(); 53 | } 54 | 55 | const QString getText() override 56 | { 57 | return qLineEdit->text(); 58 | } 59 | 60 | void setText(const QString& text) override 61 | { 62 | // Inserts new text and validates the result 63 | qLineEdit->clear(); 64 | qLineEdit->insert(text); 65 | } 66 | 67 | private: 68 | QLineEdit* qLineEdit; 69 | }; 70 | 71 | #endif // NLMLINEEDIT_H 72 | -------------------------------------------------------------------------------- /src/components/canrawsender/gui/nlmpushbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef NLMPUSHBUTTON_H 2 | #define NLMPUSHBUTTON_H 3 | 4 | #include 5 | #include 6 | 7 | struct NLMPushButton : public PushButtonInterface { 8 | 9 | NLMPushButton() 10 | : qPushButton(new QPushButton) 11 | { 12 | qPushButton->setProperty("type", "nlmItem"); 13 | } 14 | 15 | void pressedCbk(const pressed_t& cb) override 16 | { 17 | QObject::connect(qPushButton, &QPushButton::pressed, cb); 18 | } 19 | 20 | QWidget* mainWidget() override 21 | { 22 | return qPushButton; 23 | } 24 | 25 | void init(const QString& buttonName, bool isEnable) override 26 | { 27 | qPushButton->setText(buttonName); 28 | qPushButton->setFlat(true); 29 | setDisabled(!isEnable); 30 | } 31 | 32 | void setDisabled(bool state) override 33 | { 34 | qPushButton->setDisabled(state); 35 | } 36 | 37 | bool isEnabled() override 38 | { 39 | return qPushButton->isEnabled(); 40 | } 41 | 42 | void setCheckable(bool checked) override 43 | { 44 | qPushButton->setCheckable(checked); 45 | } 46 | 47 | bool checkable() override 48 | { 49 | return qPushButton->isCheckable(); 50 | } 51 | 52 | bool checked() override 53 | { 54 | return qPushButton->isChecked(); 55 | } 56 | 57 | void setChecked(bool checked) override 58 | { 59 | if(checked != qPushButton->isChecked()) { 60 | qPushButton->animateClick(); 61 | } 62 | } 63 | 64 | 65 | private: 66 | QPushButton* qPushButton; 67 | }; 68 | #endif // NLMPUSHBUTTON_H 69 | -------------------------------------------------------------------------------- /src/components/canrawsender/nlmfactory.h: -------------------------------------------------------------------------------- 1 | #ifndef NLMFACTORY_H 2 | #define NLMFACTORY_H 3 | 4 | #include "gui/nlmcheckbox.h" 5 | #include "gui/nlmlineedit.h" 6 | #include "gui/nlmpushbutton.h" 7 | #include "nlmfactoryinterface.h" 8 | 9 | struct NLMFactory : public NLMFactoryInterface { 10 | virtual ~NLMFactory() 11 | { 12 | } 13 | 14 | CheckBoxInterface* createCheckBox() override 15 | { 16 | return new NLMCheckBox(); 17 | } 18 | LineEditInterface* createLineEdit() override 19 | { 20 | return new NLMLineEdit; 21 | } 22 | PushButtonInterface* createPushButton() override 23 | { 24 | return new NLMPushButton; 25 | } 26 | }; 27 | #endif // NLMFACTORY_H 28 | -------------------------------------------------------------------------------- /src/components/canrawsender/nlmfactoryinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef NLMFACTORYINTERFACE_H 2 | #define NLMFACTORYINTERFACE_H 3 | 4 | struct CheckBoxInterface; 5 | struct LineEditInterface; 6 | struct PushButtonInterface; 7 | 8 | struct NLMFactoryInterface { 9 | virtual ~NLMFactoryInterface() 10 | { 11 | } 12 | virtual CheckBoxInterface* createCheckBox() = 0; 13 | virtual LineEditInterface* createLineEdit() = 0; 14 | virtual PushButtonInterface* createPushButton() = 0; 15 | }; 16 | #endif // NLMFACTORYINTERFACE_H 17 | -------------------------------------------------------------------------------- /src/components/canrawsender/tests/configfiles/canrawsenderconfig.cds: -------------------------------------------------------------------------------- 1 | { 2 | "senderColumns": [ 3 | "Id", 4 | "Data", 5 | "Remote", 6 | "Loop", 7 | "Interval", 8 | "" 9 | ], 10 | "content": [ 11 | { 12 | "data": "6565", 13 | "id": "1321", 14 | "interval": "2548", 15 | "loop": false, 16 | "remote": false, 17 | "send": false 18 | } 19 | ], 20 | "name": "CanRawSender", 21 | "caption": "CanRawSender", 22 | "sorting": { 23 | "currentIndex": 0 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/components/canrawsender/tests/configfiles/canrawsenderconfig_badData.cds: -------------------------------------------------------------------------------- 1 | { 2 | "columns": [ 3 | "Id", 4 | "Data", 5 | "Remote", 6 | "Loop", 7 | "Interval", 8 | "" 9 | ], 10 | "content": [ 11 | { 12 | "data": "data", 13 | "id": "1321", 14 | "interval": "2548", 15 | "loop": false, 16 | "remote": false 17 | } 18 | ], 19 | "name": "CanRawSender", 20 | "caption": "CanRawSender", 21 | "sorting": { 22 | "currentIndex": 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/components/canrawsender/tests/configfiles/canrawsenderconfig_badId.cds: -------------------------------------------------------------------------------- 1 | { 2 | "senderColumns": [ 3 | "Id", 4 | "Data", 5 | "Remote", 6 | "Loop", 7 | "Interval", 8 | "" 9 | ], 10 | "content": [ 11 | { 12 | "data": "6565", 13 | "id": "id", 14 | "interval": "2548", 15 | "loop": false, 16 | "remote": false 17 | } 18 | ], 19 | "name": "CanRawSender", 20 | "caption": "CanRawSender", 21 | "sorting": { 22 | "currentIndex": 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/components/canrawsender/tests/configfiles/canrawsenderconfig_badInterval.cds: -------------------------------------------------------------------------------- 1 | { 2 | "columns": [ 3 | "Id", 4 | "Data", 5 | "Remote", 6 | "Loop", 7 | "Interval", 8 | "" 9 | ], 10 | "content": [ 11 | { 12 | "data": "6565", 13 | "id": "1321", 14 | "interval": "-2548", 15 | "loop": false, 16 | "remote": false 17 | } 18 | ], 19 | "name": "CanRawSender", 20 | "caption": "CanRawSender", 21 | "sorting": { 22 | "currentIndex": 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/components/canrawsender/tests/configfiles/canrawsenderconfig_badcolumns.cds: -------------------------------------------------------------------------------- 1 | { 2 | "senderColumns": [ 3 | "badColumnsName_luckId", 4 | "Data", 5 | "Remote", 6 | "Loop", 7 | "Interval", 8 | "" 9 | ], 10 | "content": [ 11 | { 12 | "data": "6565", 13 | "id": "1321", 14 | "interval": "2548", 15 | "loop": false, 16 | "remote": false 17 | } 18 | ], 19 | "name": "CanRawSender", 20 | "caption": "CanRawSender", 21 | "sorting": { 22 | "currentIndex": 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/components/canrawview/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME canrawview) 2 | 3 | set(SRC 4 | gui/canrawview.ui 5 | gui/crvgui.h 6 | canrawview.cpp 7 | canrawviewmodel.cpp 8 | ) 9 | 10 | add_library(${COMPONENT_NAME} STATIC ${SRC}) 11 | target_link_libraries(${COMPONENT_NAME} cds-common) 12 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 13 | 14 | if(WITH_TESTS) 15 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 16 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 17 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 18 | 19 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 20 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 21 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 22 | 23 | set(CONFIG_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles) 24 | set(CONFIG_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/configfiles) 25 | add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD 26 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CONFIG_SOURCE} ${CONFIG_DESTINATION}) 27 | endif() 28 | 29 | -------------------------------------------------------------------------------- /src/components/canrawview/canrawviewmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "canrawviewmodel.h" 2 | #include 3 | #include 4 | #include "canrawviewplugin.h" 5 | 6 | CanRawViewModel::CanRawViewModel() 7 | : ComponentModel("CanRawView") 8 | , _painter(std::make_unique(CanRawViewPlugin::PluginType::sectionColor())) 9 | { 10 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 11 | _label->setFixedSize(75, 25); 12 | _label->setAttribute(Qt::WA_TranslucentBackground); 13 | 14 | _component.mainWidget()->setWindowTitle(_caption); 15 | 16 | connect(this, &CanRawViewModel::frameSent, &_component, &CanRawView::frameSent); 17 | connect(this, &CanRawViewModel::frameReceived, &_component, &CanRawView::frameReceived); 18 | } 19 | 20 | QtNodes::NodePainterDelegate* CanRawViewModel::painterDelegate() const 21 | { 22 | return _painter.get(); 23 | } 24 | 25 | unsigned int CanRawViewModel::nPorts(PortType portType) const 26 | { 27 | return (PortType::In == portType) ? 1 : 0; 28 | } 29 | 30 | NodeDataType CanRawViewModel::dataType(PortType, PortIndex) const 31 | { 32 | return CanRawData().type(); 33 | } 34 | 35 | std::shared_ptr CanRawViewModel::outData(PortIndex) 36 | { 37 | return std::make_shared(); 38 | } 39 | 40 | void CanRawViewModel::setInData(std::shared_ptr nodeData, PortIndex) 41 | { 42 | if (nodeData) { 43 | auto d = std::dynamic_pointer_cast(nodeData); 44 | assert(nullptr != d); 45 | if (d->direction() == Direction::TX) { 46 | emit frameSent(d->status(), d->frame()); 47 | } else if (d->direction() == Direction::RX) { 48 | emit frameReceived(d->frame()); 49 | } else { 50 | cds_warn("Incorrect direction"); 51 | } 52 | } else { 53 | cds_warn("Incorrect nodeData"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/components/canrawview/canrawviewplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANRAWVIEWPLUGIN_H_C02HULVO 2 | #define CANRAWVIEWPLUGIN_H_C02HULVO 3 | 4 | #include "plugin_type.h" 5 | #include "canrawviewmodel.h" 6 | 7 | using CanRawPlugin = PluginBase; 8 | 9 | struct CanRawViewPlugin { 10 | using Model = CanRawViewModel; 11 | static constexpr const char* name = "CanRawView"; 12 | using PluginType = CanRawPlugin; 13 | }; 14 | 15 | #endif /* end of include guard: CANRAWVIEWPLUGIN_H_C02HULVO */ 16 | -------------------------------------------------------------------------------- /src/components/canrawview/gui/crvguiinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef CRVGUIINTERFACE_H 2 | #define CRVGUIINTERFACE_H 3 | 4 | #include 5 | #include 6 | 7 | class QWidget; 8 | class QAbstractItemModel; 9 | 10 | struct CRVGuiInterface { 11 | typedef std::function clear_t; 12 | typedef std::function dockUndock_t; 13 | typedef std::function sectionClicked_t; 14 | typedef std::function filter_t; 15 | 16 | virtual void setClearCbk(const clear_t& cb) = 0; 17 | virtual void setDockUndockCbk(const dockUndock_t& cb) = 0; 18 | virtual void setSectionClikedCbk(const sectionClicked_t& cb) = 0; 19 | virtual void setFilterCbk(const filter_t& cb) = 0; 20 | 21 | virtual ~CRVGuiInterface() 22 | { 23 | } 24 | 25 | virtual QWidget* mainWidget() = 0; 26 | virtual void setModel(QAbstractItemModel* model) = 0; 27 | virtual void initTableView(QAbstractItemModel& tvModel) = 0; 28 | virtual bool isViewFrozen() = 0; 29 | virtual void setViewFrozen(bool state) = 0; 30 | virtual void scrollToBottom() = 0; 31 | virtual Qt::SortOrder getSortOrder() = 0; 32 | virtual QString getClickedColumn(int ndx) = 0; 33 | virtual void setSorting(int sortNdx, Qt::SortOrder order) = 0; 34 | virtual QString getWindowTitle() = 0; 35 | virtual bool isColumnHidden(int ndx) = 0; 36 | virtual void getColumnProper(int ndx, int& vIdx) = 0; 37 | virtual void setColumnProper(int vIdxFrom, int vIdxTo) = 0; 38 | }; 39 | 40 | #endif // CRVGUIINTERFACE_H 41 | -------------------------------------------------------------------------------- /src/components/canrawview/tests/configfiles/canrawviewconfig.cds: -------------------------------------------------------------------------------- 1 | { 2 | "viewColumns": [ 3 | { 4 | "name": "time", 5 | "vIdx": 5 6 | }, 7 | { 8 | "name": "id", 9 | "vIdx": 4 10 | }, 11 | { 12 | "name": "dir", 13 | "vIdx": 2 14 | }, 15 | { 16 | "name": "len", 17 | "vIdx": 1 18 | }, 19 | { 20 | "name": "data", 21 | "vIdx": 3 22 | } 23 | ], 24 | "name": "CanRawView", 25 | "caption": "CanRawView", 26 | "scrolling": true 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/components/canrawview/tests/configfiles/canrawviewconfig_columnluck.cds: -------------------------------------------------------------------------------- 1 | { 2 | "viewColumns": [ 3 | { 4 | "name": "id", 5 | "vIdx": 4, 6 | "width": 60 7 | }, 8 | { 9 | "name": "dir", 10 | "vIdx": 2, 11 | "width": 60 12 | }, 13 | { 14 | "name": "len", 15 | "vIdx": 1, 16 | "width": 60 17 | }, 18 | { 19 | "name": "data", 20 | "vIdx": 3, 21 | "width": 764 22 | } 23 | ], 24 | "name": "CanRawView", 25 | "caption": "CanRawView", 26 | "scrolling": true 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/components/canrawview/tests/configfiles/canrawviewconfig_sortingformat.cds: -------------------------------------------------------------------------------- 1 | { 2 | "viewColumns": [ 3 | { 4 | "name": "time", 5 | "vIdx": 5, 6 | "width": 60 7 | }, 8 | { 9 | "name": "id", 10 | "vIdx": 4, 11 | "width": 60 12 | }, 13 | { 14 | "name": "dir", 15 | "vIdx": 2, 16 | "width": 60 17 | }, 18 | { 19 | "name": "len", 20 | "vIdx": 1, 21 | "width": 60 22 | }, 23 | { 24 | "name": "data", 25 | "vIdx": 3, 26 | "width": 764 27 | } 28 | ], 29 | "name": "CanRawView", 30 | "caption": "CanRawView", 31 | "scrolling": 0 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/components/canrawview/tests/configfiles/canrawviewconfig_visualindexproblem.cds: -------------------------------------------------------------------------------- 1 | { 2 | "viewColumns": [ 3 | { 4 | "name": "time", 5 | "vIdx": 100, 6 | "width": 60 7 | }, 8 | { 9 | "name": "id", 10 | "vIdx": -5, 11 | "width": 60 12 | }, 13 | { 14 | "name": "dir", 15 | "vIdx": 5, 16 | "width": 60 17 | }, 18 | { 19 | "name": "len", 20 | "vIdx": 5, 21 | "width": 60 22 | }, 23 | { 24 | "name": "data", 25 | "vIdx": 5, 26 | "width": 764 27 | } 28 | ], 29 | "name": "CanRawView", 30 | "caption": "CanRawView", 31 | "scrolling": true 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/components/canrawview/tests/configfiles/canrawviewconfig_widthproblem.cds: -------------------------------------------------------------------------------- 1 | { 2 | "viewColumns": [ 3 | { 4 | "name": "time", 5 | "vIdx": 5, 6 | "width": 6 7 | }, 8 | { 9 | "name": "id", 10 | "vIdx": 4, 11 | "width": -60 12 | }, 13 | { 14 | "name": "dir", 15 | "vIdx": 2, 16 | "width": 60 17 | }, 18 | { 19 | "name": "len", 20 | "vIdx": 1, 21 | "width": 60 22 | }, 23 | { 24 | "name": "data", 25 | "vIdx": 3, 26 | "width": 7 27 | } 28 | ], 29 | "name": "CanRawView", 30 | "caption": "CanRawView", 31 | "scrolling": true 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/components/cansignaldata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME cansignaldata) 2 | 3 | set(SRC 4 | gui/cansignaldata.ui 5 | gui/cansignaldataguiimpl.h 6 | cansignaldata.cpp 7 | cansignaldata_p.cpp 8 | cansignaldatamodel.cpp 9 | searchmodel.cpp 10 | ) 11 | 12 | add_library(${COMPONENT_NAME} ${SRC}) 13 | target_link_libraries(${COMPONENT_NAME} cds-common CANdb) 14 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 15 | 16 | if(WITH_TESTS) 17 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 18 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 19 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 20 | 21 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 22 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 23 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 24 | 25 | set(DBC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/dbc) 26 | set(DBC_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/dbc) 27 | add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD 28 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${DBC_SOURCE} ${DBC_DESTINATION}) 29 | 30 | target_compile_definitions(${COMPONENT_NAME}_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 31 | target_compile_definitions(${COMPONENT_NAME}model_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 32 | endif() 33 | -------------------------------------------------------------------------------- /src/components/cansignaldata/cansignaldata.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDATA_H 2 | #define CANSIGNALDATA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class CanSignalDataPrivate; 12 | class QWidget; 13 | struct CanSignalDataGuiInt; 14 | typedef Context CanSignalDataCtx; 15 | 16 | Q_DECLARE_METATYPE(CANmessages_t); 17 | 18 | class CanSignalData : public QObject, public ComponentInterface { 19 | Q_OBJECT 20 | Q_DECLARE_PRIVATE(CanSignalData) 21 | 22 | public: 23 | CanSignalData(); 24 | explicit CanSignalData(CanSignalDataCtx&& ctx); 25 | ~CanSignalData(); 26 | 27 | QWidget* mainWidget() override; 28 | void setConfig(const QJsonObject& json) override; 29 | void setConfig(const QWidget& qobject) override; 30 | QJsonObject getConfig() const override; 31 | std::shared_ptr getQConfig() const override; 32 | void configChanged() override; 33 | bool mainWidgetDocked() const override; 34 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 35 | 36 | signals: 37 | void mainWidgetDockToggled(QWidget* widget) override; 38 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 39 | 40 | public slots: 41 | void stopSimulation() override; 42 | void startSimulation() override; 43 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 44 | 45 | private: 46 | QScopedPointer d_ptr; 47 | }; 48 | 49 | #endif // CANSIGNALDATA_H 50 | -------------------------------------------------------------------------------- /src/components/cansignaldata/cansignaldatamodel.cpp: -------------------------------------------------------------------------------- 1 | #include "cansignaldatamodel.h" 2 | #include "cansignaldataplugin.h" 3 | #include 4 | 5 | namespace { 6 | 7 | // clang-format off 8 | const std::map> portMappings = { 9 | { PortType::In, { } 10 | }, 11 | { PortType::Out, { } 12 | } 13 | }; 14 | // clang-format on 15 | 16 | } // namespace 17 | 18 | CanSignalDataModel::CanSignalDataModel() 19 | : ComponentModel("CanSignalData") 20 | , _painter(std::make_unique(CanSignalDataPlugin::PluginType::sectionColor(), &_component, 30)) 21 | { 22 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 23 | _label->setFixedSize(75, 70); 24 | _label->setAttribute(Qt::WA_TranslucentBackground); 25 | } 26 | 27 | QtNodes::NodePainterDelegate* CanSignalDataModel::painterDelegate() const 28 | { 29 | return _painter.get(); 30 | } 31 | 32 | unsigned int CanSignalDataModel::nPorts(PortType portType) const 33 | { 34 | return portMappings.at(portType).size(); 35 | } 36 | 37 | NodeDataType CanSignalDataModel::dataType(PortType, PortIndex) const 38 | { 39 | return {}; 40 | } 41 | 42 | std::shared_ptr CanSignalDataModel::outData(PortIndex) 43 | { 44 | return {}; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/components/cansignaldata/cansignaldatamodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDATAMODEL_H 2 | #define CANSIGNALDATAMODEL_H 3 | 4 | #include "componentmodel.h" 5 | #include "nodepainter.h" 6 | #include 7 | #include 8 | #include 9 | 10 | using QtNodes::NodeData; 11 | using QtNodes::NodeDataType; 12 | using QtNodes::PortIndex; 13 | using QtNodes::PortType; 14 | 15 | enum class Direction; 16 | 17 | class CanSignalDataModel : public ComponentModel { 18 | Q_OBJECT 19 | 20 | public: 21 | CanSignalDataModel(); 22 | 23 | unsigned int nPorts(PortType portType) const override; 24 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 25 | std::shared_ptr outData(PortIndex port) override; 26 | void setInData(std::shared_ptr, PortIndex) override{}; 27 | QtNodes::NodePainterDelegate* painterDelegate() const override; 28 | 29 | signals: 30 | void requestRedraw(); 31 | 32 | private: 33 | std::unique_ptr _painter; 34 | CANmessages_t _messages; 35 | }; 36 | 37 | #endif // CANSIGNALDATAMODEL_H 38 | -------------------------------------------------------------------------------- /src/components/cansignaldata/cansignaldataplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDATAPLUGIN_H 2 | #define CANSIGNALDATAPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "cansignaldatamodel.h" 6 | 7 | using SignalPlugin = PluginBase; 8 | 9 | struct CanSignalDataPlugin { 10 | using Model = CanSignalDataModel; 11 | static constexpr const char* name = "CanSignalData"; 12 | using PluginType = SignalPlugin; 13 | }; 14 | 15 | #endif // CANSIGNALDATAPLUGIN_H 16 | -------------------------------------------------------------------------------- /src/components/cansignaldata/gui/cansignaldataguiint.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDATAGUIINT_H 2 | #define CANSIGNALDATAGUIINT_H 3 | 4 | #include 5 | #include 6 | 7 | class QWidget; 8 | class QAbstractItemModel; 9 | class SearchModel; 10 | 11 | struct CanSignalDataGuiInt { 12 | typedef std::function msgView_t; 13 | typedef std::function dockUndock_t; 14 | typedef std::function msgSettingsUpdated_t; 15 | 16 | virtual ~CanSignalDataGuiInt() 17 | { 18 | } 19 | 20 | virtual QWidget* mainWidget() = 0; 21 | virtual void setMsgView(QAbstractItemModel& tvModel) = 0; 22 | virtual void setSigView(QAbstractItemModel& tvModel) = 0; 23 | virtual void setMsgViewCbk(const msgView_t& cb) = 0; 24 | virtual void setMsgSettingsUpdatedCbk(const msgSettingsUpdated_t& cb) = 0; 25 | virtual void setDockUndockCbk(const dockUndock_t& cb) = 0; 26 | virtual void initSearch(SearchModel& model) = 0; 27 | }; 28 | 29 | #endif // CANSIGNALDATAGUIINT_H 30 | -------------------------------------------------------------------------------- /src/components/cansignaldata/searchmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "searchmodel.h" 2 | #include "log.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | bool SearchModel::isFilterActive() const 9 | { 10 | return _filter.length() > 0; 11 | } 12 | 13 | QMimeData* SearchModel::mimeData(const QModelIndexList& indexes) const 14 | { 15 | QMimeData* pData = new QMimeData(); 16 | QByteArray encoded; 17 | QDataStream stream(&encoded, QIODevice::WriteOnly); 18 | QString type = objectName(); 19 | int row = -1; 20 | for (int i = 0; indexes.size() > i; i++) { 21 | if (false == indexes[i].isValid()) { 22 | continue; 23 | } 24 | 25 | if (indexes[i].row() != row) { 26 | row = indexes[i].row(); 27 | 28 | QString id = data(index(row, 0)).toString(); 29 | QString sig = "SignalModel" == type ? data(index(row, 1)).toString() : ""; 30 | stream << id << sig; 31 | } 32 | } 33 | 34 | pData->setData("fromCanDB", encoded); 35 | return pData; 36 | } 37 | 38 | QStringList SearchModel::mimeTypes() const 39 | { 40 | return QStringList{ "fromCanDB" }; 41 | } 42 | 43 | bool SearchModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const 44 | { 45 | bool result = false; 46 | 47 | for(int i = 0; i < sourceModel()->columnCount(); ++i) { 48 | QString str = sourceModel()->index(sourceRow, i, sourceParent).data().toString().toLower(); 49 | 50 | result |= str.contains(_filter); 51 | } 52 | 53 | return result; 54 | } 55 | 56 | void SearchModel::updateFilter(const QString& filter) 57 | { 58 | _filter = filter.toLower(); 59 | invalidate(); 60 | } 61 | -------------------------------------------------------------------------------- /src/components/cansignaldata/searchmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef __SEARCHMODEL_H 2 | #define __SEARCHMODEL_H 3 | 4 | #include 5 | 6 | class SearchModel : public QSortFilterProxyModel { 7 | Q_OBJECT 8 | public: 9 | bool isFilterActive() const; 10 | 11 | QMimeData* mimeData(const QModelIndexList& indexes) const override; 12 | QStringList mimeTypes() const override; 13 | 14 | protected: 15 | bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override; 16 | 17 | public slots: 18 | void updateFilter(const QString& filter); 19 | 20 | private: 21 | QString _filter; 22 | }; 23 | 24 | #endif /* !__SEARCHMODEL_H */ 25 | -------------------------------------------------------------------------------- /src/components/cansignaldata/tests/dbc/project.cds: -------------------------------------------------------------------------------- 1 | { 2 | "connections": [ 3 | ], 4 | "nodes": [ 5 | { 6 | "id": "{e6f3edfa-ce27-4741-bac7-2940a84c2133}", 7 | "model": { 8 | "caption": "CanSignalData #1", 9 | "file": "/home/remol/Projects/CANdevStudio/build/src/components/cansignaldata/dbc/tesla_can.dbc", 10 | "msgSettings": [ 11 | { 12 | "cycle": "123", 13 | "id": "3", 14 | "initVal": "" 15 | }, 16 | { 17 | "cycle": "", 18 | "id": "e", 19 | "initVal": "1122334455667788" 20 | }, 21 | { 22 | "cycle": "1234567890", 23 | "id": "45", 24 | "initVal": "aabbccddeeff0099" 25 | }, 26 | { 27 | "cycle": "", 28 | "id": "6d", 29 | "initVal": "AABBCCDD" 30 | }, 31 | { 32 | "cycle": "1", 33 | "id": "101", 34 | "initVal": "EEFF00" 35 | } 36 | ], 37 | "name": "CanSignalData" 38 | }, 39 | "position": { 40 | "x": 245, 41 | "y": 472 42 | } 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/components/cansignaldecoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME cansignaldecoder) 2 | 3 | set(SRC 4 | cansignaldecoder.cpp 5 | cansignaldecoder_p.cpp 6 | cansignaldecodermodel.cpp 7 | ) 8 | 9 | add_library(${COMPONENT_NAME} ${SRC}) 10 | target_link_libraries(${COMPONENT_NAME} Qt5::Widgets Qt5::Core Qt5::SerialBus nodes cds-common rwqueue) 11 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | if(WITH_TESTS) 14 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 15 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit cansignaldata) 16 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 17 | 18 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 19 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 20 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 21 | 22 | set(DBC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/dbc) 23 | set(DBC_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/dbc) 24 | add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD 25 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${DBC_SOURCE} ${DBC_DESTINATION}) 26 | 27 | target_compile_definitions(${COMPONENT_NAME}_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 28 | target_compile_definitions(${COMPONENT_NAME}model_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 29 | endif() 30 | -------------------------------------------------------------------------------- /src/components/cansignaldecoder/cansignaldecoder.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDECODER_H 2 | #define CANSIGNALDECODER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanSignalDecoderPrivate; 11 | class QWidget; 12 | typedef Context<> CanSignalDecoderCtx; 13 | class QCanBusFrame; 14 | enum class Direction; 15 | 16 | class CanSignalDecoder : public QObject, public ComponentInterface { 17 | Q_OBJECT 18 | Q_DECLARE_PRIVATE(CanSignalDecoder) 19 | 20 | public: 21 | CanSignalDecoder(); 22 | ~CanSignalDecoder(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void mainWidgetDockToggled(QWidget* widget) override; 35 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 36 | void requestRedraw(); 37 | void sndSignal(const QString& name, const QVariant& val, const Direction& dir); 38 | 39 | public slots: 40 | void stopSimulation() override; 41 | void startSimulation() override; 42 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 43 | void rcvFrame(const QCanBusFrame& frame, Direction const direction, bool status); 44 | 45 | private: 46 | QScopedPointer d_ptr; 47 | }; 48 | 49 | #endif //CANSIGNALDECODER_H 50 | -------------------------------------------------------------------------------- /src/components/cansignaldecoder/cansignaldecoder_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDECODER_P_H 2 | #define CANSIGNALDECODER_P_H 3 | 4 | #include "cansignaldecoder.h" 5 | #include 6 | #include 7 | #include 8 | 9 | class CanSignalDecoder; 10 | 11 | class CanSignalDecoderPrivate : public QObject { 12 | Q_OBJECT 13 | Q_DECLARE_PUBLIC(CanSignalDecoder) 14 | 15 | public: 16 | CanSignalDecoderPrivate(CanSignalDecoder* q, CanSignalDecoderCtx&& ctx = CanSignalDecoderCtx()); 17 | ComponentInterface::ComponentProperties getSupportedProperties() const; 18 | QJsonObject getSettings(); 19 | void setSettings(const QJsonObject& json); 20 | void decodeFrame(const QCanBusFrame& frame, Direction const direction, bool status); 21 | 22 | private: 23 | void initProps(); 24 | int64_t rawToSignal(const uint8_t* data, int startBit, int sigSize, bool littleEndian, bool isSigned); 25 | 26 | public : bool _simStarted{ false }; 27 | CanSignalDecoderCtx _ctx; 28 | std::map _props; 29 | CanDbHandler _db{ _props, _dbProperty }; 30 | 31 | private: 32 | CanSignalDecoder* q_ptr; 33 | const QString _nameProperty = "name"; 34 | const QString _dbProperty = "CAN database"; 35 | std::map _signalCache; 36 | 37 | // workaround for clang 3.5 38 | using cf = ComponentInterface::CustomEditFieldCbk; 39 | 40 | // clang-format off 41 | ComponentInterface::ComponentProperties _supportedProps = { 42 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 43 | std::make_tuple(_dbProperty, QVariant::String, true, cf(std::bind(&CanDbHandler::createPropertyWidget, &_db))) 44 | }; 45 | // clang-format on 46 | }; 47 | 48 | #endif // CANSIGNALDECODER_P_H 49 | -------------------------------------------------------------------------------- /src/components/cansignaldecoder/cansignaldecodermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDECODERMODEL_H 2 | #define CANSIGNALDECODERMODEL_H 3 | 4 | #include "componentmodel.h" 5 | #include "nodepainter.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using QtNodes::NodeData; 12 | using QtNodes::NodeDataType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::PortType; 15 | 16 | enum class Direction; 17 | class QCanBusFrame; 18 | 19 | class CanSignalDecoderModel : public ComponentModel { 20 | Q_OBJECT 21 | 22 | public: 23 | CanSignalDecoderModel(); 24 | 25 | unsigned int nPorts(PortType portType) const override; 26 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 27 | std::shared_ptr outData(PortIndex port) override; 28 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 29 | QtNodes::NodePainterDelegate* painterDelegate() const override; 30 | 31 | public slots: 32 | void rcvSignal(const QString& name, const QVariant& val, const Direction& dir); 33 | 34 | signals: 35 | void requestRedraw(); 36 | void sndFrame(const QCanBusFrame& frame, Direction const direction, bool status); 37 | 38 | private: 39 | std::unique_ptr _painter; 40 | // 127 to use 4 blocks, 512 bytes each 41 | moodycamel::ReaderWriterQueue> _rxQueue{ 127 }; 42 | }; 43 | 44 | #endif // CANSIGNALDECODERMODEL_H 45 | -------------------------------------------------------------------------------- /src/components/cansignaldecoder/cansignaldecoderplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALDECODERPLUGIN_H 2 | #define CANSIGNALDECODERPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "cansignaldecodermodel.h" 6 | 7 | // Note that max typestring length is limited to 128 chars. 64 causes VS2015 internal error. 8 | using SignalPlugin = PluginBase; 9 | 10 | struct CanSignalDecoderPlugin { 11 | using Model = CanSignalDecoderModel; 12 | static constexpr const char* name = "CanSignalDecoder"; 13 | using PluginType = SignalPlugin; 14 | }; 15 | 16 | #endif // CANSIGNALDECODERPLUGIN_H 17 | -------------------------------------------------------------------------------- /src/components/cansignalencoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME cansignalencoder) 2 | 3 | set(SRC 4 | cansignalencoder.cpp 5 | cansignalencoder_p.cpp 6 | cansignalencodermodel.cpp 7 | ) 8 | 9 | add_library(${COMPONENT_NAME} ${SRC}) 10 | target_link_libraries(${COMPONENT_NAME} Qt5::Widgets Qt5::Core Qt5::SerialBus nodes cds-common rwqueue) 11 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | if(WITH_TESTS) 14 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 15 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit cansignaldata) 16 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 17 | 18 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 19 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 20 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 21 | 22 | set(DBC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/dbc) 23 | set(DBC_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/dbc) 24 | add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD 25 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${DBC_SOURCE} ${DBC_DESTINATION}) 26 | 27 | target_compile_definitions(${COMPONENT_NAME}_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 28 | target_compile_definitions(${COMPONENT_NAME}model_test PRIVATE DBC_PATH="${DBC_DESTINATION}") 29 | endif() 30 | -------------------------------------------------------------------------------- /src/components/cansignalencoder/cansignalencoder.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALENCODER_H 2 | #define CANSIGNALENCODER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class QCanBusFrame; 11 | class CanSignalEncoderPrivate; 12 | class QWidget; 13 | struct CanSignalEncoderGuiInt; 14 | typedef Context<> CanSignalEncoderCtx; 15 | 16 | class CanSignalEncoder : public QObject, public ComponentInterface { 17 | Q_OBJECT 18 | Q_DECLARE_PRIVATE(CanSignalEncoder) 19 | 20 | public: 21 | CanSignalEncoder(); 22 | ~CanSignalEncoder(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void mainWidgetDockToggled(QWidget* widget) override; 35 | void simBcastSnd(const QJsonObject& msg, const QVariant& param = QVariant()) override; 36 | void requestRedraw(); 37 | void sndFrame(const QCanBusFrame& frame); 38 | 39 | public slots: 40 | void stopSimulation() override; 41 | void startSimulation() override; 42 | void simBcastRcv(const QJsonObject& msg, const QVariant& param) override; 43 | void rcvSignal(const QString& name, const QVariant& val); 44 | 45 | private: 46 | QScopedPointer d_ptr; 47 | }; 48 | 49 | #endif // CANSIGNALENCODER_H 50 | -------------------------------------------------------------------------------- /src/components/cansignalencoder/cansignalencoder_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALENCODER_P_H 2 | #define CANSIGNALENCODER_P_H 3 | 4 | #include "cansignalencoder.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class CanSignalEncoder; 12 | 13 | class CanSignalEncoderPrivate : public QObject { 14 | Q_OBJECT 15 | Q_DECLARE_PUBLIC(CanSignalEncoder) 16 | 17 | public: 18 | CanSignalEncoderPrivate(CanSignalEncoder* q, CanSignalEncoderCtx&& ctx = CanSignalEncoderCtx()); 19 | ComponentInterface::ComponentProperties getSupportedProperties() const; 20 | QJsonObject getSettings(); 21 | void setSettings(const QJsonObject& json); 22 | void encodeSignal(const QString& name, const QVariant& val); 23 | 24 | private: 25 | void initProps(); 26 | void signalToRaw(const uint32_t id, const CANsignal& sigDesc, const QVariant& sigVal, const uint32_t updateCycle); 27 | 28 | public: 29 | bool _simStarted{ false }; 30 | CanSignalEncoderCtx _ctx; 31 | std::map _props; 32 | CanDbHandler _db{ _props, _dbProperty }; 33 | std::vector> _cycleTimers; 34 | 35 | public slots: 36 | void initCacheAndTimers(); 37 | 38 | private: 39 | CanSignalEncoder* q_ptr; 40 | const QString _nameProperty = "name"; 41 | const QString _dbProperty = "CAN database"; 42 | std::map _rawCache; 43 | 44 | // workaround for clang 3.5 45 | using cf = ComponentInterface::CustomEditFieldCbk; 46 | 47 | // clang-format off 48 | ComponentInterface::ComponentProperties _supportedProps = { 49 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 50 | std::make_tuple(_dbProperty, QVariant::String, true, cf(std::bind(&CanDbHandler::createPropertyWidget, &_db))) 51 | }; 52 | // clang-format on 53 | }; 54 | 55 | #endif // CANSIGNALENCODER_P_H 56 | -------------------------------------------------------------------------------- /src/components/cansignalencoder/cansignalencodermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALENCODERMODEL_H 2 | #define CANSIGNALENCODERMODEL_H 3 | 4 | #include "componentmodel.h" 5 | #include "nodepainter.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using QtNodes::NodeData; 12 | using QtNodes::NodeDataType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::PortType; 15 | 16 | enum class Direction; 17 | class QCanBusFrame; 18 | 19 | class CanSignalEncoderModel : public ComponentModel { 20 | Q_OBJECT 21 | 22 | public: 23 | CanSignalEncoderModel(); 24 | 25 | unsigned int nPorts(PortType portType) const override; 26 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 27 | std::shared_ptr outData(PortIndex port) override; 28 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 29 | QtNodes::NodePainterDelegate* painterDelegate() const override; 30 | 31 | public slots: 32 | void rcvFrame(const QCanBusFrame& frame); 33 | 34 | signals: 35 | void requestRedraw(); 36 | void sndSignal(const QString& name, const QVariant& val); 37 | 38 | private: 39 | std::unique_ptr _painter; 40 | // 127 to use 4 blocks, 512 bytes each 41 | moodycamel::ReaderWriterQueue> _rxQueue{ 127 }; 42 | }; 43 | 44 | #endif // CANSIGNALENCODERMODEL_H 45 | -------------------------------------------------------------------------------- /src/components/cansignalencoder/cansignalencoderplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALENCODERPLUGIN_H 2 | #define CANSIGNALENCODERPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "cansignalencodermodel.h" 6 | 7 | // Note that max typestring length is limited to 128 chars. 64 causes VS2015 internal error. 8 | using SignalPlugin = PluginBase; 9 | 10 | struct CanSignalEncoderPlugin { 11 | using Model = CanSignalEncoderModel; 12 | static constexpr const char* name = "CanSignalEncoder"; 13 | using PluginType = SignalPlugin; 14 | }; 15 | 16 | #endif // CANSIGNALENCODERPLUGIN_H 17 | -------------------------------------------------------------------------------- /src/components/cansignalsender/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME cansignalsender) 2 | 3 | set(SRC 4 | gui/cansignalsender.ui 5 | gui/cansignalsenderguiimpl.h 6 | cansignalsender.cpp 7 | cansignalsender_p.cpp 8 | cansignalsendermodel.cpp 9 | cansignalsendertablemodel.cpp 10 | ) 11 | 12 | add_library(${COMPONENT_NAME} ${SRC}) 13 | target_link_libraries(${COMPONENT_NAME} cds-common CANdb rwqueue) 14 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 15 | 16 | if(WITH_TESTS) 17 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 18 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 19 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 20 | 21 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 22 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 23 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 24 | endif() 25 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsender.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDER_H 2 | #define CANSIGNALSENDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanSignalSenderPrivate; 11 | class QWidget; 12 | struct CanSignalSenderGuiInt; 13 | typedef Context CanSignalSenderCtx; 14 | 15 | class CanSignalSender : public QObject, public ComponentInterface { 16 | Q_OBJECT 17 | Q_DECLARE_PRIVATE(CanSignalSender) 18 | 19 | public: 20 | CanSignalSender(); 21 | explicit CanSignalSender(CanSignalSenderCtx&& ctx); 22 | ~CanSignalSender(); 23 | 24 | QWidget* mainWidget() override; 25 | void setConfig(const QJsonObject& json) override; 26 | void setConfig(const QWidget& qobject) override; 27 | QJsonObject getConfig() const override; 28 | std::shared_ptr getQConfig() const override; 29 | void configChanged() override; 30 | bool mainWidgetDocked() const override; 31 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 32 | 33 | signals: 34 | void mainWidgetDockToggled(QWidget* widget) override; 35 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 36 | void requestRedraw(); 37 | void sendSignal(const QString& name, const QVariant& val); 38 | 39 | public slots: 40 | void stopSimulation() override; 41 | void startSimulation() override; 42 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 43 | 44 | private: 45 | QScopedPointer d_ptr; 46 | }; 47 | 48 | #endif //CANSIGNALSENDER_H 49 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsender_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDER_P_H 2 | #define CANSIGNALSENDER_P_H 3 | 4 | #include 5 | #include 6 | #include "gui/cansignalsenderguiimpl.h" 7 | #include "cansignalsender.h" 8 | #include "cansignalsendertablemodel.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class CanSignalSender; 15 | 16 | class CanSignalSenderPrivate : public QObject { 17 | Q_OBJECT 18 | Q_DECLARE_PUBLIC(CanSignalSender) 19 | 20 | public: 21 | CanSignalSenderPrivate(CanSignalSender* q, CanSignalSenderCtx&& ctx = CanSignalSenderCtx(new CanSignalSenderGuiImpl)); 22 | ComponentInterface::ComponentProperties getSupportedProperties() const; 23 | QJsonObject getSettings(); 24 | void setSettings(const QJsonObject& json); 25 | 26 | private: 27 | void initProps(); 28 | 29 | private slots: 30 | void setDroppedItems(const QList>& droppedItems); 31 | 32 | public: 33 | bool _simStarted{ false }; 34 | CanSignalSenderCtx _ctx; 35 | CanSignalSenderGuiInt& _ui; 36 | bool _docked{ true }; 37 | std::map _props; 38 | CanDbHandler _db{ _props, _dbProperty }; 39 | 40 | private: 41 | CanSignalSenderTableModel _tvModel; 42 | QStringList _tvColumns; 43 | CanSignalSender* q_ptr; 44 | const QString _nameProperty = "name"; 45 | const QString _dbProperty = "CAN database"; 46 | 47 | // workaround for clang 3.5 48 | using cf = ComponentInterface::CustomEditFieldCbk; 49 | 50 | // clang-format off 51 | ComponentInterface::ComponentProperties _supportedProps = { 52 | std::make_tuple(_nameProperty, QVariant::String, true, cf(nullptr)), 53 | std::make_tuple(_dbProperty, QVariant::String, true, cf(std::bind(&CanDbHandler::createPropertyWidget, &_db))) 54 | }; 55 | }; 56 | 57 | #endif // CANSIGNALSENDER_P_H 58 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsendermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDERMODEL_H 2 | #define CANSIGNALSENDERMODEL_H 3 | 4 | #include "componentmodel.h" 5 | #include "nodepainter.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using QtNodes::NodeData; 12 | using QtNodes::NodeDataType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::PortType; 15 | 16 | enum class Direction; 17 | 18 | class CanSignalSenderModel : public ComponentModel { 19 | Q_OBJECT 20 | 21 | public: 22 | CanSignalSenderModel(); 23 | 24 | unsigned int nPorts(PortType portType) const override; 25 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 26 | std::shared_ptr outData(PortIndex port) override; 27 | void setInData(std::shared_ptr, PortIndex) override {} 28 | QtNodes::NodePainterDelegate* painterDelegate() const override; 29 | 30 | public slots: 31 | void rcvSignal(const QString& name, const QVariant& val); 32 | 33 | signals: 34 | void requestRedraw(); 35 | 36 | private: 37 | std::unique_ptr _painter; 38 | QString _sigName; 39 | QVariant _sigVal; 40 | // 127 to use 4 blocks, 512 bytes each 41 | moodycamel::ReaderWriterQueue> _rxQueue{ 127 }; 42 | }; 43 | 44 | #endif // CANSIGNALSENDERMODEL_H 45 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsenderplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDERPLUGIN_H 2 | #define CANSIGNALSENDERPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "cansignalsendermodel.h" 6 | 7 | // Note that max typestring length is limited to 128 chars. 64 causes VS2015 internal error. 8 | using SignalPlugin = PluginBase; 9 | 10 | struct CanSignalSenderPlugin { 11 | using Model = CanSignalSenderModel; 12 | static constexpr const char* name = "CanSignalSender"; 13 | using PluginType = SignalPlugin; 14 | }; 15 | 16 | #endif // CANSIGNALSENDERPLUGIN_H 17 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsendertablemodel.cpp: -------------------------------------------------------------------------------- 1 | #include "cansignalsendertablemodel.h" 2 | #include "log.h" 3 | 4 | #include 5 | #include 6 | 7 | CanSignalSenderTableModel::CanSignalSenderTableModel(QObject* parent) 8 | : QStandardItemModel(parent) 9 | { 10 | } 11 | 12 | bool CanSignalSenderTableModel::dropMimeData( 13 | const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) 14 | { 15 | cds_info("{} action: {}, row: {}, column: {}", Q_FUNC_INFO, action, row, column); 16 | Q_UNUSED(parent) 17 | 18 | if (nullptr == data) { 19 | return false; 20 | } 21 | 22 | if (Qt::DropAction::CopyAction != action) { 23 | return false; 24 | } 25 | 26 | QByteArray encoded = data->data("fromCanDB"); 27 | QDataStream stream(&encoded, QIODevice::ReadOnly); 28 | QList> dropItems; 29 | 30 | while (false == stream.atEnd()) { 31 | QString id, sig; 32 | stream >> id >> sig; 33 | dropItems.push_back(QList{ id, sig }); 34 | } 35 | 36 | emit droppedItems(dropItems); 37 | 38 | return true; 39 | } 40 | 41 | QStringList CanSignalSenderTableModel::mimeTypes() const 42 | { 43 | return QStringList{ "fromCanDB" }; 44 | } 45 | 46 | Qt::ItemFlags CanSignalSenderTableModel::flags(const QModelIndex& index) const 47 | { 48 | if (false == index.isValid()) { 49 | return QStandardItemModel::flags(index); 50 | } 51 | 52 | return QStandardItemModel::flags(index) | Qt::ItemFlag::ItemIsDropEnabled; 53 | } 54 | -------------------------------------------------------------------------------- /src/components/cansignalsender/cansignalsendertablemodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDERTABLEMODEL_H 2 | #define CANSIGNALSENDERTABLEMODEL_H 3 | 4 | #include 5 | 6 | class CanSignalSenderTableModel : public QStandardItemModel { 7 | Q_OBJECT 8 | 9 | public: 10 | explicit CanSignalSenderTableModel(QObject* parent = nullptr); 11 | ~CanSignalSenderTableModel() override = default; 12 | 13 | bool dropMimeData( 14 | const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override; 15 | QStringList mimeTypes() const override; 16 | Qt::ItemFlags flags(const QModelIndex& index) const override; 17 | 18 | signals: 19 | void droppedItems(const QList>& dropItems); 20 | }; 21 | 22 | #endif // CANSIGNALSENDERTABLEMODEL_H 23 | -------------------------------------------------------------------------------- /src/components/cansignalsender/gui/cansignalsenderguiint.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALSENDERGUIINT_H 2 | #define CANSIGNALSENDERGUIINT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QWidget; 10 | class QStandardItemModel; 11 | class CanDbHandler; 12 | 13 | struct CanSignalSenderGuiInt { 14 | using dockUndock_t = std::function; 15 | using remove_t = std::function; 16 | using add_t = std::function; 17 | using send_t = std::function; 18 | 19 | virtual ~CanSignalSenderGuiInt() {} 20 | 21 | virtual QWidget* mainWidget() = 0; 22 | virtual void initTv(QStandardItemModel& tvModel, const CanDbHandler* db) = 0; 23 | virtual void setRemoveCbk(const remove_t& cb) = 0; 24 | virtual void setAddCbk(const add_t& cb) = 0; 25 | virtual void setDockUndockCbk(const dockUndock_t& cb) = 0; 26 | virtual void setSendCbk(const send_t& cbk) = 0; 27 | virtual void addRow(const QString& id = "", const QString& sig = "", const QString& val = "") = 0; 28 | virtual QJsonArray getRows() = 0; 29 | virtual QModelIndexList getSelectedRows() = 0; 30 | }; 31 | 32 | #endif // CANSIGNALSENDERGUIINT_H 33 | -------------------------------------------------------------------------------- /src/components/cansignalviewer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME cansignalviewer) 2 | 3 | set(SRC 4 | gui/cansignalviewer.ui 5 | gui/cansignalviewerguiimpl.h 6 | cansignalviewer.cpp 7 | cansignalviewer_p.cpp 8 | cansignalviewermodel.cpp 9 | ) 10 | 11 | add_library(${COMPONENT_NAME} ${SRC}) 12 | target_link_libraries(${COMPONENT_NAME} cds-common) 13 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 14 | 15 | if(WITH_TESTS) 16 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 17 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 18 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 19 | 20 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 21 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit) 22 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 23 | endif() 24 | -------------------------------------------------------------------------------- /src/components/cansignalviewer/cansignalviewer.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALVIEWER_H 2 | #define CANSIGNALVIEWER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class CanSignalViewerPrivate; 11 | class QWidget; 12 | struct CanSignalViewerGuiInt; 13 | typedef Context CanSignalViewerCtx; 14 | enum class Direction; 15 | 16 | class CanSignalViewer : public QObject, public ComponentInterface { 17 | Q_OBJECT 18 | Q_DECLARE_PRIVATE(CanSignalViewer) 19 | 20 | public: 21 | CanSignalViewer(); 22 | explicit CanSignalViewer(CanSignalViewerCtx&& ctx); 23 | ~CanSignalViewer(); 24 | 25 | QWidget* mainWidget() override; 26 | void setConfig(const QJsonObject& json) override; 27 | void setConfig(const QWidget& qobject) override; 28 | QJsonObject getConfig() const override; 29 | std::shared_ptr getQConfig() const override; 30 | void configChanged() override; 31 | bool mainWidgetDocked() const override; 32 | ComponentInterface::ComponentProperties getSupportedProperties() const override; 33 | 34 | signals: 35 | void mainWidgetDockToggled(QWidget* widget) override; 36 | void simBcastSnd(const QJsonObject &msg, const QVariant ¶m = QVariant()) override; 37 | 38 | public slots: 39 | void stopSimulation() override; 40 | void startSimulation() override; 41 | void simBcastRcv(const QJsonObject &msg, const QVariant ¶m) override; 42 | void rcvSignal(const QString& name, const QVariant& val, const Direction& dir); 43 | 44 | private: 45 | QScopedPointer d_ptr; 46 | }; 47 | 48 | #endif //CANSIGNALVIEWER_H 49 | -------------------------------------------------------------------------------- /src/components/cansignalviewer/cansignalviewermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALVIEWERMODEL_H 2 | #define CANSIGNALVIEWERMODEL_H 3 | 4 | #include "componentmodel.h" 5 | #include "nodepainter.h" 6 | #include 7 | #include 8 | 9 | using QtNodes::NodeData; 10 | using QtNodes::NodeDataType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::PortType; 13 | 14 | enum class Direction; 15 | 16 | class CanSignalViewerModel : public ComponentModel { 17 | Q_OBJECT 18 | 19 | public: 20 | CanSignalViewerModel(); 21 | 22 | unsigned int nPorts(PortType portType) const override; 23 | NodeDataType dataType(PortType portType, PortIndex portIndex) const override; 24 | std::shared_ptr outData(PortIndex port) override; 25 | void setInData(std::shared_ptr nodeData, PortIndex port) override; 26 | QtNodes::NodePainterDelegate* painterDelegate() const override; 27 | 28 | public slots: 29 | 30 | signals: 31 | void requestRedraw(); 32 | void sndSignal(const QString& name, const QVariant& val, const Direction& dir); 33 | 34 | private: 35 | std::unique_ptr _painter; 36 | }; 37 | 38 | #endif // CANSIGNALVIEWERMODEL_H 39 | -------------------------------------------------------------------------------- /src/components/cansignalviewer/cansignalviewerplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALVIEWERPLUGIN_H 2 | #define CANSIGNALVIEWERPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "cansignalviewermodel.h" 6 | 7 | // Note that max typestring length is limited to 128 chars. 64 causes VS2015 internal error. 8 | using SignalPlugin = PluginBase; 9 | 10 | struct CanSignalViewerPlugin { 11 | using Model = CanSignalViewerModel; 12 | static constexpr const char* name = "CanSignalViewer"; 13 | using PluginType = SignalPlugin; 14 | }; 15 | 16 | #endif // CANSIGNALVIEWERPLUGIN_H 17 | -------------------------------------------------------------------------------- /src/components/cansignalviewer/gui/cansignalviewerguiint.h: -------------------------------------------------------------------------------- 1 | #ifndef CANSIGNALVIEWERGUIINT_H 2 | #define CANSIGNALVIEWERGUIINT_H 3 | 4 | #include 5 | #include 6 | 7 | class QWidget; 8 | class QAbstractItemModel; 9 | 10 | struct CanSignalViewerGuiInt { 11 | typedef std::function clear_t; 12 | typedef std::function dockUndock_t; 13 | typedef std::function sectionClicked_t; 14 | typedef std::function filter_t; 15 | 16 | virtual void setClearCbk(const clear_t& cb) = 0; 17 | virtual void setDockUndockCbk(const dockUndock_t& cb) = 0; 18 | virtual void setSectionClikedCbk(const sectionClicked_t& cb) = 0; 19 | virtual void setFilterCbk(const filter_t& cb) = 0; 20 | 21 | virtual ~CanSignalViewerGuiInt() 22 | { 23 | } 24 | 25 | virtual QWidget* mainWidget() = 0; 26 | virtual void setModel(QAbstractItemModel* model) = 0; 27 | virtual void initTableView(QAbstractItemModel& tvModel) = 0; 28 | virtual bool isViewFrozen() = 0; 29 | virtual void setViewFrozen(bool state) = 0; 30 | virtual void scrollToBottom() = 0; 31 | virtual Qt::SortOrder getSortOrder() = 0; 32 | virtual QString getClickedColumn(int ndx) = 0; 33 | virtual void setSorting(int sortNdx, Qt::SortOrder order) = 0; 34 | virtual QString getWindowTitle() = 0; 35 | virtual bool isColumnHidden(int ndx) = 0; 36 | virtual void getColumnProper(int ndx, int& vIdx) = 0; 37 | virtual void setColumnProper(int vIdxFrom, int vIdxTo) = 0; 38 | }; 39 | 40 | #endif // CANSIGNALVIEWERGUIINT_H 41 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME qmlexecutor) 2 | 3 | set(SRC 4 | gui/qmlexecutor.ui 5 | gui/qmlexecutorguiimpl.h 6 | gui/qmlexecutorguiint.h 7 | qmlexecutor.cpp 8 | qmlexecutor_p.cpp 9 | qmlexecutormodel.cpp 10 | canbusmodel.hpp 11 | ) 12 | 13 | set(QT_QML_LIBS Qt5::Quick Qt5::Widgets Qt5::Qml Qt5::QuickWidgets) 14 | 15 | add_library(${COMPONENT_NAME} ${SRC}) 16 | target_link_libraries(${COMPONENT_NAME} cds-common ${QT_QML_LIBS}) 17 | target_include_directories(${COMPONENT_NAME} INTERFACE ${Qt5Widgets_INCLUDE_DIRS}) 18 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 19 | 20 | if(WITH_TESTS) 21 | 22 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp tests/guimock.h) 23 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit ${QT_QML_LIBS}) 24 | add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test) 25 | 26 | add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp) 27 | target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit ${QT_QML_LIBS}) 28 | add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test) 29 | endif() 30 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/canbusmodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CANBUSMODEL_HPP 2 | #define CANBUSMODEL_HPP 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief The CANBusModel class is used to interface CAN operations with QML stack 9 | */ 10 | class CANBusModel : public QObject 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | CANBusModel() : QObject(nullptr) {} 16 | 17 | signals: 18 | /** 19 | * @brief Sends a CAN frame 20 | * @param frameId frame identifier 21 | * @param frameData frame payload 22 | */ 23 | void sendFrame(const quint32& frameId, const QByteArray& frameData); 24 | 25 | /** 26 | * @brief Send a CAN named signal 27 | * @param name signal name 28 | * @param value signal value 29 | */ 30 | void sendSignal(const QString& name, const QVariant& value); 31 | 32 | /** 33 | * @brief A CAN frame was received 34 | * @param frameId frame identifier 35 | * @param frameData frame payload 36 | */ 37 | void frameReceived(const quint32& frameId, const QByteArray& frameData); 38 | 39 | /** 40 | * @brief A CAN signal was received 41 | * @param signal name 42 | * @param signal value 43 | */ 44 | void signalReceived(const QString& name, const QVariant& value); 45 | 46 | /** 47 | * @brief The simulation was started 48 | */ 49 | void simulationStarted(); 50 | 51 | /** 52 | * @brief The simulation was stopped 53 | */ 54 | void simulationStopped(); 55 | }; 56 | 57 | #endif // CANBUSMODEL_HPP 58 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/examples/simple_forwarder.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | 3 | /* 4 | * This example receives a frame or signal modifies and transmit it 5 | */ 6 | 7 | Item { 8 | function frameReceived(frameId, framePayload) { 9 | // Increment frame ID of received CAN 10 | frameId += 1 11 | 12 | // LogWindow is QPlainTextEdit widget exposed to QML 13 | // You can use it to append text or control its visibility 14 | LogWindow.appendPlainText("Frame: " + frameId + " Forwarded") 15 | 16 | // Transmit frame 17 | // 18 | // CANBusModel is an QObject exposed to QML 19 | // You can use it to receive and transmit frames and signals 20 | CANBusModel.sendFrame(frameId, framePayload) 21 | } 22 | 23 | function signalReceived(signalId, signalValue) { 24 | // Increment signal value 25 | signalValue += 1 26 | 27 | // Transmit signal 28 | CANBusModel.sendSignal(signalId, signalValue) 29 | } 30 | 31 | Component.onCompleted: { 32 | // We have no GUI to display so LogWindow can be visible 33 | LogWindow.setVisible(true) 34 | 35 | // Connect QML functions to CANBusModel signals 36 | CANBusModel.frameReceived.connect(frameReceived) 37 | CANBusModel.signalReceived.connect(signalReceived) 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/gui/qmlexecutorguiint.h: -------------------------------------------------------------------------------- 1 | #ifndef QMLEXECUTORGUIINT_H 2 | #define QMLEXECUTORGUIINT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QWidget; 9 | class CANBusModel; 10 | 11 | /** 12 | * @brief Interface of gui for QMLExecutor plugin 13 | * @todo rename 14 | */ 15 | class QMLExecutorGuiInt : public QObject 16 | { 17 | 18 | Q_OBJECT 19 | 20 | public: 21 | /** 22 | * @brief constructor 23 | * @param parent qt stuff 24 | */ 25 | QMLExecutorGuiInt(QObject* parent) 26 | : QObject(parent){}; 27 | 28 | /** 29 | * @brief virtual dtor to get things working 30 | */ 31 | virtual ~QMLExecutorGuiInt() 32 | { 33 | } 34 | 35 | public: 36 | /** 37 | * @brief not used, return main widget for ui 38 | */ 39 | virtual QWidget* mainWidget() = 0; 40 | 41 | public slots: 42 | /** 43 | * Loads qml file. 44 | * 45 | * @param url url to a qml file 46 | */ 47 | virtual void loadQML(const QUrl& url) = 0; 48 | 49 | /** 50 | * @brief sets can bus model pointer 51 | * @param model can bus model 52 | */ 53 | virtual void setModel(CANBusModel* model) = 0; 54 | 55 | /** 56 | * @brief used to align empty QQuickWidget color with current color scheme 57 | */ 58 | virtual void updateUIColor() = 0; 59 | 60 | signals: 61 | /** 62 | * @brief this signal is emitted when qml was loaded 63 | * @param url url of qml file 64 | */ 65 | void QMLLoaded(const QUrl& url); 66 | 67 | void dockUndock(); 68 | }; 69 | 70 | 71 | #endif // QMLEXECUTORGUIINT_H 72 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/qmlexecutorplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef QMLEXECUTORPLUGIN_H 2 | #define QMLEXECUTORPLUGIN_H 3 | 4 | #include "plugin_type.h" 5 | #include "qmlexecutormodel.h" 6 | 7 | // Note that max typestring length is limited to 128 chars. 64 causes VS2015 internal error. 8 | using MiscPlugin = PluginBase; 9 | 10 | struct QMLExecutorPlugin { 11 | using Model = QMLExecutorModel; 12 | static constexpr const char* name = "QMLExecutor"; 13 | using PluginType = MiscPlugin; 14 | }; 15 | 16 | #endif // QMLEXECUTORPLUGIN_H 17 | -------------------------------------------------------------------------------- /src/components/qmlexecutor/tests/guimock.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIMOC_H 2 | #define GUIMOC_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "gui/qmlexecutorguiint.h" 9 | 10 | /** 11 | * @brief fakeit is broken so wrap broken solution to get it working with qt signals 12 | */ 13 | class GuiMock : public QMLExecutorGuiInt 14 | { 15 | Q_OBJECT 16 | public: 17 | GuiMock(QObject* parent = nullptr) 18 | : QMLExecutorGuiInt(parent) 19 | { } 20 | 21 | public: 22 | void loadQML(const QUrl& url) override 23 | { 24 | mock.get().loadQML(url); 25 | } 26 | 27 | void setModel(CANBusModel* model) override 28 | { 29 | mock.get().setModel(model); 30 | } 31 | 32 | QWidget* mainWidget() override 33 | { 34 | return mock.get().mainWidget(); 35 | } 36 | 37 | void updateUIColor() override 38 | { 39 | return mock.get().updateUIColor(); 40 | } 41 | 42 | public: 43 | fakeit::Mock mock; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(projectconfig) 2 | 3 | set(srcs 4 | main.cpp 5 | mainwindow.cpp 6 | mainwindow.ui 7 | toolbar.ui 8 | aboutdialog.ui 9 | ) 10 | 11 | add_executable(CANdevStudio MACOSX_BUNDLE ${GUI_TYPE} ${srcs}) 12 | target_link_libraries(CANdevStudio projectconfig) 13 | target_compile_definitions(CANdevStudio PRIVATE $<$:CDS_DEBUG=true> $<$>:CDS_DEBUG=false>) 14 | target_include_directories(CANdevStudio 15 | PRIVATE 16 | "${CMAKE_SOURCE_DIR}/components/" 17 | "${CMAKE_BINARY_DIR}/generated" 18 | ) 19 | install(TARGETS CANdevStudio 20 | BUNDLE DESTINATION . COMPONENT Runtime 21 | RUNTIME DESTINATION ${INSTALL_DEST_BIN} COMPONENT Runtime 22 | ) 23 | -------------------------------------------------------------------------------- /src/gui/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "projectconfig/projectconfig.h" 9 | 10 | class QCloseEvent; 11 | class QPushButton; 12 | 13 | namespace Ui { 14 | class ToolBar; 15 | class MainWindow; 16 | } // namespace Ui 17 | 18 | class MainWindow : public QMainWindow { 19 | Q_OBJECT 20 | 21 | public: 22 | enum class Styles { darkStyle, lightStyle }; 23 | 24 | explicit MainWindow(QWidget* parent = nullptr); 25 | ~MainWindow(); 26 | 27 | private: 28 | std::unique_ptr _ui; 29 | std::unique_ptr _toolBar; 30 | std::unique_ptr _projectConfig; 31 | QString _projectFile; 32 | QString _projectName; 33 | Styles _currentStyle; 34 | QSettings _settings; 35 | QVector> _recentProjects; 36 | QVector> _recentProjectsButtons; 37 | 38 | void connectToolbarSignals(); 39 | void connectMenuSignals(); 40 | void closeEvent(QCloseEvent* event); 41 | void handleLoadAction(); 42 | void handleAboutAction(); 43 | void handleSaveAction(); 44 | void handleSaveAsAction(); 45 | void addToMdi(QWidget* component); 46 | void loadSettings(); 47 | void saveSettings(); 48 | void addRecentProject(const QString &name, const QString &path); 49 | void refreshRecentProjects(); 50 | void handleRecentProject(int ndx); 51 | 52 | public slots: 53 | void handleDock(QWidget* component); 54 | void handleWidgetDeletion(QWidget* widget); 55 | void handleWidgetShowing(QWidget* widget, bool docked); 56 | bool createProjectConfig(const QString& name); 57 | bool closeProjectConfig(); 58 | void switchStyle(); 59 | void setStyle(Styles style); 60 | }; 61 | 62 | #endif // MAINWINDOW_H 63 | -------------------------------------------------------------------------------- /src/gui/projectconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_NAME projectconfig) 2 | 3 | set(SRC 4 | projectconfig.ui 5 | projectconfig.cpp 6 | dragwidget.cpp 7 | flowviewwrapper.cpp 8 | projectconfigvalidator.cpp 9 | propertyeditordialog.cpp 10 | propertyeditordialog.ui 11 | ${CMAKE_SOURCE_DIR}/CANdevResources.qrc 12 | ) 13 | 14 | add_library(${COMPONENT_NAME} STATIC ${SRC}) 15 | target_link_libraries(${COMPONENT_NAME} ${PLUGIN_LIBRARIES} rapidjson) 16 | target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} 17 | PRIVATE ${CMAKE_BINARY_DIR}) 18 | 19 | if(WITH_TESTS) 20 | add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp) 21 | target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit) 22 | add_test(NAME ProjectConfigTestTest COMMAND ${COMPONENT_NAME}_test) 23 | target_include_directories(${COMPONENT_NAME}_test INTERFACE PRIVATE ${CMAKE_BINARY_DIR}) 24 | 25 | add_executable(${COMPONENT_NAME}_test_noqrc tests/${COMPONENT_NAME}_test_noqrc.cpp) 26 | target_link_libraries(${COMPONENT_NAME}_test_noqrc ${COMPONENT_NAME} Qt5::Test fakeit) 27 | add_test(NAME ProjectConfigTestNoQrc COMMAND ${COMPONENT_NAME}_test_noqrc) 28 | 29 | add_definitions(-DPC_TEST_CONFIG_FILES="${CMAKE_CURRENT_SOURCE_DIR}/tests/configfiles") 30 | endif() 31 | -------------------------------------------------------------------------------- /src/gui/projectconfig/dragwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef DRAGWIDGET_H 2 | #define DRAGWIDGET_H 3 | 4 | #include 5 | 6 | class QDragEnterEvent; 7 | class QDropEvent; 8 | 9 | class DragWidget : public QFrame 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | DragWidget(QWidget *parent = 0); 15 | 16 | protected: 17 | void dragEnterEvent(QDragEnterEvent *event) override; 18 | void mousePressEvent(QMouseEvent *event) override; 19 | }; 20 | 21 | #endif // DRAGWIDGET_H 22 | -------------------------------------------------------------------------------- /src/gui/projectconfig/flowviewwrapper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flowviewwrapper.h" 6 | 7 | void FlowViewWrapper::dragMoveEvent(QDragMoveEvent *) {} 8 | 9 | void FlowViewWrapper::dropEvent(QDropEvent *event) 10 | { 11 | QByteArray itemData = event->mimeData()->data("CANdevStudio/x-dnditemdata"); 12 | QDataStream dataStream(&itemData, QIODevice::ReadOnly); 13 | 14 | QPoint offset; 15 | QString nodeType; 16 | dataStream >> offset >> nodeType; 17 | 18 | addNode(nodeType, event->pos()); 19 | } 20 | 21 | void FlowViewWrapper::addNode(const QString& modelName, const QPoint& pos) 22 | { 23 | cds_debug("addNode"); 24 | auto type = _scene->registry().create(modelName); 25 | if (type) { 26 | auto& node = _scene->createNode(std::move(type)); 27 | node.nodeGraphicsObject().setPos(mapToScene(pos)); 28 | } else { 29 | cds_warn("Failed to create {} node", modelName.toStdString()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/gui/projectconfig/flowviewwrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef FLOWVIEWWRAPPER_H 2 | #define FLOWVIEWWRAPPER_H 3 | 4 | #include 5 | #include 6 | 7 | struct FlowViewWrapper : public QtNodes::FlowView { 8 | FlowViewWrapper(QtNodes::FlowScene* scene) 9 | : QtNodes::FlowView(scene) 10 | , _scene(scene) 11 | { 12 | setAcceptDrops(true); 13 | } 14 | 15 | void dragMoveEvent(QDragMoveEvent *event) override; 16 | void dropEvent(QDropEvent *event) override; 17 | void addNode(const QString& modelName, const QPoint& pos); 18 | private: 19 | QtNodes::FlowScene* _scene; 20 | }; 21 | 22 | #endif // FLOWVIEWWRAPPER_H 23 | -------------------------------------------------------------------------------- /src/gui/projectconfig/iconlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef __ICONLABEL_H 2 | #define __ICONLABEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class IconLabel : public QLabel { 10 | public: 11 | IconLabel(const QString& name, const QColor& headerColor, const QColor& bgColor) 12 | { 13 | QPixmap pix(_width, _height); 14 | pix.fill(Qt::transparent); 15 | QPainter painter(&pix); 16 | 17 | painter.setPen(Qt::NoPen); 18 | 19 | painter.setRenderHint(QPainter::Antialiasing); 20 | 21 | painter.setBrush(QBrush(bgColor)); 22 | QRectF boundary(0, 0, pix.width(), pix.height()); 23 | painter.drawRoundedRect(boundary, _radius, _radius); 24 | painter.setBrush(QBrush(headerColor)); 25 | 26 | QRectF boundary2(0, 0, pix.width(), _labelHeight); 27 | painter.drawRoundedRect(boundary2, _radius, _radius); 28 | 29 | QRectF boundary3(0, _labelHeight / 2, pix.width(), _labelHeight / 2); 30 | painter.drawRect(boundary3); 31 | 32 | painter.setPen({ Qt::white, 1 }); 33 | QFont font({ "Arial", 8 }); 34 | font.setBold(true); 35 | painter.setFont(font); 36 | painter.drawText(6, 15, name); 37 | 38 | setMinimumSize(_width, _height); 39 | setMaximumSize(_width, _height); 40 | setObjectName(name); 41 | setPixmap(pix); 42 | 43 | setProperty("type", "IconLabel"); 44 | } 45 | 46 | QSize minimumSizeHint() const override 47 | { 48 | return { _width, _height }; 49 | } 50 | 51 | private: 52 | const int _width = 140; 53 | const int _height = 48; 54 | const int _labelHeight = 22; 55 | const double _radius = 3.0; 56 | }; 57 | 58 | #endif /* !__ICONLABEL_H */ 59 | -------------------------------------------------------------------------------- /src/gui/projectconfig/modeltoolbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef MODELTOOLBUTTON_H 2 | #define MODELTOOLBUTTON_H 3 | #include 4 | struct ModelToolButton : public QToolButton { 5 | ModelToolButton(QWidget* parent = nullptr) 6 | : QToolButton(parent) 7 | { 8 | setAcceptDrops(true); 9 | } 10 | }; 11 | 12 | #endif // MODELTOOLBUTTON_H 13 | -------------------------------------------------------------------------------- /src/gui/projectconfig/pcinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef __PCINTERFACE_H 2 | #define __PCINTERFACE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace QtNodes { 8 | class FlowScene; 9 | class Node; 10 | } 11 | 12 | class QPoint; 13 | class QPointF; 14 | class QMenu; 15 | 16 | struct PCInterface { 17 | virtual ~PCInterface() 18 | { 19 | } 20 | 21 | using node_t = std::function; 22 | using menu_t = std::function; 23 | 24 | virtual void setNodeCreatedCallback(QtNodes::FlowScene* scene, const node_t& cb) = 0; 25 | virtual void setNodeDeletedCallback(QtNodes::FlowScene* scene, const node_t& cb) = 0; 26 | virtual void setNodeDoubleClickedCallback(QtNodes::FlowScene* scene, const node_t& cb) = 0; 27 | virtual void setNodeContextMenuCallback(QtNodes::FlowScene* scene, const menu_t& cb) = 0; 28 | virtual void setConfigChangedCbk(const node_t cb) = 0; 29 | virtual void openProperties(QtNodes::Node& node) = 0; 30 | virtual void showContextMenu(QMenu &menu, const QPoint& pos) = 0; 31 | }; 32 | 33 | 34 | #endif /* !__PCINTERFACE_H */ 35 | -------------------------------------------------------------------------------- /src/gui/projectconfig/projectconfig.cpp: -------------------------------------------------------------------------------- 1 | #include "projectconfig.h" 2 | #include "projectconfig_p.h" 3 | #include 4 | 5 | ProjectConfig::ProjectConfig(QWidget* parent_) 6 | : QWidget(parent_), d_ptr(new ProjectConfigPrivate(this, this)) 7 | { 8 | Q_D(ProjectConfig); 9 | 10 | setLayout(d->_ui->layout); 11 | } 12 | 13 | ProjectConfig::ProjectConfig(QWidget* parent_, ProjectConfigCtx&& ctx) 14 | : QWidget(parent_), d_ptr(new ProjectConfigPrivate(this, this, std::move(ctx))) 15 | { 16 | Q_D(ProjectConfig); 17 | 18 | setLayout(d->_ui->layout); 19 | } 20 | 21 | ProjectConfig::~ProjectConfig() 22 | { 23 | } 24 | 25 | void ProjectConfig::closeEvent(QCloseEvent* e) 26 | { 27 | emit closeProject(); 28 | e->ignore(); 29 | } 30 | 31 | QByteArray ProjectConfig::save() 32 | { 33 | Q_D(ProjectConfig); 34 | return d->save(); 35 | } 36 | 37 | void ProjectConfig::load(const QByteArray& data) 38 | { 39 | Q_D(ProjectConfig); 40 | return d->load(data); 41 | } 42 | 43 | void ProjectConfig::clearGraphView() 44 | { 45 | Q_D(ProjectConfig); 46 | return d->clearGraphView(); 47 | } 48 | 49 | void ProjectConfig::setColorMode(bool darkMode) 50 | { 51 | Q_D(ProjectConfig); 52 | QColor bgViewColor; 53 | 54 | if(darkMode) { 55 | bgViewColor = QColor(38, 38, 38); 56 | } else { 57 | bgViewColor = QColor(205, 205, 205); 58 | } 59 | 60 | d->_graphView->setBackgroundBrush(QBrush(bgViewColor, Qt::SolidPattern)); 61 | d->updateNodeStyle(darkMode); 62 | d->addModelIcons(); 63 | } 64 | 65 | void ProjectConfig::simulationStarted() 66 | { 67 | emit startSimulation(); 68 | 69 | d_ptr->_simStarted = true; 70 | } 71 | 72 | void ProjectConfig::simulationStopped() 73 | { 74 | emit stopSimulation(); 75 | 76 | d_ptr->_simStarted = false; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/gui/projectconfig/projectconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef PROJECTCONFIG_H 2 | #define PROJECTCONFIG_H 3 | 4 | #include 5 | #include 6 | 7 | struct PCInterface; 8 | typedef Context ProjectConfigCtx; 9 | 10 | namespace QtNodes { 11 | class Node; 12 | } 13 | 14 | class ProjectConfigPrivate; 15 | 16 | class ProjectConfig : public QWidget { 17 | Q_OBJECT 18 | Q_DECLARE_PRIVATE(ProjectConfig) 19 | 20 | public: 21 | explicit ProjectConfig(QWidget* parent_); 22 | explicit ProjectConfig(QWidget* parent_, ProjectConfigCtx&& ctx); 23 | ~ProjectConfig(); 24 | void closeEvent(QCloseEvent* e); 25 | QByteArray save(); 26 | void load(const QByteArray& data); 27 | void clearGraphView(); 28 | void setColorMode(bool darkMode); 29 | 30 | public slots: 31 | void simulationStarted(); 32 | void simulationStopped(); 33 | 34 | signals: 35 | void handleDock(QWidget* component); 36 | void handleWidgetDeletion(QWidget* widget); 37 | void handleWidgetShowing(QWidget* widget, bool docked); 38 | void stopSimulation(); 39 | void startSimulation(); 40 | void componentWidgetCreated(QWidget* component); 41 | void closeProject(); 42 | 43 | private: 44 | QScopedPointer d_ptr; 45 | }; 46 | 47 | #endif // PROJECTCONFIG_H 48 | -------------------------------------------------------------------------------- /src/gui/projectconfig/projectconfigvalidator.h: -------------------------------------------------------------------------------- 1 | #ifndef SRC_COMPONENTS_PROJECTCONFIG_PROJECTCONFIGVALIDATOR_H_ 2 | #define SRC_COMPONENTS_PROJECTCONFIG_PROJECTCONFIGVALIDATOR_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | class ProjectConfigValidator 11 | { 12 | public: 13 | static bool loadConfigSchema(const char* filename=":/files/json/projectConfigSchema.json"); 14 | static bool validateConfiguration(const QByteArray& wholeFile); 15 | 16 | private: 17 | static std::shared_ptr configSchema; 18 | static bool schemaInitialized; 19 | }; 20 | 21 | #endif /* SRC_COMPONENTS_PROJECTCONFIG_PROJECTCONFIGVALIDATOR_H_ */ 22 | -------------------------------------------------------------------------------- /src/gui/projectconfig/propertyeditordialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SRC_GUI_PROPERTYEDITORDIALOG_H_ 2 | #define SRC_GUI_PROPERTYEDITORDIALOG_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Ui { 12 | class PropertyEditorDialog; 13 | } 14 | 15 | /** 16 | * Class defining Property Editor Dialog 17 | */ 18 | class PropertyEditorDialog : public QDialog { 19 | Q_OBJECT 20 | 21 | public: 22 | PropertyEditorDialog(const QString& title, const QWidget& propertySource, QWidget* parent = nullptr); 23 | virtual ~PropertyEditorDialog(); 24 | 25 | std::shared_ptr properties(); 26 | 27 | private: 28 | std::unique_ptr _ui; 29 | QStandardItemModel _model; 30 | 31 | void fillModel(const QWidget& propsObj); 32 | }; 33 | 34 | #endif /* SRC_GUI_PROPERTYEDITORDIALOG_H_ */ 35 | -------------------------------------------------------------------------------- /src/gui/projectconfig/tests/projectconfig_test_noqrc.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_RUNNER 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | std::shared_ptr kDefaultLogger; 11 | 12 | TEST_CASE("Validation - failed to load schema", "[projectconfig]") 13 | { 14 | REQUIRE(ProjectConfigValidator::validateConfiguration({}) == false); 15 | } 16 | 17 | TEST_CASE("PropertyEditorDialog", "[projectconfig]") 18 | { 19 | CanDevice obj; 20 | PropertyEditorDialog dialog("title", *obj.getQConfig().get()); 21 | 22 | auto props = dialog.properties(); 23 | 24 | REQUIRE(props->property("name").isValid()); 25 | REQUIRE(props->property("backend").isValid()); 26 | REQUIRE(props->property("interface").isValid()); 27 | REQUIRE(props->property("unsupported").isValid() == false); 28 | } 29 | 30 | TEST_CASE("PropertyEditorDialog no exposed props", "[projectconfig]") 31 | { 32 | QWidget obj; 33 | PropertyEditorDialog dialog("title", obj); 34 | 35 | auto props = dialog.properties(); 36 | 37 | REQUIRE(props->property("name").isValid() == false); 38 | REQUIRE(props->property("backend").isValid() == false); 39 | REQUIRE(props->property("interface").isValid() == false); 40 | REQUIRE(props->property("unsupported").isValid() == false); 41 | } 42 | 43 | int main(int argc, char* argv[]) 44 | { 45 | bool haveDebug = std::getenv("CDS_DEBUG") != nullptr; 46 | kDefaultLogger = spdlog::stdout_color_mt("cds"); 47 | if (haveDebug) { 48 | kDefaultLogger->set_level(spdlog::level::debug); 49 | } 50 | cds_debug("Starting unit tests"); 51 | QApplication a(argc, argv); 52 | return Catch::Session().run(argc, argv); 53 | } 54 | -------------------------------------------------------------------------------- /src/gui/subwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef __SUBWINDOW_H 2 | #define __SUBWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct SubWindow : public QMdiSubWindow { 10 | SubWindow(QWidget* parent) 11 | : QMdiSubWindow(parent) 12 | { 13 | setAttribute(Qt::WA_DeleteOnClose); 14 | setWindowIcon(QIcon(" ")); 15 | } 16 | 17 | virtual void closeEvent(QCloseEvent* event) override 18 | { 19 | cds_debug("On closing"); 20 | 21 | // Allow to close the window but prevent deletion of the widget 22 | setWidget(nullptr); 23 | QMdiSubWindow::closeEvent(event); 24 | } 25 | 26 | virtual QSize minimumSizeHint() const override 27 | { 28 | return { 200, 100 }; 29 | } 30 | 31 | virtual QSize sizeHint() const override 32 | { 33 | QSize size; 34 | 35 | if (parentWidget()) { 36 | size.setHeight(parentWidget()->size().height() / 2); 37 | size.setWidth(parentWidget()->size().width() / 2); 38 | } else { 39 | cds_error("parentWidget() is NULL!"); 40 | } 41 | 42 | return size; 43 | } 44 | }; 45 | 46 | #endif /* !__SUBWINDOW_H */ 47 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(templategen) 2 | -------------------------------------------------------------------------------- /tools/templategen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_SOURCE_DIR}/3rdParty/spdlog/include) 2 | include_directories(${CMAKE_SOURCE_DIR}/3rdParty/cxxopts/include) 3 | 4 | set(SRC 5 | main.cpp 6 | ) 7 | 8 | set(CMAKE_AUTOMOC OFF) 9 | set(CMAKE_AUTOUIC OFF) 10 | 11 | add_executable(templategen ${SRC}) 12 | target_include_directories(templategen PUBLIC ${Boost_INCLUDE_DIRS}) 13 | #this is needed on windows 14 | #target_link_directories(templategen PUBLIC ${Boost_LIBRARY_DIRS}) 15 | target_link_libraries(templategen ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}) 16 | 17 | set(CMAKE_AUTOMOC ON) 18 | set(CMAKE_AUTOUIC ON) 19 | 20 | --------------------------------------------------------------------------------