-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Remigiusz Kołłątaj <[email protected]>
- Loading branch information
Remigiusz Kołłątaj
authored
Oct 24, 2019
1 parent
b1f3f40
commit a231e8e
Showing
31 changed files
with
2,523 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ build | |
*.user | ||
.vimrc | ||
.ycm_extra_conf.py | ||
|
||
.*.un~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.