/** * @brief reads the configuration and stores the information in the deviceInfos QMap * @return * void */ void OpenBeaconUSBStrategy::readConfiguration () { QStringList groups = settings->childGroups(); maxPackages = settings->value ("maxPackagesOnOB", 10).toInt(); for (int i = 0; i < groups.size(); ++i) { DeviceInformation info; settings->beginGroup(groups.at(i)); info.path = ""; info.id = settings->value ("id", 0).toInt(); info.setX(settings->value ("x", 0).toDouble()); info.setY(settings->value ("y", 0).toDouble()); info.setZ(settings->value ("z", 0).toDouble()); deviceInfos.append (info); settings->endGroup (); } }
/** * @brief sets the path for the matching ID * @param id the id which path should be set * @param path path to which it should be set * @return * void */ void OpenBeaconUSBStrategy::setPath (int id, QString path) { QMutableListIterator<DeviceInformation> it(deviceInfos); while (it.hasNext()) { DeviceInformation & info = it.next(); if (info.id == id) { qCDebug(OPENBEACON_STRATEGY) << QString("Set path(%1) for id: %2").arg(path).arg(id); info.path = path; return ; } } // when the method reaches this position than we have an unconfigured device // therefore create a new one DeviceInformation info; info.path = path; info.id = id; info.fromQVector3D(QVector3D(0.0, 0.0, 0.0)); deviceInfos.append (info); qCInfo(OPENBEACON_STRATEGY) << QString("Added new device with path(%1) for id: %2").arg(path).arg(id); }
void CommonTestUtils::assertValues(const DeviceInformation& info, const DeviceType& expectedType, const QString& expectedName) { QVERIFY (info.getDeviceId() == DEVICEINFORMATION_DEVICE_ID); QCOMPARE (info.getDeviceNode(), DEVICEINFORMATION_DEVICE_NODE); QCOMPARE (info.getName(), expectedName); QVERIFY (info.getProductId() == DEVICEINFORMATION_PRODUCT_ID); QVERIFY (info.getTabletSerial() == DEVICEINFORMATION_TABLET_SERIAL); QVERIFY (info.getType() == expectedType); QVERIFY (info.getVendorId() == DEVICEINFORMATION_VENDOR_ID); }
/** * @brief parse the data that comes from the OB nodes * @param data the data that is coming from the OB * @return * void */ void OpenBeaconUSBStrategy::parseNewData (const QString & data) { if (data.isEmpty ()) return ; QString receivedPath = reinterpret_cast<OpenBeaconCommunication(*)> (sender ())->getDevicePath (); QStringList answerParts = data.split(" ", QString::SkipEmptyParts); if (answerParts.at(0) == "Id:") { setPath (answerParts.at(1).toInt(), receivedPath); DeviceInformation deviceInfo = getDeviceInformation (receivedPath); qCInfo(OPENBEACON_STRATEGY) << QString ("device with Id: %1 added.").arg (deviceInfo.id); emit newNode (deviceInfo.id, deviceInfo.x(), deviceInfo.y(), deviceInfo.z()); return; } if (answerParts.at (0) == "FIFO" && answerParts.at (1) == "lifetime") { qCInfo(OPENBEACON_STRATEGY) << QString ("FIFO of >%1< set to %2").arg (receivedPath).arg (answerParts.at (4)); return; } if (answerParts.at(0) == "RX:") { // if no tag is in reach if (answerParts.size () < 2 || answerParts.at(1).isEmpty()) return ; DeviceInformation deviceInfo = getDeviceInformation (receivedPath); if (!deviceInfo.isValid()) { qCInfo(OPENBEACON_STRATEGY) << QString ("Received information(%1) from unconfigured device: %2").arg(data).arg(receivedPath); return ; } //RX: 0,2213,3 // first is the powerlevel (0, 85, 170, 255) // second is the tagId // third is the count of received packets // strength = (powerlevel/85)*10 + (MAXPACKETS - packets) // gives us a scale from 0->40 QStringList tagInfo = answerParts.at(1).split(",", QString::SkipEmptyParts); int strength = ((tagInfo.at(0).toInt() / 85) * 10) + (maxPackages - tagInfo.at(2).toInt()); emit newStrength (deviceInfo.id, tagInfo.at(1), strength); return; } }
// HardwareInformation // ------------------- HardwareInformation::HardwareInformation() { devices = new std::map<std::string, DeviceInformation*>(); // the FPGA runs @ 100MHz instead of 800MHz, so we need to corrent // the timinigs for a comparison with the ARM processor unsigned int fpgaClockMultiplier = 8; // add timinigs for the ARM Cortex-A9 @ 800MHz DeviceInformation *cortexA9 = new DeviceInformation("Cortex-A9", DeviceInformation::CPU_LINUX); cortexA9->addInstructionInfo("ret", 0); cortexA9->addInstructionInfo("br", 0); cortexA9->addInstructionInfo("fadd", 4); cortexA9->addInstructionInfo("fsub", 4); cortexA9->addInstructionInfo("fmul", 6); cortexA9->addInstructionInfo("fdiv", 25); cortexA9->addInstructionInfo("or", 2); cortexA9->addInstructionInfo("alloca", 0); cortexA9->addInstructionInfo("load", 4); cortexA9->addInstructionInfo("store", 6); cortexA9->addInstructionInfo("getelementptr", 3); cortexA9->addInstructionInfo("zext", 1); cortexA9->addInstructionInfo("icmp", 3); cortexA9->addInstructionInfo("fcmp", 4); cortexA9->addInstructionInfo("select", 4); cortexA9->addInstructionInfo("phi", 0); cortexA9->addInstructionInfo("call", 50); // NOTE: approximation cortexA9->addCommunicationInfo("Cortex-A9", DataDependency, 455); cortexA9->addCommunicationInfo("Cortex-A9", OrderDependency, 220); cortexA9->addCommunicationInfo("xc7z020-1", DataDependency, fpgaClockMultiplier * 275); cortexA9->addCommunicationInfo("xc7z020-1", OrderDependency, fpgaClockMultiplier * 115); devices->insert(std::pair<std::string, DeviceInformation*>(cortexA9->getName(), cortexA9)); // add timinigs for the FPGA DeviceInformation *fpga = new DeviceInformation("xc7z020-1", DeviceInformation::FPGA_RECONOS); fpga->addInstructionInfo("ret", fpgaClockMultiplier * 0); fpga->addInstructionInfo("br", fpgaClockMultiplier * 0); fpga->addInstructionInfo("fadd", fpgaClockMultiplier * 13); fpga->addInstructionInfo("fsub", fpgaClockMultiplier * 13); fpga->addInstructionInfo("fmul", fpgaClockMultiplier * 10); fpga->addInstructionInfo("fdiv", fpgaClockMultiplier * 58); fpga->addInstructionInfo("or", fpgaClockMultiplier * 1); fpga->addInstructionInfo("alloca", fpgaClockMultiplier * 0); fpga->addInstructionInfo("load", fpgaClockMultiplier * 40); fpga->addInstructionInfo("store", fpgaClockMultiplier * 40); fpga->addInstructionInfo("getelementptr", fpgaClockMultiplier * 0); fpga->addInstructionInfo("zext", fpgaClockMultiplier * 0); fpga->addInstructionInfo("icmp", fpgaClockMultiplier * 1); fpga->addInstructionInfo("fcmp", fpgaClockMultiplier * 3); fpga->addInstructionInfo("select", fpgaClockMultiplier * 0); fpga->addInstructionInfo("phi", fpgaClockMultiplier * 0); fpga->addInstructionInfo("call", fpgaClockMultiplier * (1<<20)); fpga->addInstructionInfo("call#sin", fpgaClockMultiplier * (7+54+8)); fpga->addInstructionInfo("call#cos", fpgaClockMultiplier * (7+54+8)); fpga->addCommunicationInfo("Cortex-A9", DataDependency, fpgaClockMultiplier * 315); fpga->addCommunicationInfo("Cortex-A9", OrderDependency, fpgaClockMultiplier * 240); fpga->addCommunicationInfo("xc7z020-1", DataDependency, fpgaClockMultiplier * 1); fpga->addCommunicationInfo("xc7z020-1", OrderDependency, fpgaClockMultiplier * 1); devices->insert(std::pair<std::string, DeviceInformation*>(fpga->getName(), fpga)); // calculate the device independent communication costs // -> average value of all devices for the communication cost types std::vector<std::string> targets; for (std::map<std::string, DeviceInformation*>::iterator it = devices->begin(); it != devices->end(); ++it) targets.push_back(it->first); unsigned int dataDepCostSum = 0, orderDepCostSum = 0, count = 0; for (std::map<std::string, DeviceInformation*>::iterator it = devices->begin(); it != devices->end(); ++it) { for (std::vector<std::string>::iterator targetIt = targets.begin(); targetIt != targets.end(); ++targetIt) { dataDepCostSum += it->second->getCommunicationInfo(*targetIt)->getCommunicationCost(DataDependency); orderDepCostSum += it->second->getCommunicationInfo(*targetIt)->getCommunicationCost(OrderDependency); count++; } } deviceIndependentComCosts[DataDependency] = dataDepCostSum/count; deviceIndependentComCosts[OrderDependency] = orderDepCostSum/count; }