本文整理汇总了C++中DataRef::setAccuracy方法的典型用法代码示例。如果您正苦于以下问题:C++ DataRef::setAccuracy方法的具体用法?C++ DataRef::setAccuracy怎么用?C++ DataRef::setAccuracy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataRef
的用法示例。
在下文中一共展示了DataRef::setAccuracy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readClient
void TcpClient::readClient() {
while(_socket->canReadLine()) {
QByteArray lineBA = _socket->readLine();
QString line = QString(lineBA).trimmed();
DEBUG << "Client says: " << line;
// Split the command in strings
QStringList subLine = line.split(" ", QString::SkipEmptyParts);
QString command = subLine.value(0);
if(command == "disconnect") {
DEBUG << "killing this client connection";
deleteLater();
} else if(command == "sub") { // Subscribe command
if(subLine.length() >= 2) {
QString refName = subLine[1].trimmed();
double accuracy = 0;
if(subLine.length() >=3)
accuracy = subLine[2].toDouble();
DataRef *ref = getSubscribedRef(refName);
if(!ref) { // Ref not subscribed yet, try to subscribe
ref = _refProvider->subscribeRef(refName);
if(ref) { // Succesfully subscribed
connect(ref, SIGNAL(changed(DataRef*)), this, SLOT(refChanged(DataRef*)));
_subscribedRefs.insert(ref);
ref->setAccuracy(accuracy);
//TODO: why is ref->updateValue() not sufficient here?
if(ref->type() == xplmType_Float) {
_refValueF[ref] = qobject_cast<FloatDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Int) {
_refValueI[ref] = qobject_cast<IntDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Double) {
_refValueD[ref] = qobject_cast<DoubleDataRef*>(ref)->value();
} else if(ref->type() == xplmType_FloatArray) {
_refValueFA[ref] = qobject_cast<FloatArrayDataRef*>(ref)->value();
} else if(ref->type() == xplmType_IntArray) {
_refValueIA[ref] = qobject_cast<IntArrayDataRef*>(ref)->value();
} else if(ref->type() == xplmType_Data) {
_refValueB[ref] = qobject_cast<DataDataRef*>(ref)->value();
}
INFO << "Subscribed to " << ref->name() << ", accuracy " << accuracy << ", type " << ref->typeString();
} else {
INFO << "Ref not found" << refName;
}
} else { // Ref already subscribed - update accuracy