fix some plugin's json
This commit is contained in:
parent
d81dd97d5f
commit
ba8e3d7ec9
@ -163,6 +163,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
|||||||
deviceClass.setCreateMethods(createMethods);
|
deviceClass.setCreateMethods(createMethods);
|
||||||
|
|
||||||
deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray()));
|
deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray()));
|
||||||
|
qDebug() << "loaded deviceClass" << deviceClass.discoveryParamTypes();
|
||||||
|
|
||||||
QString setupMethod = jo.value("setupMethod").toString();
|
QString setupMethod = jo.value("setupMethod").toString();
|
||||||
if (setupMethod == "pushButton") {
|
if (setupMethod == "pushButton") {
|
||||||
@ -293,6 +294,11 @@ QList<ParamType> DevicePlugin::parseParamTypes(const QJsonArray &array) const
|
|||||||
foreach (const QJsonValue ¶mTypesJson, array) {
|
foreach (const QJsonValue ¶mTypesJson, array) {
|
||||||
QJsonObject pt = paramTypesJson.toObject();
|
QJsonObject pt = paramTypesJson.toObject();
|
||||||
QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data());
|
QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data());
|
||||||
|
Q_ASSERT_X(t != QVariant::Invalid,
|
||||||
|
pluginName().toLatin1().data(),
|
||||||
|
QString("Invalid type %1 for param %2 in json file.")
|
||||||
|
.arg(pt.value("type").toString())
|
||||||
|
.arg(pt.value("name").toString()).toLatin1().data());
|
||||||
ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
|
ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
|
||||||
QVariantList allowedValues;
|
QVariantList allowedValues;
|
||||||
foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) {
|
foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"name": "button",
|
"name": "button",
|
||||||
"type": "string"
|
"type": "QString"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "repeat",
|
"name": "repeat",
|
||||||
|
|||||||
@ -13,21 +13,21 @@
|
|||||||
"discoveryParamTypes": [
|
"discoveryParamTypes": [
|
||||||
{
|
{
|
||||||
"name": "location",
|
"name": "location",
|
||||||
"type": "string"
|
"type": "QString"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"name": "location",
|
"name": "location",
|
||||||
"type": "string"
|
"type": "QString"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "country",
|
"name": "country",
|
||||||
"type": "string"
|
"type": "QString"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"type": "string"
|
"type": "QString"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actionTypes": [
|
"actionTypes": [
|
||||||
|
|||||||
@ -371,6 +371,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
|
|||||||
}
|
}
|
||||||
QVariantList discoveryParamTypes;
|
QVariantList discoveryParamTypes;
|
||||||
foreach (const ParamType ¶mType, deviceClass.discoveryParamTypes()) {
|
foreach (const ParamType ¶mType, deviceClass.discoveryParamTypes()) {
|
||||||
|
qDebug() << "packing discoverparam" << packParamType(paramType);
|
||||||
discoveryParamTypes.append(packParamType(paramType));
|
discoveryParamTypes.append(packParamType(paramType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user