Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UID mapper #237

Merged
merged 2 commits into from
Feb 1, 2023
Merged

Improve UID mapper #237

merged 2 commits into from
Feb 1, 2023

Conversation

chriadam
Copy link
Contributor

Instead of listening to all active topics, only listen to specific service name to path mapping changes.

src/uidhelper.h Outdated Show resolved Hide resolved
src/uidhelper.h Outdated Show resolved Hide resolved
@@ -84,7 +84,7 @@ QtObject {
sourceObject.destroy()
sourceObject = null
}
sourceObject = _mqttImpl.createObject(root, { uid: _mqttUidHelper.mqttUid })
sourceObject = _mqttImpl.createObject(root, { uid: Qt.binding(function() { return _mqttUidHelper.mqttUid }) })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would have to happen for _mqttUidHelper.mqttUid to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. pathForServiceNameChanged() if the provider gets new data for a service name we've already connected to (in the case where, at the time we first connected, the provider hadn't enumerated all of the values from the MQTT broker yet).

@chriadam chriadam force-pushed the chriadam-uid-mapper-fix branch from 923332d to 21ded2c Compare December 16, 2022 08:09
Copy link
Contributor

@blammit blammit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some trouble building this -- it seems this references a version of velib that has already moved the VeQItem etc. to veutil, so then files like ve_qitem_dbus_publisher.hpp are no longer available, even though they are still referenced in gui-v2/CMakeLists.txt.

if (path.endsWith(QStringLiteral("/ServiceName"))) {
const QString serviceName = message.toString();
m_pathToServiceName.insert(path, serviceName);
const QString devicePath = path.mid(0, path.length() - 11);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put "/ServiceName" in a static const string and reference the string length here to make this more explicit?

Instead of listening to all active topics, only listen to specific
service name to path mapping changes.
@chriadam chriadam force-pushed the chriadam-uid-mapper-fix branch from 21ded2c to a892b42 Compare January 5, 2023 03:44
@chriadam
Copy link
Contributor Author

chriadam commented Jan 5, 2023

I've now ported on top of veutil etc.
BUT: I can't push to veutil repo directly, so I had to create a fork and PR from there: https://github.com/victronenergy/veutil/pull/1/files

So, until that PR is merged, the veutil submodule in this repo will point to the wrong sha1...
To test locally, just do: git format-patch -1 in my branch of the veutil repo to get my patch, then apply it in the submodule repo here with git am *.patch.

@chriadam chriadam mentioned this pull request Jan 5, 2023
#include "veutil/qt/ve_qitems_mqtt.hpp"
#include "veutil/qt/ve_qitem_table_model.hpp"
#include "veutil/qt/ve_qitem_sort_table_model.hpp"
#include "veutil/qt/ve_qitem_child_model.hpp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently register types into Victron.Velib, should we register them into Victron.Veutil instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds best

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@blammit blammit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing this when running for MQTT:

expression for onCompleted@qrc:/data/mqtt/EssImpl.qml:90
Too many arguments, ignoring 2
expression for onCompleted@qrc:/data/mqtt/EssImpl.qml:95
Too many arguments, ignoring 2
expression for onCompleted@qrc:/data/mqtt/EssImpl.qml:101
Too many arguments, ignoring 2
expression for onCompleted@qrc:/data/mqtt/EssImpl.qml:107
Too many arguments, ignoring 2

In EssImpl, looks like the first two Component.onCompleted calls for veState and veHub4Mode do nothing, and can be removed. The second two for veMinimumSocLimit and veSocLimit could just have a Component.onCompleted that duplicates the functionality of their onValueChanged handlers.

There are a lot of warnings like this when running on device with dbus:

qt.core.qobject.connect: QObject::connect: No such signal VeQItemDbus::stateChanged(VeQItem*,State)
qt.core.qobject.connect: QObject::connect:  (sender name:   'CustomName')
qt.core.qobject.connect: QObject::connect: No such signal VeQItemDbus::stateChanged(VeQItem*,State)
qt.core.qobject.connect: QObject::connect:  (sender name:   'ProductName')
qt.core.qobject.connect: QObject::connect: Incompatible sender/receiver arguments
        VeQItemDbus::valueChanged(QVariant) --> DBusService::updateDescription(VeQItem*,QVariant)
qt.core.qobject.connect: QObject::connect: Incompatible sender/receiver arguments
        VeQItemDbus::initValue(QVariant) --> DBusService::updateDescription(VeQItem*,QVariant)
qt.core.qobject.connect: QObject::connect: Incompatible sender/receiver arguments
        VeQItemDbus::valueChanged(QVariant) --> DBusService::updateDescription(VeQItem*,QVariant)
qt.core.qobject.connect: QObject::connect: Incompatible sender/receiver arguments
        VeQItemDbus::initValue(QVariant) --> DBusService::updateDescription(VeQItem*,QVariant)
qt.core.qobject.connect: QObject::connect: No such signal VeQItemDbus::stateChanged(VeQItem*,State)
qt.core.qobject.connect: QObject::connect:  (sender name:   'com.victronenergy.battery.ttyUSB0')

Looking at https://github.com/victronenergy/gui/blob/master/src/dbus_service.cpp#L16, src/gui-v1/dbus_service.cpp needs to be updated to connect to e.g. SIGNAL(stateChanged(VeQItem::State)) instead of SIGNAL(stateChanged(VeQItem*,State)) ?

@chriadam chriadam force-pushed the chriadam-uid-mapper-fix branch 2 times, most recently from a48dd73 to 3eacd3a Compare January 6, 2023 04:37
@chriadam
Copy link
Contributor Author

chriadam commented Jan 6, 2023

Thanks, fixed all the warnings now as far as I know.

@@ -2,7 +2,7 @@
#define ALARMMONITOR_H

#include <QObject>
#include <velib/qt/ve_qitem.hpp>
#include <veutil/qt/ve_qitem.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this #include could be replaced by a forward declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't changed these files, aside from search/replacing velib to veutil in the paths.

@@ -3,8 +3,8 @@

#include <QObject>

#include <velib/qt/ve_qitem.hpp>
#include <velib/qt/ve_qitem_table_model.hpp>
#include <veutil/qt/ve_qitem.hpp>
Copy link
Contributor

@DanielMcInnes DanielMcInnes Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this #include could be replaced with a forward declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, I don't want to change these files if possible, aside from updating paths from velib to veutil

Copy link
Contributor

@DanielMcInnes DanielMcInnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, 2 nits

@chriadam chriadam force-pushed the chriadam-uid-mapper-fix branch from 3eacd3a to b693fc8 Compare February 1, 2023 03:27
@chriadam
Copy link
Contributor Author

chriadam commented Feb 1, 2023

I've now updated the veutil submodule sha1 to point to victronenergy/veutil#2 which is based in a "proper" branch there. Once that PR is merged, we'll have to update it again, but victronenergy/veutil#1 languished for over a month without any movement, so let's not wait longer.

@chriadam chriadam merged commit a213673 into main Feb 1, 2023
@chriadam chriadam deleted the chriadam-uid-mapper-fix branch February 27, 2023 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants