mirror of
https://github.com/Fishwaldo/libqtihandclient.git
synced 2025-03-15 19:31:30 +00:00
work on XBH-53 - QT now handles new/deleted ConfigDescriptors
This commit is contained in:
parent
7362c89229
commit
c3913961c9
6 changed files with 342 additions and 58 deletions
|
@ -79,8 +79,12 @@ public:
|
|||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
bool setData (const QModelIndex & index, const QVariant &value, int role = Qt::EditRole);
|
||||
void setData (QString serial, QString name, QVariant value, bool sync = true);
|
||||
void updateDevice(const VarStorage &device);
|
||||
void updateDeviceVars(const VarStorage &device);
|
||||
void updateDeviceConfig(const VarStorage &device);
|
||||
void addDeviceVarDescriptors(const std::string &device, const VarStorage &cd);
|
||||
void addDeviceConfigDescriptors(const std::string &device, const VarStorage &cd);
|
||||
void delDeviceVarDescriptors(const std::string &device, const std::string &field);
|
||||
void delDeviceConfigDescriptors(const std::string &device, const std::string &field);
|
||||
signals:
|
||||
void sendMsg(MessageBus);
|
||||
|
||||
|
|
|
@ -72,6 +72,10 @@ Q_SIGNALS:
|
|||
void updateConfig(MessageBus vals);
|
||||
void gotTermTypeMapping(MessageBus vals);
|
||||
void gotMyInfo(MessageBus vals);
|
||||
void addConfig(MessageBus vals);
|
||||
void addVar(MessageBus vals);
|
||||
void delConfig(MessageBus vals);
|
||||
void delVar(MessageBus vals);
|
||||
|
||||
public Q_SLOTS:
|
||||
void sendMessage(MessageBus);
|
||||
|
@ -89,6 +93,10 @@ private:
|
|||
void processSensorUpdate(MessageBus msg);
|
||||
void processConfigUpdate(MessageBus msg);
|
||||
void processSetup(MessageBus msg);
|
||||
void processAddConfig(MessageBus msg);
|
||||
void processAddVar(MessageBus msg);
|
||||
void processDelConfig(MessageBus msg);
|
||||
void processDelVar(MessageBus msg);
|
||||
int type;
|
||||
QString username;
|
||||
QString password;
|
||||
|
|
|
@ -86,6 +86,10 @@ Q_SIGNALS:
|
|||
void delEndPt(std::string item);
|
||||
void updateValues(QString, QVector<QString>);
|
||||
void updateConfig(QString, QVector<QString>);
|
||||
void newDeviceConfig(QString , QString );
|
||||
void newDeviceVar(QString , QString );
|
||||
void delDeviceConfig(QString , QString );
|
||||
void delDeviceVar(QString , QString );
|
||||
void StateChange(State_e);
|
||||
public Q_SLOTS:
|
||||
void sendMessage(MessageBus);
|
||||
|
@ -97,6 +101,10 @@ private Q_SLOTS:
|
|||
void HandleDelDevice(MessageBus item);
|
||||
void HandleDeviceUpdate(MessageBus item);
|
||||
void HandleDeviceConfigUpdate(MessageBus item);
|
||||
void HandleAddConfig(MessageBus item);
|
||||
void HandleAddVar(MessageBus item);
|
||||
void HandleDelConfig(MessageBus item);
|
||||
void HandleDelVar(MessageBus item);
|
||||
void HandleStateChange(State_e state);
|
||||
void HandleTermTypeMappings(MessageBus vals);
|
||||
void HandleClientInform(MessageBus vals);
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace boost;
|
|||
DeviceItem::DeviceItem(VarStorage data, DeviceItem *parent) {
|
||||
parentItem = parent;
|
||||
itemData = data;
|
||||
// cout << "new DeviceItem: Data:" << data << " parent: " << parent << " this: " << this << std::endl;
|
||||
// cout << "new DeviceItem: Data:" << data << " parent: " << parent << " this: " << this << std::endl;
|
||||
}
|
||||
DeviceItem::~DeviceItem() {
|
||||
qDeleteAll(childItems);
|
||||
|
@ -25,11 +25,11 @@ void DeviceItem::setData(VarStorage data) {
|
|||
itemData = data;
|
||||
}
|
||||
void DeviceItem::appendChild(DeviceItem *item) {
|
||||
//cout << "appendChild" << std::endl;
|
||||
//cout << "appendChild" << std::endl;
|
||||
childItems.append(item);
|
||||
}
|
||||
DeviceItem *DeviceItem::child(int row) {
|
||||
//cout << "row: " << row << std::endl;
|
||||
//cout << "row: " << row << std::endl;
|
||||
return childItems.value(row);
|
||||
}
|
||||
int DeviceItem::childCount() const {
|
||||
|
@ -37,7 +37,7 @@ int DeviceItem::childCount() const {
|
|||
return childItems.count();
|
||||
}
|
||||
int DeviceItem::row() const {
|
||||
//cout << "getrow()" << std::endl;
|
||||
//cout << "getrow()" << std::endl;
|
||||
if (parentItem)
|
||||
return parentItem->childItems.indexOf(const_cast<DeviceItem*>(this));
|
||||
|
||||
|
@ -48,11 +48,11 @@ int DeviceItem::columnCount() const {
|
|||
return DeviceModel_t::DEVICEMODEL_T_COLUMNS_MAX;
|
||||
}
|
||||
VarStorage DeviceItem::data() const {
|
||||
//cout << "getdata" << std::endl;
|
||||
//cout << "getdata" << std::endl;
|
||||
return itemData;
|
||||
}
|
||||
DeviceItem *DeviceItem::parent() {
|
||||
//cout << "getparent" << std::endl;
|
||||
//cout << "getparent" << std::endl;
|
||||
return parentItem;
|
||||
}
|
||||
bool DeviceItem::removeChild(DeviceItem *item) {
|
||||
|
@ -67,7 +67,7 @@ bool DeviceItem::remove() {
|
|||
|
||||
|
||||
DeviceModel_t::DeviceModel_t(QObject *parent) :
|
||||
QAbstractItemModel(parent) {
|
||||
QAbstractItemModel(parent) {
|
||||
setParent(parent);
|
||||
#if QT_VERSION < 0x050000
|
||||
QHash<int, QByteArray> roles;
|
||||
|
@ -178,7 +178,7 @@ void DeviceModel_t::addDevice(const VarStorage &Device) {
|
|||
long type;
|
||||
Device->getStringValue("EndPtName", deviceName);
|
||||
Device->getLongValue(SRVCAP_ENDPT_TYPE, type);
|
||||
// qDebug() << QString("Adding Device ").append(deviceName.c_str()) << " to DeviceModel of type " << type;
|
||||
// qDebug() << QString("Adding Device ").append(deviceName.c_str()) << " to DeviceModel of type " << type;
|
||||
if (Device->getStringValue(SRVCAP_ENDPT_SERIAL, deviceid) == true) {
|
||||
if (!m_devices.contains(deviceid)) {
|
||||
/* does it have a parent? */
|
||||
|
@ -195,7 +195,7 @@ void DeviceModel_t::addDevice(const VarStorage &Device) {
|
|||
this->rootItem->appendChild(item);
|
||||
}
|
||||
m_devices.insert(deviceid, item);
|
||||
// qDebug() << QString("Added Device ").append(deviceName.c_str()) << " to DeviceModel of type " << type;
|
||||
// qDebug() << QString("Added Device ").append(deviceName.c_str()) << " to DeviceModel of type " << type;
|
||||
endInsertRows();
|
||||
} else {
|
||||
qWarning() << QString("Device ").append(deviceName.c_str()) << " already present in DeviceModel";
|
||||
|
@ -227,7 +227,7 @@ void DeviceModel_t::delDevice(const std::string deviceid) {
|
|||
}
|
||||
}
|
||||
|
||||
void DeviceModel_t::updateDevice(const VarStorage &device) {
|
||||
void DeviceModel_t::updateDeviceVars(const VarStorage &device) {
|
||||
std::string from;
|
||||
if (!device->getStringValue(SRVCAP_ENDPT_SERIAL, from)) {
|
||||
//cout << "Cant Find Device" << std::endl;
|
||||
|
@ -241,7 +241,7 @@ void DeviceModel_t::updateDevice(const VarStorage &device) {
|
|||
if (this->m_devices.contains(from)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for Update";
|
||||
qWarning() << "Can't find Device in m_devices list for UpdateVars";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,9 +259,63 @@ void DeviceModel_t::updateDeviceConfig(const VarStorage &device) {
|
|||
if (this->m_devices.contains(from)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for Update";
|
||||
qWarning() << "Can't find Device in m_devices list for UpdateConfig";
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceModel_t::addDeviceVarDescriptors(const std::string &device, const VarStorage &cd) {
|
||||
QModelIndexList Items = this->match(this->index(0, 0, QModelIndex()), (int) SerialRole, QString::fromStdString(device), 2, Qt::MatchRecursive);
|
||||
if (Items.count() <= 0) {
|
||||
qWarning() << "Can't find Device in match list for Model";
|
||||
return;
|
||||
}
|
||||
if (this->m_devices.contains(device)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for addDeviceVarDescriptors";
|
||||
}
|
||||
}
|
||||
void DeviceModel_t::addDeviceConfigDescriptors(const std::string &device, const VarStorage &cd) {
|
||||
QModelIndexList Items = this->match(this->index(0, 0, QModelIndex()), (int) SerialRole, QString::fromStdString(device), 2, Qt::MatchRecursive);
|
||||
if (Items.count() <= 0) {
|
||||
qWarning() << "Can't find Device in match list for Model";
|
||||
return;
|
||||
}
|
||||
if (this->m_devices.contains(device)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for addDeviceConfigDescriptors";
|
||||
}
|
||||
}
|
||||
void DeviceModel_t::delDeviceVarDescriptors(const std::string &device, const std::string &field) {
|
||||
QModelIndexList Items = this->match(this->index(0, 0, QModelIndex()), (int) SerialRole, QString::fromStdString(device), 2, Qt::MatchRecursive);
|
||||
if (Items.count() <= 0) {
|
||||
qWarning() << "Can't find Device in match list for Model";
|
||||
return;
|
||||
}
|
||||
if (this->m_devices.contains(device)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for delDeviceVarDescriptors";
|
||||
}
|
||||
|
||||
}
|
||||
void DeviceModel_t::delDeviceConfigDescriptors(const std::string &device, const std::string &field) {
|
||||
QModelIndexList Items = this->match(this->index(0, 0, QModelIndex()), (int) SerialRole, QString::fromStdString(device), 2, Qt::MatchRecursive);
|
||||
if (Items.count() <= 0) {
|
||||
qWarning() << "Can't find Device in match list for Model";
|
||||
return;
|
||||
}
|
||||
if (this->m_devices.contains(device)) {
|
||||
emit dataChanged(Items[0], Items[0]);
|
||||
} else {
|
||||
qWarning() << "Can't find Device in m_devices list for delDeviceConfigDescriptors";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DeviceModel_t::rowCount(const QModelIndex & parent) const {
|
||||
DeviceItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
|
@ -310,13 +364,13 @@ QVariant DeviceModel_t::data(const QModelIndex & index, int role) const {
|
|||
*/
|
||||
const DeviceItem *item = static_cast<DeviceItem*>(index.internalPointer());
|
||||
const VarStorage Device = item->data();
|
||||
//cout << "want " << item << " stored in " << Device << std::endl;
|
||||
//cout << "want " << item << " stored in " << Device << std::endl;
|
||||
if (Device.get() == NULL) {
|
||||
qCritical() << "Device Is Empty?";
|
||||
return QVariant();
|
||||
}
|
||||
// qDebug() << "get Role" << role;
|
||||
// Device->printToStream();
|
||||
// qDebug() << "get Role" << role;
|
||||
// Device->printToStream();
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case DeviceName: {
|
||||
|
@ -551,35 +605,35 @@ void DeviceModel_t::setData(QString serial, QString name, QVariant value, bool s
|
|||
VarContainerFactory(newvariable);
|
||||
switch (variable->getType(name.toStdString())) {
|
||||
case ST_STRING:
|
||||
newvariable->addStringValue(name.toStdString(), value.toString().toStdString());
|
||||
break;
|
||||
newvariable->addStringValue(name.toStdString(), value.toString().toStdString());
|
||||
break;
|
||||
case ST_INT:
|
||||
newvariable->addIntValue(name.toStdString(), value.toInt());
|
||||
break;
|
||||
newvariable->addIntValue(name.toStdString(), value.toInt());
|
||||
break;
|
||||
case ST_LONG:
|
||||
newvariable->addLongValue(name.toStdString(), value.toLongLong());
|
||||
break;
|
||||
newvariable->addLongValue(name.toStdString(), value.toLongLong());
|
||||
break;
|
||||
case ST_LONGLONG:
|
||||
newvariable->addLongLongValue(name.toStdString(), value.toLongLong());
|
||||
break;
|
||||
newvariable->addLongLongValue(name.toStdString(), value.toLongLong());
|
||||
break;
|
||||
case ST_FLOAT:
|
||||
newvariable->addFloatValue(name.toStdString(), value.toFloat());
|
||||
break;
|
||||
newvariable->addFloatValue(name.toStdString(), value.toFloat());
|
||||
break;
|
||||
case ST_HASH:
|
||||
qWarning() << "Hash Not implemented in setData";
|
||||
break;
|
||||
qWarning() << "Hash Not implemented in setData";
|
||||
break;
|
||||
case ST_BOOL:
|
||||
newvariable->addBoolValue(name.toStdString(), value.toBool());
|
||||
break;
|
||||
newvariable->addBoolValue(name.toStdString(), value.toBool());
|
||||
break;
|
||||
case ST_DATETIME:
|
||||
qWarning() << "DateTime not implemented in setData";
|
||||
break;
|
||||
qWarning() << "DateTime not implemented in setData";
|
||||
break;
|
||||
case ST_VARSTORAGE:
|
||||
qWarning() << "VarStorage not implemented in setData";
|
||||
break;
|
||||
qWarning() << "VarStorage not implemented in setData";
|
||||
break;
|
||||
case ST_INVALID:
|
||||
qWarning() << "setData for a INVALID???";
|
||||
break;
|
||||
qWarning() << "setData for a INVALID???";
|
||||
break;
|
||||
}
|
||||
if (sync) {
|
||||
/* send it out straight away using MSG_WHAT_ENDPNT */
|
||||
|
@ -771,8 +825,14 @@ QVariant VarStorageHelper_t::getValue(QString name, int pos) {
|
|||
qWarning() << "Out of Bounds Request for a Array Field: " << fieldName;
|
||||
return QVariant();
|
||||
}
|
||||
/* see if it exists, otherwise, return the default */
|
||||
if (val->getSize(fieldName.toStdString()) <= 0) {
|
||||
qWarning() << "Returning Default Value for " << fieldName << " as it doesn't exist in our Vars Yet";
|
||||
return this->getDefault(fieldName);
|
||||
}
|
||||
|
||||
switch (val->getType(fieldName.toStdString())) {
|
||||
|
||||
switch (this->getRealType(fieldName)) {
|
||||
case ST_STRING:
|
||||
return QVariant(VSE.getString(val, fieldName, pos));
|
||||
case ST_INT:
|
||||
|
@ -853,27 +913,31 @@ qlonglong VarStorageHelper_t::getMax(QString name) {
|
|||
|
||||
QVariant VarStorageHelper_t::getDefault(QString name) {
|
||||
HashVals vals;
|
||||
if (this->descriptor->getHashValue(name.toStdString(), vals)) {
|
||||
switch (boost::get<int>(vals["type"])) {
|
||||
case ST_STRING:
|
||||
case ST_DATETIME:
|
||||
return QVariant((char *) boost::get<std::string>(vals["defaultstr"]).c_str());
|
||||
case ST_INT:
|
||||
case ST_LONG:
|
||||
case ST_LONGLONG:
|
||||
case ST_FLOAT:
|
||||
case ST_BOOL:
|
||||
case ST_LIST:
|
||||
return QVariant((long long) boost::get<long long>(vals["defaultnum"]));
|
||||
case ST_HASH:
|
||||
case ST_VARSTORAGE:
|
||||
case ST_INVALID:
|
||||
qWarning() << "Unsupported Type Requested from getDefault(name): " << name;
|
||||
return QVariant();
|
||||
try {
|
||||
if (this->descriptor->getHashValue(name.toStdString(), vals)) {
|
||||
switch (boost::get<int>(vals["Type"])) {
|
||||
case ST_STRING:
|
||||
case ST_DATETIME:
|
||||
return QVariant((char *) boost::get<std::string>(vals["defaultstr"]).c_str());
|
||||
case ST_INT:
|
||||
case ST_LONG:
|
||||
case ST_LONGLONG:
|
||||
case ST_FLOAT:
|
||||
case ST_BOOL:
|
||||
case ST_LIST:
|
||||
return QVariant((long long) boost::get<long long>(vals["defaultnum"]));
|
||||
case ST_HASH:
|
||||
case ST_VARSTORAGE:
|
||||
case ST_INVALID:
|
||||
qWarning() << "Unsupported Type Requested from getDefault(name): " << name;
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
qWarning() << name << " does not exist in Descriptors (getDescription())";
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
qWarning() << name << " does not exist in Descriptors (getDescription())";
|
||||
return QVariant();
|
||||
} catch (std::exception &e) {
|
||||
qWarning() << "Exception Caught in getDefault: " << e.what();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -132,6 +132,18 @@ void MessageHandler::MessageReceivedFromGateway(const muscle::MessageRef & msg,
|
|||
case MSB_SETUP:
|
||||
processSetup(mb);
|
||||
break;
|
||||
case MSB_ADD_CONFIG:
|
||||
processAddConfig(mb);
|
||||
break;
|
||||
case MSB_ADD_VAR:
|
||||
processAddVar(mb);
|
||||
break;
|
||||
case MSB_DEL_CONFIG:
|
||||
processDelConfig(mb);
|
||||
break;
|
||||
case MSB_DEL_VAR:
|
||||
processDelVar(mb);
|
||||
|
||||
default:
|
||||
qWarning() << "Got Unknown What Message: " << mb->getTypeAsString().c_str();
|
||||
//qWarning() << mb;
|
||||
|
@ -224,6 +236,61 @@ void MessageHandler::processConfigUpdate(MessageBus msg) {
|
|||
emit updateConfig(msg);
|
||||
}
|
||||
|
||||
void MessageHandler::processAddConfig(MessageBus msg) {
|
||||
if (msg->getType() != MSB_ADD_CONFIG) {
|
||||
qWarning() << "Invalid MessageBus Type recieved in processAddConfig" << msg->getTypeAsString().c_str();
|
||||
return;
|
||||
}
|
||||
VarStorage config = msg->getNewConfig();
|
||||
if (config->getSize() == 0) {
|
||||
qWarning() << "Empty config message from MessageBus";
|
||||
std::cout << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << "Doing" << std::endl;
|
||||
emit addConfig(msg);
|
||||
}
|
||||
void MessageHandler::processAddVar(MessageBus msg) {
|
||||
if (msg->getType() != MSB_ADD_VAR) {
|
||||
qWarning() << "Invalid MessageBus Type recieved in processAddVar" << msg->getTypeAsString().c_str();
|
||||
return;
|
||||
}
|
||||
VarStorage config = msg->getNewVar();
|
||||
if (config->getSize() == 0) {
|
||||
qWarning() << "Empty config message from MessageBus";
|
||||
std::cout << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
emit addVar(msg);
|
||||
}
|
||||
void MessageHandler::processDelConfig(MessageBus msg) {
|
||||
if (msg->getType() != MSB_DEL_CONFIG) {
|
||||
qWarning() << "Invalid MessageBus Type recieved in processDelConfig" << msg->getTypeAsString().c_str();
|
||||
return;
|
||||
}
|
||||
VarStorage config = msg->getDelConfig();
|
||||
if (config->getSize() == 0) {
|
||||
qWarning() << "Empty config message from MessageBus";
|
||||
std::cout << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
emit delConfig(msg);
|
||||
}
|
||||
void MessageHandler::processDelVar(MessageBus msg) {
|
||||
if (msg->getType() != MSB_DEL_VAR) {
|
||||
qWarning() << "Invalid MessageBus Type recieved in processDelVar" << msg->getTypeAsString().c_str();
|
||||
return;
|
||||
}
|
||||
VarStorage config = msg->getDelVar();
|
||||
if (config->getSize() == 0) {
|
||||
qWarning() << "Empty config message from MessageBus";
|
||||
std::cout << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
emit delVar(msg);
|
||||
}
|
||||
|
||||
|
||||
void MessageHandler::setType(int Type) {
|
||||
this->type = Type;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,15 @@ QtiHanClient::QtiHanClient(QObject *parent) {
|
|||
this, SLOT(HandleDeviceUpdate(MessageBus)));
|
||||
QObject::connect(this->mh, SIGNAL(updateConfig(MessageBus)),
|
||||
this, SLOT(HandleDeviceConfigUpdate(MessageBus)));
|
||||
QObject::connect(this->mh, SIGNAL(addConfig(MessageBus)),
|
||||
this, SLOT(HandleAddConfig(MessageBus)));
|
||||
QObject::connect(this->mh, SIGNAL(addVar(MessageBus)),
|
||||
this, SLOT(HandleAddVar(MessageBus)));
|
||||
QObject::connect(this->mh, SIGNAL(delConfig(MessageBus)),
|
||||
this, SLOT(HandleDelConfig(MessageBus)));
|
||||
QObject::connect(this->mh, SIGNAL(delVar(MessageBus)),
|
||||
this, SLOT(HandleDelVar(MessageBus)));
|
||||
|
||||
QObject::connect(this->mh, SIGNAL(StateChange(State_e)),
|
||||
this, SLOT(HandleStateChange(State_e)));
|
||||
QObject::connect(this->mh, SIGNAL(gotTermTypeMapping(MessageBus)),
|
||||
|
@ -416,7 +425,7 @@ void QtiHanClient::HandleDeviceUpdate(MessageBus msg) {
|
|||
|
||||
//newvals->addStringValue(SRVCAP_ENDPT_SERIAL, deviceID);
|
||||
//GlobalDevices[deviceID]->replaceVarStorageValue(SRVCAP_ENDPT_VARS, newvals);
|
||||
this->tdm->updateDevice(newvals);
|
||||
this->tdm->updateDeviceVars(newvals);
|
||||
emit updateValues(deviceID.c_str(), updatedfields);
|
||||
}
|
||||
|
||||
|
@ -653,6 +662,130 @@ void QtiHanClient::HandleDeviceConfigUpdate(MessageBus msg) {
|
|||
emit updateConfig(deviceID.c_str(), updatedfields);
|
||||
}
|
||||
|
||||
void QtiHanClient::HandleAddConfig(MessageBus item) {
|
||||
VarStorage msg = item->getNewConfig();
|
||||
HashVals hv;
|
||||
if (!msg->getHashValue("ConfigDescriptor", hv)) {
|
||||
qWarning() << "Can't get ConfigDescriptor for HandleAddConfig";
|
||||
return;
|
||||
}
|
||||
std::string deviceID = item->getSource();
|
||||
/* Regardless of whats going on, add this new End Point to the Global DeviceMap */
|
||||
if (!GlobalDevices.contains(deviceID)) {
|
||||
qWarning() << "Cannot Find device " << QString::fromStdString(deviceID) << " in GlobalDevices List for HandleAddConfig";
|
||||
return;
|
||||
}
|
||||
VarStorage config;
|
||||
if (GlobalDevices[deviceID]->getVarStorageValue(SRVCAP_ENDPT_CONFIG_DESC, config) == false) {
|
||||
qWarning("Can't get End Point Config from GloablDevices");
|
||||
return;
|
||||
}
|
||||
if (config->getSize(boost::get<std::string>(hv["Name"])) > 0) {
|
||||
qWarning() << "ConfigDescriptor for Field " << QString::fromStdString(boost::get<std::string>(hv["Name"])) << " Already Exists";
|
||||
return;
|
||||
}
|
||||
if (!config->addHashValue(boost::get<std::string>(hv["Name"]), hv)) {
|
||||
qWarning() << "Failed to add ConfigDescriptor for field " << QString::fromStdString(boost::get<std::string>(hv["Name"]));
|
||||
return;
|
||||
}
|
||||
std::cout << "HandleAddConfig: " << deviceID << " Field:" << boost::get<std::string>(hv["Name"]) << std::endl;
|
||||
this->tdm->addDeviceConfigDescriptors(deviceID, msg);
|
||||
emit newDeviceConfig(QString::fromStdString(deviceID), QString::fromStdString(boost::get<std::string>(hv["Name"])));
|
||||
}
|
||||
void QtiHanClient::HandleAddVar(MessageBus item) {
|
||||
VarStorage msg = item->getNewVar();
|
||||
HashVals hv;
|
||||
if (!msg->getHashValue("VarDescriptor", hv)) {
|
||||
qWarning() << "Can't get ConfigDescriptor for HandleAddVar";
|
||||
return;
|
||||
}
|
||||
std::string deviceID = item->getSource();
|
||||
/* Regardless of whats going on, add this new End Point to the Global DeviceMap */
|
||||
if (!GlobalDevices.contains(deviceID)) {
|
||||
qWarning() << "Cannot Find device " << QString::fromStdString(deviceID) << " in GlobalDevices List for HandleAddVar";
|
||||
return;
|
||||
}
|
||||
VarStorage config;
|
||||
if (GlobalDevices[deviceID]->getVarStorageValue(SRVCAP_ENDPT_VARS_DESC, config) == false) {
|
||||
qWarning("Can't get End Point Config from GloablDevices");
|
||||
return;
|
||||
}
|
||||
if (config->getSize(boost::get<std::string>(hv["Name"])) > 0) {
|
||||
qWarning() << "ConfigDescriptor for Field " << QString::fromStdString(boost::get<std::string>(hv["Name"])) << " Already Exists";
|
||||
return;
|
||||
}
|
||||
if (!config->addHashValue(boost::get<std::string>(hv["Name"]), hv)) {
|
||||
qWarning() << "Failed to add ConfigDescriptor for field " << QString::fromStdString(boost::get<std::string>(hv["Name"]));
|
||||
return;
|
||||
}
|
||||
std::cout << "HandleAddVar: " << deviceID << " Field:" << boost::get<std::string>(hv["Name"]) << std::endl;
|
||||
this->tdm->addDeviceVarDescriptors(deviceID, msg);
|
||||
emit newDeviceVar(QString::fromStdString(deviceID), QString::fromStdString(boost::get<std::string>(hv["Name"])));
|
||||
}
|
||||
void QtiHanClient::HandleDelConfig(MessageBus item) {
|
||||
VarStorage msg = item->getDelConfig();
|
||||
std::string field;
|
||||
if (!msg->getStringValue("DelConfig", field)) {
|
||||
qWarning() << "Can't get DelConfig Field for HandleDelConfig";
|
||||
return;
|
||||
}
|
||||
std::string deviceID = item->getSource();
|
||||
/* Regardless of whats going on, add this new End Point to the Global DeviceMap */
|
||||
if (!GlobalDevices.contains(deviceID)) {
|
||||
qWarning() << "Cannot Find device " << QString::fromStdString(deviceID) << " in GlobalDevices List for HandleDelConfig";
|
||||
return;
|
||||
}
|
||||
VarStorage config;
|
||||
if (GlobalDevices[deviceID]->getVarStorageValue(SRVCAP_ENDPT_CONFIG_DESC, config) == false) {
|
||||
qWarning("Can't get End Point Config from GloablDevices");
|
||||
return;
|
||||
}
|
||||
if (config->getSize(field) <= 0) {
|
||||
qWarning() << "ConfigDescriptor for Field " << QString::fromStdString(field) << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (!config->delValue(field)) {
|
||||
qWarning() << "Can't Delete ConfigDescriptor for Field " << QString::fromStdString(field);
|
||||
return;
|
||||
}
|
||||
std::cout << "HandleDelConfig: " << deviceID << " Field:" << field << std::endl;
|
||||
this->tdm->delDeviceConfigDescriptors(deviceID, field);
|
||||
emit delDeviceConfig(QString::fromStdString(deviceID), QString::fromStdString(field));
|
||||
}
|
||||
void QtiHanClient::HandleDelVar(MessageBus item) {
|
||||
VarStorage msg = item->getDelVar();
|
||||
std::string field;
|
||||
if (!msg->getStringValue("delVar", field)) {
|
||||
qWarning() << "Can't get delVar Field for HandleDelVar";
|
||||
return;
|
||||
}
|
||||
std::string deviceID = item->getSource();
|
||||
/* Regardless of whats going on, add this new End Point to the Global DeviceMap */
|
||||
if (!GlobalDevices.contains(deviceID)) {
|
||||
qWarning() << "Cannot Find device " << QString::fromStdString(deviceID) << " in GlobalDevices List for HandleDelVar";
|
||||
return;
|
||||
}
|
||||
VarStorage config;
|
||||
if (GlobalDevices[deviceID]->getVarStorageValue(SRVCAP_ENDPT_VARS_DESC, config) == false) {
|
||||
qWarning("Can't get End Point Config from GloablDevices");
|
||||
return;
|
||||
}
|
||||
if (config->getSize(field) <= 0) {
|
||||
qWarning() << "ConfigDescriptor for Field " << QString::fromStdString(field) << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (!config->delValue(field)) {
|
||||
qWarning() << "Can't Delete ConfigDescriptor for Field " << QString::fromStdString(field);
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "HandleDelVar: " << deviceID << " Field:" << field << std::endl;
|
||||
this->tdm->delDeviceVarDescriptors(deviceID, field);
|
||||
emit delDeviceConfig(QString::fromStdString(deviceID), QString::fromStdString(field));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QtiHanClient::sendMessage(MessageBus msg) {
|
||||
this->mh->sendMessage(msg);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue