Merge PR #181: Add nymea-plugininfocompiler to replace nymea-generateplugininfo

This commit is contained in:
Jenkins 2019-07-22 12:16:57 +02:00
commit 2df402ab8f
44 changed files with 2519 additions and 1413 deletions

2
.gitignore vendored
View File

@ -23,8 +23,6 @@ qrc_*.cpp
*.dirs
*.install
*.substvars
plugininfo.h
extern-plugininfo.h
tests/auto/actions/testactions
tests/auto/configurations/testconfigurations
tests/auto/devices/testdevices

26
debian/control vendored
View File

@ -7,7 +7,6 @@ Homepage: https://nymea.io
Vcs-Git: https://github.com/guh/guh.git
Build-Depends: debhelper (>= 9.0.0),
dpkg-dev (>= 1.16.1~),
python:any,
rsync,
qtchooser,
qt5-default,
@ -154,7 +153,6 @@ Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends},
${misc:Depends},
libqt5bluetooth5,
Replaces: libguh1
Description: An open source IoT server - core library
The nymea daemon is a plugin based IoT (Internet of Things) server. The
@ -173,12 +171,7 @@ Multi-Arch: same
Depends: ${shlibs:Depends},
${misc:Depends},
libnymea1 (= ${binary:Version}),
libqt5websockets5-dev,
pkg-config,
python:any,
qtconnectivity5-dev,
qttools5-dev-tools,
rsync,
Replaces: libguh1-dev
Description: An open source IoT server - development files
The nymea daemon is a plugin based IoT (Internet of Things) server. The
@ -187,4 +180,21 @@ Description: An open source IoT server - development files
With the powerful rule engine you are able to connect any device available
in the system and create individual scenes and behaviors for your environment.
.
This package will install the development files and compilers for nymea.
This package will install the development files for nymea.
Package: nymea-dev-tools
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends},
${misc:Depends},
libnymea1 (= ${binary:Version}),
qttools5-dev-tools,
Description: An open source IoT server - development files
The nymea daemon is a plugin based IoT (Internet of Things) server. The
server works like a translator for devices, things and services and
allows them to interact.
With the powerful rule engine you are able to connect any device available
in the system and create individual scenes and behaviors for your environment.
.
This package will install the development tools for nymea.

View File

@ -1,5 +1,4 @@
usr/lib/@DEB_HOST_MULTIARCH@/libnymea.so
usr/include/nymea/* usr/include/nymea
usr/bin/nymea-generateplugininfo usr/bin
libnymea/devices/plugin.pri usr/include/nymea/
usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/nymea.pc

View File

@ -1 +1 @@
debian/man/nymea-generateplugininfo.1
debian/man/nymea-plugininfocompiler.1

View File

@ -1,38 +1,29 @@
.\" Manpage for nymea-generateplugininfo.
.\" Manpage for nymea-plugininfo.
.\" Contact simon.stuerz@guh.io to correct errors or typos.
.TH man 1 "March 2017" "1.0.1" "nymea-generateplugininfo man page"
.TH man 1 "Jun 2019" "1.0.0" "nymea-plugininfocompiler man page"
.SH NAME
nymea-generateplugininfo \- A precompiler for building nymea plugins.
nymea-plugininfocompiler \- A precompiler for building nymea plugins.
.SH SYNOPSIS
.B nymea-generateplugininfo
.B nymea-plugininfocompiler
[\fIOPTION\fR]
.SH DESCRIPTION
The nymea-generateplugininfo is a precompiler for building plugins. This
The nymea-plugininfocompiler is a precompiler for building plugins. This
precompiler will create a plugininfo.h containing the uuid definitions from
the plugin json file and creates the translations for the plugin.
.SH USAGE
nymea-plugininfocompiler [options] inputfile
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
Displays this help.
.TP
\fB\-v\fR, \fB\-\-version\fR
Displays version information.
.TP
\fB\-f\fR, \fB\-\-filetype\fR, \fB{e, i}\fR
The file type to generate: e = extern infofile, i = infofile.
.TP
\fB\-j\fR, \fB\-\-jsonfile\fR, \fB\<jsonfile>\fR
The JSON input file name with the plugin description.
.TP
\fB\-b\fR, \fB\-\-builddir\fR, \fB\<build directory>\fR
The path to the build directory of the plugin where the plugininfo.h
file can be found..
.TP
\fB\-o\fR, \fB\-\-output\fR, \fB\<outputfile>\fR
The plugininfo.h outputFile with the uuid declarations.
The plugininfo.h outputFile with the uuid definitions.
.TP
\fB\-t\fR, \fB\-\-translations\fR, \fB[<*.ts>]\fR
The translation files for the plugin.
\fB\-e\fR, \fB\-\-extern\fR, \fB[<extern-outputfile>]\fR
The extern-plugininfo.h output file with the uuid forward declarations.
.SH SEE ALSO
Full developer documentation at: <https://doc.nymea.io>

1
debian/nymea-dev-tools.install.in vendored Normal file
View File

@ -0,0 +1 @@
usr/bin/nymea-plugininfocompiler

View File

@ -5,9 +5,9 @@
Each \l{DevicePlugin}{Plugin} in nymea will be defined in the corresponding JSON file. You can find information how to read JSON \l{http://json.org/}{here}. This file will be loaded from the \l{DeviceManager} to define the plugin and the corresponding DeviceClasses internal.
\section1 The nymea-generateplugininfo precompiler
\section1 The nymea-plugininfocompiler precompiler
The \tt {\b nymea-generateplugininfo} precompiler will parse this file and generates a \tt plugininfo.h and a \tt extern-plugininfo.h file containing the definitions of:
The \tt {\b nymea-plugininfocompiler} precompiler will parse this file and generates a \tt plugininfo.h and a \tt extern-plugininfo.h file containing the definitions of:
\list
\li \l{PluginId}: <\e pluginId \unicode{0x2192} the defined UUID for the \l{DevicePlugin}.
\li \l{VendorId}: <\e name>VendorId \unicode{0x2192} the defined UUID for the corresponding \l{Vendor}.

View File

@ -176,7 +176,7 @@
The implementation of each method can be found in the corresponding \tt{cpp} file.
As you can see, the plugin includes in the cpp file the \tt{plugininfo.h} file, which will be generated during build time
from the \tt{nymea-generateplugininfo} tool. This tool translates the \l{deviceplugintemplate.json} into a c++ header file
from the \tt{nymea-plugininfocompiler} tool. This tool translates the \l{deviceplugintemplate.json} into a c++ header file
containing all uuid definitions, translations strings and the debug catergory definition.
\quotefromfile template/deviceplugintemplate.cpp

View File

@ -111,9 +111,9 @@
Once you updated the JSON file, you have to rebuild the whole plugin in order to trigger a rebuild of the plugin information
include files.
\section2 nymea-generateplugininfo
\section2 nymea-plugininfocompiler
Before the source code will be compiled, a precompiler called \tt {nymea-generateplugininfo} will be launched. This tool will
Before the source code will be compiled, a precompiler called \tt {nymea-plugininfocompiler} will be launched. This tool will
read the plugin JSON file and generate two header files for the plugin in the build directory.
\section3 plugininfo.h
@ -150,7 +150,7 @@
\section1 Test the plugin
Now it's time to build you first plugin. In order to make sure all changes in you JSON file are up to date press the \tt{Rebuild all} instead
of only \tt {Build}. This will rerun the nymea-generateplugininfo tool and update the \tt plugininfo.h and \tt extern-plugininfo.h files.
of only \tt {Build}. This will rerun the nymea-plugininfocompiler tool and update the \tt plugininfo.h and \tt extern-plugininfo.h files.
\note Coming soon!

View File

@ -847,15 +847,40 @@ void DeviceManagerImplementation::loadPlugins()
continue;
}
// Check plugin API version compatibility
QLibrary lib(fi.absoluteFilePath());
QFunctionPointer versionFunc = lib.resolve("libnymea_api_version");
if (!versionFunc) {
qCWarning(dcDeviceManager()).nospace() << "Unable to resolve version in plugin " << entry << ". Not loading plugin.";
loader.unload();
lib.unload();
continue;
}
QString version = reinterpret_cast<QString(*)()>(versionFunc)();
// QString *version = reinterpret_cast<QString*>(lib.resolve("libnymea_api_version"));
// if (!version) {
// }
lib.unload();
QStringList parts = version.split('.');
QStringList coreParts = QString(LIBNYMEA_API_VERSION).split('.');
if (parts.length() != 3 || parts.at(0).toInt() != coreParts.at(0).toInt() || parts.at(1).toInt() > coreParts.at(1).toInt()) {
qCWarning(dcDeviceManager()).nospace() << "Libnymea API mismatch for " << entry << ". Core API: " << LIBNYMEA_API_VERSION << ", Plugin API: " << version;
loader.unload();
continue;
}
PluginMetadata metaData(loader.metaData().value("MetaData").toObject());
if (!metaData.isValid()) {
qCWarning(dcDeviceManager()) << "Plugin metadata not valid for" << entry;
loader.unload();
continue;
}
DevicePlugin *pluginIface = qobject_cast<DevicePlugin *>(loader.instance());
if (!pluginIface) {
qCWarning(dcDeviceManager) << "Could not get plugin instance of" << entry;
loader.unload();
continue;
}
loadPlugin(pluginIface, metaData);
@ -983,9 +1008,10 @@ void DeviceManagerImplementation::loadConfiguredDevices()
foreach (const QString &paramTypeIdString, settings.childGroups()) {
ParamTypeId paramTypeId(paramTypeIdString);
ParamType paramType = deviceClass.paramTypes().findById(paramTypeId);
QVariant defaultValue;
if (!paramType.isValid()) {
qCWarning(dcDeviceManager()) << "Not loading Param for device" << device << "because the ParamType for the saved Param" << ParamTypeId(paramTypeIdString).toString() << "could not be found.";
continue;
// NOTE: We're not skipping unknown parameters to give plugins a chance to still access old values if they change their config and migrate things over.
qCWarning(dcDeviceManager()) << "Unknown param" << paramTypeIdString << "for" << device << ". ParamType could not be found in device class.";
}
// Note: since nymea 0.12.2

View File

@ -1,473 +0,0 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (C) 2015-2018 Simon Stuerz <simon.stuerz@guh.io> #
# Copyright (C) 2014-2019 Michael Zanetti <michael.zanetti@nymea.io> #
# #
# This file is part of nymea. #
# #
# nymea is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, version 2 of the License. #
# #
# nymea is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with nymea. If not, see <http://www.gnu.org/licenses/>. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import argparse
import traceback
import json
import os
import subprocess
__version__='1.0.2'
##################################################################################################################
# Methods
#-----------------------------------------------------------------------------------------------------------------
def printInfo(info):
if args.filetype is 'i':
print(info)
#-----------------------------------------------------------------------------------------------------------------
def printWarning(warning):
print('Warning: ' + warning)
#-----------------------------------------------------------------------------------------------------------------
def printError(error):
print('Error: ' + error)
#-----------------------------------------------------------------------------------------------------------------
def writeToFile(line):
outputFile.write('%s\n' % line)
#-----------------------------------------------------------------------------------------------------------------
def extractPlugin(pluginMap):
variableName = 'pluginId'
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define PluginId pluginId = %s' % (pluginMap['id']))
if args.filetype is 'i':
writeToFile('PluginId pluginId = PluginId(\"%s\");' % (pluginMap['id']))
addTranslationString(pluginMap['displayName'], 'The name of the plugin %s (%s)' % (pluginMap['name'], pluginMap['id']))
createExternDefinition('PluginId', variableName)
# Extract plugin params (configurations)
if 'paramTypes' in pluginMap:
extractParamTypes(pluginMap['paramTypes'], pluginMap['name'][0].lower() + pluginMap['name'][1:], "", 'plugin')
if 'vendors' in pluginMap:
extractVendors(pluginMap['vendors'])
#-----------------------------------------------------------------------------------------------------------------
def extractParamTypes(paramTypes, deviceClassName, typeClass, typeName):
for paramType in paramTypes:
try:
variableName = '%sParamTypeId' % (deviceClassName + typeName[0].capitalize() + typeName[1:] + typeClass + paramType['name'][0].capitalize() + paramType['name'][1:])
print("....variable:", variableName)
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define ParamTypeId %s = %s' % (variableName, paramType['id']))
if args.filetype is 'i':
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, paramType['id']))
addTranslationString(paramType['displayName'], 'The name of the ParamType (DeviceClass: %s, %sType: %s, ID: %s)' % (deviceClassName, typeClass, typeName, paramType['id']))
createExternDefinition('ParamTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for ParamTypeId %s -> skipping' % (variableName, paramType['id']))
except:
pass
#-----------------------------------------------------------------------------------------------------------------
def extractVendors(vendors):
for vendor in vendors:
try:
variableName = '%sVendorId' % (vendor['name'])
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define VendorId %s = %s' % (variableName, vendor['id']))
if args.filetype is 'i':
writeToFile('VendorId %s = VendorId(\"%s\");' % (variableName, vendor['id']))
addTranslationString(vendor['displayName'], 'The name of the vendor (%s)' % vendor['id'])
createExternDefinition('VendorId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for VendorId %s -> skipping' % (variableName, param['id']))
except:
pass
if 'deviceClasses' in vendor:
extractDeviceClasses(vendor['deviceClasses'])
#-----------------------------------------------------------------------------------------------------------------
def extractDeviceClasses(deviceClasses):
for deviceClass in deviceClasses:
try:
variableName = '%sDeviceClassId' % (deviceClass['name'])
if 'pairingInfo' in deviceClass:
addTranslationString(deviceClass['pairingInfo'], 'The pairing info of deviceClass %s' % deviceClass['name'])
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define DeviceClassId %s = %s' % (variableName, deviceClass['id']))
if args.filetype is 'i':
writeToFile('DeviceClassId %s = DeviceClassId(\"%s\");' % (variableName, deviceClass['id']))
addTranslationString(deviceClass['displayName'], 'The name of the DeviceClass (%s)' %(deviceClass['id']))
createExternDefinition('DeviceClassId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for DeviceClassId %s -> skipping' % (variableName, deviceClass['deviceClassId']))
except:
pass
if 'paramTypes' in deviceClass:
extractParamTypes(deviceClass['paramTypes'], deviceClass['name'], "", 'device')
if 'settingsTypes' in deviceClass:
extractParamTypes(deviceClass['settingsTypes'], deviceClass['name'], "", 'settings')
if 'discoveryParamTypes' in deviceClass:
extractParamTypes(deviceClass['discoveryParamTypes'], deviceClass['name'], "", 'discovery')
if 'stateTypes' in deviceClass:
extractStateTypes(deviceClass['stateTypes'], deviceClass['name'],)
if 'actionTypes' in deviceClass:
extractActionTypes(deviceClass['actionTypes'], deviceClass['name'])
if 'eventTypes' in deviceClass:
extractEventTypes(deviceClass['eventTypes'], deviceClass['name'])
#-----------------------------------------------------------------------------------------------------------------
def extractStateTypes(stateTypes, deviceClassName):
for stateType in stateTypes:
try:
# Define StateType
variableName = '%s%sStateTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:])
#addTranslationString(stateType['name'], 'The name of the stateType (%s) of DeviceClass %s' % (stateType['id'], deviceClassName))
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define StateTypeId %s = %s' % (variableName, stateType['id']))
if args.filetype is 'i':
writeToFile('StateTypeId %s = StateTypeId(\"%s\");' % (variableName, stateType['id']))
createExternDefinition('StateTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for StateTypeId %s -> skipping' % (variableName, stateType['id']))
# Create EventTypeId for this state
variableName = '%s%sEventTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:])
if not variableName in variableNames:
addTranslationString(stateType['displayNameEvent'], 'The name of the autocreated EventType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
variableNames.append(variableName)
printInfo('Define EventTypeId %s = %s' % (variableName, stateType['id']))
if args.filetype is 'i':
writeToFile('EventTypeId %s = EventTypeId(\"%s\");' % (variableName, stateType['id']))
createExternDefinition('EventTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for autocreated EventTypeId %s -> skipping' % (variableName, stateType['id']))
# ParamType for the autocreated EventType
variableName = '%s%sEvent%sParamTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:], stateType['name'][0].capitalize() + stateType['name'][1:])
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define ParamTypeId %s for StateType %s = %s' % (variableName, variableName, stateType['id']))
addTranslationString(stateType['displayName'], 'The name of the ParamType for the autocreated EventType (DeviceClass: %s, StateType: %s, ID: %s' % (deviceClassName, stateType['name'], stateType['id']))
if args.filetype is 'i':
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
createExternDefinition('ParamTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for ParamTypeId %s -> skipping' % (variableName, stateType['id']))
# Create ActionTypeId and ParamTypeId for action if the state is writable
if 'writable' in stateType and stateType['writable']:
# Create ActionType for the writable state
variableName = '%s%sActionTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:])
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define ActionTypeId for writable StateType %s = %s' % (variableName, stateType['id']))
addTranslationString(stateType['displayNameAction'], 'The name of the autocreated ActionType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
if args.filetype is 'i':
writeToFile('ActionTypeId %s = ActionTypeId(\"%s\");' % (variableName, stateType['id']))
createExternDefinition('ActionTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for autocreated ActionTypeId %s -> skipping' % (variableName, stateType['id']))
# ParamType for the autocreated ActionType
variableName = '%s%sAction%sParamTypeId' % (deviceClassName, stateType['name'][0].capitalize() + stateType['name'][1:], stateType['name'][0].capitalize() + stateType['name'][1:])
if not variableName in variableNames:
variableNames.append(variableName)
printInfo('Define ParamTypeId %s for autocreated ActionType %s = %s' % (variableName, variableName, stateType['id']))
addTranslationString(stateType['displayName'], 'The name of the ParamType for the autocreated ActionType (DeviceClass: %s, StateType: %s, ID: %s)' % (deviceClassName, stateType['name'], stateType['id']))
if args.filetype is 'i':
writeToFile('ParamTypeId %s = ParamTypeId(\"%s\");' % (variableName, stateType['id']))
createExternDefinition('ParamTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for ParamTypeId %s -> skipping' % (variableName, stateType['id']))
except:
pass
#-----------------------------------------------------------------------------------------------------------------
def extractActionTypes(actionTypes, deviceClassName):
for actionType in actionTypes:
try:
# Define ActionTypeId
variableName = '%s%sActionTypeId' % (deviceClassName, actionType['name'][0].capitalize() + actionType['name'][1:])
if not variableName in variableNames:
variableNames.append(variableName)
addTranslationString(actionType['displayName'], 'The name of the ActionType %s of deviceClass %s' % (actionType['id'], deviceClassName))
if args.filetype is 'i':
writeToFile('ActionTypeId %s = ActionTypeId(\"%s\");' % (variableName, actionType['id']))
createExternDefinition('ActionTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for ActionTypeId %s -> skipping' % (variableName, actionType['id']))
except:
pass
# Define paramTypes of this ActionType
if 'paramTypes' in actionType:
extractParamTypes(actionType['paramTypes'], deviceClassName, 'Action', actionType['name'])
#-----------------------------------------------------------------------------------------------------------------
def extractEventTypes(eventTypes, deviceClassName):
for eventType in eventTypes:
try:
# Define EventTypeId
variableName = '%s%sEventTypeId' % (deviceClassName, eventType['name'][0].capitalize() + eventType['name'][1:])
if not variableName in variableNames:
variableNames.append(variableName)
addTranslationString(eventType['displayName'], 'The name of the EventType %s of deviceClass %s' % (eventType['id'], deviceClassName))
if args.filetype is 'i':
writeToFile('EventTypeId %s = EventTypeId(\"%s\");' % (variableName, eventType['id']))
createExternDefinition('EventTypeId', variableName)
else:
printWarning('Duplicated variable name \"%s\" for EventTypeId %s -> skipping' % (variableName, eventType['id']))
except:
pass
# Define paramTypes of this EventType
if 'paramTypes' in eventType:
extractParamTypes(eventType['paramTypes'], deviceClassName, 'Event', eventType['name'])
#-----------------------------------------------------------------------------------------------------------------
def createExternDefinition(type, name):
definition = {}
definition['type'] = type
definition['variable'] = name
externDefinitions.append(definition)
#-----------------------------------------------------------------------------------------------------------------
def addTranslationString(string, comment):
translationStrings.append([string, comment])
#-----------------------------------------------------------------------------------------------------------------
def writeTranslationStrings():
if len(translationStrings) is not 0:
writeToFile('// Translation strings')
writeToFile('const QString translations[] {')
for index, value in enumerate(translationStrings):
writeToFile(' //: %s' % value[1])
if index != len(translationStrings) - 1:
writeToFile(' QT_TRANSLATE_NOOP(\"%s\", \"%s\"), \n' % (pluginMap['name'], value[0]))
else:
writeToFile(' QT_TRANSLATE_NOOP(\"%s\", \"%s\")' % (pluginMap['name'], value[0]))
writeToFile('};')
#-----------------------------------------------------------------------------------------------------------------
def createTranslationFiles():
for translation in args.translations:
translationFile = (sourceDir + '/' + translation)
path, fileName = os.path.split(translationFile)
translationOutput = (path + '/' + pluginMap['id'] + '-' + os.path.splitext(fileName)[0] + '.qm')
printInfo(' --> Translation update %s' % translationFile)
printInfo(subprocess.check_output(['mkdir', '-p', path]))
printInfo(subprocess.check_output(['lupdate', '-recursive', '-no-obsolete', sourceDir, (args.builddir + '/' + args.output), '-ts', translationFile]))
printInfo(' --> Translation release %s' % translationOutput)
printInfo(subprocess.check_output(['lrelease', translationFile, '-qm', translationOutput]))
printInfo(' --> Copy translation files to build dir %s' % args.builddir + '/translations/')
subprocess.check_output(['rsync', '-a', translationOutput, args.builddir + '/translations/'])
#-----------------------------------------------------------------------------------------------------------------
def writePluginInfoFile():
print(' --> Generate plugininfo.h for plugin \"%s\" = %s' % (pluginMap['name'], pluginMap['id']))
writeToFile('/* This file is generated by the nymea build system. Any changes to this file will')
writeToFile(' * be lost.')
writeToFile(' *')
writeToFile(' * If you want to change this file, edit the plugin\'s json file.')
writeToFile(' */')
writeToFile('')
writeToFile('#ifndef PLUGININFO_H')
writeToFile('#define PLUGININFO_H')
writeToFile('')
writeToFile('#include <QLoggingCategory>')
writeToFile('#include <QObject>')
writeToFile('')
writeToFile('#include \"typeutils.h\"')
writeToFile('')
writeToFile('// Id definitions')
extractPlugin(pluginMap)
writeToFile('')
writeToFile('// Logging category')
if 'name' in pluginMap:
debugCategoryName = pluginMap['name'][0].capitalize() + pluginMap['name'][1:]
writeToFile('Q_DECLARE_LOGGING_CATEGORY(dc%s)' % debugCategoryName)
writeToFile('Q_LOGGING_CATEGORY(dc%s, \"%s\")' % (debugCategoryName, debugCategoryName))
printInfo('Define logging category: \'dc%s\'' % debugCategoryName)
writeToFile('')
# Write translation strings
writeTranslationStrings()
writeToFile('')
writeToFile('#endif // PLUGININFO_H')
outputFile.close()
print(' --> Generated successfully \"%s\"' % (args.output))
#-----------------------------------------------------------------------------------------------------------------
def writeExternPluginInfoFile():
print(' --> Generate extern-plugininfo.h for plugin \"%s\" = %s' % (pluginMap['name'], pluginMap['id']))
extractPlugin(pluginMap)
writeToFile('/* This file is generated by the nymea build system. Any changes to this file will')
writeToFile(' * be lost.')
writeToFile(' *')
writeToFile(' * If you want to change this file, edit the plugin\'s json file.')
writeToFile(' */')
writeToFile('')
writeToFile('#ifndef EXTERNPLUGININFO_H')
writeToFile('#define EXTERNPLUGININFO_H')
writeToFile('#include \"typeutils.h\"')
writeToFile('#include <QLoggingCategory>')
writeToFile('')
writeToFile('// Id definitions')
for externDefinition in externDefinitions:
writeToFile('extern %s %s;' % (externDefinition['type'], externDefinition['variable']))
writeToFile('')
writeToFile('// Logging category definition')
if 'name' in pluginMap:
debugCategoryName = pluginMap['name'][0].capitalize() + pluginMap['name'][1:]
writeToFile('Q_DECLARE_LOGGING_CATEGORY(dc%s)' % debugCategoryName)
writeToFile('')
writeToFile('#endif // EXTERNPLUGININFO_H')
outputFile.close()
print(' --> Generated successfully \'%s\'' % (args.output))
##################################################################################################################
# Main
##################################################################################################################
if __name__ == '__main__':
# Argument parser
parser = argparse.ArgumentParser(description='The nymea-generateplugininfo is a precompiler for building plugins. This precompiler will create a plugininfo.h containing the uuid definitions from the plugin json file and creates the translations for the plugin.')
parser.add_argument('-j', '--jsonfile', help='The JSON input file name with the plugin description', metavar='jsonfile', required=True)
parser.add_argument('-b', '--builddir', help='The path to the build directory of the plugin where the plugininfo.h file can be found.', metavar='buildpath', required=True)
parser.add_argument('-f', '--filetype', help='The file type to generate: e = extern infofile, i = infofile', action='store', choices=['e', 'i'], default='i')
parser.add_argument('-o', '--output', help='The plugininfo.h outputFile with the uuid declarations', metavar='output')
parser.add_argument('-t', '--translations', help='The translation files for the plugin.', nargs='*', type=str, metavar='*.ts')
parser.add_argument('-v', '--version', action='version', version=__version__)
args = parser.parse_args()
# Get the source directors
sourceDir = os.path.dirname(os.path.abspath(args.jsonfile))
# Print build information for debugging
printInfo('Json file: %s' % args.jsonfile)
printInfo('Output: %s/%s' % (args.builddir, args.output))
printInfo('Build directory: %s' % args.builddir)
printInfo('Source directory: %s' % sourceDir)
printInfo('Translations: %s' % args.translations)
printInfo('FileType: %s' % args.filetype)
# Tuple ('string to translate', 'comment for translater')
translationStrings = []
variableNames = []
externDefinitions = []
# Open files
try:
inputFile = open(args.jsonfile, 'r')
except:
printError('Could not open file \"%s\"' % (args.jsonfile))
exit -1
try:
outputFile = open(args.builddir + '/' + args.output, 'w')
except:
printError('Could not open file \"%s\"' % (args.jsonfile))
exit -1
# Read json file
try:
pluginMap = json.loads(inputFile.read())
inputFile.close()
except ValueError as error:
printError(' --> Could not load json input file \"%s\"' % (args.input))
printError(' %s' % (error))
inputFile.close()
exit -1
# If there is no translation yet, generate an empty one
translationsDir = "%s/translations/" % sourceDir
baseTranslationFile = "%s/%s-en_US.ts" % (translationsDir, pluginMap['id'])
if not os.path.isfile(baseTranslationFile):
try:
os.stat(translationsDir)
except:
os.mkdir(translationsDir)
try:
tsFile = open(baseTranslationFile, 'w')
tsFile.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE TS>\n<TS version=\"2.1\">\n</TS>")
tsFile.close()
printInfo("Successfully generated base translation file: %s" % baseTranslationFile)
except:
printError("Could not generate %s" % baseTranslationsFile)
# Write files
if args.filetype is 'i':
writePluginInfoFile()
else:
writeExternPluginInfoFile()

View File

@ -1,4 +1,4 @@
# Copyright (C) 2018 Michael Zanetti <michael.zanetti@guh.io>
# Copyright (C) 2019 Michael Zanetti <michael.zanetti@nymea.io>
# Copyright (C) 2018 Simon Stürz <simon.stuerz@guh.io>
#
# This file is part of nymea.
@ -18,10 +18,10 @@
# <http://www.gnu.org/licenses/>.
# This project include file is meant to be used by nymea plugins.
# Example project file for a plugin:
# include(/usr/include/nymea/plugi.pri)
# TARGET = $$qtLibraryTarget(nymea_devicepluginexample)
# include($$[QT_INSTALL_PREFIX]/include/nymea/plugi.pri)
# SOURCES += devicepluginexample.cpp
# HEADERS += devicepluginexample.h
@ -34,32 +34,26 @@ PKGCONFIG += nymea
QMAKE_CXXFLAGS *= -Werror -std=c++11 -g
QMAKE_LFLAGS *= -std=c++11
# Check if ccache is enabled
ccache {
QMAKE_CXX = ccache g++
}
JSONFILE=$${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json
# Make the device plugin json file visible in the Qt Creator
OTHER_FILES+=deviceplugin"$$TARGET".json
OTHER_FILES += $$JSONFILE
# NOTE: if the code includes "plugininfo.h", it would fail if we only give it a compiler for $$OUT_PWD/plugininfo.h
# Let's add a dummy target with the plugininfo.h file without any path to allow the developer to just include it like that.
# Compile the plugininfo.h file
plugininfo.input = JSONFILE
plugininfo.output = plugininfo.h
plugininfo.commands = nymea-plugininfocompiler ${QMAKE_FILE_NAME} --output ${QMAKE_FILE_OUT}
plugininfo.dependency_type = TYPE_C
plugininfo.CONFIG += no_link combine
QMAKE_EXTRA_COMPILERS += plugininfo
# Create plugininfo file
plugininfo.target = $$OUT_PWD/plugininfo.h
plugininfo_dummy.target = plugininfo.h
plugininfo.depends = FORCE
plugininfo.commands = nymea-generateplugininfo --filetype i --jsonfile $${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json --output plugininfo.h --builddir $$OUT_PWD
plugininfo_dummy.commands = $$plugininfo.commands
QMAKE_EXTRA_TARGETS += plugininfo plugininfo_dummy
# Create extern-plugininfo file
extern_plugininfo.target = $$OUT_PWD/extern-plugininfo.h
extern_plugininfo_dummy.target = extern-plugininfo.h
extern_plugininfo.depends = FORCE
extern_plugininfo.commands = nymea-generateplugininfo --filetype e --jsonfile $${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json --output extern-plugininfo.h --builddir $$OUT_PWD
extern_plugininfo_dummy.commands = $$extern_plugininfo.commands
QMAKE_EXTRA_TARGETS += extern_plugininfo extern_plugininfo_dummy
# Compile the extern-plugininfo.h file
extern_plugininfo.input = JSONFILE
extern_plugininfo.output = extern-plugininfo.h
extern_plugininfo.commands = nymea-plugininfocompiler ${QMAKE_FILE_NAME} --extern ${QMAKE_FILE_OUT}
extern_plugininfo.dependency_type = TYPE_C
extern_plugininfo.CONFIG += no_link combine
QMAKE_EXTRA_COMPILERS += extern_plugininfo
# Clean up autogenerated plugin info files
plugininfo_clean.commands = rm -fv $$OUT_PWD/plugininfo.h $$OUT_PWD/extern-plugininfo.h
@ -82,10 +76,7 @@ QMAKE_EXTRA_TARGETS += lrelease
translations.path = /usr/share/nymea/translations
translations.files = $$[QT_SOURCE_TREE]/translations/*.qm
HEADERS += $$OUT_PWD/plugininfo.h \
$$OUT_PWD/extern-plugininfo.h
DEPENDPATH += $$OUT_PWD
# Redefine target to make output file suite the plugin filename schema
TARGET = $$qtLibraryTarget(nymea_deviceplugin"$$TARGET")
# Install plugin

View File

@ -29,6 +29,7 @@
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QMetaObject>
#include <QMetaEnum>
@ -84,37 +85,43 @@ DeviceClasses PluginMetadata::deviceClasses() const
void PluginMetadata::parse(const QJsonObject &jsonObject)
{
bool hasError = false;
// General plugin info
QStringList pluginMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors";
QStringList pluginJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors" << "paramTypes" << "builtIn";
QPair<QStringList, QStringList> verificationResult = verifyFields(pluginJsonProperties, pluginMandatoryJsonProperties, jsonObject);
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping plugin because of missing fields:" << verificationResult.first.join(", ") << endl << jsonObject;
qCWarning(dcPluginMetadata()) << "Plugin has missing fields:" << verificationResult.first.join(", ") << endl << jsonObject;
hasError = true;
// Not gonna continue parsing as we rely on mandatory fields being available
return;
}
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping plugin because of unknown fields:" << verificationResult.second.join(", ") << endl << jsonObject;
return;
qCWarning(dcPluginMetadata()) << "Plugin has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(jsonObject.toVariantMap()).toJson(QJsonDocument::Indented));
hasError = true;
}
m_pluginId = jsonObject.value("id").toString();
m_pluginName = jsonObject.value("name").toString();
m_pluginDisplayName = jsonObject.value("displayName").toString();
// Mandatory fields available... All the rest will be skipped if not valid, but it won't invalidate the entire meta data
m_isValid = true;
if (!verifyDuplicateUuid(m_pluginId)) {
qCWarning(dcPluginMetadata()) << "Plugin" << m_pluginName << "has duplicate UUID:" << m_pluginId.toString();
hasError = true;
}
// parse plugin configuration params
if (jsonObject.contains("paramTypes")) {
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(jsonObject.value("paramTypes").toArray());
if (paramVerification.first) {
m_pluginSettings = paramVerification.second;
} else {
hasError = true;
}
}
// Load vendors
foreach (const QJsonValue &vendorJson, jsonObject.value("vendors").toArray()) {
bool broken = false;
QJsonObject vendorObject = vendorJson.toObject();
QStringList vendorMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "deviceClasses";
@ -124,25 +131,34 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping vendor because of missing fields:" << verificationResult.first.join(", ") << endl << vendorObject;
broken = true;
qCWarning(dcPluginMetadata()) << "Vendor has missing fields:" << verificationResult.first.join(", ") << endl << vendorObject;
hasError = true;
// Not continuing parsing vendor as we rely on mandatory fields being around.
break;
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping vendor because of unknown fields:" << verificationResult.second.join(", ") << endl << vendorObject;
broken = true;
break;
qCWarning(dcPluginMetadata()) << pluginName() << "Vendor has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(vendorObject.toVariantMap()).toJson(QJsonDocument::Indented));
hasError = true;
}
VendorId vendorId = VendorId(vendorObject.value("id").toString());
Vendor vendor(vendorId, vendorObject.value("name").toString());
QString vendorName = vendorObject.value("name").toString();
if (!verifyDuplicateUuid(vendorId)) {
qCWarning(dcPluginMetadata()) << "Vendor" << vendorName << "has duplicate UUID:" << vendorId.toString();
hasError = true;
}
Vendor vendor(vendorId, vendorName);
vendor.setDisplayName(vendorObject.value("displayName").toString());
m_vendors.append(vendor);
// Load deviceclasses of this vendor
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
// FIXME: Drop this when possible, see .h for context
m_currentScopUuids.clear();
QJsonObject deviceClassObject = deviceClassJson.toObject();
/*! Returns a list of all valid JSON properties a DeviceClass JSON definition can have. */
QStringList deviceClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
@ -154,20 +170,27 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class because of missing fields:" << verificationResult.first.join(", ") << endl << deviceClassObject;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class has missing fields:" << verificationResult.first.join(", ") << endl << deviceClassObject;
hasError = true;
// Stop parsing this deviceClass as we rely on mandatory fields being around.
continue;
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class because of unknown fields:" << verificationResult.second.join(", ") << endl << deviceClassObject;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(deviceClassObject.toVariantMap()).toJson(QJsonDocument::Indented));
hasError = true;
}
DeviceClass deviceClass(pluginId(), vendorId, deviceClassObject.value("id").toString());
deviceClass.setName(deviceClassObject.value("name").toString());
DeviceClassId deviceClassId = deviceClassObject.value("id").toString();
QString deviceClassName = deviceClassObject.value("name").toString();
if (!verifyDuplicateUuid(deviceClassId)) {
qCWarning(dcPluginMetadata()) << "Device class" << deviceClassName << "has duplicate UUID:" << deviceClassName;
hasError = true;
}
DeviceClass deviceClass(pluginId(), vendorId, deviceClassId);
deviceClass.setName(deviceClassName);
deviceClass.setDisplayName(deviceClassObject.value("displayName").toString());
// Read create methods
@ -184,9 +207,8 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
} else if (createMethodValue.toString().toLower() == "user") {
createMethods |= DeviceClass::CreateMethodUser;
} else {
qCWarning(dcDevice()) << "Unknown createMehtod" << createMethodValue.toString() << "in deviceClass "
<< deviceClass.name() << ". Falling back to CreateMethodUser.";
createMethods |= DeviceClass::CreateMethodUser;
qCWarning(dcPluginMetadata()) << "Unknown createMehtod" << createMethodValue.toString() << "in deviceClass " << deviceClass.name() << ".";
hasError = true;
}
}
}
@ -195,8 +217,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Read params
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(deviceClassObject.value("paramTypes").toArray());
if (!paramTypesVerification.first) {
broken = true;
break;
hasError = true;
} else {
deviceClass.setParamTypes(paramTypesVerification.second);
}
@ -204,8 +225,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Read settings
QPair<bool, QList<ParamType> > settingsTypesVerification = parseParamTypes(deviceClassObject.value("settingsTypes").toArray());
if (!settingsTypesVerification.first) {
broken = true;
break;
hasError = true;
} else {
deviceClass.setSettingsTypes(settingsTypesVerification.second);
}
@ -213,8 +233,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Read discover params
QPair<bool, QList<ParamType> > discoveryParamVerification = parseParamTypes(deviceClassObject.value("discoveryParamTypes").toArray());
if (!discoveryParamVerification.first) {
broken = true;
break;
hasError = true;
} else {
deviceClass.setDiscoveryParamTypes(discoveryParamVerification.second);
}
@ -232,9 +251,8 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
} else if (setupMethodString.toLower() == "justadd") {
setupMethod = DeviceClass::SetupMethodJustAdd;
} else {
qCWarning(dcDevice()) << "Unknown setupMehtod" << setupMethod << "in deviceClass"
<< deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
setupMethod = DeviceClass::SetupMethodJustAdd;
qCWarning(dcPluginMetadata()) << "Unknown setupMethod" << setupMethod << "in deviceClass" << deviceClass.name() << ".";
hasError = true;
}
}
deviceClass.setSetupMethod(setupMethod);
@ -256,44 +274,48 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in stateType" << st;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class stateType" << deviceClass.name() << "has missing properties" << verificationResult.first.join(", ") << "in stateType" << st;
hasError = true;
// Not processing further as mandatory fields are expected to be here
continue;
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << "because of unknown properties" << verificationResult.second.join(", ") << "in stateType" << st;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class stateType" << deviceClass.name() << "has unknown properties" << verificationResult.second.join(", ") << "in stateType" << st;
hasError = true;
}
// If this is a writable stateType, there must be also the displayNameAction property
if (st.contains("writable") && st.value("writable").toBool()) {
writableState = true;
if (!st.contains("displayNameAction")) {
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << ". The state is writable, but does not define the displayNameAction property" << st;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class" << deviceClass.name() << " has writable state but does not define the displayNameAction property" << st;
hasError = true;
}
}
QVariant::Type t = QVariant::nameToType(st.value("type").toString().toLatin1().data());
if (t == QVariant::Invalid) {
qCWarning(dcDevice()) << "Invalid StateType type:" << st.value("type").toString();
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Invalid StateType type:" << st.value("type").toString();
hasError = true;
}
StateType stateType(st.value("id").toString());
stateType.setName(st.value("name").toString());
StateTypeId stateTypeId = st.value("id").toString();
QString stateTypeName = st.value("name").toString();
if (!verifyDuplicateUuid(stateTypeId)) {
qCWarning(dcPluginMetadata()) << "StateType" << stateTypeName << "has duplicate UUID" << stateTypeId.toString();
hasError = true;
}
StateType stateType(stateTypeId);
stateType.setName(stateTypeName);
stateType.setDisplayName(st.value("displayName").toString());
stateType.setIndex(index++);
stateType.setType(t);
QPair<bool, Types::Unit> unitVerification = loadAndVerifyUnit(st.value("unit").toString());
if (!unitVerification.first) {
broken = true;
break;
hasError = true;
} else {
stateType.setUnit(unitVerification.second);
}
@ -313,9 +335,9 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
stateType.setPossibleValues(possibleValues);
if (!stateType.possibleValues().contains(stateType.defaultValue())) {
qCWarning(dcDevice()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("The given default value \"%1\" is not in the possible values of the stateType \"%2\".")
qCWarning(dcPluginMetadata()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("The given default value \"%1\" is not in the possible values of the stateType \"%2\".")
.arg(stateType.defaultValue().toString()).arg(stateType.name()).toLatin1().data();
broken = true;
hasError = true;
break;
}
}
@ -325,7 +347,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
}
stateTypes.append(stateType);
// Events for state changed
// Events for state changed (Not checking for duplicate UUID, this is expected to be the same as the state!)
EventType eventType(EventTypeId(stateType.id().toString()));
eventType.setName(st.value("name").toString());
eventType.setDisplayName(st.value("displayNameEvent").toString());
@ -360,26 +382,31 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in action type:" << endl << at;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class" << deviceClass.name() << " has missing fields" << verificationResult.first.join(", ") << "in action type:" << endl << at;
hasError = true;
continue;
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of unknown fields:" << verificationResult.second.join(", ") << "in action type:" << endl << at;
broken = true;
break;
qCWarning(dcPluginMetadata()) << pluginName() << "Device class" << deviceClass.name() << "has unknown fields:" << verificationResult.second.join(", ") << "in action type:" << endl << at;
hasError = true;
}
ActionType actionType(at.value("id").toString());
actionType.setName(at.value("name").toString());
ActionTypeId actionTypeId = ActionTypeId(at.value("id").toString());
QString actionTypeName = at.value("name").toString();
if (!verifyDuplicateUuid(actionTypeId)) {
qCWarning(dcPluginMetadata()) << "Action Type" << actionTypeName << "has duplicate UUID:" << actionTypeId.toString();
hasError = true;
}
ActionType actionType(actionTypeId);
actionType.setName(actionTypeName);
actionType.setDisplayName(at.value("displayName").toString());
actionType.setIndex(index++);
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(at.value("paramTypes").toArray());
if (!paramVerification.first) {
broken = true;
hasError = true;
break;
} else {
actionType.setParamTypes(paramVerification.second);
@ -398,27 +425,31 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in event type:" << endl << et;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class" << deviceClass.name() << "has missing fields" << verificationResult.first.join(", ") << "in event type:" << endl << et;
hasError = true;
continue;
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of unknown fields:" << verificationResult.second.join(", ") << "in event type:" << endl << et;
broken = true;
break;
qCWarning(dcPluginMetadata()) << "Device class" << deviceClass.name() << "has unknown fields:" << verificationResult.second.join(", ") << "in event type:" << endl << et;
hasError = true;
}
EventType eventType(et.value("id").toString());
eventType.setName(et.value("name").toString());
EventTypeId eventTypeId = EventTypeId(et.value("id").toString());
QString eventTypeName = et.value("name").toString();
if (!verifyDuplicateUuid(eventTypeId)) {
qCWarning(dcPluginMetadata()) << "Event type" << eventTypeName << "has duplicate UUID:" << eventTypeId.toString();
hasError = true;
}
EventType eventType(eventTypeId);
eventType.setName(eventTypeName);
eventType.setDisplayName(et.value("displayName").toString());
eventType.setIndex(index++);
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(et.value("paramTypes").toArray());
if (!paramVerification.first) {
broken = true;
break;
hasError = true;
} else {
eventType.setParamTypes(paramVerification.second);
}
@ -435,48 +466,47 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
ActionTypes actionTypes(deviceClass.actionTypes());
EventTypes eventTypes(deviceClass.eventTypes());
bool valid = true;
foreach (const StateType &ifaceStateType, iface.stateTypes()) {
StateType stateType = stateTypes.findByName(ifaceStateType.name());
if (stateType.id().isNull()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement state" << ifaceStateType.name();
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement state" << ifaceStateType.name();
hasError = true;
continue;
}
if (ifaceStateType.type() != stateType.type()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching type" << stateType.type() << "!=" << ifaceStateType.type();
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching type" << stateType.type() << "!=" << ifaceStateType.type();
hasError = true;
continue;
}
if (ifaceStateType.minValue().isValid() && !ifaceStateType.minValue().isNull()) {
if (ifaceStateType.minValue().toString() == "any") {
if (stateType.minValue().isNull()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no minimum value defined.";
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no minimum value defined.";
hasError = true;
continue;
}
} else if (ifaceStateType.minValue() != stateType.minValue()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching minimum value:" << ifaceStateType.minValue() << "!=" << stateType.minValue();
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching minimum value:" << ifaceStateType.minValue() << "!=" << stateType.minValue();
hasError = true;
continue;
}
}
if (ifaceStateType.maxValue().isValid() && !ifaceStateType.maxValue().isNull()) {
if (ifaceStateType.maxValue().toString() == "any") {
if (stateType.maxValue().isNull()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no maximum value defined.";
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no maximum value defined.";
hasError = true;
continue;
}
} else if (ifaceStateType.maxValue() != stateType.maxValue()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching maximum value:" << ifaceStateType.maxValue() << "!=" << stateType.minValue();
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching maximum value:" << ifaceStateType.maxValue() << "!=" << stateType.minValue();
hasError = true;
continue;
}
}
if (!ifaceStateType.possibleValues().isEmpty() && ifaceStateType.possibleValues() != stateType.possibleValues()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching allowed values" << ifaceStateType.possibleValues() << "!=" << stateType.possibleValues();
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching allowed values" << ifaceStateType.possibleValues() << "!=" << stateType.possibleValues();
hasError = true;
continue;
}
}
@ -484,18 +514,18 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
foreach (const ActionType &ifaceActionType, iface.actionTypes()) {
ActionType actionType = actionTypes.findByName(ifaceActionType.name());
if (actionType.id().isNull()) {
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action" << ifaceActionType.name();
valid = false;
qCWarning(dcPluginMetadata) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action" << ifaceActionType.name();
hasError = true;
}
foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) {
ParamType paramType = actionType.paramTypes().findByName(ifaceActionParamType.name());
if (!paramType.isValid()) {
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action param" << ifaceActionType.name() << ":" << ifaceActionParamType.name();
valid = false;
qCWarning(dcPluginMetadata) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action param" << ifaceActionType.name() << ":" << ifaceActionParamType.name();
hasError = true;
} else {
if (paramType.type() != ifaceActionParamType.type()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceActionParamType.type());
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceActionParamType.type());
hasError = true;
}
}
}
@ -504,37 +534,36 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
foreach (const EventType &ifaceEventType, iface.eventTypes()) {
EventType eventType = eventTypes.findByName(ifaceEventType.name());
if (!eventType.isValid()) {
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event" << ifaceEventType.name();
valid = false;
qCWarning(dcPluginMetadata) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event" << ifaceEventType.name();
hasError = true;
}
foreach (const ParamType &ifaceEventParamType, ifaceEventType.paramTypes()) {
ParamType paramType = eventType.paramTypes().findByName(ifaceEventParamType.name());
if (!paramType.isValid()) {
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event param" << ifaceEventType.name() << ":" << ifaceEventParamType.name();
valid = false;
qCWarning(dcPluginMetadata) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event param" << ifaceEventType.name() << ":" << ifaceEventParamType.name();
hasError = true;
} else {
if (paramType.type() != ifaceEventParamType.type()) {
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceEventParamType.type());
valid = false;
qCWarning(dcPluginMetadata()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceEventParamType.type());
hasError = true;
}
}
}
}
if (valid) {
interfaces.append(DeviceUtils::generateInterfaceParentList(value.toString()));
}
interfaces.append(DeviceUtils::generateInterfaceParentList(value.toString()));
}
interfaces.removeDuplicates();
deviceClass.setInterfaces(interfaces);
if (!broken) {
m_deviceClasses.append(deviceClass);
} else {
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name();
}
m_deviceClasses.append(deviceClass);
}
}
if (!hasError) {
m_isValid = true;
} else {
qCWarning(dcPluginMetadata()) << "Device metadata has errors.";
}
}
QPair<bool, Types::Unit> PluginMetadata::loadAndVerifyUnit(const QString &unitString)
@ -556,7 +585,7 @@ QPair<bool, Types::Unit> PluginMetadata::loadAndVerifyUnit(const QString &unitSt
// inform the plugin developer about the error in the plugin json file
if (enumValue == -1) {
qCWarning(dcDeviceManager()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("Invalid unit type \"%1\" in json file.").arg(unitString).toLatin1().data();
qCWarning(dcPluginMetadata()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("Invalid unit type \"%1\" in json file.").arg(unitString).toLatin1().data();
return QPair<bool, Types::Unit>(false, Types::UnitNone);
}
@ -596,26 +625,32 @@ QPair<bool, ParamTypes> PluginMetadata::parseParamTypes(const QJsonArray &array)
// Check mandatory fields
if (!verificationResult.first.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Error parsing ParamType: missing fields:" << verificationResult.first.join(", ") << endl << pt;
qCWarning(dcPluginMetadata()) << pluginName() << "Error parsing ParamType: missing fields:" << verificationResult.first.join(", ") << endl << pt;
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
}
// Check if there are any unknown fields
if (!verificationResult.second.isEmpty()) {
qCWarning(dcDevice()) << pluginName() << "Error parsing ParamType: unknown fields:" << verificationResult.second.join(", ") << endl << pt;
qCWarning(dcPluginMetadata()) << pluginName() << "Error parsing ParamType: unknown fields:" << verificationResult.second.join(", ") << endl << pt;
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
}
// Check type
QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data());
if (t == QVariant::Invalid) {
qCWarning(dcDevice()) << pluginName() << QString("Invalid type %1 for param %2 in json file.")
qCWarning(dcPluginMetadata()) << pluginName() << QString("Invalid type %1 for param %2 in json file.")
.arg(pt.value("type").toString())
.arg(pt.value("name").toString()).toLatin1().data();
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
}
ParamType paramType(ParamTypeId(pt.value("id").toString()), pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
ParamTypeId paramTypeId = ParamTypeId(pt.value("id").toString());
QString paramName = pt.value("name").toString();
if (!verifyDuplicateUuid(paramTypeId)) {
qCWarning(dcPluginMetadata()) << "Param" << paramName << "has duplicate UUID:" << paramTypeId.toString();
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
}
ParamType paramType(paramTypeId, paramName, t, pt.value("defaultValue").toVariant());
paramType.setDisplayName(pt.value("displayName").toString());
@ -629,7 +664,7 @@ QPair<bool, ParamTypes> PluginMetadata::parseParamTypes(const QJsonArray &array)
if (pt.contains("inputType")) {
QPair<bool, Types::InputType> inputTypeVerification = loadAndVerifyInputType(pt.value("inputType").toString());
if (!inputTypeVerification.first) {
qCWarning(dcDevice()) << pluginName() << QString("Invalid inputType for paramType") << pt;
qCWarning(dcPluginMetadata()) << pluginName() << QString("Invalid inputType for paramType") << pt;
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
} else {
paramType.setInputType(inputTypeVerification.second);
@ -640,7 +675,7 @@ QPair<bool, ParamTypes> PluginMetadata::parseParamTypes(const QJsonArray &array)
if (pt.contains("unit")) {
QPair<bool, Types::Unit> unitVerification = loadAndVerifyUnit(pt.value("unit").toString());
if (!unitVerification.first) {
qCWarning(dcDevice()) << pluginName() << QString("Invalid unit type for paramType") << pt;
qCWarning(dcPluginMetadata()) << pluginName() << QString("Invalid unit type for paramType") << pt;
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
} else {
paramType.setUnit(unitVerification.second);
@ -679,9 +714,23 @@ QPair<bool, Types::InputType> PluginMetadata::loadAndVerifyInputType(const QStri
// inform the plugin developer about the error in the plugin json file
if (enumValue == -1) {
qCWarning(dcDeviceManager()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("Invalid inputType \"%1\" in json file.").arg(inputType).toLatin1().data();
qCWarning(dcPluginMetadata()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("Invalid inputType \"%1\" in json file.").arg(inputType).toLatin1().data();
return QPair<bool, Types::InputType>(false, Types::InputTypeNone);
}
return QPair<bool, Types::InputType>(true, (Types::InputType)enumValue);
}
bool PluginMetadata::verifyDuplicateUuid(const QUuid &uuid)
{
if (m_allUuids.contains(uuid)) {
// FIXME: Drop debug, activate return! (see .h for more context)
qCWarning(dcPluginMetadata()) << "THIS PLUGIN USES DUPLICATE UUID" << uuid.toString() << "! THIS WILL STOP WORKING SOON.";
// return false;
}
if (m_currentScopUuids.contains(uuid)) {
return false;
}
m_allUuids.append(uuid);
return true;
}

View File

@ -52,6 +52,8 @@ private:
QPair<bool, Types::Unit> loadAndVerifyUnit(const QString &unitString);
QPair<bool, Types::InputType> loadAndVerifyInputType(const QString &inputType);
bool verifyDuplicateUuid(const QUuid &uuid);
private:
bool m_isValid = false;
bool m_isBuiltIn = false;
@ -61,6 +63,14 @@ private:
ParamTypes m_pluginSettings;
Vendors m_vendors;
DeviceClasses m_deviceClasses;
QList<QUuid> m_allUuids;
// FIXME: Due to the fact that we have duplicate UUIDs in use in plugins out there in
// products, we can't just break those plugins now. For now, let's make the check
// As strict as possible without breaking them, but this should be removed ASAP
// and only m_allUuids should be used to check for dupes
QList<QUuid> m_currentScopUuids;
};
#endif // PLUGINMETADATA_H

View File

@ -142,11 +142,6 @@ RESOURCES += \
## Install instructions
# install plugininfo python script for libnymea-dev
generateplugininfo.files = devices/nymea-generateplugininfo
generateplugininfo.path = $$[QT_INSTALL_PREFIX]/bin
INSTALLS += generateplugininfo
# install plugin.pri for external plugins
pluginpri.files = devices/plugin.pri
pluginpri.path = $$[QT_INSTALL_PREFIX]/include/nymea/

View File

@ -23,6 +23,7 @@
#include "loggingcategories.h"
Q_LOGGING_CATEGORY(dcApplication, "Application")
Q_LOGGING_CATEGORY(dcPluginMetadata, "PluginMetadata")
Q_LOGGING_CATEGORY(dcDevice, "Device")
Q_LOGGING_CATEGORY(dcDeviceManager, "DeviceManager")
Q_LOGGING_CATEGORY(dcSystem, "System")

View File

@ -28,6 +28,7 @@
// Core / libnymea
Q_DECLARE_LOGGING_CATEGORY(dcApplication)
Q_DECLARE_LOGGING_CATEGORY(dcPluginMetadata)
Q_DECLARE_LOGGING_CATEGORY(dcDevice)
Q_DECLARE_LOGGING_CATEGORY(dcDeviceManager)
Q_DECLARE_LOGGING_CATEGORY(dcSystem)

View File

@ -5,6 +5,9 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"
JSON_PROTOCOL_VERSION_MAJOR=2
JSON_PROTOCOL_VERSION_MINOR=2
REST_API_VERSION=1
LIBNYMEA_API_VERSION_MAJOR=2
LIBNYMEA_API_VERSION_MINOR=1
LIBNYMEA_API_VERSION_PATCH=0
COPYRIGHT_YEAR_FROM=2013
COPYRIGHT_YEAR_TO=2019
@ -12,7 +15,8 @@ COPYRIGHT_YEAR_TO=2019
DEFINES += NYMEA_VERSION_STRING=\\\"$${NYMEA_VERSION_STRING}\\\" \
JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}\\\" \
REST_API_VERSION=\\\"$${REST_API_VERSION}\\\" \
COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\"
COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\" \
LIBNYMEA_API_VERSION=\\\"$${LIBNYMEA_API_VERSION_MAJOR}.$${LIBNYMEA_API_VERSION_MINOR}.$${LIBNYMEA_API_VERSION_PATCH}\\\"
QT *= network websockets bluetooth dbus

View File

@ -2,11 +2,12 @@ include(nymea.pri)
TEMPLATE=subdirs
SUBDIRS += libnymea libnymea-core server plugins
SUBDIRS += libnymea libnymea-core server plugins tools
libnymea-core.depends = libnymea
server.depends = libnymea libnymea-core plugins
plugins.depends = libnymea
tools.depends = libnymea
plugins.depends = libnymea tools
tests.depends = libnymea libnymea-core
doc.depends = FORCE

View File

@ -224,13 +224,13 @@ Device::DeviceError DevicePluginMock::executeAction(Device *device, const Action
return Device::DeviceErrorDeviceNotFound;
if (device->deviceClassId() == mockDeviceClassId) {
if (action.actionTypeId() == mockMockAsyncActionTypeId || action.actionTypeId() == mockMockAsyncFailingActionTypeId) {
if (action.actionTypeId() == mockAsyncActionTypeId || action.actionTypeId() == mockAsyncFailingActionTypeId) {
m_asyncActions.append(qMakePair<Action, Device*>(action, device));
QTimer::singleShot(1000, this, SLOT(emitActionExecuted()));
return Device::DeviceErrorAsync;
}
if (action.actionTypeId() == mockMockFailingActionTypeId)
if (action.actionTypeId() == mockFailingActionTypeId)
return Device::DeviceErrorSetupFailed;
if (action.actionTypeId() == mockPowerActionTypeId) {
@ -514,10 +514,10 @@ void DevicePluginMock::emitDeviceSetupFinished()
void DevicePluginMock::emitActionExecuted()
{
QPair<Action, Device*> action = m_asyncActions.takeFirst();
if (action.first.actionTypeId() == mockMockAsyncActionTypeId) {
if (action.first.actionTypeId() == mockAsyncActionTypeId) {
m_daemons.value(action.second)->actionExecuted(action.first.actionTypeId());
emit actionExecutionFinished(action.first.id(), Device::DeviceErrorNoError);
} else if (action.first.actionTypeId() == mockMockAsyncFailingActionTypeId) {
} else if (action.first.actionTypeId() == mockAsyncFailingActionTypeId) {
emit actionExecutionFinished(action.first.id(), Device::DeviceErrorSetupFailed);
}
}

View File

@ -30,7 +30,7 @@
"id": "753f0d32-0468-4d08-82ed-1964aab03298",
"name": "mock",
"displayName": "Mock Device",
"interfaces": ["system", "light", "gateway", "battery"],
"interfaces": ["system", "light", "battery"],
"createMethods": ["user", "discovery"],
"discoveryParamTypes": [
{
@ -135,17 +135,17 @@
"eventTypes": [
{
"id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b",
"name": "mockEvent1",
"name": "event1",
"displayName": "Mock Event 1"
},
{
"id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf",
"name": "mockEvent2",
"name": "event2",
"displayName": "Mock Event 2",
"paramTypes": [
{
"id": "0550e16d-60b9-4ba5-83f4-4d3cee656121",
"name": "mockParamInt",
"name": "intParam",
"displayName": "mockParamInt",
"type": "int",
"defaultValue": 10
@ -161,13 +161,13 @@
"paramTypes": [
{
"id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb",
"name": "mockActionParam1",
"name": "param1",
"displayName": "mockActionParam1",
"type": "int"
},
{
"id": "304a4899-18be-4e3b-94f4-d03be52f3233",
"name": "mockActionParam2",
"name": "param2",
"displayName": "mockActionParam2",
"type": "bool"
}
@ -180,17 +180,17 @@
},
{
"id": "fbae06d3-7666-483e-a39e-ec50fe89054e",
"name": "mockAsync",
"name": "async",
"displayName": "Mock Action 3 (async)"
},
{
"id": "df3cf33d-26d5-4577-9132-9823bd33fad0",
"name": "mockFailing",
"name": "failing",
"displayName": "Mock Action 4 (broken)"
},
{
"id": "bfe89a1d-3497-4121-8318-e77c37537219",
"name": "mockAsyncFailing",
"name": "asyncFailing",
"displayName": "Mock Action 5 (async, broken)"
}
]
@ -203,13 +203,13 @@
"createMethods": ["auto"],
"paramTypes": [
{
"id": "d4f06047-125e-4479-9810-b54c189917f5",
"id": "bfeb0613-dab6-408c-aa27-c362c921d0d1",
"name": "httpport",
"displayName": "http port",
"type": "int"
},
{
"id": "f2977061-4dd0-4ef5-85aa-3b7134743be3",
"id": "a5c4315f-0624-4971-87c1-4bbfbfdbd16e",
"name": "async",
"displayName": "async",
"type": "bool",
@ -217,7 +217,7 @@
"readOnly": true
},
{
"id": "ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4",
"id": "66179395-ef7a-4013-9fc6-2084104eea09",
"name": "broken",
"displayName": "broken",
"type": "bool",
@ -226,7 +226,7 @@
],
"stateTypes": [
{
"id": "80baec19-54de-4948-ac46-31eabfaceb83",
"id": "74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c",
"name": "int",
"displayName": "Dummy int state",
"displayNameEvent": "Dummy int state changed",
@ -234,7 +234,7 @@
"type": "int"
},
{
"id": "9dd6a97c-dfd1-43dc-acbd-367932742310",
"id": "978b0ba5-d008-41bd-b63d-a3bd23cb6469",
"name": "boolValue",
"displayName": "Dummy bool state",
"displayNameEvent": "Dummy bool state changed",
@ -245,18 +245,18 @@
],
"eventTypes": [
{
"id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b",
"id": "00f81fca-26f1-4a84-aa2b-4c6a3d953ec6",
"name": "event1",
"displayName": "Mock Event 1"
},
{
"id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf",
"id": "6e27922d-aa9d-44d1-b9b4-9faf31b6bd97",
"name": "event2",
"displayName": "Mock Event 2",
"paramTypes": [
{
"id": "0550e16d-60b9-4ba5-83f4-4d3cee656121",
"name": "mockParamInt",
"id": "12ed5a15-96b4-4381-9d9c-a24875283d4f",
"name": "intParam",
"displayName": "mockParamInt",
"type": "int",
"defaultValue": 10
@ -266,18 +266,18 @@
],
"actionTypes": [
{
"id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185",
"id": "e6a22f52-1818-46a7-9d15-5ca08b0612c",
"name": "withParams",
"displayName": "Mock Action 1 (with params)",
"paramTypes": [
{
"id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb",
"id": "b8126ba6-3a54-45a3-be4d-63feb0ddb77b",
"name": "mockActionParam1",
"displayName": "mockActionParam1",
"type": "int"
},
{
"id": "304a4899-18be-4e3b-94f4-d03be52f3233",
"id": "df41ba71-e43b-4854-91d1-b19d8066d4f9",
"name": "mockActionParam2",
"displayName": "mockActionParam2",
"type": "bool"
@ -285,22 +285,22 @@
]
},
{
"id": "defd3ed6-1a0d-400b-8879-a0202cf39935",
"id": "ef518d53-50e2-4ca5-a4b1-e9a8b9309d44",
"name": "mockActionNoParms",
"displayName": "Mock Action 2 (without params)"
},
{
"id": "fbae06d3-7666-483e-a39e-ec50fe89054e",
"id": "5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed",
"name": "mockActionAsync",
"displayName": "Mock Action 3 (async)"
},
{
"id": "df3cf33d-26d5-4577-9132-9823bd33fad0",
"id": "58a61de4-472c-4775-8fe8-583a9c83fcf1",
"name": "mockActionBroken",
"displayName": "Mock Action 4 (broken)"
},
{
"id": "bfe89a1d-3497-4121-8318-e77c37537219",
"id": "17ad52dd-ef2f-4947-9b73-5bf6e172a9d0",
"name": "mockActionAsyncBroken",
"displayName": "Mock Action 5 (async, broken)"
}
@ -317,7 +317,7 @@
"paramTypes": [ ],
"discoveryParamTypes": [
{
"id": "d222adb4-2f9c-4c3f-8655-76400d0fb6ce",
"id": "c40dbc59-4bba-4871-9b8e-bbd8d5d9193b",
"name": "resultCount",
"displayName": "resultCount",
"type": "int",
@ -406,7 +406,7 @@
"pairingInfo": "Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681.",
"discoveryParamTypes": [
{
"id": "d222adb4-2f9c-4c3f-8655-76400d0fb6ce",
"id": "35f6e4ba-28ad-4152-a58d-ec2600667bcf",
"name": "resultCount",
"displayName": "resultCount",
"type": "int",
@ -427,7 +427,7 @@
],
"stateTypes": [
{
"id": "20dc7c22-c50e-42db-837c-2bbced939f8e",
"id": "3e161294-8a0d-4384-9676-6959e08cc2fa",
"name": "color",
"displayName": "color",
"displayNameEvent": "color changed",
@ -437,7 +437,7 @@
"writable": true
},
{
"id": "72981c04-267a-4ba0-a59e-9921d2f3af9c",
"id": "527f0687-0b28-4c26-852c-25b8f83e4797",
"name": "percentage",
"displayName": "percentage",
"displayNameEvent": "percentage changed",
@ -450,7 +450,7 @@
"writable": true
},
{
"id": "05f63f9c-f61e-4dcf-ad55-3f13fde2765b",
"id": "b463c5ae-4d55-402f-8480-a5cdb485c143",
"name": "allowedValues",
"displayName": "allowed values",
"displayNameEvent": "allowed values changed",
@ -466,7 +466,7 @@
"writable": true
},
{
"id": "53cd7c55-49b7-441b-b970-9048f20f0e2c",
"id": "17635624-7c19-4bae-8429-2f7aa5d2f843",
"name": "double",
"displayName": "double value",
"displayNameEvent": "double value changed",
@ -478,7 +478,7 @@
"writable": true
},
{
"id": "e680f7a4-b39e-46da-be41-fa3170fe3768",
"id": "7ffe514f-7999-4998-8350-0e73e222a8c4",
"name": "bool",
"displayName": "bool value",
"displayNameEvent": "bool value changed",
@ -490,7 +490,7 @@
],
"actionTypes": [
{
"id": "54646e7c-bc54-4895-81a2-590d72d120f9",
"id": "854a0a4a-803f-4b7f-9dce-b07794f9011b",
"name": "timeout",
"displayName": "Timeout action"
}
@ -524,7 +524,7 @@
"paramTypes": [],
"stateTypes": [
{
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
"id": "80ba1449-b485-47d4-a067-6bf306e2a568",
"name": "boolValue",
"displayName": "bool value",
"displayNameEvent": "bool value changed",

View File

@ -0,0 +1,245 @@
/* This file is generated by the nymea build system. Any changes to this file will *
* be lost. If you want to change this file, edit the plugin's json file. */
#ifndef EXTERNPLUGININFO_H
#define EXTERNPLUGININFO_H
#include "typeutils.h"
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(dcMockDevice)
extern PluginId pluginId;
extern ParamTypeId mockDevicePluginConfigParamIntParamTypeId;
extern ParamTypeId mockDevicePluginConfigParamBoolParamTypeId;
extern VendorId nymeaVendorId;
extern DeviceClassId mockDeviceClassId;
extern ParamTypeId mockDeviceHttpportParamTypeId;
extern ParamTypeId mockDeviceAsyncParamTypeId;
extern ParamTypeId mockDeviceBrokenParamTypeId;
extern ParamTypeId mockSettingsSetting1ParamTypeId;
extern ParamTypeId mockDiscoveryResultCountParamTypeId;
extern StateTypeId mockIntStateTypeId;
extern StateTypeId mockBoolStateTypeId;
extern StateTypeId mockDoubleStateTypeId;
extern StateTypeId mockBatteryLevelStateTypeId;
extern StateTypeId mockBatteryCriticalStateTypeId;
extern StateTypeId mockPowerStateTypeId;
extern EventTypeId mockIntEventTypeId;
extern ParamTypeId mockIntEventIntParamTypeId;
extern EventTypeId mockBoolEventTypeId;
extern ParamTypeId mockBoolEventBoolParamTypeId;
extern EventTypeId mockDoubleEventTypeId;
extern ParamTypeId mockDoubleEventDoubleParamTypeId;
extern EventTypeId mockBatteryLevelEventTypeId;
extern ParamTypeId mockBatteryLevelEventBatteryLevelParamTypeId;
extern EventTypeId mockBatteryCriticalEventTypeId;
extern ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId;
extern EventTypeId mockPowerEventTypeId;
extern ParamTypeId mockPowerEventPowerParamTypeId;
extern EventTypeId mockEvent1EventTypeId;
extern EventTypeId mockEvent2EventTypeId;
extern ParamTypeId mockEvent2EventIntParamParamTypeId;
extern ActionTypeId mockPowerActionTypeId;
extern ParamTypeId mockPowerActionPowerParamTypeId;
extern ActionTypeId mockWithParamsActionTypeId;
extern ParamTypeId mockWithParamsActionParam1ParamTypeId;
extern ParamTypeId mockWithParamsActionParam2ParamTypeId;
extern ActionTypeId mockWithoutParamsActionTypeId;
extern ActionTypeId mockAsyncActionTypeId;
extern ActionTypeId mockFailingActionTypeId;
extern ActionTypeId mockAsyncFailingActionTypeId;
extern DeviceClassId mockDeviceAutoDeviceClassId;
extern ParamTypeId mockDeviceAutoDeviceHttpportParamTypeId;
extern ParamTypeId mockDeviceAutoDeviceAsyncParamTypeId;
extern ParamTypeId mockDeviceAutoDeviceBrokenParamTypeId;
extern StateTypeId mockDeviceAutoIntStateTypeId;
extern StateTypeId mockDeviceAutoBoolValueStateTypeId;
extern EventTypeId mockDeviceAutoIntEventTypeId;
extern ParamTypeId mockDeviceAutoIntEventIntParamTypeId;
extern EventTypeId mockDeviceAutoBoolValueEventTypeId;
extern ParamTypeId mockDeviceAutoBoolValueEventBoolValueParamTypeId;
extern EventTypeId mockDeviceAutoEvent1EventTypeId;
extern EventTypeId mockDeviceAutoEvent2EventTypeId;
extern ParamTypeId mockDeviceAutoEvent2EventIntParamParamTypeId;
extern ActionTypeId mockDeviceAutoWithParamsActionTypeId;
extern ParamTypeId mockDeviceAutoWithParamsActionMockActionParam1ParamTypeId;
extern ParamTypeId mockDeviceAutoWithParamsActionMockActionParam2ParamTypeId;
extern ActionTypeId mockDeviceAutoMockActionNoParmsActionTypeId;
extern ActionTypeId mockDeviceAutoMockActionAsyncActionTypeId;
extern ActionTypeId mockDeviceAutoMockActionBrokenActionTypeId;
extern ActionTypeId mockDeviceAutoMockActionAsyncBrokenActionTypeId;
extern DeviceClassId mockPushButtonDeviceClassId;
extern ParamTypeId mockPushButtonDiscoveryResultCountParamTypeId;
extern StateTypeId mockPushButtonColorStateTypeId;
extern StateTypeId mockPushButtonPercentageStateTypeId;
extern StateTypeId mockPushButtonAllowedValuesStateTypeId;
extern StateTypeId mockPushButtonDoubleStateTypeId;
extern StateTypeId mockPushButtonBoolStateTypeId;
extern EventTypeId mockPushButtonColorEventTypeId;
extern ParamTypeId mockPushButtonColorEventColorParamTypeId;
extern EventTypeId mockPushButtonPercentageEventTypeId;
extern ParamTypeId mockPushButtonPercentageEventPercentageParamTypeId;
extern EventTypeId mockPushButtonAllowedValuesEventTypeId;
extern ParamTypeId mockPushButtonAllowedValuesEventAllowedValuesParamTypeId;
extern EventTypeId mockPushButtonDoubleEventTypeId;
extern ParamTypeId mockPushButtonDoubleEventDoubleParamTypeId;
extern EventTypeId mockPushButtonBoolEventTypeId;
extern ParamTypeId mockPushButtonBoolEventBoolParamTypeId;
extern ActionTypeId mockPushButtonColorActionTypeId;
extern ParamTypeId mockPushButtonColorActionColorParamTypeId;
extern ActionTypeId mockPushButtonPercentageActionTypeId;
extern ParamTypeId mockPushButtonPercentageActionPercentageParamTypeId;
extern ActionTypeId mockPushButtonAllowedValuesActionTypeId;
extern ParamTypeId mockPushButtonAllowedValuesActionAllowedValuesParamTypeId;
extern ActionTypeId mockPushButtonDoubleActionTypeId;
extern ParamTypeId mockPushButtonDoubleActionDoubleParamTypeId;
extern ActionTypeId mockPushButtonBoolActionTypeId;
extern ParamTypeId mockPushButtonBoolActionBoolParamTypeId;
extern ActionTypeId mockPushButtonTimeoutActionTypeId;
extern DeviceClassId mockDisplayPinDeviceClassId;
extern ParamTypeId mockDisplayPinDevicePinParamTypeId;
extern ParamTypeId mockDisplayPinDiscoveryResultCountParamTypeId;
extern StateTypeId mockDisplayPinColorStateTypeId;
extern StateTypeId mockDisplayPinPercentageStateTypeId;
extern StateTypeId mockDisplayPinAllowedValuesStateTypeId;
extern StateTypeId mockDisplayPinDoubleStateTypeId;
extern StateTypeId mockDisplayPinBoolStateTypeId;
extern EventTypeId mockDisplayPinColorEventTypeId;
extern ParamTypeId mockDisplayPinColorEventColorParamTypeId;
extern EventTypeId mockDisplayPinPercentageEventTypeId;
extern ParamTypeId mockDisplayPinPercentageEventPercentageParamTypeId;
extern EventTypeId mockDisplayPinAllowedValuesEventTypeId;
extern ParamTypeId mockDisplayPinAllowedValuesEventAllowedValuesParamTypeId;
extern EventTypeId mockDisplayPinDoubleEventTypeId;
extern ParamTypeId mockDisplayPinDoubleEventDoubleParamTypeId;
extern EventTypeId mockDisplayPinBoolEventTypeId;
extern ParamTypeId mockDisplayPinBoolEventBoolParamTypeId;
extern ActionTypeId mockDisplayPinColorActionTypeId;
extern ParamTypeId mockDisplayPinColorActionColorParamTypeId;
extern ActionTypeId mockDisplayPinPercentageActionTypeId;
extern ParamTypeId mockDisplayPinPercentageActionPercentageParamTypeId;
extern ActionTypeId mockDisplayPinAllowedValuesActionTypeId;
extern ParamTypeId mockDisplayPinAllowedValuesActionAllowedValuesParamTypeId;
extern ActionTypeId mockDisplayPinDoubleActionTypeId;
extern ParamTypeId mockDisplayPinDoubleActionDoubleParamTypeId;
extern ActionTypeId mockDisplayPinBoolActionTypeId;
extern ParamTypeId mockDisplayPinBoolActionBoolParamTypeId;
extern ActionTypeId mockDisplayPinTimeoutActionTypeId;
extern DeviceClassId mockParentDeviceClassId;
extern StateTypeId mockParentBoolValueStateTypeId;
extern EventTypeId mockParentBoolValueEventTypeId;
extern ParamTypeId mockParentBoolValueEventBoolValueParamTypeId;
extern ActionTypeId mockParentBoolValueActionTypeId;
extern ParamTypeId mockParentBoolValueActionBoolValueParamTypeId;
extern DeviceClassId mockChildDeviceClassId;
extern StateTypeId mockChildBoolValueStateTypeId;
extern EventTypeId mockChildBoolValueEventTypeId;
extern ParamTypeId mockChildBoolValueEventBoolValueParamTypeId;
extern ActionTypeId mockChildBoolValueActionTypeId;
extern ParamTypeId mockChildBoolValueActionBoolValueParamTypeId;
extern DeviceClassId mockInputTypeDeviceClassId;
extern ParamTypeId mockInputTypeDeviceTextLineParamTypeId;
extern ParamTypeId mockInputTypeDeviceTextAreaParamTypeId;
extern ParamTypeId mockInputTypeDevicePasswordParamTypeId;
extern ParamTypeId mockInputTypeDeviceSearchParamTypeId;
extern ParamTypeId mockInputTypeDeviceMailParamTypeId;
extern ParamTypeId mockInputTypeDeviceIp4ParamTypeId;
extern ParamTypeId mockInputTypeDeviceIp6ParamTypeId;
extern ParamTypeId mockInputTypeDeviceUrlParamTypeId;
extern ParamTypeId mockInputTypeDeviceMacParamTypeId;
extern StateTypeId mockInputTypeBoolStateTypeId;
extern StateTypeId mockInputTypeWritableBoolStateTypeId;
extern StateTypeId mockInputTypeIntStateTypeId;
extern StateTypeId mockInputTypeWritableIntStateTypeId;
extern StateTypeId mockInputTypeWritableIntMinMaxStateTypeId;
extern StateTypeId mockInputTypeUintStateTypeId;
extern StateTypeId mockInputTypeWritableUIntStateTypeId;
extern StateTypeId mockInputTypeWritableUIntMinMaxStateTypeId;
extern StateTypeId mockInputTypeDoubleStateTypeId;
extern StateTypeId mockInputTypeWritableDoubleStateTypeId;
extern StateTypeId mockInputTypeWritableDoubleMinMaxStateTypeId;
extern StateTypeId mockInputTypeStringStateTypeId;
extern StateTypeId mockInputTypeWritableStringStateTypeId;
extern StateTypeId mockInputTypeWritableStringSelectionStateTypeId;
extern StateTypeId mockInputTypeColorStateTypeId;
extern StateTypeId mockInputTypeWritableColorStateTypeId;
extern StateTypeId mockInputTypeTimeStateTypeId;
extern StateTypeId mockInputTypeWritableTimeStateTypeId;
extern StateTypeId mockInputTypeTimestampIntStateTypeId;
extern StateTypeId mockInputTypeWritableTimestampIntStateTypeId;
extern StateTypeId mockInputTypeTimestampUIntStateTypeId;
extern StateTypeId mockInputTypeWritableTimestampUIntStateTypeId;
extern EventTypeId mockInputTypeBoolEventTypeId;
extern ParamTypeId mockInputTypeBoolEventBoolParamTypeId;
extern EventTypeId mockInputTypeWritableBoolEventTypeId;
extern ParamTypeId mockInputTypeWritableBoolEventWritableBoolParamTypeId;
extern EventTypeId mockInputTypeIntEventTypeId;
extern ParamTypeId mockInputTypeIntEventIntParamTypeId;
extern EventTypeId mockInputTypeWritableIntEventTypeId;
extern ParamTypeId mockInputTypeWritableIntEventWritableIntParamTypeId;
extern EventTypeId mockInputTypeWritableIntMinMaxEventTypeId;
extern ParamTypeId mockInputTypeWritableIntMinMaxEventWritableIntMinMaxParamTypeId;
extern EventTypeId mockInputTypeUintEventTypeId;
extern ParamTypeId mockInputTypeUintEventUintParamTypeId;
extern EventTypeId mockInputTypeWritableUIntEventTypeId;
extern ParamTypeId mockInputTypeWritableUIntEventWritableUIntParamTypeId;
extern EventTypeId mockInputTypeWritableUIntMinMaxEventTypeId;
extern ParamTypeId mockInputTypeWritableUIntMinMaxEventWritableUIntMinMaxParamTypeId;
extern EventTypeId mockInputTypeDoubleEventTypeId;
extern ParamTypeId mockInputTypeDoubleEventDoubleParamTypeId;
extern EventTypeId mockInputTypeWritableDoubleEventTypeId;
extern ParamTypeId mockInputTypeWritableDoubleEventWritableDoubleParamTypeId;
extern EventTypeId mockInputTypeWritableDoubleMinMaxEventTypeId;
extern ParamTypeId mockInputTypeWritableDoubleMinMaxEventWritableDoubleMinMaxParamTypeId;
extern EventTypeId mockInputTypeStringEventTypeId;
extern ParamTypeId mockInputTypeStringEventStringParamTypeId;
extern EventTypeId mockInputTypeWritableStringEventTypeId;
extern ParamTypeId mockInputTypeWritableStringEventWritableStringParamTypeId;
extern EventTypeId mockInputTypeWritableStringSelectionEventTypeId;
extern ParamTypeId mockInputTypeWritableStringSelectionEventWritableStringSelectionParamTypeId;
extern EventTypeId mockInputTypeColorEventTypeId;
extern ParamTypeId mockInputTypeColorEventColorParamTypeId;
extern EventTypeId mockInputTypeWritableColorEventTypeId;
extern ParamTypeId mockInputTypeWritableColorEventWritableColorParamTypeId;
extern EventTypeId mockInputTypeTimeEventTypeId;
extern ParamTypeId mockInputTypeTimeEventTimeParamTypeId;
extern EventTypeId mockInputTypeWritableTimeEventTypeId;
extern ParamTypeId mockInputTypeWritableTimeEventWritableTimeParamTypeId;
extern EventTypeId mockInputTypeTimestampIntEventTypeId;
extern ParamTypeId mockInputTypeTimestampIntEventTimestampIntParamTypeId;
extern EventTypeId mockInputTypeWritableTimestampIntEventTypeId;
extern ParamTypeId mockInputTypeWritableTimestampIntEventWritableTimestampIntParamTypeId;
extern EventTypeId mockInputTypeTimestampUIntEventTypeId;
extern ParamTypeId mockInputTypeTimestampUIntEventTimestampUIntParamTypeId;
extern EventTypeId mockInputTypeWritableTimestampUIntEventTypeId;
extern ParamTypeId mockInputTypeWritableTimestampUIntEventWritableTimestampUIntParamTypeId;
extern ActionTypeId mockInputTypeWritableBoolActionTypeId;
extern ParamTypeId mockInputTypeWritableBoolActionWritableBoolParamTypeId;
extern ActionTypeId mockInputTypeWritableIntActionTypeId;
extern ParamTypeId mockInputTypeWritableIntActionWritableIntParamTypeId;
extern ActionTypeId mockInputTypeWritableIntMinMaxActionTypeId;
extern ParamTypeId mockInputTypeWritableIntMinMaxActionWritableIntMinMaxParamTypeId;
extern ActionTypeId mockInputTypeWritableUIntActionTypeId;
extern ParamTypeId mockInputTypeWritableUIntActionWritableUIntParamTypeId;
extern ActionTypeId mockInputTypeWritableUIntMinMaxActionTypeId;
extern ParamTypeId mockInputTypeWritableUIntMinMaxActionWritableUIntMinMaxParamTypeId;
extern ActionTypeId mockInputTypeWritableDoubleActionTypeId;
extern ParamTypeId mockInputTypeWritableDoubleActionWritableDoubleParamTypeId;
extern ActionTypeId mockInputTypeWritableDoubleMinMaxActionTypeId;
extern ParamTypeId mockInputTypeWritableDoubleMinMaxActionWritableDoubleMinMaxParamTypeId;
extern ActionTypeId mockInputTypeWritableStringActionTypeId;
extern ParamTypeId mockInputTypeWritableStringActionWritableStringParamTypeId;
extern ActionTypeId mockInputTypeWritableStringSelectionActionTypeId;
extern ParamTypeId mockInputTypeWritableStringSelectionActionWritableStringSelectionParamTypeId;
extern ActionTypeId mockInputTypeWritableColorActionTypeId;
extern ParamTypeId mockInputTypeWritableColorActionWritableColorParamTypeId;
extern ActionTypeId mockInputTypeWritableTimeActionTypeId;
extern ParamTypeId mockInputTypeWritableTimeActionWritableTimeParamTypeId;
extern ActionTypeId mockInputTypeWritableTimestampIntActionTypeId;
extern ParamTypeId mockInputTypeWritableTimestampIntActionWritableTimestampIntParamTypeId;
extern ActionTypeId mockInputTypeWritableTimestampUIntActionTypeId;
extern ParamTypeId mockInputTypeWritableTimestampUIntActionWritableTimestampUIntParamTypeId;
#endif // EXTERNPLUGININFO_H

View File

@ -39,7 +39,10 @@
HttpDaemon::HttpDaemon(Device *device, DevicePlugin *parent):
QTcpServer(parent), disabled(false), m_plugin(parent), m_device(device)
{
listen(QHostAddress::Any, device->paramValue(mockDeviceHttpportParamTypeId).toInt());
QHash<DeviceClassId, ParamTypeId> portMap;
portMap.insert(mockDeviceClassId, mockDeviceHttpportParamTypeId);
portMap.insert(mockDeviceAutoDeviceClassId, mockDeviceAutoDeviceHttpportParamTypeId);
listen(QHostAddress::Any, device->paramValue(portMap.value(device->deviceClassId())).toInt());
}
HttpDaemon::~HttpDaemon()

950
plugins/mock/plugininfo.h Normal file
View File

@ -0,0 +1,950 @@
/* This file is generated by the nymea build system. Any changes to this file will *
* be lost. If you want to change this file, edit the plugin's json file. */
#ifndef PLUGININFO_H
#define PLUGININFO_H
#include "typeutils.h"
#include <QLoggingCategory>
#include <QObject>
extern "C" const QString libnymea_api_version() { return QString("2.1.0");}
Q_DECLARE_LOGGING_CATEGORY(dcMockDevice)
Q_LOGGING_CATEGORY(dcMockDevice, "MockDevice")
PluginId pluginId = PluginId("{727a4a9a-c187-446f-aadf-f1b2220607d1}");
ParamTypeId mockDevicePluginConfigParamIntParamTypeId = ParamTypeId("{e1f72121-a426-45e2-b475-8262b5cdf103}");
ParamTypeId mockDevicePluginConfigParamBoolParamTypeId = ParamTypeId("{c75723b6-ea4f-4982-9751-6c5e39c88145}");
VendorId nymeaVendorId = VendorId("{2062d64d-3232-433c-88bc-0d33c0ba2ba6}");
DeviceClassId mockDeviceClassId = DeviceClassId("{753f0d32-0468-4d08-82ed-1964aab03298}");
ParamTypeId mockDeviceHttpportParamTypeId = ParamTypeId("{d4f06047-125e-4479-9810-b54c189917f5}");
ParamTypeId mockDeviceAsyncParamTypeId = ParamTypeId("{f2977061-4dd0-4ef5-85aa-3b7134743be3}");
ParamTypeId mockDeviceBrokenParamTypeId = ParamTypeId("{ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4}");
ParamTypeId mockSettingsSetting1ParamTypeId = ParamTypeId("{367f7ba4-5039-47be-abd8-59cc8eaf4b9a}");
ParamTypeId mockDiscoveryResultCountParamTypeId = ParamTypeId("{d222adb4-2f9c-4c3f-8655-76400d0fb6ce}");
StateTypeId mockIntStateTypeId = StateTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
StateTypeId mockBoolStateTypeId = StateTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
StateTypeId mockDoubleStateTypeId = StateTypeId("{7cac53ee-7048-4dc9-b000-7b585390f34c}");
StateTypeId mockBatteryLevelStateTypeId = StateTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}");
StateTypeId mockBatteryCriticalStateTypeId = StateTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}");
StateTypeId mockPowerStateTypeId = StateTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
EventTypeId mockIntEventTypeId = EventTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
ParamTypeId mockIntEventIntParamTypeId = ParamTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
EventTypeId mockBoolEventTypeId = EventTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
ParamTypeId mockBoolEventBoolParamTypeId = ParamTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
EventTypeId mockDoubleEventTypeId = EventTypeId("{7cac53ee-7048-4dc9-b000-7b585390f34c}");
ParamTypeId mockDoubleEventDoubleParamTypeId = ParamTypeId("{7cac53ee-7048-4dc9-b000-7b585390f34c}");
EventTypeId mockBatteryLevelEventTypeId = EventTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}");
ParamTypeId mockBatteryLevelEventBatteryLevelParamTypeId = ParamTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}");
EventTypeId mockBatteryCriticalEventTypeId = EventTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}");
ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId = ParamTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}");
EventTypeId mockPowerEventTypeId = EventTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
ParamTypeId mockPowerEventPowerParamTypeId = ParamTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
EventTypeId mockEvent1EventTypeId = EventTypeId("{45bf3752-0fc6-46b9-89fd-ffd878b5b22b}");
EventTypeId mockEvent2EventTypeId = EventTypeId("{863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}");
ParamTypeId mockEvent2EventIntParamParamTypeId = ParamTypeId("{0550e16d-60b9-4ba5-83f4-4d3cee656121}");
ActionTypeId mockPowerActionTypeId = ActionTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
ParamTypeId mockPowerActionPowerParamTypeId = ParamTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
ActionTypeId mockWithParamsActionTypeId = ActionTypeId("{dea0f4e1-65e3-4981-8eaa-2701c53a9185}");
ParamTypeId mockWithParamsActionParam1ParamTypeId = ParamTypeId("{a2d3a256-a551-4712-a65b-ecd5a436a1cb}");
ParamTypeId mockWithParamsActionParam2ParamTypeId = ParamTypeId("{304a4899-18be-4e3b-94f4-d03be52f3233}");
ActionTypeId mockWithoutParamsActionTypeId = ActionTypeId("{defd3ed6-1a0d-400b-8879-a0202cf39935}");
ActionTypeId mockAsyncActionTypeId = ActionTypeId("{fbae06d3-7666-483e-a39e-ec50fe89054e}");
ActionTypeId mockFailingActionTypeId = ActionTypeId("{df3cf33d-26d5-4577-9132-9823bd33fad0}");
ActionTypeId mockAsyncFailingActionTypeId = ActionTypeId("{bfe89a1d-3497-4121-8318-e77c37537219}");
DeviceClassId mockDeviceAutoDeviceClassId = DeviceClassId("{ab4257b3-7548-47ee-9bd4-7dc3004fd197}");
ParamTypeId mockDeviceAutoDeviceHttpportParamTypeId = ParamTypeId("{bfeb0613-dab6-408c-aa27-c362c921d0d1}");
ParamTypeId mockDeviceAutoDeviceAsyncParamTypeId = ParamTypeId("{a5c4315f-0624-4971-87c1-4bbfbfdbd16e}");
ParamTypeId mockDeviceAutoDeviceBrokenParamTypeId = ParamTypeId("{66179395-ef7a-4013-9fc6-2084104eea09}");
StateTypeId mockDeviceAutoIntStateTypeId = StateTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
StateTypeId mockDeviceAutoBoolValueStateTypeId = StateTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
EventTypeId mockDeviceAutoIntEventTypeId = EventTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
ParamTypeId mockDeviceAutoIntEventIntParamTypeId = ParamTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
EventTypeId mockDeviceAutoBoolValueEventTypeId = EventTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
ParamTypeId mockDeviceAutoBoolValueEventBoolValueParamTypeId = ParamTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
EventTypeId mockDeviceAutoEvent1EventTypeId = EventTypeId("{00f81fca-26f1-4a84-aa2b-4c6a3d953ec6}");
EventTypeId mockDeviceAutoEvent2EventTypeId = EventTypeId("{6e27922d-aa9d-44d1-b9b4-9faf31b6bd97}");
ParamTypeId mockDeviceAutoEvent2EventIntParamParamTypeId = ParamTypeId("{12ed5a15-96b4-4381-9d9c-a24875283d4f}");
ActionTypeId mockDeviceAutoWithParamsActionTypeId = ActionTypeId("{00000000-0000-0000-0000-000000000000}");
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam1ParamTypeId = ParamTypeId("{b8126ba6-3a54-45a3-be4d-63feb0ddb77b}");
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam2ParamTypeId = ParamTypeId("{df41ba71-e43b-4854-91d1-b19d8066d4f9}");
ActionTypeId mockDeviceAutoMockActionNoParmsActionTypeId = ActionTypeId("{ef518d53-50e2-4ca5-a4b1-e9a8b9309d44}");
ActionTypeId mockDeviceAutoMockActionAsyncActionTypeId = ActionTypeId("{5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed}");
ActionTypeId mockDeviceAutoMockActionBrokenActionTypeId = ActionTypeId("{58a61de4-472c-4775-8fe8-583a9c83fcf1}");
ActionTypeId mockDeviceAutoMockActionAsyncBrokenActionTypeId = ActionTypeId("{17ad52dd-ef2f-4947-9b73-5bf6e172a9d0}");
DeviceClassId mockPushButtonDeviceClassId = DeviceClassId("{9e03144c-e436-4eea-82d9-ccb33ef778db}");
ParamTypeId mockPushButtonDiscoveryResultCountParamTypeId = ParamTypeId("{c40dbc59-4bba-4871-9b8e-bbd8d5d9193b}");
StateTypeId mockPushButtonColorStateTypeId = StateTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
StateTypeId mockPushButtonPercentageStateTypeId = StateTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
StateTypeId mockPushButtonAllowedValuesStateTypeId = StateTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
StateTypeId mockPushButtonDoubleStateTypeId = StateTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
StateTypeId mockPushButtonBoolStateTypeId = StateTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
EventTypeId mockPushButtonColorEventTypeId = EventTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
ParamTypeId mockPushButtonColorEventColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
EventTypeId mockPushButtonPercentageEventTypeId = EventTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
ParamTypeId mockPushButtonPercentageEventPercentageParamTypeId = ParamTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
EventTypeId mockPushButtonAllowedValuesEventTypeId = EventTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
ParamTypeId mockPushButtonAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
EventTypeId mockPushButtonDoubleEventTypeId = EventTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
ParamTypeId mockPushButtonDoubleEventDoubleParamTypeId = ParamTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
EventTypeId mockPushButtonBoolEventTypeId = EventTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
ParamTypeId mockPushButtonBoolEventBoolParamTypeId = ParamTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
ActionTypeId mockPushButtonColorActionTypeId = ActionTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
ParamTypeId mockPushButtonColorActionColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
ActionTypeId mockPushButtonPercentageActionTypeId = ActionTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
ParamTypeId mockPushButtonPercentageActionPercentageParamTypeId = ParamTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
ActionTypeId mockPushButtonAllowedValuesActionTypeId = ActionTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
ParamTypeId mockPushButtonAllowedValuesActionAllowedValuesParamTypeId = ParamTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
ActionTypeId mockPushButtonDoubleActionTypeId = ActionTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
ParamTypeId mockPushButtonDoubleActionDoubleParamTypeId = ParamTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
ActionTypeId mockPushButtonBoolActionTypeId = ActionTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
ParamTypeId mockPushButtonBoolActionBoolParamTypeId = ParamTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
ActionTypeId mockPushButtonTimeoutActionTypeId = ActionTypeId("{54646e7c-bc54-4895-81a2-590d72d120f9}");
DeviceClassId mockDisplayPinDeviceClassId = DeviceClassId("{296f1fd4-e893-46b2-8a42-50d1bceb8730}");
ParamTypeId mockDisplayPinDevicePinParamTypeId = ParamTypeId("{da820e07-22dc-4173-9c07-2f49a4e265f9}");
ParamTypeId mockDisplayPinDiscoveryResultCountParamTypeId = ParamTypeId("{35f6e4ba-28ad-4152-a58d-ec2600667bcf}");
StateTypeId mockDisplayPinColorStateTypeId = StateTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
StateTypeId mockDisplayPinPercentageStateTypeId = StateTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
StateTypeId mockDisplayPinAllowedValuesStateTypeId = StateTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
StateTypeId mockDisplayPinDoubleStateTypeId = StateTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
StateTypeId mockDisplayPinBoolStateTypeId = StateTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
EventTypeId mockDisplayPinColorEventTypeId = EventTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
ParamTypeId mockDisplayPinColorEventColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
EventTypeId mockDisplayPinPercentageEventTypeId = EventTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
ParamTypeId mockDisplayPinPercentageEventPercentageParamTypeId = ParamTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
EventTypeId mockDisplayPinAllowedValuesEventTypeId = EventTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
ParamTypeId mockDisplayPinAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
EventTypeId mockDisplayPinDoubleEventTypeId = EventTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
ParamTypeId mockDisplayPinDoubleEventDoubleParamTypeId = ParamTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
EventTypeId mockDisplayPinBoolEventTypeId = EventTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
ParamTypeId mockDisplayPinBoolEventBoolParamTypeId = ParamTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
ActionTypeId mockDisplayPinColorActionTypeId = ActionTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
ParamTypeId mockDisplayPinColorActionColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
ActionTypeId mockDisplayPinPercentageActionTypeId = ActionTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
ParamTypeId mockDisplayPinPercentageActionPercentageParamTypeId = ParamTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
ActionTypeId mockDisplayPinAllowedValuesActionTypeId = ActionTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
ParamTypeId mockDisplayPinAllowedValuesActionAllowedValuesParamTypeId = ParamTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
ActionTypeId mockDisplayPinDoubleActionTypeId = ActionTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
ParamTypeId mockDisplayPinDoubleActionDoubleParamTypeId = ParamTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
ActionTypeId mockDisplayPinBoolActionTypeId = ActionTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
ParamTypeId mockDisplayPinBoolActionBoolParamTypeId = ParamTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
ActionTypeId mockDisplayPinTimeoutActionTypeId = ActionTypeId("{854a0a4a-803f-4b7f-9dce-b07794f9011b}");
DeviceClassId mockParentDeviceClassId = DeviceClassId("{a71fbde9-9a38-4bf8-beab-c8aade2608ba}");
StateTypeId mockParentBoolValueStateTypeId = StateTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
EventTypeId mockParentBoolValueEventTypeId = EventTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
ParamTypeId mockParentBoolValueEventBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
ActionTypeId mockParentBoolValueActionTypeId = ActionTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
ParamTypeId mockParentBoolValueActionBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
DeviceClassId mockChildDeviceClassId = DeviceClassId("{40893c9f-bc47-40c1-8bf7-b390c7c1b4fc}");
StateTypeId mockChildBoolValueStateTypeId = StateTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
EventTypeId mockChildBoolValueEventTypeId = EventTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
ParamTypeId mockChildBoolValueEventBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
ActionTypeId mockChildBoolValueActionTypeId = ActionTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
ParamTypeId mockChildBoolValueActionBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
DeviceClassId mockInputTypeDeviceClassId = DeviceClassId("{515ffdf1-55e5-498d-9abc-4e2fe768f3a9}");
ParamTypeId mockInputTypeDeviceTextLineParamTypeId = ParamTypeId("{e6acf0c7-4b8e-4296-ac62-855d20deb816}");
ParamTypeId mockInputTypeDeviceTextAreaParamTypeId = ParamTypeId("{716f0994-bc01-42b0-b64d-59236f7320d2}");
ParamTypeId mockInputTypeDevicePasswordParamTypeId = ParamTypeId("{e5c0d14b-c9f1-4aca-a56e-85bfa6977150}");
ParamTypeId mockInputTypeDeviceSearchParamTypeId = ParamTypeId("{22add8c9-ee4f-43ad-8931-58e999313ac3}");
ParamTypeId mockInputTypeDeviceMailParamTypeId = ParamTypeId("{a8494faf-3a0f-4cf3-84b7-4b39148a838d}");
ParamTypeId mockInputTypeDeviceIp4ParamTypeId = ParamTypeId("{9e5f86a0-4bb3-4892-bff8-3fc4032af6e2}");
ParamTypeId mockInputTypeDeviceIp6ParamTypeId = ParamTypeId("{43bf3832-dd48-4090-a836-656e8b60216e}");
ParamTypeId mockInputTypeDeviceUrlParamTypeId = ParamTypeId("{fa67229f-fcef-496f-b671-59a4b48f3ab5}");
ParamTypeId mockInputTypeDeviceMacParamTypeId = ParamTypeId("{e93db587-7919-48f3-8c88-1651de63c765}");
StateTypeId mockInputTypeBoolStateTypeId = StateTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}");
StateTypeId mockInputTypeWritableBoolStateTypeId = StateTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}");
StateTypeId mockInputTypeIntStateTypeId = StateTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}");
StateTypeId mockInputTypeWritableIntStateTypeId = StateTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}");
StateTypeId mockInputTypeWritableIntMinMaxStateTypeId = StateTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}");
StateTypeId mockInputTypeUintStateTypeId = StateTypeId("{19e74fcc-bfd5-491f-8eb6-af128e8f1162}");
StateTypeId mockInputTypeWritableUIntStateTypeId = StateTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}");
StateTypeId mockInputTypeWritableUIntMinMaxStateTypeId = StateTypeId("{79238998-eaab-4d71-b406-5d78f1749751}");
StateTypeId mockInputTypeDoubleStateTypeId = StateTypeId("{f7d2063d-959e-46ac-8568-8b99722d3b22}");
StateTypeId mockInputTypeWritableDoubleStateTypeId = StateTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}");
StateTypeId mockInputTypeWritableDoubleMinMaxStateTypeId = StateTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}");
StateTypeId mockInputTypeStringStateTypeId = StateTypeId("{27f69ca9-a321-40ff-bfee-4b0272a671b4}");
StateTypeId mockInputTypeWritableStringStateTypeId = StateTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}");
StateTypeId mockInputTypeWritableStringSelectionStateTypeId = StateTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}");
StateTypeId mockInputTypeColorStateTypeId = StateTypeId("{4507d5c6-b692-4bd6-87f2-00364bc0cb4d}");
StateTypeId mockInputTypeWritableColorStateTypeId = StateTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}");
StateTypeId mockInputTypeTimeStateTypeId = StateTypeId("{8250c71e-59bc-41ab-b576-99fcfc34e8d1}");
StateTypeId mockInputTypeWritableTimeStateTypeId = StateTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}");
StateTypeId mockInputTypeTimestampIntStateTypeId = StateTypeId("{2c91b5ef-c2d1-4367-bc65-5a13abf69641}");
StateTypeId mockInputTypeWritableTimestampIntStateTypeId = StateTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}");
StateTypeId mockInputTypeTimestampUIntStateTypeId = StateTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}");
StateTypeId mockInputTypeWritableTimestampUIntStateTypeId = StateTypeId("{45d0069a-63ac-4265-8170-8152778608ee}");
EventTypeId mockInputTypeBoolEventTypeId = EventTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}");
ParamTypeId mockInputTypeBoolEventBoolParamTypeId = ParamTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}");
EventTypeId mockInputTypeWritableBoolEventTypeId = EventTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}");
ParamTypeId mockInputTypeWritableBoolEventWritableBoolParamTypeId = ParamTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}");
EventTypeId mockInputTypeIntEventTypeId = EventTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}");
ParamTypeId mockInputTypeIntEventIntParamTypeId = ParamTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}");
EventTypeId mockInputTypeWritableIntEventTypeId = EventTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}");
ParamTypeId mockInputTypeWritableIntEventWritableIntParamTypeId = ParamTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}");
EventTypeId mockInputTypeWritableIntMinMaxEventTypeId = EventTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}");
ParamTypeId mockInputTypeWritableIntMinMaxEventWritableIntMinMaxParamTypeId = ParamTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}");
EventTypeId mockInputTypeUintEventTypeId = EventTypeId("{19e74fcc-bfd5-491f-8eb6-af128e8f1162}");
ParamTypeId mockInputTypeUintEventUintParamTypeId = ParamTypeId("{19e74fcc-bfd5-491f-8eb6-af128e8f1162}");
EventTypeId mockInputTypeWritableUIntEventTypeId = EventTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}");
ParamTypeId mockInputTypeWritableUIntEventWritableUIntParamTypeId = ParamTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}");
EventTypeId mockInputTypeWritableUIntMinMaxEventTypeId = EventTypeId("{79238998-eaab-4d71-b406-5d78f1749751}");
ParamTypeId mockInputTypeWritableUIntMinMaxEventWritableUIntMinMaxParamTypeId = ParamTypeId("{79238998-eaab-4d71-b406-5d78f1749751}");
EventTypeId mockInputTypeDoubleEventTypeId = EventTypeId("{f7d2063d-959e-46ac-8568-8b99722d3b22}");
ParamTypeId mockInputTypeDoubleEventDoubleParamTypeId = ParamTypeId("{f7d2063d-959e-46ac-8568-8b99722d3b22}");
EventTypeId mockInputTypeWritableDoubleEventTypeId = EventTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}");
ParamTypeId mockInputTypeWritableDoubleEventWritableDoubleParamTypeId = ParamTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}");
EventTypeId mockInputTypeWritableDoubleMinMaxEventTypeId = EventTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}");
ParamTypeId mockInputTypeWritableDoubleMinMaxEventWritableDoubleMinMaxParamTypeId = ParamTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}");
EventTypeId mockInputTypeStringEventTypeId = EventTypeId("{27f69ca9-a321-40ff-bfee-4b0272a671b4}");
ParamTypeId mockInputTypeStringEventStringParamTypeId = ParamTypeId("{27f69ca9-a321-40ff-bfee-4b0272a671b4}");
EventTypeId mockInputTypeWritableStringEventTypeId = EventTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}");
ParamTypeId mockInputTypeWritableStringEventWritableStringParamTypeId = ParamTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}");
EventTypeId mockInputTypeWritableStringSelectionEventTypeId = EventTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}");
ParamTypeId mockInputTypeWritableStringSelectionEventWritableStringSelectionParamTypeId = ParamTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}");
EventTypeId mockInputTypeColorEventTypeId = EventTypeId("{4507d5c6-b692-4bd6-87f2-00364bc0cb4d}");
ParamTypeId mockInputTypeColorEventColorParamTypeId = ParamTypeId("{4507d5c6-b692-4bd6-87f2-00364bc0cb4d}");
EventTypeId mockInputTypeWritableColorEventTypeId = EventTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}");
ParamTypeId mockInputTypeWritableColorEventWritableColorParamTypeId = ParamTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}");
EventTypeId mockInputTypeTimeEventTypeId = EventTypeId("{8250c71e-59bc-41ab-b576-99fcfc34e8d1}");
ParamTypeId mockInputTypeTimeEventTimeParamTypeId = ParamTypeId("{8250c71e-59bc-41ab-b576-99fcfc34e8d1}");
EventTypeId mockInputTypeWritableTimeEventTypeId = EventTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}");
ParamTypeId mockInputTypeWritableTimeEventWritableTimeParamTypeId = ParamTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}");
EventTypeId mockInputTypeTimestampIntEventTypeId = EventTypeId("{2c91b5ef-c2d1-4367-bc65-5a13abf69641}");
ParamTypeId mockInputTypeTimestampIntEventTimestampIntParamTypeId = ParamTypeId("{2c91b5ef-c2d1-4367-bc65-5a13abf69641}");
EventTypeId mockInputTypeWritableTimestampIntEventTypeId = EventTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}");
ParamTypeId mockInputTypeWritableTimestampIntEventWritableTimestampIntParamTypeId = ParamTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}");
EventTypeId mockInputTypeTimestampUIntEventTypeId = EventTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}");
ParamTypeId mockInputTypeTimestampUIntEventTimestampUIntParamTypeId = ParamTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}");
EventTypeId mockInputTypeWritableTimestampUIntEventTypeId = EventTypeId("{45d0069a-63ac-4265-8170-8152778608ee}");
ParamTypeId mockInputTypeWritableTimestampUIntEventWritableTimestampUIntParamTypeId = ParamTypeId("{45d0069a-63ac-4265-8170-8152778608ee}");
ActionTypeId mockInputTypeWritableBoolActionTypeId = ActionTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}");
ParamTypeId mockInputTypeWritableBoolActionWritableBoolParamTypeId = ParamTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}");
ActionTypeId mockInputTypeWritableIntActionTypeId = ActionTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}");
ParamTypeId mockInputTypeWritableIntActionWritableIntParamTypeId = ParamTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}");
ActionTypeId mockInputTypeWritableIntMinMaxActionTypeId = ActionTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}");
ParamTypeId mockInputTypeWritableIntMinMaxActionWritableIntMinMaxParamTypeId = ParamTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}");
ActionTypeId mockInputTypeWritableUIntActionTypeId = ActionTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}");
ParamTypeId mockInputTypeWritableUIntActionWritableUIntParamTypeId = ParamTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}");
ActionTypeId mockInputTypeWritableUIntMinMaxActionTypeId = ActionTypeId("{79238998-eaab-4d71-b406-5d78f1749751}");
ParamTypeId mockInputTypeWritableUIntMinMaxActionWritableUIntMinMaxParamTypeId = ParamTypeId("{79238998-eaab-4d71-b406-5d78f1749751}");
ActionTypeId mockInputTypeWritableDoubleActionTypeId = ActionTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}");
ParamTypeId mockInputTypeWritableDoubleActionWritableDoubleParamTypeId = ParamTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}");
ActionTypeId mockInputTypeWritableDoubleMinMaxActionTypeId = ActionTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}");
ParamTypeId mockInputTypeWritableDoubleMinMaxActionWritableDoubleMinMaxParamTypeId = ParamTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}");
ActionTypeId mockInputTypeWritableStringActionTypeId = ActionTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}");
ParamTypeId mockInputTypeWritableStringActionWritableStringParamTypeId = ParamTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}");
ActionTypeId mockInputTypeWritableStringSelectionActionTypeId = ActionTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}");
ParamTypeId mockInputTypeWritableStringSelectionActionWritableStringSelectionParamTypeId = ParamTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}");
ActionTypeId mockInputTypeWritableColorActionTypeId = ActionTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}");
ParamTypeId mockInputTypeWritableColorActionWritableColorParamTypeId = ParamTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}");
ActionTypeId mockInputTypeWritableTimeActionTypeId = ActionTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}");
ParamTypeId mockInputTypeWritableTimeActionWritableTimeParamTypeId = ParamTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}");
ActionTypeId mockInputTypeWritableTimestampIntActionTypeId = ActionTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}");
ParamTypeId mockInputTypeWritableTimestampIntActionWritableTimestampIntParamTypeId = ParamTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}");
ActionTypeId mockInputTypeWritableTimestampUIntActionTypeId = ActionTypeId("{45d0069a-63ac-4265-8170-8152778608ee}");
ParamTypeId mockInputTypeWritableTimestampUIntActionWritableTimestampUIntParamTypeId = ParamTypeId("{45d0069a-63ac-4265-8170-8152778608ee}");
const QString translations[] {
//: The name of the ParamType (DeviceClass: mockInputType, EventType: bool, ID: {3bad3a09-5826-4ed7-a832-10e3e2ee2a7d})
QT_TRANSLATE_NOOP("mockDevice", "Bool"),
//: The name of the StateType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Bool"),
//: The name of the EventType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Bool changed"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: color, ID: {4507d5c6-b692-4bd6-87f2-00364bc0cb4d})
QT_TRANSLATE_NOOP("mockDevice", "Color"),
//: The name of the StateType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Color"),
//: The name of the EventType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Color changed"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: double, ID: {f7d2063d-959e-46ac-8568-8b99722d3b22})
QT_TRANSLATE_NOOP("mockDevice", "Double"),
//: The name of the StateType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Double"),
//: The name of the EventType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Double changed"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: boolValue, ID: {978b0ba5-d008-41bd-b63d-a3bd23cb6469})
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
//: The name of the StateType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
//: The name of the ParamType (DeviceClass: mock, EventType: bool, ID: {9dd6a97c-dfd1-43dc-acbd-367932742310})
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
//: The name of the StateType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
//: The name of the EventType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state changed"),
//: The name of the EventType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state changed"),
//: The name of the ParamType (DeviceClass: mock, EventType: double, ID: {7cac53ee-7048-4dc9-b000-7b585390f34c})
QT_TRANSLATE_NOOP("mockDevice", "Dummy double state"),
//: The name of the StateType ({7cac53ee-7048-4dc9-b000-7b585390f34c}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy double state"),
//: The name of the EventType ({7cac53ee-7048-4dc9-b000-7b585390f34c}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy double state changed"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: int, ID: {74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c})
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
//: The name of the StateType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
//: The name of the ParamType (DeviceClass: mock, EventType: int, ID: {80baec19-54de-4948-ac46-31eabfaceb83})
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
//: The name of the StateType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
//: The name of the EventType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state changed"),
//: The name of the EventType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state changed"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {9e5f86a0-4bb3-4892-bff8-3fc4032af6e2})
QT_TRANSLATE_NOOP("mockDevice", "IPv4 address"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {43bf3832-dd48-4090-a836-656e8b60216e})
QT_TRANSLATE_NOOP("mockDevice", "IPv6 address"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: int, ID: {d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb})
QT_TRANSLATE_NOOP("mockDevice", "Int"),
//: The name of the StateType ({d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Int"),
//: The name of the EventType ({d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Int changed"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {e93db587-7919-48f3-8c88-1651de63c765})
QT_TRANSLATE_NOOP("mockDevice", "Mac address"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {a8494faf-3a0f-4cf3-84b7-4b39148a838d})
QT_TRANSLATE_NOOP("mockDevice", "Mail address"),
//: The name of the ActionType ({00000000-0000-0000-0000-000000000000}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 1 (with params)"),
//: The name of the ActionType ({dea0f4e1-65e3-4981-8eaa-2701c53a9185}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 1 (with params)"),
//: The name of the ActionType ({ef518d53-50e2-4ca5-a4b1-e9a8b9309d44}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 2 (without params)"),
//: The name of the ActionType ({defd3ed6-1a0d-400b-8879-a0202cf39935}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 2 (without params)"),
//: The name of the ActionType ({5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 3 (async)"),
//: The name of the ActionType ({fbae06d3-7666-483e-a39e-ec50fe89054e}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 3 (async)"),
//: The name of the ActionType ({58a61de4-472c-4775-8fe8-583a9c83fcf1}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 4 (broken)"),
//: The name of the ActionType ({df3cf33d-26d5-4577-9132-9823bd33fad0}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 4 (broken)"),
//: The name of the ActionType ({17ad52dd-ef2f-4947-9b73-5bf6e172a9d0}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 5 (async, broken)"),
//: The name of the ActionType ({bfe89a1d-3497-4121-8318-e77c37537219}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 5 (async, broken)"),
//: The name of the DeviceClass ({753f0d32-0468-4d08-82ed-1964aab03298})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device"),
//: The name of the DeviceClass ({ab4257b3-7548-47ee-9bd4-7dc3004fd197})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (Auto created)"),
//: The name of the DeviceClass ({40893c9f-bc47-40c1-8bf7-b390c7c1b4fc})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (Child)"),
//: The name of the DeviceClass ({296f1fd4-e893-46b2-8a42-50d1bceb8730})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (Display Pin)"),
//: The name of the DeviceClass ({515ffdf1-55e5-498d-9abc-4e2fe768f3a9})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (InputTypes)"),
//: The name of the DeviceClass ({a71fbde9-9a38-4bf8-beab-c8aade2608ba})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (Parent)"),
//: The name of the DeviceClass ({9e03144c-e436-4eea-82d9-ccb33ef778db})
QT_TRANSLATE_NOOP("mockDevice", "Mock Device (Push Button)"),
//: The name of the plugin mockDevice ({727a4a9a-c187-446f-aadf-f1b2220607d1})
QT_TRANSLATE_NOOP("mockDevice", "Mock Devices"),
//: The name of the EventType ({00f81fca-26f1-4a84-aa2b-4c6a3d953ec6}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 1"),
//: The name of the EventType ({45bf3752-0fc6-46b9-89fd-ffd878b5b22b}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 1"),
//: The name of the EventType ({6e27922d-aa9d-44d1-b9b4-9faf31b6bd97}) of DeviceClass mockDeviceAuto
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 2"),
//: The name of the EventType ({863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 2"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {e5c0d14b-c9f1-4aca-a56e-85bfa6977150})
QT_TRANSLATE_NOOP("mockDevice", "Password text"),
//: The pairing info of deviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681."),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {22add8c9-ee4f-43ad-8931-58e999313ac3})
QT_TRANSLATE_NOOP("mockDevice", "Search text"),
//: The name of the ActionType ({a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Bool"),
//: The name of the ActionType ({455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Color"),
//: The name of the ActionType ({8e2eb91b-d60b-4461-9a50-d7b8ad263170}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Double"),
//: The name of the ActionType ({00d3425e-1da6-4748-8906-4555ceefb136}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Double (min/max)"),
//: The name of the ActionType ({857a8422-983c-47d6-a15f-d8450b3162f7}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Int"),
//: The name of the ActionType ({86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Int (min/max)"),
//: The name of the ActionType ({ef511043-bd1a-4a5f-984c-222b7da43f38}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable String"),
//: The name of the ActionType ({209d7afc-6fe9-4fe9-939b-e472ea0ad639}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable String (selection)"),
//: The name of the ActionType ({d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Time"),
//: The name of the ActionType ({88b6746a-b009-4df6-8986-d7884ffd94b2}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Timestamp (Int)"),
//: The name of the ActionType ({45d0069a-63ac-4265-8170-8152778608ee}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable Timestamp (UInt)"),
//: The name of the ActionType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable UInt"),
//: The name of the ActionType ({79238998-eaab-4d71-b406-5d78f1749751}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Set Writable UInt (min/max)"),
//: The name of the ActionType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Set allowed values"),
//: The name of the ActionType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Set allowed values"),
//: The name of the ActionType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
//: The name of the ActionType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
//: The name of the ActionType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
//: The name of the ActionType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
//: The name of the ActionType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Set color"),
//: The name of the ActionType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Set color"),
//: The name of the ActionType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Set double value"),
//: The name of the ActionType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Set double value"),
//: The name of the ActionType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Set percentage"),
//: The name of the ActionType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Set percentage"),
//: The name of the ParamType (DeviceClass: mock, Type: settings, ID: {367f7ba4-5039-47be-abd8-59cc8eaf4b9a})
QT_TRANSLATE_NOOP("mockDevice", "Setting 1"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: string, ID: {27f69ca9-a321-40ff-bfee-4b0272a671b4})
QT_TRANSLATE_NOOP("mockDevice", "String"),
//: The name of the StateType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "String"),
//: The name of the EventType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "String changed"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {716f0994-bc01-42b0-b64d-59236f7320d2})
QT_TRANSLATE_NOOP("mockDevice", "Text area"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {e6acf0c7-4b8e-4296-ac62-855d20deb816})
QT_TRANSLATE_NOOP("mockDevice", "Text line"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: time, ID: {8250c71e-59bc-41ab-b576-99fcfc34e8d1})
QT_TRANSLATE_NOOP("mockDevice", "Time"),
//: The name of the StateType ({8250c71e-59bc-41ab-b576-99fcfc34e8d1}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Time"),
//: The name of the EventType ({8250c71e-59bc-41ab-b576-99fcfc34e8d1}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Time changed"),
//: The name of the ActionType ({854a0a4a-803f-4b7f-9dce-b07794f9011b}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "Timeout action"),
//: The name of the ActionType ({54646e7c-bc54-4895-81a2-590d72d120f9}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Timeout action"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: timestampInt, ID: {2c91b5ef-c2d1-4367-bc65-5a13abf69641})
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (Int)"),
//: The name of the StateType ({2c91b5ef-c2d1-4367-bc65-5a13abf69641}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (Int)"),
//: The name of the EventType ({2c91b5ef-c2d1-4367-bc65-5a13abf69641}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (Int) changed"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: timestampUInt, ID: {6c9a96e8-0d48-4f42-8967-848358fd7f79})
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (UInt)"),
//: The name of the StateType ({6c9a96e8-0d48-4f42-8967-848358fd7f79}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (UInt)"),
//: The name of the EventType ({6c9a96e8-0d48-4f42-8967-848358fd7f79}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Timestamp (UInt) changed"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: uint, ID: {19e74fcc-bfd5-491f-8eb6-af128e8f1162})
QT_TRANSLATE_NOOP("mockDevice", "UInt"),
//: The name of the StateType ({19e74fcc-bfd5-491f-8eb6-af128e8f1162}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "UInt"),
//: The name of the EventType ({19e74fcc-bfd5-491f-8eb6-af128e8f1162}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "UInt changed"),
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {fa67229f-fcef-496f-b671-59a4b48f3ab5})
QT_TRANSLATE_NOOP("mockDevice", "URL"),
//: The pairing info of deviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "Wait 3 second before you continue, the push button will be pressed automatically."),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableBool, ID: {a7c11774-f31f-4d64-99d1-e0ae5fb35a5c})
QT_TRANSLATE_NOOP("mockDevice", "Writable Bool"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableBool, ID: {a7c11774-f31f-4d64-99d1-e0ae5fb35a5c})
QT_TRANSLATE_NOOP("mockDevice", "Writable Bool"),
//: The name of the StateType ({a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Bool"),
//: The name of the EventType ({a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Bool changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableColor, ID: {455f4f68-3cb0-4e8a-a707-62e4a2a8035c})
QT_TRANSLATE_NOOP("mockDevice", "Writable Color"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableColor, ID: {455f4f68-3cb0-4e8a-a707-62e4a2a8035c})
QT_TRANSLATE_NOOP("mockDevice", "Writable Color"),
//: The name of the StateType ({455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Color"),
//: The name of the EventType ({455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Color changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableDouble, ID: {8e2eb91b-d60b-4461-9a50-d7b8ad263170})
QT_TRANSLATE_NOOP("mockDevice", "Writable Double"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableDouble, ID: {8e2eb91b-d60b-4461-9a50-d7b8ad263170})
QT_TRANSLATE_NOOP("mockDevice", "Writable Double"),
//: The name of the StateType ({8e2eb91b-d60b-4461-9a50-d7b8ad263170}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Double"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableDoubleMinMax, ID: {00d3425e-1da6-4748-8906-4555ceefb136})
QT_TRANSLATE_NOOP("mockDevice", "Writable Double (min/max)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableDoubleMinMax, ID: {00d3425e-1da6-4748-8906-4555ceefb136})
QT_TRANSLATE_NOOP("mockDevice", "Writable Double (min/max)"),
//: The name of the StateType ({00d3425e-1da6-4748-8906-4555ceefb136}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Double (min/max)"),
//: The name of the EventType ({00d3425e-1da6-4748-8906-4555ceefb136}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Double (min/max) changed"),
//: The name of the EventType ({8e2eb91b-d60b-4461-9a50-d7b8ad263170}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Double changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableInt, ID: {857a8422-983c-47d6-a15f-d8450b3162f7})
QT_TRANSLATE_NOOP("mockDevice", "Writable Int"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableInt, ID: {857a8422-983c-47d6-a15f-d8450b3162f7})
QT_TRANSLATE_NOOP("mockDevice", "Writable Int"),
//: The name of the StateType ({857a8422-983c-47d6-a15f-d8450b3162f7}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Int"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableIntMinMax, ID: {86a107bc-510a-4d38-bfeb-0a9c2b6d8d87})
QT_TRANSLATE_NOOP("mockDevice", "Writable Int (min/max)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableIntMinMax, ID: {86a107bc-510a-4d38-bfeb-0a9c2b6d8d87})
QT_TRANSLATE_NOOP("mockDevice", "Writable Int (min/max)"),
//: The name of the StateType ({86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Int (min/max)"),
//: The name of the EventType ({86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Int (min/max) changed"),
//: The name of the EventType ({857a8422-983c-47d6-a15f-d8450b3162f7}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Int changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableString, ID: {ef511043-bd1a-4a5f-984c-222b7da43f38})
QT_TRANSLATE_NOOP("mockDevice", "Writable String"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableString, ID: {ef511043-bd1a-4a5f-984c-222b7da43f38})
QT_TRANSLATE_NOOP("mockDevice", "Writable String"),
//: The name of the StateType ({ef511043-bd1a-4a5f-984c-222b7da43f38}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable String"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableStringSelection, ID: {209d7afc-6fe9-4fe9-939b-e472ea0ad639})
QT_TRANSLATE_NOOP("mockDevice", "Writable String (selection)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableStringSelection, ID: {209d7afc-6fe9-4fe9-939b-e472ea0ad639})
QT_TRANSLATE_NOOP("mockDevice", "Writable String (selection)"),
//: The name of the StateType ({209d7afc-6fe9-4fe9-939b-e472ea0ad639}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable String (selection)"),
//: The name of the EventType ({209d7afc-6fe9-4fe9-939b-e472ea0ad639}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable String (selection) changed"),
//: The name of the EventType ({ef511043-bd1a-4a5f-984c-222b7da43f38}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable String changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableTime, ID: {d64c8b3f-ca7d-47f6-b271-867ffd80a4d4})
QT_TRANSLATE_NOOP("mockDevice", "Writable Time"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableTime, ID: {d64c8b3f-ca7d-47f6-b271-867ffd80a4d4})
QT_TRANSLATE_NOOP("mockDevice", "Writable Time"),
//: The name of the StateType ({d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Time"),
//: The name of the EventType ({d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Time changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableTimestampInt, ID: {88b6746a-b009-4df6-8986-d7884ffd94b2})
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (Int)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableTimestampInt, ID: {88b6746a-b009-4df6-8986-d7884ffd94b2})
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (Int)"),
//: The name of the StateType ({88b6746a-b009-4df6-8986-d7884ffd94b2}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (Int)"),
//: The name of the EventType ({88b6746a-b009-4df6-8986-d7884ffd94b2}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (Int) changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableTimestampUInt, ID: {45d0069a-63ac-4265-8170-8152778608ee})
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (UInt)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableTimestampUInt, ID: {45d0069a-63ac-4265-8170-8152778608ee})
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (UInt)"),
//: The name of the StateType ({45d0069a-63ac-4265-8170-8152778608ee}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (UInt)"),
//: The name of the EventType ({45d0069a-63ac-4265-8170-8152778608ee}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable Timestamp (UInt) changed"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableUInt, ID: {563e9c4c-5198-400a-9f6c-358f4752af58})
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableUInt, ID: {563e9c4c-5198-400a-9f6c-358f4752af58})
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt"),
//: The name of the StateType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt"),
//: The name of the ParamType (DeviceClass: mockInputType, ActionType: writableUIntMinMax, ID: {79238998-eaab-4d71-b406-5d78f1749751})
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt (min/max)"),
//: The name of the ParamType (DeviceClass: mockInputType, EventType: writableUIntMinMax, ID: {79238998-eaab-4d71-b406-5d78f1749751})
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt (min/max)"),
//: The name of the StateType ({79238998-eaab-4d71-b406-5d78f1749751}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt (min/max)"),
//: The name of the EventType ({79238998-eaab-4d71-b406-5d78f1749751}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt (min/max) changed"),
//: The name of the EventType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of DeviceClass mockInputType
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt changed"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143})
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143})
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the StateType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b})
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the ParamType (DeviceClass: mockPushButton, EventType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b})
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the StateType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
//: The name of the EventType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "allowed values changed"),
//: The name of the EventType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "allowed values changed"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {a5c4315f-0624-4971-87c1-4bbfbfdbd16e})
QT_TRANSLATE_NOOP("mockDevice", "async"),
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {f2977061-4dd0-4ef5-85aa-3b7134743be3})
QT_TRANSLATE_NOOP("mockDevice", "async"),
//: The name of the ParamType (DeviceClass: mock, EventType: batteryLevel, ID: {6c8ab9a6-0164-4795-b829-f4394fe4edc4})
QT_TRANSLATE_NOOP("mockDevice", "battery level"),
//: The name of the EventType ({6c8ab9a6-0164-4795-b829-f4394fe4edc4}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "battery level"),
//: The name of the StateType ({6c8ab9a6-0164-4795-b829-f4394fe4edc4}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "battery level"),
//: The name of the ParamType (DeviceClass: mock, EventType: batteryCritical, ID: {580bc611-1a55-41f3-996f-8d3ccf543db3})
QT_TRANSLATE_NOOP("mockDevice", "battery level critical"),
//: The name of the EventType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "battery level critical"),
//: The name of the StateType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "battery level critical"),
//: The name of the ParamType (DeviceClass: mockChild, ActionType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockChild, EventType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the StateType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockParent, ActionType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockParent, EventType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the StateType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the StateType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the ParamType (DeviceClass: mockPushButton, EventType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768})
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the StateType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
//: The name of the EventType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
//: The name of the EventType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
//: The name of the EventType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
//: The name of the EventType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {66179395-ef7a-4013-9fc6-2084104eea09})
QT_TRANSLATE_NOOP("mockDevice", "broken"),
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4})
QT_TRANSLATE_NOOP("mockDevice", "broken"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa})
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa})
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the StateType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e})
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the ParamType (DeviceClass: mockPushButton, EventType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e})
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the StateType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "color"),
//: The name of the EventType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "color changed"),
//: The name of the EventType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "color changed"),
//: The name of the ParamType (DeviceClass: mockDevice, Type: plugin, ID: {c75723b6-ea4f-4982-9751-6c5e39c88145})
QT_TRANSLATE_NOOP("mockDevice", "configParamBool"),
//: The name of the ParamType (DeviceClass: mockDevice, Type: plugin, ID: {e1f72121-a426-45e2-b475-8262b5cdf103})
QT_TRANSLATE_NOOP("mockDevice", "configParamInt"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843})
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843})
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the StateType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c})
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the ParamType (DeviceClass: mockPushButton, EventType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c})
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the StateType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "double value"),
//: The name of the EventType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "double value changed"),
//: The name of the EventType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "double value changed"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {bfeb0613-dab6-408c-aa27-c362c921d0d1})
QT_TRANSLATE_NOOP("mockDevice", "http port"),
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {d4f06047-125e-4479-9810-b54c189917f5})
QT_TRANSLATE_NOOP("mockDevice", "http port"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {b8126ba6-3a54-45a3-be4d-63feb0ddb77b})
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam1"),
//: The name of the ParamType (DeviceClass: mock, ActionType: withParams, ID: {a2d3a256-a551-4712-a65b-ecd5a436a1cb})
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam1"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {df41ba71-e43b-4854-91d1-b19d8066d4f9})
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam2"),
//: The name of the ParamType (DeviceClass: mock, ActionType: withParams, ID: {304a4899-18be-4e3b-94f4-d03be52f3233})
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam2"),
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: event2, ID: {12ed5a15-96b4-4381-9d9c-a24875283d4f})
QT_TRANSLATE_NOOP("mockDevice", "mockParamInt"),
//: The name of the ParamType (DeviceClass: mock, EventType: event2, ID: {0550e16d-60b9-4ba5-83f4-4d3cee656121})
QT_TRANSLATE_NOOP("mockDevice", "mockParamInt"),
//: The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6})
QT_TRANSLATE_NOOP("mockDevice", "nymea"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797})
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797})
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the StateType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c})
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the ParamType (DeviceClass: mockPushButton, EventType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c})
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the StateType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
//: The name of the EventType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
QT_TRANSLATE_NOOP("mockDevice", "percentage changed"),
//: The name of the EventType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
QT_TRANSLATE_NOOP("mockDevice", "percentage changed"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, Type: device, ID: {da820e07-22dc-4173-9c07-2f49a4e265f9})
QT_TRANSLATE_NOOP("mockDevice", "pin"),
//: The name of the ParamType (DeviceClass: mock, ActionType: power, ID: {064aed0d-da4c-49d4-b236-60f97e98ff84})
QT_TRANSLATE_NOOP("mockDevice", "powered"),
//: The name of the ParamType (DeviceClass: mock, EventType: power, ID: {064aed0d-da4c-49d4-b236-60f97e98ff84})
QT_TRANSLATE_NOOP("mockDevice", "powered"),
//: The name of the StateType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "powered"),
//: The name of the EventType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "powered changed"),
//: The name of the ParamType (DeviceClass: mockDisplayPin, Type: discovery, ID: {35f6e4ba-28ad-4152-a58d-ec2600667bcf})
QT_TRANSLATE_NOOP("mockDevice", "resultCount"),
//: The name of the ParamType (DeviceClass: mockPushButton, Type: discovery, ID: {c40dbc59-4bba-4871-9b8e-bbd8d5d9193b})
QT_TRANSLATE_NOOP("mockDevice", "resultCount"),
//: The name of the ParamType (DeviceClass: mock, Type: discovery, ID: {d222adb4-2f9c-4c3f-8655-76400d0fb6ce})
QT_TRANSLATE_NOOP("mockDevice", "resultCount"),
//: The name of the ActionType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of DeviceClass mock
QT_TRANSLATE_NOOP("mockDevice", "set power")
};
#endif // PLUGININFO_H

View File

@ -7,30 +7,18 @@ QT += network
INCLUDEPATH += $$top_srcdir/libnymea
LIBS += -L../../libnymea -lnymea
HEADERS += plugininfo.h
HEADERS += plugininfo.h extern-plugininfo.h
# A target for manually updating the plugininfo file
# NOTE: In cross compiling environments we can't run the plugininfocompiler
# so we can't do this automatically at build time
plugininfo.commands = LD_LIBRARY_PATH=$$top_builddir/libnymea \
$$top_builddir/tools/nymea-plugininfocompiler/nymea-plugininfocompiler \
$$PWD/$${TARGET}/deviceplugin"$$TARGET".json \
--output $$PWD/$${TARGET}/plugininfo.h \
--extern $$PWD/$${TARGET}/extern-plugininfo.h
QMAKE_EXTRA_TARGETS += plugininfo
# Create plugininfo file
JSONFILE=$$PWD/$$TARGET/deviceplugin"$$TARGET".json
plugininfo.input = JSONFILE
plugininfo.output = plugininfo.h
plugininfo.CONFIG = no_link target_predeps
plugininfo.commands = $$top_srcdir/libnymea/devices/nymea-generateplugininfo \
--filetype i \
--jsonfile $$PWD/$$TARGET/deviceplugin"$$TARGET".json \
--output plugininfo.h \
--builddir $$OUT_PWD;
extern-plugininfo.input = JSONFILE
extern-plugininfo.output = extern-plugininfo.h
extern-plugininfo.CONFIG = no_link target_predeps
extern-plugininfo.commands = $$top_srcdir/libnymea/devices/nymea-generateplugininfo \
--filetype e \
--jsonfile $$PWD/$$TARGET/deviceplugin"$$TARGET".json \
--output extern-plugininfo.h \
--builddir $$OUT_PWD;
# Add it as a compiler, so it will be called before building like moc
QMAKE_EXTRA_COMPILERS += plugininfo extern-plugininfo
# But also add it as a target so we can add it separately without building. E.g. for updating translations.
QMAKE_EXTRA_TARGETS += plugininfo extern-plugininfo
# Install plugin
target.path = $$[QT_INSTALL_LIBS]/nymea/plugins/

View File

@ -45,21 +45,21 @@ void TestActions::executeAction_data()
QVariantList params;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 5);
params.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
params.append(param2);
QTest::newRow("valid action") << m_mockDeviceId << mockActionIdWithParams << params << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockActionIdWithParams << params << Device::DeviceErrorDeviceNotFound;
QTest::newRow("valid action") << m_mockDeviceId << mockWithParamsActionTypeId << params << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockWithParamsActionTypeId << params << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid actionTypeId") << m_mockDeviceId << ActionTypeId::createActionTypeId() << params << Device::DeviceErrorActionTypeNotFound;
QTest::newRow("missing params") << m_mockDeviceId << mockActionIdWithParams << QVariantList() << Device::DeviceErrorMissingParameter;
QTest::newRow("async action") << m_mockDeviceId << mockActionIdAsync << QVariantList() << Device::DeviceErrorNoError;
QTest::newRow("broken action") << m_mockDeviceId << mockActionIdFailing << QVariantList() << Device::DeviceErrorSetupFailed;
QTest::newRow("async broken action") << m_mockDeviceId << mockActionIdAsyncFailing << QVariantList() << Device::DeviceErrorSetupFailed;
QTest::newRow("missing params") << m_mockDeviceId << mockWithParamsActionTypeId << QVariantList() << Device::DeviceErrorMissingParameter;
QTest::newRow("async action") << m_mockDeviceId << mockAsyncActionTypeId << QVariantList() << Device::DeviceErrorNoError;
QTest::newRow("broken action") << m_mockDeviceId << mockFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed;
QTest::newRow("async broken action") << m_mockDeviceId << mockAsyncFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed;
}
void TestActions::executeAction()
@ -119,7 +119,7 @@ void TestActions::getActionType_data()
QTest::addColumn<ActionTypeId>("actionTypeId");
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("valid actiontypeid") << mockActionIdWithParams << Device::DeviceErrorNoError;
QTest::newRow("valid actiontypeid") << mockWithParamsActionTypeId << Device::DeviceErrorNoError;
QTest::newRow("invalid actiontypeid") << ActionTypeId::createActionTypeId() << Device::DeviceErrorActionTypeNotFound;
}

View File

@ -161,7 +161,7 @@ void TestDevices::setPluginConfig()
QVariantList configuration;
QVariantMap configParam;
configParam.insert("paramTypeId", configParamIntParamTypeId);
configParam.insert("paramTypeId", mockDevicePluginConfigParamIntParamTypeId);
configParam.insert("value", value);
configuration.append(configParam);
params.insert("configuration", configuration);
@ -174,7 +174,7 @@ void TestDevices::setPluginConfig()
response = injectAndWait("Devices.GetPluginConfiguration", params);
verifyDeviceError(response);
qDebug() << value << response.toMap().value("params").toMap().value("configuration").toList().first();
QVERIFY2(ParamTypeId(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("paramTypeId").toString()) == configParamIntParamTypeId, "Value not set correctly");
QVERIFY2(ParamTypeId(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("paramTypeId").toString()) == mockDevicePluginConfigParamIntParamTypeId, "Value not set correctly");
QVERIFY2(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("value") == value, "Value not set correctly");
}
}
@ -255,13 +255,13 @@ void TestDevices::addConfiguredDevice_data()
QTest::addColumn<Device::DeviceError>("deviceError");
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId.toString());
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId.toString());
httpportParam.insert("value", m_mockDevice1Port - 1);
QVariantMap asyncParam;
asyncParam.insert("paramTypeId", asyncParamTypeId);
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParam.insert("value", true);
QVariantMap brokenParam;
brokenParam.insert("paramTypeId", brokenParamTypeId);
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParam.insert("value", true);
QVariantList deviceParams;
@ -330,15 +330,15 @@ void TestDevices::storedDevices()
params.insert("name", "Test stored Device");
QVariantList deviceParams;
QVariantMap asyncParam;
asyncParam.insert("paramTypeId", asyncParamTypeId);
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParam.insert("value", false);
deviceParams.append(asyncParam);
QVariantMap brokenParam;
brokenParam.insert("paramTypeId", brokenParamTypeId);
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParam.insert("value", false);
deviceParams.append(brokenParam);
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8889);
deviceParams.append(httpportParam);
params.insert("deviceParams", deviceParams);
@ -380,7 +380,7 @@ void TestDevices::discoverDevices_data()
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -445,7 +445,7 @@ void TestDevices::addPushButtonDevices()
// Discover device
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockPushButtonDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -511,7 +511,7 @@ void TestDevices::addDisplayPinDevices()
// Discover device
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -636,7 +636,7 @@ void TestDevices::getActionTypes_data()
QTest::addColumn<QList<ActionTypeId> >("actionTypeTestData");
QTest::newRow("valid deviceclass") << mockDeviceClassId
<< (QList<ActionTypeId>() << mockActionIdAsync << mockActionIdAsyncFailing << mockActionIdFailing << mockActionIdNoParams << mockActionIdPower << mockActionIdWithParams);
<< (QList<ActionTypeId>() << mockAsyncActionTypeId << mockAsyncFailingActionTypeId << mockFailingActionTypeId << mockWithoutParamsActionTypeId << mockPowerActionTypeId << mockWithoutParamsActionTypeId);
QTest::newRow("invalid deviceclass") << DeviceClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << QList<ActionTypeId>();
}
@ -709,7 +709,7 @@ void TestDevices::getStateTypes()
QVariantList stateTypes = response.toMap().value("params").toMap().value("stateTypes").toList();
QCOMPARE(stateTypes.count(), resultCount);
if (resultCount > 0) {
QCOMPARE(stateTypes.first().toMap().value("id").toString(), mockIntStateId.toString());
QCOMPARE(stateTypes.first().toMap().value("id").toString(), mockIntStateTypeId.toString());
}
}
@ -718,8 +718,8 @@ void TestDevices::getStateType_data()
QTest::addColumn<StateTypeId>("stateTypeId");
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("valid int state") << mockIntStateId << Device::DeviceErrorNoError;
QTest::newRow("valid bool state") << mockBoolStateId << Device::DeviceErrorNoError;
QTest::newRow("valid int state") << mockIntStateTypeId << Device::DeviceErrorNoError;
QTest::newRow("valid bool state") << mockBoolStateTypeId << Device::DeviceErrorNoError;
QTest::newRow("invalid stateTypeId") << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound;
}
@ -750,8 +750,8 @@ void TestDevices::getStateValue_data()
QTest::addColumn<StateTypeId>("stateTypeId");
QTest::addColumn<Device::DeviceError>("statusCode");
QTest::newRow("valid deviceId") << m_mockDeviceId << mockIntStateId << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << mockIntStateId << Device::DeviceErrorDeviceNotFound;
QTest::newRow("valid deviceId") << m_mockDeviceId << mockIntStateTypeId << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << mockIntStateTypeId << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid statetypeId") << m_mockDeviceId << StateTypeId("120514f1-343e-4621-9bff-dac616169df9") << Device::DeviceErrorStateTypeNotFound;
}
@ -816,7 +816,7 @@ void TestDevices::editDevices()
// add device
QVariantList deviceParams;
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8889);
deviceParams.append(httpportParam);
@ -874,7 +874,7 @@ void TestDevices::testDeviceSettings()
// add device
QVariantList deviceParams;
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8889);
deviceParams.append(httpportParam);
@ -899,7 +899,7 @@ void TestDevices::testDeviceSettings()
QVariantList settings = device.value("settings").toList();
QCOMPARE(settings.count(), 1);
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
QVERIFY2(settings.first().toMap().value("value").toInt() == 5, "Setting 1 default value not matching");
// change a setting
@ -907,7 +907,7 @@ void TestDevices::testDeviceSettings()
params.insert("deviceId", deviceId);
settings.clear();
QVariantMap setting;
setting.insert("paramTypeId", mockSetting1ParamTypeId);
setting.insert("paramTypeId", mockSettingsSetting1ParamTypeId);
setting.insert("value", 7);
settings.append(setting);
params.insert("settings", settings);
@ -926,7 +926,7 @@ void TestDevices::testDeviceSettings()
settings = device.value("settings").toList();
QCOMPARE(settings.count(), 1);
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
QVERIFY2(settings.first().toMap().value("value").toInt() == 7, "Setting 1 changed value not matching");
restartServer();
@ -944,7 +944,7 @@ void TestDevices::testDeviceSettings()
settings = device.value("settings").toList();
QCOMPARE(settings.count(), 1);
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
QVERIFY2(settings.first().toMap().value("value").toInt() == 7, "Setting 1 changed value not persisting restart");
}
@ -953,19 +953,19 @@ void TestDevices::reconfigureDevices_data()
{
QVariantList asyncChangeDeviceParams;
QVariantMap asyncParamDifferent;
asyncParamDifferent.insert("paramTypeId", asyncParamTypeId);
asyncParamDifferent.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParamDifferent.insert("value", true);
asyncChangeDeviceParams.append(asyncParamDifferent);
QVariantList httpportChangeDeviceParams;
QVariantMap httpportParamDifferent;
httpportParamDifferent.insert("paramTypeId", httpportParamTypeId);
httpportParamDifferent.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParamDifferent.insert("value", 8893); // if change -> change also newPort in reconfigureDevices()
httpportChangeDeviceParams.append(httpportParamDifferent);
QVariantList brokenChangedDeviceParams;
QVariantMap brokenParamDifferent;
brokenParamDifferent.insert("paramTypeId", brokenParamTypeId);
brokenParamDifferent.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParamDifferent.insert("value", true);
brokenChangedDeviceParams.append(brokenParamDifferent);
@ -1000,15 +1000,15 @@ void TestDevices::reconfigureDevices()
params.insert("name", "Device to edit");
QVariantList deviceParams;
QVariantMap asyncParam;
asyncParam.insert("paramTypeId", asyncParamTypeId);
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParam.insert("value", false);
deviceParams.append(asyncParam);
QVariantMap brokenParam;
brokenParam.insert("paramTypeId", brokenParamTypeId);
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParam.insert("value", broken);
deviceParams.append(brokenParam);
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8892);
deviceParams.append(httpportParam);
params.insert("deviceParams", deviceParams);
@ -1123,7 +1123,7 @@ void TestDevices::reconfigureByDiscovery_data()
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 2);
discoveryParams.append(resultCountParam);
@ -1228,7 +1228,7 @@ void TestDevices::reconfigureByDiscovery()
// Note: this shows that by discovery a not editable param (name) can be changed!
foreach (QVariant param, deviceMap.value("params").toList()) {
if (param.toMap().value("paramTypeId") == httpportParamTypeId) {
if (param.toMap().value("paramTypeId") == mockDeviceHttpportParamTypeId) {
QCOMPARE(param.toMap().value("value").toInt(), 55556);
}
}
@ -1261,7 +1261,7 @@ void TestDevices::reconfigureByDiscoveryAndPair()
{
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -1363,27 +1363,28 @@ void TestDevices::reconfigureAutodevice()
qCDebug(dcTests()) << "Reconfigure auto device";
// Get the autodevice
QList<Device *> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
QList<Device *> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
// Get current auto device infos
Device *currentDevice = devices.first();
DeviceId deviceId = currentDevice->id();
int currentPort = currentDevice->paramValue(httpportParamTypeId).toInt();
int currentPort = currentDevice->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
// Trigger reconfigure signal in mock device
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
QSignalSpy spy(nam, SIGNAL(finished(QNetworkReply*)));
QSignalSpy spy(nam, &QNetworkAccessManager::finished);
QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(QString("http://localhost:%1/reconfigureautodevice").arg(currentPort))));
spy.wait();
QCOMPARE(spy.count(), 1);
qCDebug(dcTests()) << "Reconfigure reply:" << reply->error() << reply->readAll();
reply->deleteLater();
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
QVERIFY(device);
int newPort = device->paramValue(httpportParamTypeId).toInt();
int newPort = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
// Note: reconfigure autodevice increases the http port by 1
QVERIFY(newPort == currentPort + 1);
QCOMPARE(newPort, currentPort + 1);
}
@ -1436,7 +1437,7 @@ void TestDevices::removeAutoDevice()
Device *device = devices.first();
// trigger disappear signal in mock device
int port = device->paramValue(httpportParamTypeId).toInt();
int port = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/disappear").arg(port)));
QNetworkReply *reply = nam->get(request);
spy.wait();
@ -1446,7 +1447,7 @@ void TestDevices::removeAutoDevice()
// Ok, now do the same with an autocreated one. It should go away
devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
device = devices.first();
@ -1454,7 +1455,7 @@ void TestDevices::removeAutoDevice()
// trigger disappear signal in mock device
spy.clear();
port = device->paramValue(httpportParamTypeId).toInt();
port = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
request.setUrl(QUrl(QString("http://localhost:%1/disappear").arg(port)));
reply = nam->get(request);
@ -1462,7 +1463,7 @@ void TestDevices::removeAutoDevice()
QCOMPARE(spy.count(), 1);
reply->deleteLater();
QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId).count() == 0, "Mock device has not disappeared even though it should have.");
QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId).count() == 0, "Mock device has not disappeared even though it should have.");
}
#include "testdevices.moc"

View File

@ -50,8 +50,8 @@ void TestEvents::triggerEvent()
QNetworkAccessManager nam;
// trigger event in mock device
int port = device->paramValue(httpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
@ -62,7 +62,7 @@ void TestEvents::triggerEvent()
Event event = spy.at(i).at(0).value<Event>();
if (event.deviceId() == device->id()) {
// Make sure the event contains all the stuff we expect
QCOMPARE(event.eventTypeId(), mockEvent1Id);
QCOMPARE(event.eventTypeId(), mockEvent1EventTypeId);
}
}
}
@ -79,8 +79,8 @@ void TestEvents::triggerStateChangeEvent()
QNetworkAccessManager nam;
// trigger state changed event in mock device
int port = device->paramValue(httpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateId.toString()).arg(11)));
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateTypeId.toString()).arg(11)));
QNetworkReply *reply = nam.get(request);
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
@ -91,8 +91,8 @@ void TestEvents::triggerStateChangeEvent()
Event event = spy.at(i).at(0).value<Event>();
if (event.deviceId() == device->id()) {
// Make sure the event contains all the stuff we expect
QCOMPARE(event.eventTypeId().toString(), mockIntStateId.toString());
QCOMPARE(event.param(ParamTypeId(mockIntStateId.toString())).value().toInt(), 11);
QCOMPARE(event.eventTypeId().toString(), mockIntStateTypeId.toString());
QCOMPARE(event.param(ParamTypeId(mockIntStateTypeId.toString())).value().toInt(), 11);
}
}
}
@ -115,7 +115,7 @@ void TestEvents::getEventType_data()
QTest::addColumn<EventTypeId>("eventTypeId");
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("valid eventypeid") << mockEvent1Id << Device::DeviceErrorNoError;
QTest::newRow("valid eventypeid") << mockEvent1EventTypeId << Device::DeviceErrorNoError;
QTest::newRow("invalid eventypeid") << EventTypeId::createEventTypeId() << Device::DeviceErrorEventTypeNotFound;
}

View File

@ -184,7 +184,7 @@ void TestJSONRPC::testHandshakeLocale()
QVariantMap supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap();
bool found = false;
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) {
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoClassId) {
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoDeviceClassId) {
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Device (Auto created)"));
found = true;
}
@ -200,7 +200,7 @@ void TestJSONRPC::testHandshakeLocale()
supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap();
found = false;
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) {
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoClassId) {
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoDeviceClassId) {
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Gerät (Automatisch erzeugt)"));
found = true;
}
@ -650,7 +650,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
// add device and wait for notification
QVariantList deviceParams;
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8765);
deviceParams.append(httpportParam);
@ -697,7 +697,7 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
// Add rule and wait for notification
// StateDescriptor
QVariantMap stateDescriptor;
stateDescriptor.insert("stateTypeId", mockIntStateId);
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor.insert("deviceId", m_mockDeviceId);
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
stateDescriptor.insert("value", "20");
@ -707,13 +707,13 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
// RuleAction
QVariantMap actionNoParams;
actionNoParams.insert("actionTypeId", mockActionIdNoParams);
actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
actionNoParams.insert("deviceId", m_mockDeviceId);
actionNoParams.insert("ruleActionParams", QVariantList());
// EventDescriptor
QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1Id);
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockDeviceId);
eventDescriptor.insert("paramDescriptors", QVariantList());
@ -761,7 +761,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
// Add rule and wait for notification
// StateDescriptor
QVariantMap stateDescriptor;
stateDescriptor.insert("stateTypeId", mockIntStateId);
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor.insert("deviceId", m_mockDeviceId);
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptor.insert("value", "20");
@ -771,7 +771,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
// RuleAction
QVariantMap actionNoParams;
actionNoParams.insert("actionTypeId", mockActionIdNoParams);
actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
actionNoParams.insert("deviceId", m_mockDeviceId);
actionNoParams.insert("ruleActionParams", QVariantList());
@ -804,7 +804,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
// state state to 20
qDebug() << "setting mock int state to 20";
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(20)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(20)));
QNetworkReply *reply = nam.get(request);
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
@ -819,7 +819,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
// set the rule inactive
qDebug() << "setting mock int state to 42";
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(42)));
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(42)));
QNetworkReply *reply2 = nam.get(request2);
if (spy.count() == 0) spy.wait();
QCOMPARE(spy.count(), 1);
@ -861,7 +861,7 @@ void TestJSONRPC::deviceChangedNotifications()
// add device and wait for notification
QVariantList deviceParams;
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 23234);
deviceParams.append(httpportParam);
@ -888,7 +888,7 @@ void TestJSONRPC::deviceChangedNotifications()
// now reconfigure the device and check the deviceChanged notification
QVariantList newDeviceParams;
QVariantMap newHttpportParam;
newHttpportParam.insert("paramTypeId", httpportParamTypeId);
newHttpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
newHttpportParam.insert("value", 45473);
newDeviceParams.append(newHttpportParam);
@ -1039,7 +1039,7 @@ void TestJSONRPC::pluginConfigChangeEmitsNotification()
params.insert("pluginId", mockPluginId);
QVariantList pluginParams;
QVariantMap param1;
param1.insert("paramTypeId", configParamIntParamTypeId);
param1.insert("paramTypeId", mockDevicePluginConfigParamIntParamTypeId);
param1.insert("value", 42);
pluginParams.append(param1);
params.insert("configuration", pluginParams);

View File

@ -213,8 +213,8 @@ void TestLogging::eventLogs()
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
// trigger event in mock device
int port = device->paramValue(httpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
// Lets wait for the notification
@ -233,7 +233,7 @@ void TestLogging::eventLogs()
if (logEntry.value("deviceId").toString() == device->id().toString()) {
found = true;
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1Id.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1EventTypeId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
@ -250,7 +250,7 @@ void TestLogging::eventLogs()
params.insert("deviceIds", QVariantList() << device->id());
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockEvent1Id);
params.insert("typeIds", QVariantList() << mockEvent1EventTypeId);
QVariant response = injectAndWait("Logging.GetLogEntries", params);
verifyLoggingError(response);
@ -268,16 +268,16 @@ void TestLogging::actionLog()
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 7);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
QVariantMap params;
params.insert("actionTypeId", mockActionIdWithParams);
params.insert("actionTypeId", mockWithParamsActionTypeId);
params.insert("deviceId", m_mockDeviceId);
params.insert("params", actionParams);
@ -304,7 +304,7 @@ void TestLogging::actionLog()
if (logEntry.value("deviceId").toString() == m_mockDeviceId.toString()) {
found = true;
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdWithParams.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockWithParamsActionTypeId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
@ -318,7 +318,7 @@ void TestLogging::actionLog()
// EXECUTE without params
params.clear(); clientSpy.clear();
params.insert("actionTypeId", mockActionIdNoParams);
params.insert("actionTypeId", mockWithoutParamsActionTypeId);
params.insert("deviceId", m_mockDeviceId);
response = injectAndWait("Actions.ExecuteAction", params);
verifyDeviceError(response);
@ -345,7 +345,7 @@ void TestLogging::actionLog()
// EXECUTE broken action
params.clear(); clientSpy.clear();
params.insert("actionTypeId", mockActionIdFailing);
params.insert("actionTypeId", mockFailingActionTypeId);
params.insert("deviceId", m_mockDeviceId);
response = injectAndWait("Actions.ExecuteAction", params);
verifyDeviceError(response, Device::DeviceErrorSetupFailed);
@ -363,7 +363,7 @@ void TestLogging::actionLog()
if (logEntry.value("deviceId").toString() == m_mockDeviceId.toString()) {
found = true;
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdFailing.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockFailingActionTypeId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelAlert));
@ -396,7 +396,7 @@ void TestLogging::actionLog()
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockActionIdNoParams);
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId);
response = injectAndWait("Logging.GetLogEntries", params);
verifyLoggingError(response);
@ -408,7 +408,7 @@ void TestLogging::actionLog()
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockActionIdNoParams << mockActionIdWithParams << mockActionIdFailing);
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId << mockWithParamsActionTypeId << mockFailingActionTypeId);
response = injectAndWait("Logging.GetLogEntries", params);
verifyLoggingError(response);
@ -465,7 +465,7 @@ void TestLogging::testDoubleValues()
// Discover device
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -505,12 +505,12 @@ void TestLogging::testDoubleValues()
// Set the double state value and sniff for LogEntryAdded notification
double value = 23.80;
QVariantMap actionParam;
actionParam.insert("paramTypeId", doubleStateParamTypeId.toString());
actionParam.insert("paramTypeId", mockDisplayPinDoubleActionDoubleParamTypeId.toString());
actionParam.insert("value", value);
params.clear(); response.clear();
params.insert("deviceId", deviceId);
params.insert("actionTypeId", doubleStateParamTypeId.toString());
params.insert("actionTypeId", mockDisplayPinDoubleActionTypeId.toString());
params.insert("params", QVariantList() << actionParam);
response = injectAndWait("Actions.ExecuteAction", params);
@ -523,8 +523,8 @@ void TestLogging::testDoubleValues()
foreach (const QVariant &logNotificationVariant, logNotificationsList) {
QVariantMap logNotification = logNotificationVariant.toMap().value("params").toMap().value("logEntry").toMap();
if (logNotification.value("typeId").toString() == doubleStateParamTypeId.toString()) {
if (logNotification.value("typeId").toString() == doubleStateParamTypeId.toString()) {
if (logNotification.value("typeId").toString() == mockDisplayPinDoubleActionDoubleParamTypeId.toString()) {
if (logNotification.value("typeId").toString() == mockDisplayPinDoubleActionDoubleParamTypeId.toString()) {
// If state source
if (logNotification.value("source").toString() == JsonTypes::loggingSourceToString(Logging::LoggingSourceStates)) {
@ -558,7 +558,7 @@ void TestLogging::testHouseKeeping()
params.insert("name", "TestDeviceToBeRemoved");
QVariantList deviceParams;
QVariantMap httpParam;
httpParam.insert("paramTypeId", httpportParamTypeId);
httpParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpParam.insert("value", 6667);
deviceParams.append(httpParam);
params.insert("deviceParams", deviceParams);
@ -569,7 +569,7 @@ void TestLogging::testHouseKeeping()
// Trigger something that creates a logging entry
QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(6667).arg(mockIntStateId.toString()).arg(4321)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(6667).arg(mockIntStateTypeId.toString()).arg(4321)));
QNetworkReply *reply = nam.get(request);
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
spy.wait();
@ -598,16 +598,16 @@ void TestLogging::testLimits()
for (int i = 0; i < 50; i++) {
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", i);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
QVariantMap params;
params.insert("actionTypeId", mockActionIdWithParams);
params.insert("actionTypeId", mockWithParamsActionTypeId);
params.insert("deviceId", m_mockDeviceId);
params.insert("params", actionParams);

View File

@ -139,11 +139,11 @@ void TestRestDeviceClasses::getActionTypes_data()
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType async") << mockDeviceClassId.toString() << mockActionIdAsync.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType no params") << mockDeviceClassId.toString() << mockActionIdNoParams.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType failing") << mockDeviceClassId.toString() << mockActionIdFailing.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType with params") << mockDeviceClassId.toString() << mockActionIdWithParams.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockActionIdNoParams.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("ActionType async") << mockDeviceClassId.toString() << mockAsyncActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType no params") << mockDeviceClassId.toString() << mockWithoutParamsActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType failing") << mockDeviceClassId.toString() << mockFailingActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("ActionType with params") << mockDeviceClassId.toString() << mockWithParamsActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockWithoutParamsActionTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("invalid ActionTypeId") << mockDeviceClassId.toString() << ActionTypeId::createActionTypeId().toString() << 404 << Device::DeviceErrorActionTypeNotFound;
QTest::newRow("invalid ActionTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorActionTypeNotFound;
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
@ -180,9 +180,9 @@ void TestRestDeviceClasses::getStateTypes_data()
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("StateType bool") << mockDeviceClassId.toString() << mockBoolStateId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("StateType int") << mockDeviceClassId.toString() << mockIntStateId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockBoolStateId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("StateType bool") << mockDeviceClassId.toString() << mockBoolStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("StateType int") << mockDeviceClassId.toString() << mockIntStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockBoolStateTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("invalid StateTypeId") << mockDeviceClassId.toString() << StateTypeId::createStateTypeId().toString() << 404 << Device::DeviceErrorStateTypeNotFound;
QTest::newRow("invalid StateTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorStateTypeNotFound;
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
@ -218,9 +218,9 @@ void TestRestDeviceClasses::getEventTypes_data()
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("EventType 1") << mockDeviceClassId.toString() << mockEvent1Id.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("EventType 2") << mockDeviceClassId.toString() << mockEvent2Id.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockEvent2Id.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("EventType 1") << mockDeviceClassId.toString() << mockEvent1EventTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("EventType 2") << mockDeviceClassId.toString() << mockEvent2EventTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockEvent2EventTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
QTest::newRow("invalid EventTypeId") << mockDeviceClassId.toString() << EventTypeId::createEventTypeId().toString() << 404 << Device::DeviceErrorEventTypeNotFound;
QTest::newRow("invalid EventTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorEventTypeNotFound;
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
@ -257,11 +257,11 @@ void TestRestDeviceClasses::discoverDevices_data()
QTest::addColumn<Device::DeviceError>("error");
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
QVariantMap invalidResultCountParam;
invalidResultCountParam.insert("paramTypeId", resultCountParamTypeId);
invalidResultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
invalidResultCountParam.insert("value", 10);
QVariantList discoveryParams;

View File

@ -104,19 +104,19 @@ void TestRestDevices::addConfiguredDevice_data()
QTest::addColumn<int>("expectedStatusCode");
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", m_mockDevice1Port - 1);
QVariantMap asyncParam;
asyncParam.insert("paramTypeId", asyncParamTypeId);
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParam.insert("value", true);
QVariantMap notAsyncParam;
notAsyncParam.insert("paramTypeId", asyncParamTypeId);
notAsyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
notAsyncParam.insert("value", false);
QVariantMap notBrokenParam;
notBrokenParam.insert("paramTypeId", brokenParamTypeId);
notBrokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
notBrokenParam.insert("value", false);
QVariantMap brokenParam;
brokenParam.insert("paramTypeId", brokenParamTypeId);
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParam.insert("value", true);
QVariantList deviceParams;
@ -198,7 +198,7 @@ void TestRestDevices::addPushButtonDevices()
// Discover device
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockPushButtonDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -279,7 +279,7 @@ void TestRestDevices::addDisplayPinDevices()
// Discover device
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 1);
discoveryParams.append(resultCountParam);
@ -419,21 +419,21 @@ void TestRestDevices::executeAction_data()
QVariantList params;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 5);
params.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
params.append(param2);
QTest::newRow("valid action") << m_mockDeviceId << mockActionIdWithParams << params << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockActionIdWithParams << params << 404 << Device::DeviceErrorDeviceNotFound;
QTest::newRow("valid action") << m_mockDeviceId << mockWithParamsActionTypeId << params << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockWithParamsActionTypeId << params << 404 << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid actionTypeId") << m_mockDeviceId << ActionTypeId::createActionTypeId() << params << 404 << Device::DeviceErrorActionTypeNotFound;
QTest::newRow("missing params") << m_mockDeviceId << mockActionIdWithParams << QVariantList() << 500 << Device::DeviceErrorMissingParameter;
QTest::newRow("async action") << m_mockDeviceId << mockActionIdAsync << QVariantList() << 200 << Device::DeviceErrorNoError;
QTest::newRow("broken action") << m_mockDeviceId << mockActionIdFailing << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
QTest::newRow("async broken action") << m_mockDeviceId << mockActionIdAsyncFailing << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
QTest::newRow("missing params") << m_mockDeviceId << mockWithParamsActionTypeId << QVariantList() << 500 << Device::DeviceErrorMissingParameter;
QTest::newRow("async action") << m_mockDeviceId << mockAsyncActionTypeId << QVariantList() << 200 << Device::DeviceErrorNoError;
QTest::newRow("broken action") << m_mockDeviceId << mockFailingActionTypeId << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
QTest::newRow("async broken action") << m_mockDeviceId << mockAsyncFailingActionTypeId << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
}
void TestRestDevices::executeAction()
@ -501,9 +501,9 @@ void TestRestDevices::getStateValue_data()
QTest::addColumn<int>("expectedStatusCode");
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("existing state") << device->id().toString() << mockIntStateId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("existing state") << device->id().toString() << mockIntStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("all states") << device->id().toString() << QString() << 200 << Device::DeviceErrorNoError;
QTest::newRow("invalid device") << DeviceId::createDeviceId().toString() << mockIntStateId.toString() << 404 << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid device") << DeviceId::createDeviceId().toString() << mockIntStateTypeId.toString() << 404 << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid device id format") << "uuid" << StateTypeId::createStateTypeId().toString() << 400 << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid statetype") << device->id().toString() << StateTypeId::createStateTypeId().toString() << 404 << Device::DeviceErrorStateTypeNotFound;
QTest::newRow("invalid statetype format") << device->id().toString() << "uuid" << 400 << Device::DeviceErrorStateTypeNotFound;
@ -548,7 +548,7 @@ void TestRestDevices::editDevices()
QVariantList deviceParams;
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", m_mockDevice1Port - 2);
deviceParams.append(httpportParam);
@ -587,19 +587,19 @@ void TestRestDevices::reconfigureDevices_data()
{
QVariantList asyncChangeDeviceParams;
QVariantMap asyncParamDifferent;
asyncParamDifferent.insert("paramTypeId", asyncParamTypeId);
asyncParamDifferent.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParamDifferent.insert("value", true);
asyncChangeDeviceParams.append(asyncParamDifferent);
QVariantList httpportChangeDeviceParams;
QVariantMap httpportParamDifferent;
httpportParamDifferent.insert("paramTypeId", httpportParamTypeId);
httpportParamDifferent.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParamDifferent.insert("value", 8895); // if change -> change also newPort in reconfigureDevices()
httpportChangeDeviceParams.append(httpportParamDifferent);
QVariantList brokenChangedDeviceParams;
QVariantMap brokenParamDifferent;
brokenParamDifferent.insert("paramTypeId", brokenParamTypeId);
brokenParamDifferent.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParamDifferent.insert("value", true);
brokenChangedDeviceParams.append(brokenParamDifferent);
@ -635,15 +635,15 @@ void TestRestDevices::reconfigureDevices()
params.insert("name", "Edit mock device");
QVariantList deviceParams;
QVariantMap asyncParam;
asyncParam.insert("paramTypeId", asyncParamTypeId);
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
asyncParam.insert("value", false);
deviceParams.append(asyncParam);
QVariantMap brokenParam;
brokenParam.insert("paramTypeId", brokenParamTypeId);
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
brokenParam.insert("value", broken);
deviceParams.append(brokenParam);
QVariantMap httpportParam;
httpportParam.insert("paramTypeId", httpportParamTypeId);
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
httpportParam.insert("value", 8896);
deviceParams.append(httpportParam);
params.insert("deviceParams", deviceParams);
@ -695,7 +695,7 @@ void TestRestDevices::reconfigureByDiscovery_data()
QVariantList discoveryParams;
QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
resultCountParam.insert("value", 2);
discoveryParams.append(resultCountParam);

View File

@ -150,8 +150,8 @@ void TestRestLogging::eventLogs()
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
// trigger event in mock device
int port = device->paramValue(httpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
clientSpy.wait();
@ -169,7 +169,7 @@ void TestRestLogging::eventLogs()
if (logEntry.value("deviceId").toString() == device->id().toString()) {
found = true;
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1Id.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1EventTypeId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
@ -186,7 +186,7 @@ void TestRestLogging::eventLogs()
params.insert("deviceIds", QVariantList() << device->id());
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockEvent1Id);
params.insert("typeIds", QVariantList() << mockEvent1EventTypeId);
QVariant response = injectAndWait("Logging.GetLogEntries", params);
verifyLoggingError(response);
@ -202,16 +202,16 @@ void TestRestLogging::actionLog()
{
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 7);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
QVariantMap params;
params.insert("actionTypeId", mockActionIdWithParams);
params.insert("actionTypeId", mockWithParamsActionTypeId);
params.insert("deviceId", m_mockDeviceId);
params.insert("params", actionParams);
@ -232,7 +232,7 @@ void TestRestLogging::actionLog()
QVariantMap logEntry = notification.toMap().value("params").toMap().value("logEntry").toMap();
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdWithParams.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockWithParamsActionTypeId.toString());
QCOMPARE(logEntry.value("deviceId").toString(), m_mockDeviceId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
@ -240,7 +240,7 @@ void TestRestLogging::actionLog()
// EXECUTE without params
params.clear(); clientSpy.clear();
params.insert("actionTypeId", mockActionIdNoParams);
params.insert("actionTypeId", mockWithoutParamsActionTypeId);
params.insert("deviceId", m_mockDeviceId);
response = injectAndWait("Actions.ExecuteAction", params);
verifyDeviceError(response);
@ -269,7 +269,7 @@ void TestRestLogging::actionLog()
// EXECUTE broken action
params.clear(); clientSpy.clear();
params.insert("actionTypeId", mockActionIdFailing);
params.insert("actionTypeId", mockFailingActionTypeId);
params.insert("deviceId", m_mockDeviceId);
response = injectAndWait("Actions.ExecuteAction", params);
verifyDeviceError(response, Device::DeviceErrorSetupFailed);
@ -281,7 +281,7 @@ void TestRestLogging::actionLog()
logEntry = notification.toMap().value("params").toMap().value("logEntry").toMap();
// Make sure the notification contains all the stuff we expect
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdFailing.toString());
QCOMPARE(logEntry.value("typeId").toString(), mockFailingActionTypeId.toString());
QCOMPARE(logEntry.value("deviceId").toString(), m_mockDeviceId.toString());
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
@ -310,7 +310,7 @@ void TestRestLogging::actionLog()
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockActionIdNoParams);
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId);
query.clear();
query.addQueryItem("filter", QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact));
@ -324,7 +324,7 @@ void TestRestLogging::actionLog()
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
params.insert("typeIds", QVariantList() << mockActionIdNoParams << mockActionIdWithParams << mockActionIdFailing);
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId << mockWithParamsActionTypeId << mockFailingActionTypeId);
query.clear();
query.addQueryItem("filter", QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact));

View File

@ -89,7 +89,7 @@ void TestRestRules::cleanupMockHistory()
{
QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
spy.wait();
QCOMPARE(spy.count(), 1);
@ -149,7 +149,7 @@ void TestRestRules::triggerMockEvent()
// trigger event in mock device
QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
QNetworkRequest request = QNetworkRequest(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
QNetworkRequest request = QNetworkRequest(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
spy.wait();
QCOMPARE(spy.count(), 1);
@ -162,7 +162,7 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
// StateDescriptor
QVariantMap stateDescriptor;
stateDescriptor.insert("stateTypeId", mockIntStateId);
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor.insert("deviceId", m_mockDeviceId);
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
stateDescriptor.insert("value", 25);
@ -174,14 +174,14 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
// RuleAction
QVariantMap action;
action.insert("actionTypeId", mockActionIdWithParams);
action.insert("actionTypeId", mockWithParamsActionTypeId);
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 5);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
action.insert("deviceId", m_mockDeviceId);
@ -189,7 +189,7 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
// RuleExitAction
QVariantMap exitAction;
exitAction.insert("actionTypeId", mockActionIdNoParams);
exitAction.insert("actionTypeId", mockWithoutParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", QVariantList());
@ -340,7 +340,7 @@ void TestRestRules::addRemoveRules_data()
{
// RuleAction
QVariantMap validActionNoParams;
validActionNoParams.insert("actionTypeId", mockActionIdNoParams);
validActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
validActionNoParams.insert("deviceId", m_mockDeviceId);
validActionNoParams.insert("ruleActionParams", QVariantList());
@ -351,7 +351,7 @@ void TestRestRules::addRemoveRules_data()
// RuleExitAction
QVariantMap validExitActionNoParams;
validExitActionNoParams.insert("actionTypeId", mockActionIdNoParams);
validExitActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
validExitActionNoParams.insert("deviceId", m_mockDeviceId);
validExitActionNoParams.insert("ruleActionParams", QVariantList());
@ -362,7 +362,7 @@ void TestRestRules::addRemoveRules_data()
// StateDescriptor
QVariantMap stateDescriptor;
stateDescriptor.insert("stateTypeId", mockIntStateId);
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor.insert("deviceId", m_mockDeviceId);
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
stateDescriptor.insert("value", 20);
@ -378,23 +378,23 @@ void TestRestRules::addRemoveRules_data()
// EventDescriptor
QVariantMap validEventDescriptor1;
validEventDescriptor1.insert("eventTypeId", mockEvent1Id);
validEventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
validEventDescriptor1.insert("deviceId", m_mockDeviceId);
validEventDescriptor1.insert("paramDescriptors", QVariantList());
QVariantMap validEventDescriptor2;
validEventDescriptor2.insert("eventTypeId", mockEvent2Id);
validEventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
validEventDescriptor2.insert("deviceId", m_mockDeviceId);
QVariantList params;
QVariantMap param1;
param1.insert("paramTypeId", mockParamIntParamTypeId);
param1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
param1.insert("value", 3);
param1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
params.append(param1);
validEventDescriptor2.insert("paramDescriptors", params);
QVariantMap validEventDescriptor3;
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
validEventDescriptor3.insert("paramDescriptors", QVariantList());
@ -404,48 +404,48 @@ void TestRestRules::addRemoveRules_data()
eventDescriptorList.append(validEventDescriptor2);
QVariantMap invalidEventDescriptor;
invalidEventDescriptor.insert("eventTypeId", mockEvent1Id);
invalidEventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
invalidEventDescriptor.insert("deviceId", DeviceId());
invalidEventDescriptor.insert("paramDescriptors", QVariantList());
// RuleAction event based
QVariantMap validActionEventBased;
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
validActionEventBased.insert("deviceId", m_mockDeviceId);
QVariantMap validActionEventBasedParam1;
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
validActionEventBasedParam1.insert("eventParamTypeId", mockParamIntParamTypeId);
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
QVariantMap validActionEventBasedParam2;
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
validActionEventBasedParam2.insert("value", false);
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
QVariantMap invalidActionEventBased;
invalidActionEventBased.insert("actionTypeId", mockActionIdNoParams);
invalidActionEventBased.insert("actionTypeId", mockWithoutParamsActionTypeId);
invalidActionEventBased.insert("deviceId", m_mockDeviceId);
validActionEventBasedParam1.insert("value", 10);
invalidActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1);
QVariantMap invalidActionEventBased2;
invalidActionEventBased2.insert("actionTypeId", mockActionIdWithParams);
invalidActionEventBased2.insert("actionTypeId", mockWithParamsActionTypeId);
invalidActionEventBased2.insert("deviceId", m_mockDeviceId);
QVariantMap invalidActionEventBasedParam2;
invalidActionEventBasedParam2.insert("paramTypeId", mockActionParam1ParamTypeId);
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1Id);
invalidActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1EventTypeId);
invalidActionEventBasedParam2.insert("eventParamTypeId", ParamTypeId::createParamTypeId());
QVariantMap invalidActionEventBasedParam3;
invalidActionEventBasedParam3.insert("paramTypeId", mockActionParam2ParamTypeId);
invalidActionEventBasedParam3.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
invalidActionEventBasedParam3.insert("value", 2);
invalidActionEventBased2.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam2 << invalidActionEventBasedParam3);
QVariantMap invalidActionEventBased3;
invalidActionEventBased3.insert("actionTypeId", mockActionIdWithParams);
invalidActionEventBased3.insert("actionTypeId", mockWithParamsActionTypeId);
invalidActionEventBased3.insert("deviceId", m_mockDeviceId);
QVariantMap invalidActionEventBasedParam4;
invalidActionEventBasedParam4.insert("paramTypeId", mockActionParam1ParamTypeId);
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1Id);
invalidActionEventBasedParam4.insert("eventParamTypeId", mockParamIntParamTypeId);
invalidActionEventBasedParam4.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1EventTypeId);
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
invalidActionEventBased3.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam4);
QTest::addColumn<bool>("enabled");
@ -574,7 +574,7 @@ void TestRestRules::editRules_data()
{
// RuleAction
QVariantMap validActionNoParams;
validActionNoParams.insert("actionTypeId", mockActionIdNoParams);
validActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
validActionNoParams.insert("deviceId", m_mockDeviceId);
validActionNoParams.insert("ruleActionParams", QVariantList());
@ -585,7 +585,7 @@ void TestRestRules::editRules_data()
// RuleExitAction
QVariantMap validExitActionNoParams;
validExitActionNoParams.insert("actionTypeId", mockActionIdNoParams);
validExitActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
validExitActionNoParams.insert("deviceId", m_mockDeviceId);
validExitActionNoParams.insert("ruleActionParams", QVariantList());
@ -596,7 +596,7 @@ void TestRestRules::editRules_data()
// StateDescriptor
QVariantMap stateDescriptor;
stateDescriptor.insert("stateTypeId", mockIntStateId);
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor.insert("deviceId", m_mockDeviceId);
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
stateDescriptor.insert("value", 20);
@ -612,23 +612,23 @@ void TestRestRules::editRules_data()
// EventDescriptor
QVariantMap validEventDescriptor1;
validEventDescriptor1.insert("eventTypeId", mockEvent1Id);
validEventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
validEventDescriptor1.insert("deviceId", m_mockDeviceId);
validEventDescriptor1.insert("paramDescriptors", QVariantList());
QVariantMap validEventDescriptor2;
validEventDescriptor2.insert("eventTypeId", mockEvent2Id);
validEventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
validEventDescriptor2.insert("deviceId", m_mockDeviceId);
QVariantList params;
QVariantMap param1;
param1.insert("paramTypeId", mockParamIntParamTypeId);
param1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
param1.insert("value", 3);
param1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
params.append(param1);
validEventDescriptor2.insert("paramDescriptors", params);
QVariantMap validEventDescriptor3;
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
validEventDescriptor3.insert("paramDescriptors", QVariantList());
@ -638,48 +638,48 @@ void TestRestRules::editRules_data()
eventDescriptorList.append(validEventDescriptor2);
QVariantMap invalidEventDescriptor;
invalidEventDescriptor.insert("eventTypeId", mockEvent1Id);
invalidEventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
invalidEventDescriptor.insert("deviceId", DeviceId());
invalidEventDescriptor.insert("paramDescriptors", QVariantList());
// RuleAction event based
QVariantMap validActionEventBased;
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
validActionEventBased.insert("deviceId", m_mockDeviceId);
QVariantMap validActionEventBasedParam1;
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
validActionEventBasedParam1.insert("eventParamTypeId", mockParamIntParamTypeId);
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
QVariantMap validActionEventBasedParam2;
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
validActionEventBasedParam2.insert("value", false);
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
QVariantMap invalidActionEventBased;
invalidActionEventBased.insert("actionTypeId", mockActionIdNoParams);
invalidActionEventBased.insert("actionTypeId", mockWithoutParamsActionTypeId);
invalidActionEventBased.insert("deviceId", m_mockDeviceId);
validActionEventBasedParam1.insert("value", 10);
invalidActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1);
QVariantMap invalidActionEventBased2;
invalidActionEventBased2.insert("actionTypeId", mockActionIdWithParams);
invalidActionEventBased2.insert("actionTypeId", mockWithoutParamsActionTypeId);
invalidActionEventBased2.insert("deviceId", m_mockDeviceId);
QVariantMap invalidActionEventBasedParam2;
invalidActionEventBasedParam2.insert("paramTypeId", mockActionParam1ParamTypeId);
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1Id);
invalidActionEventBasedParam2.insert("eventParamTypeId", mockEvent1Id);
invalidActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1EventTypeId);
invalidActionEventBasedParam2.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
QVariantMap invalidActionEventBasedParam3;
invalidActionEventBasedParam3.insert("paramTypeId", mockActionParam2ParamTypeId);
invalidActionEventBasedParam3.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
invalidActionEventBasedParam3.insert("value", 2);
invalidActionEventBased2.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam2 << invalidActionEventBasedParam3);
QVariantMap invalidActionEventBased3;
invalidActionEventBased3.insert("actionTypeId", mockActionIdWithParams);
invalidActionEventBased3.insert("actionTypeId", mockWithParamsActionTypeId);
invalidActionEventBased3.insert("deviceId", m_mockDeviceId);
QVariantMap invalidActionEventBasedParam4;
invalidActionEventBasedParam4.insert("paramTypeId", mockActionParam1ParamTypeId);
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1Id);
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent1Id);
invalidActionEventBasedParam4.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1EventTypeId);
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
invalidActionEventBased3.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam4);
QTest::addColumn<bool>("enabled");
@ -728,15 +728,15 @@ void TestRestRules::editRules()
// Add the rule we want to edit
QVariantList eventParamDescriptors;
QVariantMap eventDescriptor1;
eventDescriptor1.insert("eventTypeId", mockEvent1Id);
eventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor1.insert("deviceId", m_mockDeviceId);
eventDescriptor1.insert("paramDescriptors", QVariantList());
QVariantMap eventDescriptor2;
eventDescriptor2.insert("eventTypeId", mockEvent2Id);
eventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
eventDescriptor2.insert("deviceId", m_mockDeviceId);
eventDescriptor2.insert("paramDescriptors", QVariantList());
QVariantMap eventParam1;
eventParam1.insert("paramTypeId", mockParamIntParamTypeId);
eventParam1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
eventParam1.insert("value", 3);
eventParam1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
eventParamDescriptors.append(eventParam1);
@ -750,12 +750,12 @@ void TestRestRules::editRules()
QVariantMap stateDescriptor1;
stateDescriptor1.insert("deviceId", m_mockDeviceId);
stateDescriptor1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptor1.insert("stateTypeId", mockIntStateId);
stateDescriptor1.insert("stateTypeId", mockIntStateTypeId);
stateDescriptor1.insert("value", 1);
QVariantMap stateDescriptor2;
stateDescriptor2.insert("deviceId", m_mockDeviceId);
stateDescriptor2.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptor2.insert("stateTypeId", mockBoolStateId);
stateDescriptor2.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptor2.insert("value", true);
QVariantMap stateEvaluator1;
stateEvaluator1.insert("stateDescriptor", stateDescriptor1);
@ -770,39 +770,39 @@ void TestRestRules::editRules()
stateEvaluator0.insert("operator", JsonTypes::stateOperatorToString(Types::StateOperatorAnd));
QVariantMap action1;
action1.insert("actionTypeId", mockActionIdNoParams);
action1.insert("actionTypeId", mockWithoutParamsActionTypeId);
action1.insert("deviceId", m_mockDeviceId);
action1.insert("ruleActionParams", QVariantList());
QVariantMap action2;
action2.insert("actionTypeId", mockActionIdWithParams);
action2.insert("actionTypeId", mockWithParamsActionTypeId);
action2.insert("deviceId", m_mockDeviceId);
QVariantList action2Params;
QVariantMap action2Param1;
action2Param1.insert("paramTypeId", mockActionParam1ParamTypeId);
action2Param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
action2Param1.insert("value", 5);
action2Params.append(action2Param1);
QVariantMap action2Param2;
action2Param2.insert("paramTypeId", mockActionParam2ParamTypeId);
action2Param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
action2Param2.insert("value", true);
action2Params.append(action2Param2);
action2.insert("ruleActionParams", action2Params);
// RuleAction event based
QVariantMap validActionEventBased;
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
validActionEventBased.insert("deviceId", m_mockDeviceId);
QVariantMap validActionEventBasedParam1;
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2Id);
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
QVariantMap validActionEventBasedParam2;
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
validActionEventBasedParam2.insert("value", false);
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
QVariantList validEventDescriptors3;
QVariantMap validEventDescriptor3;
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
validEventDescriptor3.insert("paramDescriptors", QVariantList());
validEventDescriptors3.append(validEventDescriptor3);
@ -885,7 +885,7 @@ void TestRestRules::enableDisableRule()
QVariantMap addRuleParams;
QVariantList events;
QVariantMap event1;
event1.insert("eventTypeId", mockEvent1Id);
event1.insert("eventTypeId", mockEvent1EventTypeId);
event1.insert("deviceId", m_mockDeviceId);
events.append(event1);
addRuleParams.insert("eventDescriptors", events);
@ -893,7 +893,7 @@ void TestRestRules::enableDisableRule()
QVariantList actions;
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
actions.append(action);
addRuleParams.insert("actions", actions);
@ -912,7 +912,7 @@ void TestRestRules::enableDisableRule()
// Trigger an event
triggerMockEvent();
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
@ -934,7 +934,7 @@ void TestRestRules::enableDisableRule()
// trigger event in mock device
triggerMockEvent();
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupRules();
}
@ -977,7 +977,7 @@ void TestRestRules::executeRuleActions()
QCOMPARE(JsonTypes::ruleErrorToString(ruleError), response.toMap().value("error").toString());
if (ruleError == RuleEngine::RuleErrorNoError) {
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
} else {
verifyRuleNotExecuted();
}
@ -991,7 +991,7 @@ void TestRestRules::executeRuleActions()
QCOMPARE(JsonTypes::ruleErrorToString(ruleError), response.toMap().value("error").toString());
if (ruleError == RuleEngine::RuleErrorNoError) {
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
} else {
verifyRuleNotExecuted();
}

File diff suppressed because it is too large Load Diff

View File

@ -56,8 +56,8 @@ void TestStates::getStateValue_data()
QTest::addColumn<StateTypeId>("stateTypeId");
QTest::addColumn<Device::DeviceError>("error");
QTest::newRow("existing state") << device->id() << mockIntStateId << Device::DeviceErrorNoError;
QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateId << Device::DeviceErrorDeviceNotFound;
QTest::newRow("existing state") << device->id() << mockIntStateTypeId << Device::DeviceErrorNoError;
QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateTypeId << Device::DeviceErrorDeviceNotFound;
QTest::newRow("invalid statetype") << device->id() << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound;
}
@ -80,26 +80,26 @@ void TestStates::save_load_states()
{
DeviceClass mockDeviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(mockDeviceClassId);
QVERIFY2(mockDeviceClass.getStateType(mockIntStateId).cached(), "Mock int state is not cached (required to be true for this test)");
QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateId).cached(), "Mock bool state is cached (required to be false for this test)");
QVERIFY2(mockDeviceClass.getStateType(mockIntStateTypeId).cached(), "Mock int state is not cached (required to be true for this test)");
QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateTypeId).cached(), "Mock bool state is cached (required to be false for this test)");
Device* device = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).first();
int port = device->paramValue(httpportParamTypeId).toInt();
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
// First set the state values to something that is *not* the default
int newIntValue = mockDeviceClass.getStateType(mockIntStateId).defaultValue().toInt() + 1;
bool newBoolValue = !mockDeviceClass.getStateType(mockBoolStateId).defaultValue().toBool();
int newIntValue = mockDeviceClass.getStateType(mockIntStateTypeId).defaultValue().toInt() + 1;
bool newBoolValue = !mockDeviceClass.getStateType(mockBoolStateTypeId).defaultValue().toBool();
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateId.toString()).arg(newIntValue)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateTypeId.toString()).arg(newIntValue)));
QNetworkReply *reply = nam.get(request);
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
spy.wait();
spy.clear();
request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockBoolStateId.toString()).arg(newBoolValue)));
request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockBoolStateTypeId.toString()).arg(newBoolValue)));
reply = nam.get(request);
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
spy.wait();
@ -108,11 +108,11 @@ void TestStates::save_load_states()
QVariantMap params;
params.insert("deviceId", device->id());
params["stateTypeId"] = mockIntStateId;
params["stateTypeId"] = mockIntStateTypeId;
QVariant response = injectAndWait("Devices.GetStateValue", params);
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newIntValue);
params["stateTypeId"] = mockBoolStateId;
params["stateTypeId"] = mockBoolStateTypeId;
response = injectAndWait("Devices.GetStateValue", params);
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), newBoolValue);
@ -120,14 +120,14 @@ void TestStates::save_load_states()
restartServer();
// And check if the cached int state has successfully been restored
params["stateTypeId"] = mockIntStateId;
params["stateTypeId"] = mockIntStateTypeId;
response = injectAndWait("Devices.GetStateValue", params);
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newIntValue);
// and that the non-cached bool state is back to its default
params["stateTypeId"] = mockBoolStateId;
params["stateTypeId"] = mockBoolStateTypeId;
response = injectAndWait("Devices.GetStateValue", params);
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), mockDeviceClass.getStateType(mockBoolStateId).defaultValue().toBool());
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), mockDeviceClass.getStateType(mockBoolStateTypeId).defaultValue().toBool());
}
#include "teststates.moc"

View File

@ -201,7 +201,7 @@ void TestTimeManager::loadSaveTimeDescriptor()
// Action (without params)
QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -355,7 +355,7 @@ void TestTimeManager::addTimeDescriptor()
// ADD the rule
QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
ruleMap.insert("name", "TimeBased rule");
@ -395,21 +395,21 @@ void TestTimeManager::testCalendarDateTime()
// Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
// Exit action (with params)
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", actionParams);
@ -435,14 +435,14 @@ void TestTimeManager::testCalendarDateTime()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// active unchanged
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
@ -471,17 +471,17 @@ void TestTimeManager::testCalendarItemHourly()
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap repeatingOptionHourly;
repeatingOptionHourly.insert("mode", "RepeatingModeHourly");
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 7);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("deviceId", m_mockDeviceId);
@ -507,7 +507,7 @@ void TestTimeManager::testCalendarItemHourly()
if (duration == 60) {
NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
} else {
// check the next 24 hours in 8h steps
for (int i = 0; i < 24; i+=8) {
@ -516,14 +516,14 @@ void TestTimeManager::testCalendarItemHourly()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 5)));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// active unchanged
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 7)));
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 10)));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 11)));
@ -564,17 +564,17 @@ void TestTimeManager::testCalendarItemDaily()
initTimeManager();
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("deviceId", m_mockDeviceId);
@ -597,7 +597,7 @@ void TestTimeManager::testCalendarItemDaily()
if (time == "08:00") {
NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
} else {
// check the next 7 days
for (int i = 0; i < 7; i++) {
@ -606,14 +606,14 @@ void TestTimeManager::testCalendarItemDaily()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// active unchanged
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
@ -663,21 +663,21 @@ void TestTimeManager::testCalendarItemWeekly()
// Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
// Exit action (with params)
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", actionParams);
@ -707,7 +707,7 @@ void TestTimeManager::testCalendarItemWeekly()
if (repeatingOption.isEmpty()) {
NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
} else {
if (!overlapping) {
// check the next 7 days (because not overlapping the week)
@ -722,14 +722,14 @@ void TestTimeManager::testCalendarItemWeekly()
// should trigger today
// active
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// active unchanged
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
@ -762,7 +762,7 @@ void TestTimeManager::testCalendarItemWeekly()
// active
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// still active
@ -775,7 +775,7 @@ void TestTimeManager::testCalendarItemWeekly()
// inactive
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
}
}
@ -818,21 +818,21 @@ void TestTimeManager::testCalendarItemMonthly()
// Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
// Exit action (with params)
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", actionParams);
@ -871,14 +871,14 @@ void TestTimeManager::testCalendarItemMonthly()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// active unchanged
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60));
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60));
@ -906,7 +906,7 @@ void TestTimeManager::testCalendarItemMonthly()
// active
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// still active
@ -915,7 +915,7 @@ void TestTimeManager::testCalendarItemMonthly()
// inactive
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
}
cleanupMockHistory();
@ -946,21 +946,21 @@ void TestTimeManager::testCalendarYearlyDateTime()
// Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
// Exit action (with params)
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", actionParams);
@ -991,7 +991,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
cleanupMockHistory();
// active unchanged
@ -999,7 +999,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
cleanupMockHistory();
// inactive unchanged
@ -1015,7 +1015,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
verifyRuleNotExecuted();
// active
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
cleanupMockHistory();
// active unchanged
@ -1023,7 +1023,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
verifyRuleNotExecuted();
// inactive
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
// inactive unchanged
@ -1049,7 +1049,7 @@ void TestTimeManager::testCalendarItemStates_data()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1057,14 +1057,14 @@ void TestTimeManager::testCalendarItemStates_data()
QVariantMap exitAction;
QVariantList actionParams;
QVariantMap param1;
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
param1.insert("value", 12);
actionParams.append(param1);
QVariantMap param2;
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true);
actionParams.append(param2);
exitAction.insert("actionTypeId", mockActionIdWithParams);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockDeviceId);
exitAction.insert("ruleActionParams", actionParams);
@ -1073,12 +1073,12 @@ void TestTimeManager::testCalendarItemStates_data()
QVariantMap stateDescriptorInt;
stateDescriptorInt.insert("deviceId", m_mockDeviceId);
stateDescriptorInt.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorGreaterOrEqual));
stateDescriptorInt.insert("stateTypeId", mockIntStateId);
stateDescriptorInt.insert("stateTypeId", mockIntStateTypeId);
stateDescriptorInt.insert("value", 65);
QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true);
QVariantMap stateEvaluatorInt;
stateEvaluatorInt.insert("stateDescriptor", stateDescriptorInt);
@ -1141,13 +1141,13 @@ void TestTimeManager::testCalendarItemStates()
// Actions
if (trigger && active) {
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
}
// Exit actions
if (trigger && !active) {
verifyRuleExecuted(mockActionIdWithParams);
verifyRuleExecuted(mockWithParamsActionTypeId);
cleanupMockHistory();
}
@ -1164,12 +1164,12 @@ void TestTimeManager::testCalendarItemEvent_data()
// Action (without params)
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1Id);
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockDeviceId);
// The rule
@ -1214,7 +1214,7 @@ void TestTimeManager::testCalendarItemEvent()
triggerMockEvent1();
if (trigger) {
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
} else {
verifyRuleNotExecuted();
}
@ -1228,20 +1228,20 @@ void TestTimeManager::testCalendarItemStatesEvent_data()
// Action (without params)
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
// Event descriptor
QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1Id);
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockDeviceId);
// State evaluator
QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true);
QVariantMap stateEvaluator;
@ -1287,7 +1287,7 @@ void TestTimeManager::testCalendarItemStatesEvent()
triggerMockEvent1();
if (trigger) {
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
} else {
verifyRuleNotExecuted();
@ -1302,7 +1302,7 @@ void TestTimeManager::testCalendarItemCrossesMidnight()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1370,12 +1370,12 @@ void TestTimeManager::testEventBasedWithCalendarItemCrossingMidnight()
// Event descriptor
QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1Id);
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockDeviceId);
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1407,17 +1407,17 @@ void TestTimeManager::testEventBasedWithCalendarItemCrossingMidnight()
cleanupMockHistory();
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(23, 00)));
triggerMockEvent1();
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(23, 50)));
triggerMockEvent1();
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(00, 00)));
triggerMockEvent1();
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(01, 00)));
@ -1442,7 +1442,7 @@ void TestTimeManager::testEventItemDateTime()
// Action (without params)
QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1463,7 +1463,7 @@ void TestTimeManager::testEventItemDateTime()
// trigger
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
@ -1499,7 +1499,7 @@ void TestTimeManager::testEventItemHourly()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1529,7 +1529,7 @@ void TestTimeManager::testEventItemHourly()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
@ -1568,7 +1568,7 @@ void TestTimeManager::testEventItemDaily()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1599,7 +1599,7 @@ void TestTimeManager::testEventItemDaily()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
@ -1641,7 +1641,7 @@ void TestTimeManager::testEventItemWeekly()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1675,7 +1675,7 @@ void TestTimeManager::testEventItemWeekly()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
@ -1723,7 +1723,7 @@ void TestTimeManager::testEventItemMonthly()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1757,7 +1757,7 @@ void TestTimeManager::testEventItemMonthly()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
@ -1802,7 +1802,7 @@ void TestTimeManager::testEventItemYearly()
// Action (without params)
QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1823,7 +1823,7 @@ void TestTimeManager::testEventItemYearly()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
@ -1837,7 +1837,7 @@ void TestTimeManager::testEventItemYearly()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(nextYear);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(60));
@ -1861,7 +1861,7 @@ void TestTimeManager::testEventItemStates_data()
// Action (without params)
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1875,7 +1875,7 @@ void TestTimeManager::testEventItemStates_data()
QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true);
QVariantMap stateEvaluator;
@ -1925,7 +1925,7 @@ void TestTimeManager::testEventItemStates()
NymeaCore::instance()->timeManager()->setTime(dateTime);
if (trigger) {
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
} else {
verifyRuleNotExecuted();
@ -1944,7 +1944,7 @@ void TestTimeManager::testEnableDisableTimeRule()
// Action
QVariantMap action;
action.insert("actionTypeId", mockActionIdNoParams);
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockDeviceId);
action.insert("ruleActionParams", QVariantList());
@ -1964,7 +1964,7 @@ void TestTimeManager::testEnableDisableTimeRule()
verifyRuleNotExecuted();
// trigger
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// not triggering
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(1));
@ -1991,7 +1991,7 @@ void TestTimeManager::testEnableDisableTimeRule()
// trigger
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams);
verifyRuleExecuted(mockWithoutParamsActionTypeId);
cleanupMockHistory();
// REMOVE rule
@ -2070,7 +2070,7 @@ void TestTimeManager::setIntState(const int &value)
QVariantMap params;
params.insert("deviceId", m_mockDeviceId);
params.insert("stateTypeId", mockIntStateId);
params.insert("stateTypeId", mockIntStateTypeId);
QVariant response = injectAndWait("Devices.GetStateValue", params);
verifyDeviceError(response);
@ -2082,7 +2082,7 @@ void TestTimeManager::setIntState(const int &value)
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
spy.clear();
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(value)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(value)));
QNetworkReply *reply = nam.get(request);
spy.wait();
QCOMPARE(spy.count(), 1);
@ -2098,7 +2098,7 @@ void TestTimeManager::setIntState(const int &value)
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId");
QVERIFY2(DeviceId(notification.value("deviceId").toString()) == m_mockDeviceId, "Devices.StateChanged notification does not contain the correct deviceId");
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateId, "Devices.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value");
QVERIFY2(notification.value("value").toInt() == value, "Devices.StateChanged notification does not contain the new value");
}
@ -2111,7 +2111,7 @@ void TestTimeManager::setBoolState(const bool &value)
// Get the current state value to check if we have to wait for state changed notfication
QVariantMap params;
params.insert("deviceId", m_mockDeviceId);
params.insert("stateTypeId", mockBoolStateId);
params.insert("stateTypeId", mockBoolStateTypeId);
QVariant response = injectAndWait("Devices.GetStateValue", params);
verifyDeviceError(response);
@ -2122,7 +2122,7 @@ void TestTimeManager::setBoolState(const bool &value)
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockBoolStateId.toString()).arg(value)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockBoolStateTypeId.toString()).arg(value)));
QNetworkReply *reply = nam.get(request);
spy.wait();
QCOMPARE(spy.count(), 1);
@ -2138,7 +2138,7 @@ void TestTimeManager::setBoolState(const bool &value)
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId");
QVERIFY2(DeviceId(notification.value("deviceId").toString()) == m_mockDeviceId, "Devices.StateChanged notification does not contain the correct deviceId");
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateId, "Devices.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value");
QVERIFY2(notification.value("value").toBool() == value, "Devices.StateChanged notification does not contain the new value");
}
@ -2153,7 +2153,7 @@ void TestTimeManager::triggerMockEvent1()
QSignalSpy eventSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request);
spy.wait();
QCOMPARE(spy.count(), 1);
@ -2168,7 +2168,7 @@ void TestTimeManager::triggerMockEvent1()
QVERIFY2(eventMap.contains("deviceId"), "Events.EventTriggered notification does not contain deviceId");
QVERIFY2(DeviceId(eventMap.value("deviceId").toString()) == m_mockDeviceId, "Events.EventTriggered notification does not contain the correct deviceId");
QVERIFY2(eventMap.contains("eventTypeId"), "Events.EventTriggered notification does not contain eventTypeId");
QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1Id, "Events.EventTriggered notification does not contain the correct eventTypeId");
QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1EventTypeId, "Events.EventTriggered notification does not contain the correct eventTypeId");
}
QVariantMap TestTimeManager::createTimeEventItem(const QString &time, const QVariantMap &repeatingOption) const

View File

@ -28,65 +28,7 @@ using namespace nymeaserver;
Q_LOGGING_CATEGORY(dcTests, "Tests")
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
DeviceClassId mockPushButtonDeviceClassId = DeviceClassId("9e03144c-e436-4eea-82d9-ccb33ef778db");
DeviceClassId mockDisplayPinDeviceClassId = DeviceClassId("296f1fd4-e893-46b2-8a42-50d1bceb8730");
DeviceClassId mockParentDeviceClassId = DeviceClassId("a71fbde9-9a38-4bf8-beab-c8aade2608ba");
DeviceClassId mockChildDeviceClassId = DeviceClassId("40893c9f-bc47-40c1-8bf7-b390c7c1b4fc");
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
DeviceClassId mockDeviceAsyncSetupClassId = DeviceClassId("c08a8b27-8200-413d-b96b-4cff78b864d9");
DeviceClassId mockDeviceBrokenClassId = DeviceClassId("ba5fb404-c9ce-4db4-8cd4-f48c61c24b13");
DeviceClassId mockDeviceBrokenAsyncSetupClassId = DeviceClassId("bd5b78c5-53c9-4417-8eac-8ab2bce97bd0");
EventTypeId mockEvent1Id = EventTypeId("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
EventTypeId mockEvent2Id = EventTypeId("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
StateTypeId mockIntStateId = StateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
StateTypeId mockBoolStateId = StateTypeId("9dd6a97c-dfd1-43dc-acbd-367932742310");
StateTypeId mockDoubleStateId = StateTypeId("7cac53ee-7048-4dc9-b000-7b585390f34c");
StateTypeId mockBatteryCriticalStateId = StateTypeId("580bc611-1a55-41f3-996f-8d3ccf543db3");
StateTypeId mockPowerStateTypeId = StateTypeId("064aed0d-da4c-49d4-b236-60f97e98ff84");
ActionTypeId mockActionIdPower = ActionTypeId("064aed0d-da4c-49d4-b236-60f97e98ff84");
ActionTypeId mockActionIdWithParams = ActionTypeId("dea0f4e1-65e3-4981-8eaa-2701c53a9185");
ActionTypeId mockActionIdNoParams = ActionTypeId("defd3ed6-1a0d-400b-8879-a0202cf39935");
ActionTypeId mockActionIdAsync = ActionTypeId("fbae06d3-7666-483e-a39e-ec50fe89054e");
ActionTypeId mockActionIdFailing = ActionTypeId("df3cf33d-26d5-4577-9132-9823bd33fad0");
ActionTypeId mockActionIdAsyncFailing = ActionTypeId("bfe89a1d-3497-4121-8318-e77c37537219");
ParamTypeId configParamIntParamTypeId = ParamTypeId("e1f72121-a426-45e2-b475-8262b5cdf103");
ParamTypeId configParamBoolParamTypeId = ParamTypeId("c75723b6-ea4f-4982-9751-6c5e39c88145");
ParamTypeId httpportParamTypeId = ParamTypeId("d4f06047-125e-4479-9810-b54c189917f5");
ParamTypeId asyncParamTypeId = ParamTypeId("f2977061-4dd0-4ef5-85aa-3b7134743be3");
ParamTypeId brokenParamTypeId = ParamTypeId("ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4");
ParamTypeId resultCountParamTypeId = ParamTypeId("d222adb4-2f9c-4c3f-8655-76400d0fb6ce");
ParamTypeId mockActionParam1ParamTypeId = ParamTypeId("a2d3a256-a551-4712-a65b-ecd5a436a1cb");
ParamTypeId mockActionParam2ParamTypeId = ParamTypeId("304a4899-18be-4e3b-94f4-d03be52f3233");
ParamTypeId mockParamIntParamTypeId = ParamTypeId("0550e16d-60b9-4ba5-83f4-4d3cee656121");
ParamTypeId colorStateParamTypeId = ParamTypeId("20dc7c22-c50e-42db-837c-2bbced939f8e");
ParamTypeId percentageStateParamTypeId = ParamTypeId("72981c04-267a-4ba0-a59e-9921d2f3af9c");
ParamTypeId allowedValuesStateParamTypeId = ParamTypeId("05f63f9c-f61e-4dcf-ad55-3f13fde2765b");
ParamTypeId doubleStateParamTypeId = ParamTypeId("53cd7c55-49b7-441b-b970-9048f20f0e2c");
ParamTypeId boolStateParamTypeId = ParamTypeId("e680f7a4-b39e-46da-be41-fa3170fe3768");
ParamTypeId pinParamTypeId = ParamTypeId("da820e07-22dc-4173-9c07-2f49a4e265f9");
ParamTypeId boolValueStateParamTypeId = ParamTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
ParamTypeId parentUuidParamTypeId = ParamTypeId("104b5288-404e-42d3-bf38-e40682e75681");
ParamTypeId textLineParamTypeId = ParamTypeId("e6acf0c7-4b8e-4296-ac62-855d20deb816");
ParamTypeId textAreaParamTypeId = ParamTypeId("716f0994-bc01-42b0-b64d-59236f7320d2");
ParamTypeId passwordParamTypeId = ParamTypeId("e5c0d14b-c9f1-4aca-a56e-85bfa6977150");
ParamTypeId searchParamTypeId = ParamTypeId("22add8c9-ee4f-43ad-8931-58e999313ac3");
ParamTypeId mailParamTypeId = ParamTypeId("a8494faf-3a0f-4cf3-84b7-4b39148a838d");
ParamTypeId ip4ParamTypeId = ParamTypeId("9e5f86a0-4bb3-4892-bff8-3fc4032af6e2");
ParamTypeId ip6ParamTypeId = ParamTypeId("43bf3832-dd48-4090-a836-656e8b60216e");
ParamTypeId urlParamTypeId = ParamTypeId("fa67229f-fcef-496f-b671-59a4b48f3ab5");
ParamTypeId macParamTypeId = ParamTypeId("e93db587-7919-48f3-8c88-1651de63c765");
ParamTypeId mockSetting1ParamTypeId = ParamTypeId("367f7ba4-5039-47be-abd8-59cc8eaf4b9a");
// Parent device
EventTypeId mockParentChildEventId = EventTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
ActionTypeId mockParentChildActionId = ActionTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
StateTypeId mockParentChildStateId = StateTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
#include "../plugins/mock/plugininfo.h"
NymeaTestBase::NymeaTestBase(QObject *parent) :
QObject(parent),
@ -120,7 +62,7 @@ void NymeaTestBase::initTestCase()
NymeaSettings nymeadSettings(NymeaSettings::SettingsRoleGlobal);
nymeadSettings.clear();
QLoggingCategory::setFilterRules("*.debug=false\nTests.debug=true");
QLoggingCategory::setFilterRules("*.debug=false\nTests.debug=true\nMockDevice.debug=true");
// Start the server
NymeaCore::instance()->init();
@ -150,7 +92,7 @@ void NymeaTestBase::initTestCase()
response = injectAndWait("Devices.GetConfiguredDevices", {});
foreach (const QVariant &device, response.toMap().value("params").toMap().value("devices").toList()) {
if (device.toMap().value("deviceClassId").toUuid() == mockDeviceAutoClassId) {
if (device.toMap().value("deviceClassId").toUuid() == mockDeviceAutoDeviceClassId) {
m_mockDeviceAutoId = DeviceId(device.toMap().value("id").toString());
}
}
@ -458,11 +400,11 @@ void NymeaTestBase::createMockDevice()
{
QVariantMap params;
params.insert("name", "Test Mock Device");
params.insert("deviceClassId", "{753f0d32-0468-4d08-82ed-1964aab03298}");
params.insert("deviceClassId", mockDeviceClassId.toString());
QVariantList deviceParams;
QVariantMap httpPortParam;
httpPortParam.insert("paramTypeId", httpportParamTypeId.toString());
httpPortParam.insert("paramTypeId", mockDeviceHttpportParamTypeId.toString());
httpPortParam.insert("value", m_mockDevice1Port);
deviceParams.append(httpPortParam);
params.insert("deviceParams", deviceParams);

View File

@ -31,64 +31,7 @@
Q_DECLARE_LOGGING_CATEGORY(dcTests)
extern DeviceClassId mockDeviceClassId;
extern DeviceClassId mockDeviceAutoClassId;
extern DeviceClassId mockPushButtonDeviceClassId;
extern DeviceClassId mockDisplayPinDeviceClassId;
extern DeviceClassId mockParentDeviceClassId;
extern DeviceClassId mockChildDeviceClassId;
extern DeviceClassId mockDeviceDiscoveryClassId;
extern DeviceClassId mockDeviceAsyncSetupClassId;
extern DeviceClassId mockDeviceBrokenClassId;
extern DeviceClassId mockDeviceBrokenAsyncSetupClassId;
extern ActionTypeId mockActionIdPower;
extern ActionTypeId mockActionIdWithParams;
extern ActionTypeId mockActionIdNoParams;
extern ActionTypeId mockActionIdAsync;
extern ActionTypeId mockActionIdFailing;
extern ActionTypeId mockActionIdAsyncFailing;
extern EventTypeId mockEvent1Id;
extern EventTypeId mockEvent2Id;
extern StateTypeId mockIntStateId;
extern StateTypeId mockDoubleStateId;
extern StateTypeId mockBatteryCriticalStateId;
extern StateTypeId mockBoolStateId;
extern StateTypeId mockPowerStateTypeId;
// ParamTypes from mock devices
extern ParamTypeId configParamIntParamTypeId;
extern ParamTypeId configParamBoolParamTypeId;
extern ParamTypeId httpportParamTypeId;
extern ParamTypeId asyncParamTypeId;
extern ParamTypeId brokenParamTypeId;
extern ParamTypeId resultCountParamTypeId;
extern ParamTypeId mockActionParam1ParamTypeId;
extern ParamTypeId mockActionParam2ParamTypeId;
extern ParamTypeId mockParamIntParamTypeId;
extern ParamTypeId colorStateParamTypeId;
extern ParamTypeId percentageStateParamTypeId;
extern ParamTypeId allowedValuesStateParamTypeId;
extern ParamTypeId doubleStateParamTypeId;
extern ParamTypeId boolStateParamTypeId;
extern ParamTypeId pinParamTypeId;
extern ParamTypeId boolValueStateParamTypeId;
extern ParamTypeId parentUuidParamTypeId;
extern ParamTypeId textLineParamTypeId;
extern ParamTypeId textAreaParamTypeId;
extern ParamTypeId passwordParamTypeId;
extern ParamTypeId searchParamTypeId;
extern ParamTypeId mailParamTypeId;
extern ParamTypeId ip4ParamTypeId;
extern ParamTypeId ip6ParamTypeId;
extern ParamTypeId urlParamTypeId;
extern ParamTypeId macParamTypeId;
extern ParamTypeId mockSetting1ParamTypeId;
// Parent / Child device
extern EventTypeId mockParentChildEventId;
extern ActionTypeId mockParentChildActionId;
extern StateTypeId mockParentChildStateId;
#include "../plugins/mock/extern-plugininfo.h"
namespace nymeaserver {
class MockTcpServer;

View File

@ -0,0 +1,54 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2019 Michael Zanetti <michael.zanetti@nymea.io> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <QCoreApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QDebug>
#include "plugininfocompiler.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription("The nymea plugin info compiler. Compiles a plugininfo.json into a plugininfo.h/plugininfo-extern.h.");
parser.addHelpOption();
parser.addOption({{"o", "output"}, "Write generated output header to <file>.", "file"});
parser.addOption({{"e", "extern"}, "Write generated output header (extern definitions) to <file>.", "file"});
parser.addPositionalArgument("input", "The input json file");
parser.process(a);
if (parser.positionalArguments().count() != 1) {
qWarning() << qUtf8Printable(parser.helpText());
return 1;
}
PluginInfoCompiler pic;
int ret = pic.compile(parser.positionalArguments().first(), parser.value("output"), parser.value("extern"));
return ret;
}

View File

@ -0,0 +1,17 @@
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
include(../../nymea.pri)
INCLUDEPATH += $$top_srcdir/libnymea
LIBS += -L$$top_builddir/libnymea -lnymea
SOURCES += \
main.cpp \
plugininfocompiler.cpp
HEADERS += \
plugininfocompiler.h
target.path = $$[QT_INSTALL_PREFIX]/bin
INSTALLS += target

View File

@ -0,0 +1,295 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2019 Michael Zanetti <michael.zanetti@nymea.io> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "plugininfocompiler.h"
#include <QJsonObject>
#include <QFile>
#include <QJsonParseError>
#include <QDataStream>
#include <QDebug>
PluginInfoCompiler::PluginInfoCompiler()
{
}
int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputFile, const QString outputFileExtern)
{
// First, process the input json...
QFile jsonFile(inputFile);
if (!jsonFile.open(QFile::ReadOnly)) {
qWarning() << "Error opening input JSON file for reading. Aborting.";
return 1;
}
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonFile.readAll(), &error);
jsonFile.close();
if (error.error != QJsonParseError::NoError) {
qWarning() << "Error parsing input JSON. Aborting.";
qWarning() << "Parser details:" << error.errorString();
return 1;
}
QJsonObject jsonObject = QJsonObject::fromVariantMap(jsonDoc.toVariant().toMap());
PluginMetadata metadata(jsonObject);
if (!metadata.isValid()) {
qWarning() << "Plugin JSON failed validation. Aborting.";
return 2;
}
// OK. Json parsed fine. Let's open files for writing
if (!outputFile.isEmpty()) {
if (outputFile == "-") {
if (!m_outputFile.open(stdout, QFile::WriteOnly | QFile::Text)) {
qWarning() << "Error opening stdout for writing. Aborting.";
return 1;
}
} else {
m_outputFile.setFileName(outputFile);
if (!m_outputFile.open(QFile::WriteOnly | QFile::Text)) {
qWarning() << "Error opening output file for writing. Aborting.";
return 1;
}
}
}
if (!outputFileExtern.isEmpty()) {
if (outputFileExtern == "-") {
if (!m_outputFileExtern.open(stdout, QFile::WriteOnly | QFile::Text)) {
qWarning() << "Error opening stdout for writing. Aborting.";
return 1;
}
} else {
m_outputFileExtern.setFileName(outputFileExtern);
if (!m_outputFileExtern.open(QFile::WriteOnly | QFile::Text)) {
qWarning() << "Error opening output file for writing. Aborting.";
return 1;
}
}
}
// Files are open. Ready to write content.
QString header;
header.append("/* This file is generated by the nymea build system. Any changes to this file will *\n");
header.append(" * be lost. If you want to change this file, edit the plugin's json file. */\n");
write(header);
writeExtern(header);
write("#ifndef PLUGININFO_H");
write("#define PLUGININFO_H");
write();
writeExtern("#ifndef EXTERNPLUGININFO_H");
writeExtern("#define EXTERNPLUGININFO_H");
writeExtern();
write("#include \"typeutils.h\"");
write();
writeExtern("#include \"typeutils.h\"");
writeExtern();
write("#include <QLoggingCategory>");
writeExtern("#include <QLoggingCategory>");
write("#include <QObject>");
write();
writeExtern();
// Include our API version in plugininfo.h so we can know against which library this plugin was built.
write(QString("extern \"C\" const QString libnymea_api_version() { return QString(\"%1\");}").arg(LIBNYMEA_API_VERSION));
write();
// Declare a logging category for this plugin
QString debugCategoryName = metadata.pluginName()[0].toUpper() + metadata.pluginName().right(metadata.pluginName().length() - 1);
QString debugCategoryDeclaration = QString("Q_DECLARE_LOGGING_CATEGORY(dc%1)").arg(debugCategoryName);
write(debugCategoryDeclaration);
write(QString("Q_LOGGING_CATEGORY(dc%1, \"%1\")").arg(debugCategoryName));
write();
writeExtern(debugCategoryDeclaration);
writeExtern();
// Write down all the IDs
writePlugin(metadata);
write();
writeExtern();
// And the translations
write(QString("const QString translations[] {"));
for (auto i = m_translationStrings.begin(); i != m_translationStrings.end();) {
write(QString(" //: %1").arg(i.value()));
QString line = QString(" QT_TRANSLATE_NOOP(\"%1\", \"%2\")").arg(metadata.pluginName(), i.key());
i++;
if (i != m_translationStrings.end()) {
line.append(",\n");
}
write(line);
}
write("};");
write();
write("#endif // PLUGININFO_H");
writeExtern("#endif // EXTERNPLUGININFO_H");
m_outputFile.close();
m_outputFileExtern.close();
return 0;
}
void PluginInfoCompiler::writePlugin(const PluginMetadata &metadata)
{
write(QString("PluginId pluginId = PluginId(\"%1\");").arg(metadata.pluginId().toString()));
m_translationStrings.insert(metadata.pluginDisplayName(), QString("The name of the plugin %1 (%2)").arg(metadata.pluginName()).arg(metadata.pluginId().toString()));
writeExtern(QString("extern %1 %2;").arg("PluginId").arg("pluginId"));
writeParams(metadata.pluginSettings(), metadata.pluginName()[0].toLower() + metadata.pluginName().right(metadata.pluginName().length() - 1), "", "plugin");
foreach (const Vendor &vendor, metadata.vendors()) {
writeVendor(vendor);
}
foreach (const DeviceClass &deviceClass, metadata.deviceClasses()) {
writeDeviceClass(deviceClass);
}
}
void PluginInfoCompiler::writeParams(const ParamTypes &paramTypes, const QString &deviceClassName, const QString &typeClass, const QString &typeName)
{
foreach (const ParamType &paramType, paramTypes) {
QString variableName = QString("%1ParamTypeId").arg(deviceClassName + typeName[0].toUpper() + typeName.right(typeName.length()-1) + typeClass + paramType.name()[0].toUpper() + paramType.name().right(paramType.name().length() -1 ));
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for ParamTypeId " << paramType.id() << ". Skipping entry.";
continue;
}
m_variableNames.append(variableName);
write(QString("ParamTypeId %1 = ParamTypeId(\"%2\");").arg(variableName).arg(paramType.id().toString()));
m_translationStrings.insert(paramType.displayName(), QString("The name of the ParamType (DeviceClass: %1, %2Type: %3, ID: %4)").arg(deviceClassName).arg(typeClass).arg(typeName).arg(paramType.id().toString()));
writeExtern(QString("extern ParamTypeId %1;").arg(variableName));
}
}
void PluginInfoCompiler::writeVendor(const Vendor &vendor)
{
QString variableName = QString("%1VendorId").arg(vendor.name());
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for Vendor " << vendor.id() << ". Skipping entry.";
return;
}
m_variableNames.append(variableName);
write(QString("VendorId %1 = VendorId(\"%2\");").arg(variableName).arg(vendor.id().toString()));
m_translationStrings.insert(vendor.displayName(), QString("The name of the vendor (%1)").arg(vendor.id().toString()));
writeExtern(QString("extern VendorId %1;").arg(variableName));
}
void PluginInfoCompiler::writeDeviceClass(const DeviceClass &deviceClass)
{
QString variableName = QString("%1DeviceClassId").arg(deviceClass.name());
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for DeviceClass " << deviceClass.id() << ". Skipping entry.";
return;
}
m_variableNames.append(variableName);
write(QString("DeviceClassId %1 = DeviceClassId(\"%2\");").arg(variableName).arg(deviceClass.id().toString()));
m_translationStrings.insert(deviceClass.displayName(), QString("The name of the DeviceClass (%1)").arg(deviceClass.id().toString()));
writeExtern(QString("extern DeviceClassId %1;").arg(variableName));
if (!deviceClass.pairingInfo().isEmpty()) {
m_translationStrings.insert(deviceClass.pairingInfo(), QString("The pairing info of deviceClass %1").arg(deviceClass.name()));
}
writeParams(deviceClass.paramTypes(), deviceClass.name(), "", "device");
writeParams(deviceClass.settingsTypes(), deviceClass.name(), "", "settings");
writeParams(deviceClass.discoveryParamTypes(), deviceClass.name(), "", "discovery");
writeStateTypes(deviceClass.stateTypes(), deviceClass.name());
writeEventTypes(deviceClass.eventTypes(), deviceClass.name());
writeActionTypes(deviceClass.actionTypes(), deviceClass.name());
}
void PluginInfoCompiler::writeStateTypes(const StateTypes &stateTypes, const QString &deviceClassName)
{
foreach (const StateType &stateType, stateTypes) {
QString variableName = QString("%1%2StateTypeId").arg(deviceClassName, stateType.name()[0].toUpper() + stateType.name().right(stateType.name().length() - 1));
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for StateType " << stateType.name() << " in DeviceClass " << deviceClassName << ". Skipping entry.";
return;
}
m_variableNames.append(variableName);
write(QString("StateTypeId %1 = StateTypeId(\"%2\");").arg(variableName).arg(stateType.id().toString()));
m_translationStrings.insert(stateType.displayName(), QString("The name of the StateType (%1) of DeviceClass %2").arg(stateType.id().toString()).arg(deviceClassName));
writeExtern(QString("extern StateTypeId %1;").arg(variableName));
}
}
void PluginInfoCompiler::writeEventTypes(const EventTypes &eventTypes, const QString &deviceClassName)
{
foreach (const EventType &eventType, eventTypes) {
QString variableName = QString("%1%2EventTypeId").arg(deviceClassName, eventType.name()[0].toUpper() + eventType.name().right(eventType.name().length() - 1));
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for EventType " << eventType.name() << " in DeviceClass " << deviceClassName << ". Skipping entry.";
return;
}
m_variableNames.append(variableName);
write(QString("EventTypeId %1 = EventTypeId(\"%2\");").arg(variableName).arg(eventType.id().toString()));
m_translationStrings.insert(eventType.displayName(), QString("The name of the EventType (%1) of DeviceClass %2").arg(eventType.id().toString()).arg(deviceClassName));
writeExtern(QString("extern EventTypeId %1;").arg(variableName));
writeParams(eventType.paramTypes(), deviceClassName, "Event", eventType.name());
}
}
void PluginInfoCompiler::writeActionTypes(const ActionTypes &actionTypes, const QString &deviceClassName)
{
foreach (const ActionType &actionType, actionTypes) {
QString variableName = QString("%1%2ActionTypeId").arg(deviceClassName, actionType.name()[0].toUpper() + actionType.name().right(actionType.name().length() - 1));
if (m_variableNames.contains(variableName)) {
qWarning().nospace() << "Error: Duplicate name " << variableName << " for ActionType " << actionType.name() << " in DeviceClass " << deviceClassName << ". Skipping entry.";
return;
}
m_variableNames.append(variableName);
write(QString("ActionTypeId %1 = ActionTypeId(\"%2\");").arg(variableName).arg(actionType.id().toString()));
m_translationStrings.insert(actionType.displayName(), QString("The name of the ActionType (%1) of DeviceClass %2").arg(actionType.id().toString()).arg(deviceClassName));
writeExtern(QString("extern ActionTypeId %1;").arg(variableName));
writeParams(actionType.paramTypes(), deviceClassName, "Action", actionType.name());
}
}
void PluginInfoCompiler::write(const QString &line)
{
if (m_outputFile.isOpen()) {
m_outputFile.write(QString("%1\n").arg(line).toUtf8());
}
}
void PluginInfoCompiler::writeExtern(const QString &line)
{
if (m_outputFileExtern.isOpen()) {
m_outputFileExtern.write(QString("%1\n").arg(line).toUtf8());
}
}

View File

@ -0,0 +1,60 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2019 Michael Zanetti <michael.zanetti@nymea.io> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef PLUGININFOCOMPILER_H
#define PLUGININFOCOMPILER_H
#include <QString>
#include <QFile>
#include "types/paramtype.h"
#include "devices/pluginmetadata.h"
class PluginInfoCompiler
{
public:
PluginInfoCompiler();
int compile(const QString &inputFile, const QString &outputFile, const QString outputFileExtern);
private:
void writePlugin(const PluginMetadata &metadata);
void writeParams(const ParamTypes &paramTypes, const QString &deviceClassName, const QString &typeClass, const QString &typeName);
void writeVendor(const Vendor &vendor);
void writeDeviceClass(const DeviceClass &deviceClass);
void writeStateTypes(const StateTypes &stateTypes, const QString &deviceClassName);
void writeEventTypes(const EventTypes &eventTypes, const QString &deviceClassName);
void writeActionTypes(const ActionTypes &actionTypes, const QString &deviceClassName);
void write(const QString &line = QString());
void writeExtern(const QString &line = QString());
QMultiMap<QString, QString> m_translationStrings;
QStringList m_variableNames;
QFile m_outputFile;
QFile m_outputFileExtern;
};
#endif // PLUGININFOCOMPILER_H

3
tools/tools.pro Normal file
View File

@ -0,0 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = nymea-plugininfocompiler