added first parsing

master
bernhard.trinnes 2020-08-04 10:16:41 +02:00 committed by Simon Stürz
parent 84bb9a61b9
commit d7a53bd227
4 changed files with 47 additions and 0 deletions

View File

@ -178,11 +178,42 @@ void IntegrationPluginSma::onDevicesReceived(int messageId, QList<SunnyWebBox::D
emit autoThingsAppeared(descriptors);
}
void IntegrationPluginSma::onProcessDataReceived(int messageId, const QString &deviceKey, const QHash<QString, QVariant> &channels)
{
Thing *thing = m_sunnyWebBoxes.key(static_cast<SunnyWebBox *>(sender()));
if (!thing)
return;
qCDebug(dcSma()) << "Process data received" << deviceKey;
Q_FOREACH(Thing *childThing, myThings().filterByParentId(thing->id())) {
if (childThing->paramValue(inverterThingIdParamTypeId).toString() == deviceKey) {
if (channels.contains("E-Total")) {
//TODO set total energy
}
break;
}
}
}
void IntegrationPluginSma::onParameterChannelsReceived(int messageId, const QString &deviceKey, QStringList parameterChannels)
{
Q_UNUSED(messageId)
Thing *thing = m_sunnyWebBoxes.key(static_cast<SunnyWebBox *>(sender()));
if (!thing)
return;
qCDebug(dcSma()) << "Parameter channels received" << deviceKey << parameterChannels;
}
SunnyWebBox * IntegrationPluginSma::createSunnyWebBoxConnection(Thing *thing)
{
SunnyWebBox *sunnyWebBox = new SunnyWebBox(m_sunnyWebBoxCommunication, QHostAddress(thing->paramValue(sunnyWebBoxThingHostParamTypeId).toString()), this);
m_sunnyWebBoxes.insert(thing, sunnyWebBox);
connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, this, &IntegrationPluginSma::onPlantOverviewReceived);
connect(sunnyWebBox, &SunnyWebBox::parameterChannelsReceived, this, &IntegrationPluginSma::onParameterChannelsReceived);
//connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, this, &IntegrationPluginSma::onPlantOverviewReceived);
return sunnyWebBox;
}

View File

@ -60,6 +60,8 @@ private slots:
void onPlantOverviewReceived(int messageId, SunnyWebBox::Overview overview);
void onDevicesReceived(int messageId, QList<SunnyWebBox::Device> devices);
void onProcessDataReceived(int messageId, const QString &deviceKey, const QHash<QString, QVariant> &channels);
void onParameterChannelsReceived(int messageId, const QString &deviceKey, QStringList parameterChannels);
private:
PluginTimer *m_refreshTimer = nullptr;

View File

@ -109,6 +109,11 @@ void SunnyWebBox::onMessageReceived(const QHostAddress &address, int messageId,
} else if (messageType == "GetProcessDataChannels") {
} else if (messageType == "GetProcessData") {
} else if (messageType == "GetParameterChannels") {
Q_FOREACH(QString deviceKey, result.keys()) {
QStringList parameterChannels = result.value(deviceKey).toStringList();
if (!parameterChannels.isEmpty())
emit parameterChannelsReceived(messageId, deviceKey, parameterChannels);
}
} else if (messageType == "GetParameter") {
} else if (messageType == "SetParameter") {
} else {

View File

@ -57,6 +57,13 @@ public:
QList<Device> childrens;
};
struct Channel {
QString meta;
QString name;
QVariant value;
QString unit;
};
explicit SunnyWebBox(SunnyWebBoxCommunication *communication, const QHostAddress &hostAddress, QObject *parrent = 0);
int getPlantOverview();
@ -83,6 +90,8 @@ signals:
void plantOverviewReceived(int messageId, Overview overview);
void devicesReceived(int messageId, QList<Device> devices);
void processDataReceived(int messageId, const QString &deviceKey, const QHash<QString, QVariant> &channels);
void parameterChannelsReceived(int messageId, const QString &deviceKey, QStringList parameterChannels);
};
#endif // SUNNYWEBBOX_H