fixed remarks from review

master
bernhard.trinnes 2020-07-09 20:15:13 +02:00
parent 5b2c92f0cf
commit 987df40f06
2 changed files with 13 additions and 14 deletions

View File

@ -46,7 +46,7 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
Thing *thing = info->thing();
if (thing->thingClassId() == extendedBlindThingClassId) {
uint closingTime = thing->paramValue(extendedBlindThingClosingTimeParamTypeId).toUInt();
if (closingTime <= 0) {
if (closingTime == 0) {
return info->finish(Thing::ThingErrorSetupFailed, tr("Invalid closing time"));
}
QTimer* timer = new QTimer(this);
@ -60,10 +60,6 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
if (currentPercentage == 100) {
setBlindState(BlindStateStopped, thing);
qCDebug(dcGenericThings()) << "Extended blind is closed, stopping timer";
} else if (currentPercentage > 100) {
currentPercentage = 100;
setBlindState(BlindStateStopped, thing);
qCWarning(dcGenericThings()) << "Extended blind overshoot 100 percent";
} else {
currentPercentage++;
thing->setStateValue(extendedBlindPercentageStateTypeId, currentPercentage);
@ -99,7 +95,7 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
timer->setInterval(closingTime/100.00); // closing timer / 100 to update on every percent
m_extendedBlindPercentageTimer.insert(thing, timer);
connect(timer, &QTimer::timeout, this, [thing, this] {
connect(timer, &QTimer::timeout, thing, [thing, this] {
uint currentPercentage = thing->stateValue(venetianBlindPercentageStateTypeId).toUInt();
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
@ -140,7 +136,7 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
QTimer* angleTimer = new QTimer(this);
angleTimer->setInterval(angleTime/180.00); // -90 to 90 degree -> 180 degree total
m_venetianBlindAngleTimer.insert(thing, angleTimer);
connect(angleTimer, &QTimer::timeout, this, [thing, this] {
connect(angleTimer, &QTimer::timeout, thing, [thing, this] {
int currentAngle = thing->stateValue(venetianBlindAngleStateTypeId).toInt();
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
@ -463,7 +459,7 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
}
} else {
Q_ASSERT_X(false, "setupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
}
}

View File

@ -141,8 +141,9 @@
"id": "27a95b8d-7f97-441b-a3be-0646c517cb06",
"name": "closingTime",
"displayName": "Closing time [MilliSecond]",
"type": "int",
"defaultValue": 0
"type": "uint",
"minValue": 1,
"defaultValue": 5000
}
],
"stateTypes": [
@ -232,15 +233,17 @@
"id": "4c0bf07d-aaab-4f67-af65-00ceaefbaa84",
"name": "closingTime",
"displayName": "Closing time [MilliSecond]",
"type": "int",
"defaultValue": 0
"minValue": 1,
"type": "uint",
"defaultValue": 5000
},
{
"id": "6c8340bf-7fd3-43e3-a75b-dfa2f6426e11",
"name": "angleTime",
"displayName": "Angle end to end time [MilliSecond]",
"type": "int",
"defaultValue": 0
"minValue": 1,
"type": "uint",
"defaultValue": 1000
}
],
"stateTypes": [