Skip to content
Snippets Groups Projects
Commit 8f0b5b4f authored by Hoop77's avatar Hoop77 Committed by lenoelda
Browse files

MessageGui finally working

parent 3dd169c6
No related merge requests found
......@@ -95,6 +95,9 @@ private:
void newSocket()
{
if (!socket.is_open())
return;
socket = Socket(net.getIoService(), Udp::v4());
socket.set_option(boost::asio::socket_base::reuse_address{true});
socket.set_option(boost::asio::socket_base::broadcast{true});
......
......@@ -46,7 +46,7 @@ add_executable(MessageGui ${SOURCE_FILES}
include/MessageGui/MessageList.h
include/MessageGui/SignalProducer.h
include/MessageGui/SignalConsumer.h
include/MessageGui/Utils.h
include/Utils.h
include/MessageGui/MostRecentMessageFiltertProxyModel.h
include/MessageGui/MessageRole.h
include/MessageGui/Message.h
......
......@@ -46,9 +46,9 @@ class MostRecentMessageFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QObject * source READ source WRITE setSource)
Q_PROPERTY(bool enabled READ enabled WRITE enable )
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QObject * source READ source WRITE setSource)
Q_PROPERTY(bool enabled READ enabled WRITE enable )
public:
explicit MostRecentMessageFilterProxyModel(QObject * parent = nullptr);
......@@ -74,9 +74,10 @@ protected slots:
void onRowsRemoved(const QModelIndex & parent, int first, int last);
protected:
QHash<int, QByteArray> roleNames() const;
bool filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const override;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
QHash<int, QByteArray> roleNames() const;
private:
......
......@@ -26,9 +26,9 @@ void MostRecentMessageFilterProxyModel::setSource(QObject * source)
setSourceModel(qobject_cast<QAbstractItemModel *>(source));
connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)),
connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex, int, int)),
this, SLOT(onRowsInserted(const QModelIndex &, int, int)));
connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)),
connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
this, SLOT(onRowsRemoved(const QModelIndex &, int, int)));
endResetModel();
......@@ -39,6 +39,9 @@ int MostRecentMessageFilterProxyModel::count() const
return rowCount();
}
#include <QDebug>
#include <include/Utils.h>
void MostRecentMessageFilterProxyModel::enable(bool flag)
{
enabledFlag = flag;
......@@ -65,12 +68,8 @@ void MostRecentMessageFilterProxyModel::onRowsInserted(const QModelIndex & paren
invalidateFilter();
}
#include <QDebug>
void MostRecentMessageFilterProxyModel::onRowsRemoved(const QModelIndex & parent, int first, int last)
{
for (int i = first; i <= last; i++)
qDebug() << "ID to remove: " << idFromRow(i, parent);
}
MessageKey MostRecentMessageFilterProxyModel::messageKeyFromRow(int row, const QModelIndex & parent) const
......@@ -89,15 +88,13 @@ int MostRecentMessageFilterProxyModel::idFromRow(int row, const QModelIndex & pa
bool MostRecentMessageFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
{
if (!enabled() || !sourceModel()->index(sourceRow, 0, sourceParent).isValid() ||
sourceRow < 0 || sourceRow >= rowCount())
if (!enabled())
return true;
auto key = messageKeyFromRow(sourceRow, sourceParent);
auto id = idFromRow(sourceRow, sourceParent);
if (id != mostRecent.at(key))
qDebug() << "ID not accepted: " << id;
if (!utils::contains(mostRecent, key))
return true;
auto id = idFromRow(sourceRow, sourceParent);
return id == mostRecent.at(key);
}
......@@ -46,7 +46,7 @@ void Logging::camDataCallback(const camDataMsg::ConstPtr & inMsg)
void Logging::environmentDataCallback(const environmentDataMsg::ConstPtr & inMsg)
{
*messageServer << message::Message{"environment", "distance", std::to_string(inMsg->distance)};
*messageServer << message::Message{"environmentData", "distance", std::to_string(inMsg->distance)};
}
void Logging::laneDataCallback(const laneDataMsg::ConstPtr & inMsg)
......
......@@ -22,14 +22,16 @@ void Ultrasonic::onInit()
messageOStream.write("onInit", "START");
ussData = nh.advertise<ussDataMsg>("ussData", 1);
sensor.init();
//sensor.init();
timer = networking::time::Timer::create(net);
timer->startPeriodicTimeout(
std::chrono::milliseconds(UltrasonicSensor::DELAY),
[&]
{
ussDataMsg msg;
auto distance = streamMedianFilter.moveWindow(sensor.getDistance());
//auto distance = streamMedianFilter.moveWindow(sensor.getDistance());
static int distance = 0;
distance++;
msg.distance = distance;
msg.timestamp = ros::Time::now();
ussData.publish(msg);
......
# Switch from AdHoc Network to eduroam
IFACE="wlan0"
# Reset wifi card
sudo ifconfig IFACE down
sudo iw IFACE set type managed
sudo ifconfig IFACE up
sleep 0.5
# Connect to wifi and obtain IP address
sudo wpa_cli
sudo dhclient -r
sudo dhclient
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment