|
| 1 | +#include "canrawfilter.h" |
| 2 | +#include "canrawfilter_p.h" |
| 3 | +#include <confighelpers.h> |
| 4 | +#include <log.h> |
| 5 | +#include <QCanBusFrame> |
| 6 | + |
| 7 | +CanRawFilter::CanRawFilter() |
| 8 | + : d_ptr(new CanRawFilterPrivate(this)) |
| 9 | +{ |
| 10 | +} |
| 11 | + |
| 12 | +CanRawFilter::CanRawFilter(CanRawFilterCtx&& ctx) |
| 13 | + : d_ptr(new CanRawFilterPrivate(this, std::move(ctx))) |
| 14 | +{ |
| 15 | +} |
| 16 | + |
| 17 | +CanRawFilter::~CanRawFilter() |
| 18 | +{ |
| 19 | +} |
| 20 | + |
| 21 | +QWidget* CanRawFilter::mainWidget() |
| 22 | +{ |
| 23 | + Q_D(CanRawFilter); |
| 24 | + |
| 25 | + return d->_ui.mainWidget(); |
| 26 | +} |
| 27 | + |
| 28 | +void CanRawFilter::setConfig(const QJsonObject& json) |
| 29 | +{ |
| 30 | + Q_D(CanRawFilter); |
| 31 | + |
| 32 | + d_ptr->setSettings(json); |
| 33 | +} |
| 34 | + |
| 35 | +void CanRawFilter::setConfig(const QObject& qobject) |
| 36 | +{ |
| 37 | + Q_D(CanRawFilter); |
| 38 | + |
| 39 | + configHelpers::setQConfig(qobject, getSupportedProperties(), d->_props); |
| 40 | +} |
| 41 | + |
| 42 | +QJsonObject CanRawFilter::getConfig() const |
| 43 | +{ |
| 44 | + return d_ptr->getSettings(); |
| 45 | +} |
| 46 | + |
| 47 | +std::shared_ptr<QObject> CanRawFilter::getQConfig() const |
| 48 | +{ |
| 49 | + const Q_D(CanRawFilter); |
| 50 | + |
| 51 | + return configHelpers::getQConfig(getSupportedProperties(), d->_props); |
| 52 | +} |
| 53 | + |
| 54 | +void CanRawFilter::configChanged() |
| 55 | +{ |
| 56 | +} |
| 57 | + |
| 58 | +bool CanRawFilter::mainWidgetDocked() const |
| 59 | +{ |
| 60 | + return d_ptr->_docked; |
| 61 | +} |
| 62 | + |
| 63 | +ComponentInterface::ComponentProperties CanRawFilter::getSupportedProperties() const |
| 64 | +{ |
| 65 | + return d_ptr->getSupportedProperties(); |
| 66 | +} |
| 67 | + |
| 68 | +void CanRawFilter::stopSimulation() |
| 69 | +{ |
| 70 | + Q_D(CanRawFilter); |
| 71 | + |
| 72 | + d->_simStarted = false; |
| 73 | +} |
| 74 | + |
| 75 | +void CanRawFilter::startSimulation() |
| 76 | +{ |
| 77 | + Q_D(CanRawFilter); |
| 78 | + |
| 79 | + d->_simStarted = true; |
| 80 | +} |
| 81 | + |
| 82 | +void CanRawFilter::txFrameIn(const QCanBusFrame& frame) |
| 83 | +{ |
| 84 | + Q_D(CanRawFilter); |
| 85 | + |
| 86 | + if(d->acceptTxFrame(frame) && d->_simStarted) { |
| 87 | + emit txFrameOut(frame); |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +void CanRawFilter::rxFrameIn(const QCanBusFrame& frame) |
| 92 | +{ |
| 93 | + Q_D(CanRawFilter); |
| 94 | + |
| 95 | + if(d->acceptRxFrame(frame) && d->_simStarted) { |
| 96 | + emit rxFrameOut(frame); |
| 97 | + } |
| 98 | +} |
0 commit comments