135 lines
3.5 KiB
C++
135 lines
3.5 KiB
C++
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* *
|
|
* Copyright (C) 2017 Simon Stuerz <simon.stuerz@guh.io> *
|
|
* *
|
|
* This file is part of guh-control *
|
|
* *
|
|
* 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 "device.h"
|
|
|
|
Device::Device(QObject *parent) :
|
|
QObject(parent),
|
|
m_statesProxy(new StatesProxy(this))
|
|
{
|
|
}
|
|
|
|
QString Device::name() const
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
QString Device::deviceName() const
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
void Device::setDeviceName(const QString &deviceName)
|
|
{
|
|
m_name = deviceName;
|
|
emit nameChanged();
|
|
}
|
|
|
|
QUuid Device::id() const
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
void Device::setId(const QUuid &id)
|
|
{
|
|
m_id = id;
|
|
}
|
|
|
|
QUuid Device::deviceClassId() const
|
|
{
|
|
return m_deviceClassId;
|
|
}
|
|
|
|
void Device::setDeviceClassId(const QUuid &deviceClassId)
|
|
{
|
|
m_deviceClassId = deviceClassId;
|
|
}
|
|
|
|
bool Device::setupComplete()
|
|
{
|
|
return m_setupComplete;
|
|
}
|
|
|
|
void Device::setSetupComplete(const bool &setupComplete)
|
|
{
|
|
m_setupComplete = setupComplete;
|
|
emit setupCompleteChanged();
|
|
}
|
|
|
|
Params *Device::params() const
|
|
{
|
|
return m_params;
|
|
}
|
|
|
|
void Device::setParams(Params *params)
|
|
{
|
|
m_params = params;
|
|
emit paramsChanged();
|
|
}
|
|
|
|
States *Device::states() const
|
|
{
|
|
return m_states;
|
|
}
|
|
|
|
void Device::setStates(States *states)
|
|
{
|
|
m_states = states;
|
|
emit statesChanged();
|
|
m_statesProxy->setStates(states);
|
|
}
|
|
|
|
StatesProxy *Device::statesProxy() const
|
|
{
|
|
return m_statesProxy;
|
|
}
|
|
|
|
bool Device::hasState(const QUuid &stateTypeId)
|
|
{
|
|
foreach (State *state, states()->states()) {
|
|
if (state->stateTypeId() == stateTypeId) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
QVariant Device::stateValue(const QUuid &stateTypeId)
|
|
{
|
|
foreach (State *state, states()->states()) {
|
|
if (state->stateTypeId() == stateTypeId) {
|
|
return state->value();
|
|
}
|
|
}
|
|
return QVariant();
|
|
}
|
|
|
|
void Device::setStateValue(const QUuid &stateTypeId, const QVariant &value)
|
|
{
|
|
foreach (State *state, states()->states()) {
|
|
if (state->stateTypeId() == stateTypeId) {
|
|
state->setValue(value);
|
|
return;
|
|
}
|
|
}
|
|
}
|