Skip to content

Commit

Permalink
CanSignalData (#184)
Browse files Browse the repository at this point in the history
Signed-off-by: Remigiusz Kołłątaj <[email protected]>
  • Loading branch information
Remigiusz Kołłątaj authored Oct 24, 2019
1 parent b1f3f40 commit a231e8e
Show file tree
Hide file tree
Showing 31 changed files with 2,523 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ build_script:
set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
cmake .. -G %GENERATOR% -DCMAKE_PREFIX_PATH=%QT_PATH% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
cmake .. -G %GENERATOR% -DCMAKE_PREFIX_PATH=%QT_PATH% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DBOOST_INCLUDEDIR=C:\Libraries\boost_1_67_0
cmake --build . --config %BUILD_TYPE%
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ build
*.user
.vimrc
.ycm_extra_conf.py

.*.un~
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
[submodule "3rdParty/cxxopts"]
path = 3rdParty/cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "3rdParty/CANdb"]
path = 3rdParty/CANdb
url = https://github.com/GENIVI/CANdb.git
[submodule "3rdParty/catch"]
path = 3rdParty/catch
url = https://github.com/catchorg/Catch2
1 change: 1 addition & 0 deletions 3rdParty/CANdb
Submodule CANdb added at 5ec36c
3 changes: 3 additions & 0 deletions 3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ target_include_directories(rwqueue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/readerw

add_subdirectory(nodeeditor)


add_subdirectory(CANdb)

if(LINUX)
add_subdirectory(3rdParty/qtCannelloniCanBus)

Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ message(STATUS "Qt Version found: ${Qt5Core_VERSION}")
set_property(TARGET Qt5::SerialBus PROPERTY INTERFACE_COMPILE_FEATURES "")
set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES "")

# Limit TYPESTRING to 128 (i.e. 2^7). 64 causes VS2015 internal error.
if(NOT MSVC)
add_definitions(-Wall -Wextra)
add_definitions(-Wall -Wextra -DUSE_TYPESTRING=7)
else()
add_definitions( /bigobj)
add_definitions( /bigobj /D USE_TYPESTRING=7)
endif()

include(CompilerVersion)
Expand All @@ -69,7 +70,9 @@ if(WITH_COVERAGE)
setup_target_for_coverage(NAME coverage EXECUTABLE ctest DEPENDENCIES candevice_test)
endif()

set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(UNIX)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()

set(SPDLOG_BUILD_TESTING OFF CACHE BOOL "")
set(BUILD_EXAMPLES OFF CACHE BOOL "")
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage:
- "src/components/canrawsender/gui"
- "src/components/canrawview/gui"
- "src/components/canrawfilter/gui"
- "src/components/cansignaldata/gui"
- "src/components/canload/canloadpainter.h"
- "src/common/guiinterface"
- "src/common/nodepainter.h"
Expand Down
8 changes: 7 additions & 1 deletion files/css/darkStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,20 @@ QPushButton#pbStartNew, #pbStartOpen, #close {
border: 0px;
}

QWidget#CanRawSenderPrivate, #CanRawViewPrivate, #CanRawFilterPrivate {
QWidget#CanRawSenderPrivate, #CanRawViewPrivate, #CanRawFilterPrivate, #CanSignalDataPrivate {
background-color: #616161;
}

QToolButton#toolSwitch {
image: url(:/images/files/images/light/CANbus_icon_Switch_dark.svg);
}

QLineEdit#searchLine {
background-color: #3a3a3a;
border : 1px solid #adadad;
padding: 2px;
}

QCheckBox[type=sectionHeader] {
spacing: 43px;
color: #767676;
Expand Down
21 changes: 20 additions & 1 deletion files/css/lightStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ QPushButton[flat="true"] {
margin: 0px;
padding: 0px;
background-color: #ffffff;
color: #a6a6a6;
}

QPushButton[flat="true"]:pressed {
border: 2px solid #adadad;
background-color: #eeeeee;
color: #a6a6a6;
}

QPushButton[flat="true"]:checked {
Expand All @@ -145,6 +147,11 @@ QToolButton#toolSwitch {
image: url(:/images/files/images/light/CANbus_icon_Switch.svg);
}

QLineEdit#searchLine {
border : 1px solid #adadad;
padding: 2px;
}

QCheckBox[type=sectionHeader] {
background: #dcdcdc;
spacing: 43px;
Expand Down Expand Up @@ -199,7 +206,19 @@ QPushButton[type="recentProjectFile"] {
font-size: 12px;
}

QPushButton:pressed[type="recentProjectName"], QPushButton:pressed[type="recentProjectFile"], #pbStartNew, #pbStartOpen, #close {
QPushButton:pressed[type="recentProjectFile"] {
border: 0px;
background: #ffffff;
color: #919191;
}

QPushButton:pressed[type="recentProjectName"] {
border: 0px;
background: #ffffff;
color: #0d6188;
}

QPushButton:pressed#pbStartNew, #pbStartOpen, #close {
border: 0px;
}

Expand Down
31 changes: 31 additions & 0 deletions src/common/datamodeltypes/candbdata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef __CANDBDATA_H
#define __CANDBDATA_H

#include <nodes/NodeDataModel>
#include <cantypes.hpp>

using DbData_t = std::map<CANmessage, std::vector<CANsignal>>;

class CanDbData : public NodeData {
public:
CanDbData(){};
CanDbData(const DbData_t& messages)
: _messages(messages)
{
}

NodeDataType type() const override
{
return NodeDataType{ "DbData", "DB" };
}

DbData_t messages() const
{
return _messages;
}

private:
DbData_t _messages;
};

#endif /* !__CANDBDATA_H */
32 changes: 32 additions & 0 deletions src/components/cansignaldata/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
set(COMPONENT_NAME cansignaldata)

set(SRC
gui/cansignaldata.ui
gui/cansignaldataguiimpl.h
cansignaldata.cpp
cansignaldata_p.cpp
cansignaldatamodel.cpp
searchmodel.cpp
)

add_library(${COMPONENT_NAME} ${SRC})
target_link_libraries(${COMPONENT_NAME} cds-common CANdb)
target_include_directories(${COMPONENT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

if(WITH_TESTS)
add_executable(${COMPONENT_NAME}_test tests/${COMPONENT_NAME}_test.cpp)
target_link_libraries(${COMPONENT_NAME}_test ${COMPONENT_NAME} Qt5::Test fakeit)
add_test(NAME ${COMPONENT_NAME}_test COMMAND ${COMPONENT_NAME}_test)

add_executable(${COMPONENT_NAME}model_test tests/${COMPONENT_NAME}model_test.cpp)
target_link_libraries(${COMPONENT_NAME}model_test ${COMPONENT_NAME} Qt5::Test fakeit)
add_test(NAME ${COMPONENT_NAME}model_test COMMAND ${COMPONENT_NAME}model_test)

set(DBC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/dbc)
set(DBC_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/dbc)
add_custom_command(TARGET ${COMPONENT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DBC_SOURCE} ${DBC_DESTINATION})

target_compile_definitions(${COMPONENT_NAME}_test PRIVATE DBC_PATH="${DBC_DESTINATION}")
target_compile_definitions(${COMPONENT_NAME}model_test PRIVATE DBC_PATH="${DBC_DESTINATION}")
endif()
82 changes: 82 additions & 0 deletions src/components/cansignaldata/cansignaldata.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "cansignaldata.h"
#include "cansignaldata_p.h"
#include <confighelpers.h>
#include <log.h>

CanSignalData::CanSignalData()
: d_ptr(new CanSignalDataPrivate(this))
{
}

CanSignalData::CanSignalData(CanSignalDataCtx&& ctx)
: d_ptr(new CanSignalDataPrivate(this, std::move(ctx)))
{
}

CanSignalData::~CanSignalData()
{
}

QWidget* CanSignalData::mainWidget()
{
Q_D(CanSignalData);

return d->_ui.mainWidget();
}

void CanSignalData::setConfig(const QJsonObject& json)
{
d_ptr->setSettings(json);
}

void CanSignalData::setConfig(const QWidget& qobject)
{
Q_D(CanSignalData);

configHelpers::setQConfig(qobject, getSupportedProperties(), d->_props);
}

QJsonObject CanSignalData::getConfig() const
{
return d_ptr->getSettings();
}

std::shared_ptr<QWidget> CanSignalData::getQConfig() const
{
const Q_D(CanSignalData);

return configHelpers::getQConfig(getSupportedProperties(), d->_props);
}

void CanSignalData::configChanged()
{
QString fileName = getQConfig()->property("file").toString();

cds_info("File to open: '{}'", fileName.toStdString());

d_ptr->loadDbc(fileName.toStdString());
}

bool CanSignalData::mainWidgetDocked() const
{
return d_ptr->_docked;
}

ComponentInterface::ComponentProperties CanSignalData::getSupportedProperties() const
{
return d_ptr->getSupportedProperties();
}

void CanSignalData::stopSimulation()
{
Q_D(CanSignalData);

d->_simStarted = false;
}

void CanSignalData::startSimulation()
{
Q_D(CanSignalData);

d->_simStarted = true;
}
48 changes: 48 additions & 0 deletions src/components/cansignaldata/cansignaldata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef CANSIGNALDATA_H
#define CANSIGNALDATA_H

#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#include <cantypes.hpp>
#include <componentinterface.h>
#include <context.h>
#include <memory>

class CanSignalDataPrivate;
class QWidget;
struct CanSignalDataGuiInt;
typedef Context<CanSignalDataGuiInt> CanSignalDataCtx;

Q_DECLARE_METATYPE(CANmessages_t);

class CanSignalData : public QObject, public ComponentInterface {
Q_OBJECT
Q_DECLARE_PRIVATE(CanSignalData)

public:
CanSignalData();
explicit CanSignalData(CanSignalDataCtx&& ctx);
~CanSignalData();

QWidget* mainWidget() override;
void setConfig(const QJsonObject& json) override;
void setConfig(const QWidget& qobject) override;
QJsonObject getConfig() const override;
std::shared_ptr<QWidget> getQConfig() const override;
void configChanged() override;
bool mainWidgetDocked() const override;
ComponentInterface::ComponentProperties getSupportedProperties() const override;

signals:
void mainWidgetDockToggled(QWidget* widget) override;
void canDbUpdated(const CANmessages_t& messages);

public slots:
void stopSimulation() override;
void startSimulation() override;

private:
QScopedPointer<CanSignalDataPrivate> d_ptr;
};

#endif // CANSIGNALDATA_H
Loading

0 comments on commit a231e8e

Please sign in to comment.