pull/135/head
Simon Stürz 2015-09-28 15:36:47 +02:00 committed by Michael Zanetti
parent bae722abc3
commit 67bfd952fa
5 changed files with 38 additions and 6 deletions

View File

@ -1324,12 +1324,17 @@ DeviceManager::DeviceError DeviceManager::verifyParam(const ParamType &paramType
return DeviceErrorInvalidParameter;
}
if (paramType.maxValue().isValid() && param.value().convert(paramType.type()) > paramType.maxValue().convert(paramType.type())) {
if (!param.value().convert(paramType.type())) {
qCWarning(dcDeviceManager) << "Could not convert value of param" << param.name() << " to:" << QVariant::typeToName(paramType.type()) << " Got:" << param.value();
return DeviceErrorInvalidParameter;
}
if (paramType.maxValue().isValid() && param.value() > paramType.maxValue()) {
qCWarning(dcDeviceManager) << "Value out of range for param" << param.name() << " Got:" << param.value() << " Max:" << paramType.maxValue();
return DeviceErrorInvalidParameter;
}
if (paramType.minValue().isValid() && param.value().convert(paramType.type()) < paramType.minValue().convert(paramType.type())) {
qCWarning(dcDeviceManager) << "Value out of range for param" << param.name() << " Got:" << param.value() << " Min:" << paramType.minValue().convert(paramType.type());
if (paramType.minValue().isValid() && param.value() < paramType.minValue()) {
qCWarning(dcDeviceManager) << "Value out of range for param" << param.name() << " Got:" << param.value() << " Min:" << paramType.minValue();
return DeviceErrorInvalidParameter;
}
if (!paramType.allowedValues().isEmpty() && !paramType.allowedValues().contains(param.value())) {

View File

@ -190,6 +190,11 @@ DeviceManager::DeviceError DevicePluginMock::executeAction(Device *device, const
} else if (action.actionTypeId() == percentageActionTypeId) {
device->setStateValue(percentageStateTypeId, action.param("percentage").value().toInt());
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == allowedValuesActionTypeId) {
device->setStateValue(allowedValuesStateTypeId, action.param("allowed values").value().toString());
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == timeoutActionTypeId) {
return DeviceManager::DeviceErrorAsync;
}
return DeviceManager::DeviceErrorActionTypeNotFound;
}

View File

@ -247,6 +247,28 @@
"minValue": 0,
"maxValue": 100
}
},
{
"id": "05f63f9c-f61e-4dcf-ad55-3f13fde2765b",
"idName": "allowedValues",
"name": "allowed values",
"type": "QString",
"defaultValue": "String value 1",
"writable": {
"allowedValues": [
"String value 1",
"String value 2",
"String value 3",
"String value 4"
]
}
}
],
"actionTypes": [
{
"id": "54646e7c-bc54-4895-81a2-590d72d120f9",
"idName": "timeout",
"name": "Timout action"
}
]
}

View File

@ -140,7 +140,7 @@ HttpReply::HttpReply(QObject *parent) :
setHeader(HttpHeaderType::CacheControlHeader, "no-cache");
setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive");
setRawHeader("Access-Control-Allow-Origin","*");
setRawHeader("Keep-Alive", "timeout=10, max=50");
setRawHeader("Keep-Alive", "timeout=12, max=50");
packReply();
}
@ -164,7 +164,7 @@ HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpRepl
setHeader(HttpHeaderType::CacheControlHeader, "no-cache");
setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive");
setRawHeader("Access-Control-Allow-Origin","*");
setRawHeader("Keep-Alive", "timeout=10, max=50");
setRawHeader("Keep-Alive", "timeout=12, max=50");
packReply();
}

View File

@ -701,7 +701,7 @@ void WebServerClient::addConnection(QSslSocket *socket)
{
QTimer *timer = new QTimer(this);
timer->setSingleShot(true);
timer->setInterval(9500);
timer->setInterval(12000);
connect(timer, &QTimer::timeout, this, &WebServerClient::onTimout);
m_runningConnections.insert(timer, socket);