Adjust mock plugins with new plugin info generation
This commit is contained in:
parent
023a223908
commit
2d349e28b1
@ -539,7 +539,7 @@ void DevicePlugin::loadMetaData()
|
|||||||
|
|
||||||
// Note: The DevicePlugin has no type class, so we define the json properties here
|
// Note: The DevicePlugin has no type class, so we define the json properties here
|
||||||
QStringList pluginMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors";
|
QStringList pluginMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors";
|
||||||
QStringList pluginJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors" << "paramtypes";
|
QStringList pluginJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors" << "paramTypes";
|
||||||
|
|
||||||
QPair<QStringList, QStringList> verificationResult = verifyFields(pluginJsonProperties, pluginMandatoryJsonProperties, m_metaData);
|
QPair<QStringList, QStringList> verificationResult = verifyFields(pluginJsonProperties, pluginMandatoryJsonProperties, m_metaData);
|
||||||
|
|
||||||
@ -561,8 +561,8 @@ void DevicePlugin::loadMetaData()
|
|||||||
QJsonObject vendorObject = vendorJson.toObject();
|
QJsonObject vendorObject = vendorJson.toObject();
|
||||||
|
|
||||||
// Note: The Vendor has no type class, so we define the json properties here
|
// Note: The Vendor has no type class, so we define the json properties here
|
||||||
QStringList vendorMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName";
|
QStringList vendorMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "deviceClasses";
|
||||||
QStringList vendorJsonProperties = QStringList() << "id" << "name" << "displayName";
|
QStringList vendorJsonProperties = QStringList() << "id" << "name" << "displayName" << "deviceClasses";
|
||||||
|
|
||||||
QPair<QStringList, QStringList> verificationResult = verifyFields(vendorJsonProperties, vendorMandatoryJsonProperties, vendorObject);
|
QPair<QStringList, QStringList> verificationResult = verifyFields(vendorJsonProperties, vendorMandatoryJsonProperties, vendorObject);
|
||||||
|
|
||||||
|
|||||||
@ -221,7 +221,7 @@ QStringList ParamType::jsonProperties()
|
|||||||
/*! Returns a list of mandatory JSON properties a ParamType JSON definition must have. */
|
/*! Returns a list of mandatory JSON properties a ParamType JSON definition must have. */
|
||||||
QStringList ParamType::mandatoryJsonProperties()
|
QStringList ParamType::mandatoryJsonProperties()
|
||||||
{
|
{
|
||||||
return QStringList() << "id" << "name" << "displayName" << "type" << "defaultValue";
|
return QStringList() << "id" << "name" << "displayName" << "type";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Writes the name, type, defaultValue, min value, max value and readOnly of the given \a paramType to \a dbg. */
|
/*! Writes the name, type, defaultValue, min value, max value and readOnly of the given \a paramType to \a dbg. */
|
||||||
|
|||||||
@ -251,7 +251,7 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
|
|||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (device->deviceClassId() == mockPushButtonDeviceClassId) {
|
} else if (device->deviceClassId() == mockPushButtonDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockPushButtonColorActionTypeId) {
|
if (action.actionTypeId() == mockPushButtonColorActionTypeId) {
|
||||||
QString colorString = action.param(mockPushButtonColorStateParamTypeId).value().toString();
|
QString colorString = action.param(mockPushButtonColorActionParamTypeId).value().toString();
|
||||||
QColor color(colorString);
|
QColor color(colorString);
|
||||||
if (!color.isValid()) {
|
if (!color.isValid()) {
|
||||||
qCWarning(dcMockDevice) << "Invalid color parameter";
|
qCWarning(dcMockDevice) << "Invalid color parameter";
|
||||||
@ -260,16 +260,16 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
|
|||||||
device->setStateValue(mockPushButtonColorStateTypeId, colorString);
|
device->setStateValue(mockPushButtonColorStateTypeId, colorString);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockPushButtonPercentageActionTypeId) {
|
} else if (action.actionTypeId() == mockPushButtonPercentageActionTypeId) {
|
||||||
device->setStateValue(mockPushButtonPercentageStateTypeId, action.param(mockPushButtonPercentageStateParamTypeId).value().toInt());
|
device->setStateValue(mockPushButtonPercentageStateTypeId, action.param(mockPushButtonPercentageActionParamTypeId).value().toInt());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockPushButtonAllowedValuesActionTypeId) {
|
} else if (action.actionTypeId() == mockPushButtonAllowedValuesActionTypeId) {
|
||||||
device->setStateValue(mockPushButtonAllowedValuesStateTypeId, action.param(mockPushButtonAllowedValuesStateParamTypeId).value().toString());
|
device->setStateValue(mockPushButtonAllowedValuesStateTypeId, action.param(mockPushButtonAllowedValuesActionParamTypeId).value().toString());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockPushButtonDoubleActionTypeId) {
|
} else if (action.actionTypeId() == mockPushButtonDoubleActionTypeId) {
|
||||||
device->setStateValue(mockPushButtonDoubleStateTypeId, action.param(mockPushButtonDoubleStateParamTypeId).value().toDouble());
|
device->setStateValue(mockPushButtonDoubleStateTypeId, action.param(mockPushButtonDoubleActionParamTypeId).value().toDouble());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockPushButtonBoolActionTypeId) {
|
} else if (action.actionTypeId() == mockPushButtonBoolActionTypeId) {
|
||||||
device->setStateValue(mockPushButtonBoolStateTypeId, action.param(mockPushButtonBoolStateParamTypeId).value().toBool());
|
device->setStateValue(mockPushButtonBoolStateTypeId, action.param(mockPushButtonBoolActionParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockPushButtonTimeoutActionTypeId) {
|
} else if (action.actionTypeId() == mockPushButtonTimeoutActionTypeId) {
|
||||||
return DeviceManager::DeviceErrorAsync;
|
return DeviceManager::DeviceErrorAsync;
|
||||||
@ -277,7 +277,7 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
|
|||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
} else if (device->deviceClassId() == mockDisplayPinDeviceClassId) {
|
} else if (device->deviceClassId() == mockDisplayPinDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockDisplayPinColorActionTypeId) {
|
if (action.actionTypeId() == mockDisplayPinColorActionTypeId) {
|
||||||
QString colorString = action.param(mockDisplayPinColorStateParamTypeId).value().toString();
|
QString colorString = action.param(mockDisplayPinColorActionParamTypeId).value().toString();
|
||||||
QColor color(colorString);
|
QColor color(colorString);
|
||||||
if (!color.isValid()) {
|
if (!color.isValid()) {
|
||||||
qCWarning(dcMockDevice) << "Invalid color parameter";
|
qCWarning(dcMockDevice) << "Invalid color parameter";
|
||||||
@ -286,30 +286,30 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
|
|||||||
device->setStateValue(mockDisplayPinColorStateTypeId, colorString);
|
device->setStateValue(mockDisplayPinColorStateTypeId, colorString);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockDisplayPinPercentageActionTypeId) {
|
} else if (action.actionTypeId() == mockDisplayPinPercentageActionTypeId) {
|
||||||
device->setStateValue(mockDisplayPinPercentageStateTypeId, action.param(mockDisplayPinPercentageStateParamTypeId).value().toInt());
|
device->setStateValue(mockDisplayPinPercentageStateTypeId, action.param(mockDisplayPinPercentageActionParamTypeId).value().toInt());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockDisplayPinAllowedValuesActionTypeId) {
|
} else if (action.actionTypeId() == mockDisplayPinAllowedValuesActionTypeId) {
|
||||||
device->setStateValue(mockDisplayPinAllowedValuesStateTypeId, action.param(mockDisplayPinAllowedValuesStateParamTypeId).value().toString());
|
device->setStateValue(mockDisplayPinAllowedValuesStateTypeId, action.param(mockDisplayPinAllowedValuesActionParamTypeId).value().toString());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockDisplayPinDoubleActionTypeId) {
|
} else if (action.actionTypeId() == mockDisplayPinDoubleActionTypeId) {
|
||||||
device->setStateValue(mockDisplayPinDoubleStateTypeId, action.param(mockDisplayPinDoubleStateParamTypeId).value().toDouble());
|
device->setStateValue(mockDisplayPinDoubleStateTypeId, action.param(mockDisplayPinDoubleActionParamTypeId).value().toDouble());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockDisplayPinBoolActionTypeId) {
|
} else if (action.actionTypeId() == mockDisplayPinBoolActionTypeId) {
|
||||||
device->setStateValue(mockDisplayPinBoolStateTypeId, action.param(mockDisplayPinBoolStateParamTypeId).value().toBool());
|
device->setStateValue(mockDisplayPinBoolStateTypeId, action.param(mockDisplayPinBoolActionParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == mockDisplayPinTimeoutActionTypeId) {
|
} else if (action.actionTypeId() == mockDisplayPinTimeoutActionTypeId) {
|
||||||
return DeviceManager::DeviceErrorAsync;
|
return DeviceManager::DeviceErrorAsync;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
} else if (device->deviceClassId() == mockParentDeviceClassId) {
|
} else if (device->deviceClassId() == mockParentDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockParentBoolValueActionTypeId) {
|
if (action.actionTypeId() == mockParentBoolValueParentActionTypeId) {
|
||||||
device->setStateValue(mockParentBoolValueStateTypeId, action.param(mockParentBoolValueStateParamTypeId).value().toBool());
|
device->setStateValue(mockParentBoolValueParentStateTypeId, action.param(mockParentBoolValueParentActionParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
} else if (device->deviceClassId() == mockChildDeviceClassId) {
|
||||||
if (action.actionTypeId() == mockChildBoolValueActionTypeId) {
|
if (action.actionTypeId() == mockChildBoolValueParentActionTypeId) {
|
||||||
device->setStateValue(mockChildBoolValueStateTypeId, action.param(mockChildBoolValueStateParamTypeId).value().toBool());
|
device->setStateValue(mockChildBoolValueParentStateTypeId, action.param(mockChildBoolValueParentActionParamTypeId).value().toBool());
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
}
|
}
|
||||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "MockDevice",
|
"name": "mockDevice",
|
||||||
"displayName": "Mock Devices",
|
"displayName": "Mock Devices",
|
||||||
"id": "727a4a9a-c187-446f-aadf-f1b2220607d1",
|
"id": "727a4a9a-c187-446f-aadf-f1b2220607d1",
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
|
|||||||
@ -210,7 +210,7 @@ def extractStateTypes(stateTypes, deviceClassName):
|
|||||||
if not variableName in variableNames:
|
if not variableName in variableNames:
|
||||||
variableNames.append(variableName)
|
variableNames.append(variableName)
|
||||||
printInfo('Define ParamTypeId %s for autocreated ActionType %s = %s' % (variableName, variableName, stateType['id']))
|
printInfo('Define ParamTypeId %s for autocreated ActionType %s = %s' % (variableName, variableName, stateType['id']))
|
||||||
addTranslationString(stateType['displayName'], 'The name of the autocreated ParamType of the writable StateType (%s) of DeviceClass %s' % (stateType['$
|
addTranslationString(stateType['displayName'], 'The name of the autocreated ParamType of the writable StateType (%s) of DeviceClass %s' % (stateType['id'], deviceClassName))
|
||||||
if args.filetype is 'i':
|
if args.filetype is 'i':
|
||||||
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
|
||||||
createExternDefinition('ParamTypeId', variableName)
|
createExternDefinition('ParamTypeId', variableName)
|
||||||
|
|||||||
Reference in New Issue
Block a user