void StatisticRobotWidget::paintEvent(QPaintEvent* event) { painter.begin(this); painter.setFont(font); painter.setBrush(altBrush); painter.setPen(fontPen); fillBackground = false; paintRect = painter.window(); paintRectField = QRect(headerView->sectionViewportPosition(0) + textOffset, 0, headerView->sectionSize(0) + headerView->sectionSize(1) - textOffset * 2, lineSpacing); paintRectField0 = QRect(headerView->sectionViewportPosition(0) + textOffset, 0, headerView->sectionSize(0) - textOffset * 2, lineSpacing); paintRectField1 = QRect(headerView->sectionViewportPosition(1) + textOffset, 0, headerView->sectionSize(1) - textOffset * 2, lineSpacing); { const Statistic::StatisticRobot& robot = statisticRobotView.robots[statisticRobotView.robotIndex]; print("Robot" + (robot.logCount > 1 ? '(' + QString::number(robot.logCount) + ')' : ""), robot.name.c_str()); print("Configuration", robot.scenario.empty() ? "" : TypeRegistry::getEnumName(robot.configuration)); print("Location", robot.location.c_str()); print("Scenario", robot.scenario.c_str()); print("Number", QString::number(robot.number)); print("Number of Frames", QString::number(robot.frames)); newSection(); print("Pickups", QString::number(robot.pickedUps)); print("Penalizes", QString::number(robot.penaltys)); newSection(); print("Number of Fallen", QString::number(robot.fallen)); printList(robot.fallenFrames); print("Failed getUps", QString::number(robot.failedGetUps)); printList(robot.failedGetUpFrames); print("walked distance (in m)", QString::number(robot.walkedDistance)); print("Bad localisation", QString::number(robot.badLocalisations)); newSection(); printLine("Joints of interrest:"); printJoints(); newSection(); printLine("Number of:"); print("WalkRequests", QString::number(robot.walkRequests)); print("StandRequests", QString::number(robot.standRequests)); print("SpecialActionRequests", QString::number(robot.specialActionRequests)); print("GetUpRequests", QString::number(robot.getUpRequests)); print("KickRequests", QString::number(robot.kickRequests)); print("BallKicked", QString::number(robot.ballKicked)); print("In-walk kicks", QString::number(robot.inWalkKicks)); print("Seen balls", QString::number(robot.seenBalls)); print("Guessed balls", QString::number(robot.guessedBalls)); newSection(); printLine("Communication:"); print("Received messages", QString::number(robot.receivedMessages)); for(size_t i = 0; i < robot.receivedMessagesRobots.size(); i++) { print(QString::fromStdString(getNamebyNumber(statisticRobotView.robots, static_cast<int>(i) + 1)), QString::number(robot.receivedMessagesRobots[i])); } } painter.end(); setMinimumHeight(paintRectField1.top()); }
static RList *parseSegments(RBuffer *buf, int off, int count) { ut8 *b = calloc (count, 32); (void)r_buf_read_at (buf, off, b, count * 32); int x = off; int X = 0; int i; RList *segments = r_list_newf ((RListFree)r_bin_section_free); if (!segments) { return NULL; } // eprintf ("Segments: %d\n", count); for (i = 0; i < count; i++) { int A = r_read_le32 (b + X + 16); int B = r_read_le32 (b + X + 16 + 8); // eprintf ("0x%08x segment 0x%08x 0x%08x %s\n", // x, A, A + B, b + X); const char *cname = (const char *)(b + X); char *name = r_str_ndup (cname, r_str_nlen (cname, 16)); RBinSection *section = newSection (name, A, A + B, true); free (name); r_list_append (segments, section); x += 32; X += 32; } return segments; }
static orl_return addToSymbolTable( omf_file_handle ofh, omf_symbol_handle sym ) { omf_sec_handle sh; assert( ofh ); assert( sym ); sh = ofh->symbol_table; if( !sh ) { sh = newSection( ofh, OMF_SEC_SYM_TABLE_INDEX, ORL_SEC_TYPE_SYM_TABLE ); if( !sh ) return( ORL_OUT_OF_MEMORY ); ofh->symbol_table = sh; sh->flags |= ORL_SEC_FLAG_REMOVE; sh->assoc.sym.hash_tab = ORLHashTableCreate( ofh->omf_hnd->funcs, 257, ORL_HASH_STRING, (orl_hash_comparison_func)stricmp ); if( !sh->assoc.sym.hash_tab ) { return( ORL_OUT_OF_MEMORY ); } } assert( sh->assoc.sym.hash_tab ); sh->assoc.sym.syms = checkArraySize( ofh, sh->assoc.sym.syms, sh->assoc.sym.num, STD_INC, sizeof( omf_symbol_handle ) ); if( !sh->assoc.sym.syms ) return( ORL_OUT_OF_MEMORY ); sh->assoc.sym.syms[sh->assoc.sym.num] = sym; sh->assoc.sym.num++; return( ORLHashTableInsert( sh->assoc.sym.hash_tab, sym->name.string, sym ) ); }
/*! Add \a triangles - a series of one or more triangles - to this builder. The data is broken into groups of 3 vertices, each processed as a triangle. If \a triangles has less than 3 vertices this function exits without doing anything. Any vertices at the end of the list under a multiple of 3 are ignored. If no normals are supplied in \a triangles, a normal is calculated; as the cross-product \c{(b - a) x (c - a)}, for each group of 3 logical vertices \c{a(triangle, i), b(triangle, i+1), c(triangle, i+2)}. In the case of a degenerate triangle, where the cross-product is null, that triangle is skipped. Supplying normals suppresses this behaviour (and means any degenerate triangles will be added to the geometry). \b{Raw Triangle Mode} If \a triangles has indices specified then no processing of any kind is done and all the geometry is simply dumped in to the builder. This \b{raw triangle} mode is for advanced use, and it is assumed that the user knows what they are doing, in particular that the indices supplied are correct, and normals are supplied and correct. Normals are not calculated in raw triangle mode, and skipping of null triangles is likewise not performed. See the section on \l{raw-triangle-mode}{raw triangle mode} in the class documentation above. \sa addQuads(), operator>>() */ void QGLBuilder::addTriangles(const QGeometryData &triangles) { if (triangles.count() < 3) return; if (triangles.indexCount() > 0) { // raw triangle mode if (dptr->currentSection == 0) newSection(); dptr->currentSection->appendGeometry(triangles); dptr->currentSection->appendIndices(triangles.indices()); dptr->currentNode->setCount(dptr->currentNode->count() + triangles.indexCount()); } else { QGeometryData t = triangles; bool calcNormal = !t.hasField(QGL::Normal); if (calcNormal) { QVector3DArray nm(t.count()); t.appendNormalArray(nm); } bool skip = false; int k = 0; for (int i = 0; i < t.count() - 2; i += 3) { if (calcNormal) skip = qCalculateNormal(i, i+1, i+2, t); if (!skip) dptr->addTriangle(i, i+1, i+2, t, k); } dptr->currentNode->setCount(dptr->currentNode->count() + k); } }
static orl_return addReloc( omf_file_handle ofh, omf_reloc_handle orh ) { omf_sec_handle sh; assert( ofh ); assert( orh ); if( !ofh->relocs ) { ofh->relocs = newSection( ofh, OMF_SEC_RELOC_INDEX, ORL_SEC_TYPE_RELOCS ); if( !ofh->relocs ) return( ORL_OUT_OF_MEMORY ); ofh->relocs->flags |= ORL_SEC_FLAG_REMOVE; } sh = ofh->relocs; sh->assoc.reloc.relocs = checkArraySize( ofh, sh->assoc.reloc.relocs, sh->assoc.reloc.num, STD_INC, sizeof( omf_reloc_handle ) ); if( !sh->assoc.reloc.relocs ) return( ORL_OUT_OF_MEMORY ); sh->assoc.reloc.relocs[sh->assoc.reloc.num] = orh; sh->assoc.reloc.num++; return( ORL_OKAY ); }
int ElfWriter::dwarfCallback( LIBDWARF_CALLBACK_NAME_TYPE name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info) { if (!strncmp(name, ".rel", 4)) return 0; return newSection(name, size, type, flags); }
void cNtHeader::read(basicInput& stream, bool shouldReadSections, bool isMemory) { // Remove all old componentes m_memoryImage = cForkStreamPtr(NULL); m_fastImportDll = cForkStreamPtr(NULL); IMAGE_NT_HEADERS32 newHeader; memset(&newHeader, 0, sizeof(newHeader)); // Read all header, except RVA stream.pipeRead(&newHeader, sizeof(newHeader) - (IMAGE_NUMBEROF_DIRECTORY_ENTRIES * sizeof(IMAGE_DATA_DIRECTORY))); CHECK(newHeader.Signature == IMAGE_NT_SIGNATURE); changeNtHeader(newHeader); // Read DATA_DIRCTORIES. Limited by the number of RVA uint i; for (i = 0; i < this->OptionalHeader.NumberOfRvaAndSizes; i++) stream.pipeRead(&this->OptionalHeader.DataDirectory[i], sizeof(IMAGE_DATA_DIRECTORY)); // Test whether we should read sections if (!shouldReadSections) return; // Start reading sections for (i = 0; i < this->FileHeader.NumberOfSections; i++) { // Read section cNtSectionHeader* appenedSection = new cNtSectionHeader( // If we wanted to specifiy the image base for ourselves, use it m_trueImageBase ? m_trueImageBase : this->OptionalHeader.ImageBase, stream, SECTION_TYPE_WINDOWS_CODE, true, isMemory); cSectionPtr newSection(appenedSection); // Test whether we know what is the type of the section... for (uint j = 0; j < this->OptionalHeader.NumberOfRvaAndSizes; j++) { if ((this->OptionalHeader.DataDirectory[j].VirtualAddress == appenedSection->VirtualAddress) && (this->OptionalHeader.DataDirectory[j].Size == appenedSection->SizeOfRawData)) { appenedSection->setSectionType((SectionType)j); } } m_sections.append(newSection); } // TODO! readPrivate }
/*! Creates a new scene node that is a child of the current node and, makes it the current node. A pointer to the new node is returned. The previous current node is saved on a stack and it may be made current again by calling popNode(). \sa popNode(), newNode() */ QGLSceneNode *QGLBuilder::pushNode() { if (dptr->currentSection == 0) newSection(); // calls newNode() QGLSceneNode *parentNode = dptr->currentNode; dptr->nodeStack.append(parentNode); dptr->currentNode = new QGLSceneNode(parentNode); dptr->currentNode->setStart(dptr->currentSection->indexCount()); dptr->currentNode->setPalette(parentNode->palette()); return dptr->currentNode; }
static omf_sec_handle newStringTable( omf_file_handle ofh, omf_quantity idx ) { omf_sec_handle sh; assert( ofh ); sh = newSection( ofh, idx, ORL_SEC_TYPE_STR_TABLE ); if( sh ) { sh->flags = ORL_SEC_FLAG_REMOVE; } return( sh ); }
int ElfWriter::writeStringSection() { int section = -1; if ((section = newSection( ".shstrtab", m_strtab.size(), SHT_STRTAB, SHF_STRINGS)) < 0) { logError("unable to create string section"); return -1; } if (!addSectionData(section, &m_strtab[0], m_strtab.size())) { logError("unable to add string data"); return -1; } return section; }
int ElfWriter::writeTextSection() { int section = -1; HPHP::x64::X64Assembler &a(TranslatorX64::Get()->getAsm()); if ((section = newSection( ".text.tracelets", a.code.size, SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR, reinterpret_cast<uint64_t>(a.code.base))) < 0) { logError("unable to create text section"); return -1; } if (!addSectionData(section, NULL, a.code.size)) { logError("unable to add text data"); return -1; } return section; }
int ElfWriter::writeTextSection() { int section = -1; CodeBlock& a = tx64->code.main(); if ((section = newSection( ".text.tracelets", a.capacity(), SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR, reinterpret_cast<uint64_t>(a.base()))) < 0) { logError("unable to create text section"); return -1; } if (!addSectionData(section, nullptr, a.capacity())) { logError("unable to add text data"); return -1; } return section; }
void SensorWidget::paintEvent(QPaintEvent* event) { painter.begin(this); painter.setFont(font); painter.setBrush(altBrush); painter.setPen(fontPen); fillBackground = false; paintRect = painter.window(); paintRectField0 = QRect(headerView->sectionViewportPosition(0) + textOffset, 0, headerView->sectionSize(0) - textOffset * 2, lineSpacing); paintRectField1 = QRect(headerView->sectionViewportPosition(1) + textOffset, 0, headerView->sectionSize(1) - textOffset * 2, lineSpacing); { SYNC_WITH(sensorView.console); paintInertialSensorData(); newSection(); paintSystemSensorData(); newSection(); paintFsrSensorData(); newSection(); paintKeyStates(); } painter.end(); setMinimumHeight(paintRectField1.top()); }
int ElfWriter::writeTextSection() { int section = -1; auto& code = mcg->code; if ((section = newSection( ".text.tracelets", code.codeSize(), SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR, reinterpret_cast<uint64_t>(code.base()))) < 0) { logError("unable to create text section"); return -1; } if (!addSectionData(section, nullptr, code.codeSize())) { logError("unable to add text data"); return -1; } return section; }
void cNtHeader::read(cMemoryAccesserStream& stream, bool shouldReadSections, bool isMemory) { // Read the header read((basicInput&)(stream), false, isMemory); // Test whether we should read sections if (!shouldReadSections) return; // TODO! CHECK(isMemory); // Start reading sections for (uint i = 0; i < this->FileHeader.NumberOfSections; i++) { // Read section cNtSectionHeader* appenedSection = new cNtSectionHeader( this->OptionalHeader.ImageBase, stream, SECTION_TYPE_WINDOWS_CODE, true, isMemory); cSectionPtr newSection(appenedSection); // Test whether we know what is the type of the section... for (uint j = 0; j < this->OptionalHeader.NumberOfRvaAndSizes; j++) { if ((this->OptionalHeader.DataDirectory[j].VirtualAddress == appenedSection->VirtualAddress) && (this->OptionalHeader.DataDirectory[j].Size == appenedSection->SizeOfRawData)) { appenedSection->setSectionType((SectionType)j); } } m_sections.append(newSection); } // Get a fast source m_memoryImage = stream.fork(); // And read the private dll sections. // TODO! readPrivate(stream); }
/*! Creates a new QGLSceneNode and makes it current. A pointer to the new node is returned. The node is added into the scene at the same level as the currentNode(). The node is set to reference the geometry starting from the next vertex created, such that currentNode()->start() will return the index of this next vertex. \sa newSection() */ QGLSceneNode *QGLBuilder::newNode() { if (dptr->currentSection == 0) { newSection(); // calls newNode() return dptr->currentNode; } QGLSceneNode *parentNode = dptr->rootNode; if (dptr->nodeStack.count() > 0) parentNode = dptr->nodeStack.last(); dptr->currentNode = new QGLSceneNode(parentNode); dptr->currentNode->setPalette(parentNode->palette()); dptr->currentNode->setStart(dptr->currentSection->indexCount()); if (dptr->nodeStack.count() == 0) dptr->currentSection->addNode(dptr->currentNode); return dptr->currentNode; }
/*! Removes the node from the top of the stack, makes a copy of it, and makes the copy current. If the stack is empty, behaviour is undefined. In debug mode, calling this function when the stack is empty will cause an assert. A pointer to the new current node is returned. The node is set to reference the geometry starting from the next vertex created, such that QGLSceneNode::start() will return the index of this next vertex. \sa pushNode(), newNode() */ QGLSceneNode *QGLBuilder::popNode() { if (dptr->currentSection == 0) newSection(); // calls newNode() int cnt = dptr->currentSection->indexCount(); QGLSceneNode *s = dptr->nodeStack.takeLast(); // assert here QGLSceneNode *parentNode = dptr->rootNode; if (dptr->nodeStack.count() > 0) parentNode = dptr->nodeStack.last(); dptr->currentNode = s->cloneNoChildren(parentNode); dptr->currentNode->setStart(cnt); dptr->currentNode->setCount(0); dptr->currentNode->setPalette(parentNode->palette()); if (dptr->nodeStack.count() == 0) dptr->currentSection->addNode(dptr->currentNode); return dptr->currentNode; }
static omf_sec_handle newSegSection( omf_file_handle ofh, orl_sec_type typ ) { omf_sec_handle sh; assert( ofh ); ofh->segs = checkArraySize( ofh, ofh->segs, ofh->num_segs, STD_INC, sizeof( omf_sec_handle ) ); if( !ofh->segs ) return( NULL ); sh = newSection( ofh, OMF_SEC_NEXT_AVAILABLE, typ ); if( !sh ) return( sh ); ofh->segs[ofh->num_segs] = sh; ofh->num_segs++; sh->assoc.seg.seg_id = ofh->num_segs; return( sh ); }
static omf_sec_handle newComDatSection( omf_file_handle ofh ) { omf_sec_handle sh; assert( ofh ); ofh->comdats = checkArraySize( ofh, ofh->comdats, ofh->num_comdats, STD_INC, sizeof( omf_sec_handle ) ); if( !ofh->comdats ) return( NULL ); sh = newSection( ofh, OMF_SEC_NEXT_AVAILABLE, ORL_SEC_TYPE_PROG_BITS ); if( !sh ) return( sh ); ofh->comdats[ofh->num_comdats] = sh; ofh->num_comdats++; sh->assoc.seg.seg_id = ofh->num_comdats; return( sh ); }
HRESULT PESectionMan::getSectionCreate(const char* name, unsigned flags, PESection **section) { PESection* ret = getSection(name); // If there is an existing section with the given name, return that if (ret != NULL) { *section = ret; return(S_OK); } // Check if there is space for a new section if (sectCur >= sectEnd) { unsigned curLen = (unsigned)(sectCur-sectStart); unsigned newLen = (curLen * 2) + 1; PESection** sectNew = new (nothrow) PESection*[newLen]; if (sectNew == NULL) { return E_OUTOFMEMORY; } memcpy(sectNew, sectStart, sizeof(PESection*)*curLen); delete [] sectStart; sectStart = sectNew; sectCur = §Start[curLen]; sectEnd = §Start[newLen]; } HRESULT hr; IfFailRet(newSection(name, &ret, flags)); // dbPrintf(("MAKING NEW %s SECTION data starts at 0x%x\n", name, ret->dataStart)); *sectCur++ = ret; _ASSERTE(sectCur <= sectEnd); *section = ret; return(S_OK); }
void paintEvent(QPaintEvent* event) { painter.begin(this); painter.setFont(font); painter.setBrush(altBrush); painter.setPen(fontPen); fillBackground = false; char formatedVar[257]; char formatedValue[257]; paintRect = painter.window(); defaultLeft = headerView->sectionViewportPosition(0) + textOffset; paintRectField0 = QRect(defaultLeft, 0, headerView->sectionSize(0) - textOffset * 2, lineSpacing); paintRectField1 = QRect(headerView->sectionViewportPosition(1) + textOffset, 0, headerView->sectionSize(1) - textOffset * 2, lineSpacing); TeamComm3DCtrl::TeamListener& teamListener = TeamComm3DCtrl::controller->teamListener[view.listenerIndex]; unsigned int now = TeamComm3DCtrl::controller->now; float totalTraffic = 0; std::map<unsigned int, std::pair<unsigned int, TeamComm3DCtrl::RobotData>> sortedRobotData; //map<robot id, pair<ip address, robotData>> for(std::map<unsigned int, TeamComm3DCtrl::RobotData>::iterator iter = teamListener.robotData.begin(), end = teamListener.robotData.end(); iter != end; ++iter) { TeamComm3DCtrl::RobotData& robotData = iter->second; sortedRobotData[robotData.robotNumber] = std::make_pair(iter->first, robotData); } for(const auto& iter : sortedRobotData) { const TeamComm3DCtrl::RobotData& robotData = iter.second.second; unsigned int ipAddress = iter.second.first; bool bold = robotData.puppetData && robotData.puppetData->selected; indent(0); if(robotData.robotNumber == 0) sprintf(formatedVar, "Listener"); else sprintf(formatedVar, "Robot %d", robotData.robotNumber); if(!robotData.robotHealth.robotName.empty()) sprintf(formatedValue, "%u.%u.%u.%u (%s)", (ipAddress >> 24) & 0xff, (ipAddress >> 16) & 0xff, (ipAddress >> 8) & 0xff, ipAddress & 0xff, robotData.robotHealth.robotName.c_str()); else sprintf(formatedValue, "%u.%u.%u.%u", (ipAddress >> 24) & 0xff, (ipAddress >> 16) & 0xff, (ipAddress >> 8) & 0xff, ipAddress & 0xff); print(formatedVar, formatedValue, 1.f, bold); indent(1); sprintf(formatedValue, "%u ms, %u ms", robotData.ping, now - robotData.timeStamp); float expectedPacketDelay = robotData.robotNumber != 0 ? 100.f : 2000.f; print("Ping, Packet Last Received", formatedValue, std::min(computeRegularity(robotData.ping, 100.f, 1000.f), computeRegularity(now - robotData.timeStamp, expectedPacketDelay + 50.f, expectedPacketDelay + 100.f))); //sprintf(formatedValue, "%d ms", int(robotData.lastPacketLatency)); //print("Packet Latency", formatedValue); unsigned int oldestPacketTimeStamp = robotData.packetTimeStamps.getEntry(robotData.packetTimeStamps.getNumberOfEntries() - 1); float traffic = now != oldestPacketTimeStamp ? float(robotData.packetSizes.getSum() * 1000) / float(now - oldestPacketTimeStamp) : 0; totalTraffic += traffic; float averagePackageSize = float(robotData.packetSizes.getSum()) / float(robotData.packetSizes.getNumberOfEntries()) - 28.f; float frequency = robotData.packetTimeStamps.getNumberOfEntries() * 1000.f / float(now - oldestPacketTimeStamp); sprintf(formatedValue, "%.0f bytes/s, 28 + %.1f bytes, %.1f/s", traffic, averagePackageSize, frequency); print("Packets: Traffic, Average Size, Frequency", formatedValue, std::min(std::min(computeRegularity(traffic, 5000.f, 10000.f), computeRegularity(averagePackageSize, 500.f, 1000.f)), computeRegularity(frequency, 5.f, 8.f))); //sprintf(formatedValue, "", averagePackageSize); //print("Average Packet Size", formatedValue, computeRegularity(averagePackageSize, 500.f, 1000.f)); //sprintf(formatedValue, "%u ms", now - robotData.timeStamp); //float expectedPacketDelay = robotData.robotNumber != 0 ? 100.f : 2000.f; //print("Packet Last Received", formatedValue, computeRegularity(now - robotData.timeStamp, expectedPacketDelay + 50.f, expectedPacketDelay + 100.f)); newBlock(); if(robotData.robotNumber != 0) { if(!robotData.robotHealth.robotName.empty()) { char hash[sizeof(robotData.robotHealth.hash) + 1]; strncpy(hash, robotData.robotHealth.hash, sizeof(robotData.robotHealth.hash)); hash[sizeof(robotData.robotHealth.hash)] = 0; char location[sizeof(robotData.robotHealth.location) + 1]; strncpy(location, robotData.robotHealth.location, sizeof(robotData.robotHealth.location)); location[sizeof(robotData.robotHealth.location)] = 0; sprintf(formatedValue, "%s (%s), %s, %s", hash, robotData.robotHealth.clean ? "clean" : "dirty", RobotHealth::getName(robotData.robotHealth.configuration), location); print("Revision, Config, Location", formatedValue, 1.f); newBlock(); float loadAverage1 = float(robotData.robotHealth.load[0]) / 10.f; sprintf(formatedValue, "%.1f %.1f %.1f, %hhu%%", loadAverage1, float(robotData.robotHealth.load[1]) / 10.f, float(robotData.robotHealth.load[2]) / 10.f, robotData.robotHealth.memoryUsage); print("Load Average, Memory Usage", formatedValue, std::min(computeRegularity(loadAverage1, 1.f, 1.1f), computeRegularity(robotData.robotHealth.memoryUsage, 50.f, 90.f))); newBlock(); sprintf(formatedValue, "%.1f fps, %.1f fps", robotData.robotHealth.cognitionFrameRate, robotData.robotHealth.motionFrameRate); print("Cognition, Motion Rate", formatedValue, std::min(computeRegularity(robotData.robotHealth.cognitionFrameRate, 29.f, 28.f), computeRegularity(robotData.robotHealth.motionFrameRate, 99.f, 98.f))); newBlock(); sprintf(formatedValue, "%hhu%%, %hhu°C", robotData.robotHealth.batteryLevel, robotData.robotHealth.maxJointTemperature); print((std::string("Battery, Temperature ") + JointData::getName(robotData.robotHealth.jointWithMaxTemperature)).c_str(), formatedValue, std::min(computeRegularity(robotData.robotHealth.batteryLevel, 30.f, 10.f), computeRegularity(robotData.robotHealth.maxJointTemperature, 60.f, 80.f))); newBlock(); if(robotData.robotHealthTimeStamps.getNumberOfEntries() > 0) { unsigned int oldestRobotHealthTimeStamp = robotData.robotHealthTimeStamps.getEntry(robotData.robotHealthTimeStamps.getNumberOfEntries() - 1); unsigned int newestRobotHealthTimeStamp = robotData.robotHealthTimeStamps.getEntry(0); unsigned int oldestBallPerceptCount = robotData.ballPercepts.getEntry(robotData.ballPercepts.getNumberOfEntries() - 1); unsigned int oldestLinePerceptCount = robotData.linePercepts.getEntry(robotData.linePercepts.getNumberOfEntries() - 1); unsigned int oldestGoalPerceptCount = robotData.goalPercepts.getEntry(robotData.goalPercepts.getNumberOfEntries() - 1); sprintf(formatedValue, "%.1f, %.1f, %.1f", float(robotData.robotHealth.ballPercepts - oldestBallPerceptCount) / (float(newestRobotHealthTimeStamp - oldestRobotHealthTimeStamp) * 0.001f / 60.f), float(robotData.robotHealth.goalPercepts - oldestGoalPerceptCount) / (float(newestRobotHealthTimeStamp - oldestRobotHealthTimeStamp) * 0.001f / 60.f), float(robotData.robotHealth.linePercepts - oldestLinePerceptCount) / (float(newestRobotHealthTimeStamp - oldestRobotHealthTimeStamp) * 0.001f / 60.f)); print("Ball-, Goal-, LinePercepts / min", formatedValue, 1.f); newBlock(); } } int ballLastSeen = robotData.ballModel.timeWhenLastSeen ? int(now - robotData.ballModel.timeWhenLastSeen) : 0; if(ballLastSeen) sprintf(formatedValue, "%d ms, %u%%", ballLastSeen, robotData.ballModel.seenPercentage); else sprintf(formatedValue, "never"); print("Ball Last Seen", formatedValue, computeRegularity(ballLastSeen, 10000.f, 12000.f)); //sprintf(formatedValue, robotData.goalPercept.timeWhenOwnGoalLastSeen || robotData.goalPercept.timeWhenOppGoalLastSeen ? "%d ms" : "never", std::min(int(now - robotData.goalPercept.timeWhenOwnGoalLastSeen), int(now - robotData.goalPercept.timeWhenOppGoalLastSeen))); //print("Goal Last Seen", formatedValue); newBlock(); if(robotData.robotPose.deviation == RobotPose::unknownDeviation) sprintf(formatedValue, "unknown"); else sprintf(formatedValue, "%.1f mm", robotData.robotPose.deviation); print("Pose deviation", formatedValue, computeRegularity(robotData.robotPose.deviation, 100.f, RobotPose::unknownDeviation)); newBlock(); sprintf(formatedValue, "%s%s", Role::getName(robotData.behaviorStatus.role), robotData.isPenalized ? " (Penalized)" : ""); print("Behavior Role, Activity", formatedValue, 1.f); newBlock(); } newSection(); }
//****************************************************************************** bool CIniFile::Load( //Loads the INI file // //Params: const WCHAR *wszSetFilename) //(in) { char buffer[MAX_PROFILE_STRING*2+2]; wstrFilename = wszSetFilename; this->bLoaded = true; this->bDirty = false; FILE* pFile = CFiles::Open(wstrFilename.c_str(), "r"); if (NULL == pFile) return false; string curSection; while (true) { fgets(buffer, (MAX_PROFILE_STRING+1)*2+1, pFile); if (feof(pFile)) break; if (buffer[0] == '[') { string sectionName(&buffer[1]); unsigned int end = sectionName.find_first_of(']'); if (end != string::npos) { sectionName.erase(end); curSection = sectionName; } else { // Can't find the closing ] in a section name return false; } } else { string line(buffer); bool bIsWhitespace = true; for (string::iterator c = line.begin(); c != line.end(); ++c) { if (!isspace(*c)) { bIsWhitespace = false; break; } } if (bIsWhitespace) continue; // It's a key/value pair, not a section name unsigned int equalsPos = line.find_first_of('='); if (equalsPos == string::npos) { // No = in the line return false; } else { string key = line.substr(0, equalsPos); string value = line.substr(equalsPos+1); string::iterator last = value.end(); last--; value.erase(last); // Now add the pair to the correct section. // See if the section already exists. map<string, CIniSection>::iterator sec; sec = sections.find(curSection); if (sec != sections.end()) { // Section exists sec->second.WriteString(key.c_str(), value.c_str()); } else { // Section doesn't exist - make a new one CIniSection newSection(curSection.c_str()); newSection.WriteString(key.c_str(), value.c_str()); sections.insert(pair<string,CIniSection>(curSection, newSection)); // [curSection] = newSection; } } } } return true; }
/*! Returns a pointer to the current scene node, within the current section. If there is no current section then newSection() will be called to create one. \sa newNode(), newSection() */ QGLSceneNode *QGLBuilder::currentNode() { if (dptr->currentSection == 0) newSection(); // calls newNode() return dptr->currentNode; }
int ElfWriter::dwarfCallback(char *name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info) { if (!strncmp(name, ".rel", 4)) return 0; return newSection(name, size, type, flags); }
void paintEvent(QPaintEvent *event) { static const ViewInfo viewInfoNao[] = { {SensorData::gyroX, angularSpeed, false}, {SensorData::gyroY, angularSpeed, true}, {SensorData::accX, acceleration, false}, {SensorData::accY, acceleration, false}, {SensorData::accZ, acceleration, true}, {SensorData::batteryLevel, ratio, true}, {SensorData::fsrLFL, pressure, false}, {SensorData::fsrLFR, pressure, false}, {SensorData::fsrLBL, pressure, false}, {SensorData::fsrLBR, pressure, false}, {SensorData::fsrRFL, pressure, false}, {SensorData::fsrRFR, pressure, false}, {SensorData::fsrRBL, pressure, false}, {SensorData::fsrRBR, pressure, true}, {SensorData::us, usLDistance, false}, {SensorData::us, usLtRDistance, false}, {SensorData::us, usRtLDistance, false}, {SensorData::us, usRDistance, true}, {SensorData::angleX, angle2, false}, {SensorData::angleY, angle2, false}, {SensorData::numOfSensors, end, true} }; painter.begin(this); painter.setFont(font); painter.setBrush(altBrush); painter.setPen(fontPen); fillBackground = false; paintRect = painter.window(); paintRectField0 = QRect(headerView->sectionViewportPosition(0) + textOffset, 0, headerView->sectionSize(0) - textOffset * 2, lineSpacing); paintRectField1 = QRect(headerView->sectionViewportPosition(1) + textOffset, 0, headerView->sectionSize(1) - textOffset * 2, lineSpacing); paintRectField2 = QRect(headerView->sectionViewportPosition(2) + textOffset, 0, headerView->sectionSize(2) - textOffset * 2, lineSpacing); { char value[32]; char filtered[32]; SYNC_WITH(console); const SensorData& sensorData(sensorView.sensorData); const SensorData& filteredSensorData(sensorView.filteredSensorData); if(sensorData.data[SensorData::us] != SensorData::off) usDistances[0][sensorData.usSensorType] = sensorData.data[SensorData::us]; if(filteredSensorData.data[SensorData::us] != SensorData::off) usDistances[1][sensorData.usSensorType] = filteredSensorData.data[SensorData::us]; for(int i = 0;; ++i) { const ViewInfo &vi = viewInfoNao[i]; if(vi.type == SensorWidget::end) break; formatSensor(vi.type, sensorData.data[vi.sensor], false, value); formatSensor(vi.type, filteredSensorData.data[vi.sensor], true, filtered); print(getSensorName(vi), value, filtered); newBlock(); if(vi.endOfSection) newSection(); } } painter.end(); setMinimumHeight(paintRectField1.top()); }