QString EQPacketFormat::headerFlags(const QString& prefix, bool brief) const { QString tmp; if (m_isValid) { if (brief) tmp = prefix + ": "; else tmp = prefix + " Hdr (" + QString::number(flagsHi(), 16) + ", " + QString::number(flagsLo(), 16) + "): "; tmp += m_packet->headerFlags("", true); if (!brief) { if (isARQ()) tmp += QString("arq: ") + QString::number(arq(), 16) + ", "; if (isFragment()) tmp += QString("FragSeq: ") + QString::number(fragSeq(), 16) + ", FragCur: " + QString::number(fragCur(), 16) + ", FragTot: " + QString::number(fragTot(), 16) + ", "; tmp += QString("Opcode: ") + QString::number(eqntohuint16(payload()), 16); } } else tmp = prefix + ": INVALID CRC32! Possible non-EQ packet?!"; return tmp; }
void Indice::ReadColection(string file_name) { vector<string> termos, termos_clean; string line, buffer; ifstream arq(file_name.c_str()); if (!arq.is_open()) { cout << "erro ao abrir arquivo " << file_name << endl; //return NULL; } //Faz a leitura de cada linha do arquivo while (getline(arq, line)) { //cout << "abriuuuuu o/" << endl; if ((line.empty()) && (termos.size() > 0)) { termos_clean = CleanDocument(termos); indexaDocumento(termos_clean); termos.clear(); termos_clean.clear(); } //checa se a linha deve ser lida if (CanReadLine(line) || flag_linha) { buffer = GetLineContent(line); //cout << buffer << endl; istringstream iss(buffer); copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter<vector<string> >(termos)); } } map<string, Vocabulo>::iterator it_hash; map<int, CelulaLista>::iterator it_cel; //computa o idf de cada lista invertida e o peso de cada termo na lista invertida for (it_hash = indice_invertido.begin(); it_hash != indice_invertido.end(); ++it_hash){ (*it_hash).second.idf = log2(NUM_TOTAL_COLECAO/(*it_hash).second.total_docs); for (it_cel = it_hash->second.lista_invertida.begin(); it_cel != it_hash->second.lista_invertida.end(); ++it_cel){ (*it_cel).second.peso = (*it_hash).second.idf * (*it_cel).second.tf; } } }
//---------------------------------------------------------------------- // EQPacketFormatRaw class methods QString EQPacketFormatRaw::headerFlags(const QString& prefix, bool brief) const { QString tmp; if (!prefix.isEmpty()) { if (brief) tmp = prefix + ": "; else tmp = prefix + "[Hdr (" + QString::number(flagsHi(), 16) + ", " + QString::number(flagsLo(), 16) + "): "; } else if (!brief) tmp = "[Hdr (" + QString::number(flagsHi(), 16) + ", " + QString::number(flagsLo(), 16) + "): "; if (isARQ()) tmp += "ARQ, "; if (isClosingLo()) tmp += "closingLo, "; if (isFragment()) tmp += "Fragment, "; if (isASQ()) tmp += "ASQ, "; if (isSEQStart()) tmp += "SEQStart, "; if (isClosingHi()) tmp += "closingHi, "; if (isSEQEnd()) tmp += "SEQEnd, "; if (isARSP()) tmp += "ARSP, "; if (isNAK()) tmp += "NAK, "; if (isSpecARQ()) tmp += "SpecARQ, "; if (m_flagsHi.m_unknown1) tmp += "HiUnknown1, "; if (skip() != 0) tmp += QString("Skip: ") + QString::number(skip(), 16) + ", "; tmp += QString("seq: ") + QString::number(seq(), 16); tmp += "] "; if (!brief) { if (isARQ()) tmp += QString("[ARQ: ") + QString::number(arq(), 16) + "] "; if (isFragment()) { tmp += QString("[FragSeq: ") + QString::number(fragSeq(), 16) + ", FragCur: " + QString::number(fragCur(), 16) + ", FragTot: " + QString::number(fragTot(), 16) + "] "; } } return tmp; }
void Spice::readFile(string nome, Circuit& netlist, bool reading_cadence) { ifstream arq (nome.c_str()); string linha; if (!arq.is_open()) throw AstranError("Could not open Spice file: " + nome ); vector<string> palavras; string palavra; CellNetlst subcktCell,topCell; CellNetlst *currentCell=&topCell; topCell.setName(upcase(removeExt(getFileName(nome)))); string cellName; unsigned int lineNr=0; while (!arq.eof()){ lineNr++; getline(arq,linha); palavras.clear(); istrstream clin(linha.c_str()); while (clin>>palavra) palavras.push_back(upcase(palavra)); if (palavras.size() == 0 || palavras[0] == ".GLOBAL") continue; if (palavras[0] == "*INTERFACE"){ if(palavras.size() == 4 || palavras.size() == 6){ IOType type; direction orient; switch(palavras[2][palavras[2].size()-1]){ case 'N': orient=N; break; case 'S': orient=S; break; case 'E': orient=E; break; case 'W': orient=W; break; default: throw AstranError("Line" + intToStr(lineNr) + ": Interface orientation unknown."); } switch(palavras[3][0]){ case 'I': type=IOTYPE_INPUT; break; case 'O': type=IOTYPE_OUTPUT; break; default: throw AstranError("Line" + intToStr(lineNr) + ": Interface type unknown. Use INPUT or OUTPUT"); } topCell.insertInOut(palavras[1]); netlist.insertInterface(palavras[1], orient, type, 0, 0); } else throw AstranError("Line" + intToStr(lineNr) + ": Number of parameters for *interface is not correct"); continue; } if (reading_cadence && palavras[0] == "*" && palavras.size() == 5 && palavras[1] == "SUBCIRCUIT"){ currentCell->clear(); topCell.setName(palavras[4].substr(0,palavras[4].size()-1)); } if (palavras[0][0] == '*' || palavras[0][0] == 'C' || palavras[0][0] == '+' || palavras[0][0] == 'D' || (palavras[0][0]=='X' && reading_cadence)) // corrigir aqui para ler o '+' e ignorar os parâmetros desnecessários continue; if (palavras[0] == ".MODEL" || palavras[0] == ".END") break; if (palavras[0] == ".SUBCKT" && currentCell==&topCell && !reading_cadence){ // It's a new cell definition. . . subcktCell.clear(); currentCell=&subcktCell; cellName=palavras[1]; // compare if subcircuit name is the same as the top cell name if(cellName == topCell.getName()){ string topname = topCell.getName() + "-TOP"; topCell.setName(topname); } for (int p=2; p<palavras.size(); p++) currentCell->insertInOut(palavras[p]); } else if (palavras[0] == string(".INCLUDE")){ readFile(getPath(nome)+palavras[1],netlist,reading_cadence); // throw AstranError("Could not read included file in line: " + intToStr(lineNr)); } // declaring transistor in subcircuit read from Cadence else if (palavras[0][0] == 'M' && palavras.size()>=5){ // insert in and out pins if (reading_cadence){ for (int p=1; p<5; ++p){ if (!isNumber(palavras[p]) || palavras[p] == "0") currentCell->insertInOut(palavras[p]); } } // identify transistor type transType type; if(palavras[5]=="PMOS" || palavras[5]=="CMOSP" || palavras[5]=="MODP" || palavras[5]=="PMOS_VTL") type=PMOS; else if(palavras[5]=="NMOS" || palavras[5]=="CMOSN" || palavras[5]=="MODN" || palavras[5]=="NMOS_VTL") type=NMOS; else throw AstranError("Line" + intToStr(lineNr) + ": Parameter " + palavras[5] + " is incorrect. Use NMOS or PMOS"); // get parameters' values float length=0, width=0; for (int p=6; p<palavras.size(); p++){ int pos=palavras[p].find("="); string parm=palavras[p].substr(0,pos++); float tam=atof((palavras[p].substr(pos)).c_str())*getFactor(palavras[p][palavras[p].size()-1])*getFactor(palavras[p][palavras[p].size()-2]); if(parm=="L") length=tam; else if(parm=="W") width=tam; else if(parm!="AD" && parm!="PD" && parm!="AS" && parm!="PS" && parm!="NRD" && parm!="NRS" && parm!="M") throw AstranError("Line" + intToStr(lineNr) + ": Parameter " + parm + " not supported"); } // insert transistor in cell currentCell->insertTrans(palavras[0], palavras[1], palavras[2], palavras[3], type, length, width); } else if (palavras[0][0] == 'X' && !reading_cadence){ string instName=palavras[0]; vector<string> net_ids; int p; for (p=1; p<palavras.size()-1; p++) net_ids.push_back(palavras[p]); currentCell->insertInstance(instName, palavras[p], net_ids); } else if (currentCell==&subcktCell && palavras[0] == ".ENDS"){ currentCell->setName(cellName); netlist.insertCell(*currentCell); currentCell=&topCell; } else throw AstranError("Line" + intToStr(lineNr)); } if(topCell.getNets().size() != 0) netlist.insertCell(topCell); }