Ejemplo n.º 1
0
unsigned char *  decodeThreeQuarterRate(bool bits[264]){

	bool *infoBits;  //196 info bits
	char *dibits; //98 info dibits
	char *constellationPoints; //49 constallation points
	int *tribits; //49 tribits
	bool *decodedBinary;  //144 bits
	static unsigned char bb[18];
	int x=0,a,i;

	infoBits = extractInfo(bits);
	dibits = extractDibits(infoBits);
	constellationPoints = constellationOut(dibits);
	tribits = tribitExtract(constellationPoints);
	decodedBinary = binaryConvert(tribits);

	for (a=0;a<144;a=a+8){
		bb[x] = 0;
		for (i=0;i<8;i++){
			if(decodedBinary[a+i] == true) bb[x] = bb[x] + (char)(128 / pow(2,i));
		}
		printf("(%02X)%c",bb[x],bb[x]);
		x++;
	}
	printf("\n");
	return bb;
}
Ejemplo n.º 2
0
DraftTube::DraftTube(coInteractor *inter)
{
   int i;
   vrdt=this;

   fprintf(stderr,"DraftTube::DraftTube (Konstruktor)\n");
   inter->incRefCount();
   feedback=inter;

   // get the COVISE set object
   setObj=(coDistributedObject*)inter->getObject();

   // get the number of cross sections
   fprintf(stderr,"\tDraftTube::DraftTube (before call of extractInfo())\n");
   extractInfo(inter);
   fprintf(stderr,"\tDraftTube::DraftTube (after call of extractInfo())\n");

   cover->addToggleButton("RecomputeCSGeom", NULL, false, (void*)recomputeCallback, this);

   // get the state of the create grid button
   inter->getBooleanParam(0, createGridState);
   cover->addToggleButton("CreateDraftubeGrid", NULL, false, (void*)gridCallback, this);

   dt = AllocTube();

   csList = new CrossSection*[numCS];
   for (i=0; i< numCS; i++)
      csList[i] = NULL;
}
Ejemplo n.º 3
0
// Returns vector with all users information.
std::vector<User> RadioStation::loadAllUsersToVector() {

	std::vector <User> allUsersVec;

	std::string filename = "users.csv";
	ifstream file(filename);

	std::string tempStr;

	// Temporary user information.
	unsigned int newID, newAge, newHits;
	std::string newName, newGender, newPass;
	bool newSpecial;

	if(file.is_open()) {
		getline(file, tempStr); // Get first line (fields titles).

		while(getline(file, tempStr)) {
			// Gets user information from file.
			newID = convertStrInt(extractInfo(tempStr));
			newName = extractInfo(tempStr);
			newAge = convertStrInt(extractInfo(tempStr));
			newGender = extractInfo(tempStr);
			newSpecial = convertToBool(convertStrInt(extractInfo(tempStr)));
			newPass = extractInfo(tempStr);
			newHits = convertStrInt(extractInfo(tempStr));
			// Stores user information to vector.
			allUsersVec.push_back(User(newID, newName, newAge, newGender, newSpecial, newPass, newHits, true));
		}

		file.close();
	}

	return allUsersVec;
}
Ejemplo n.º 4
0
bool CvFuzzyMeanShiftTracker::SearchWindow::meanShift(IplImage* maskImage, IplImage* depthMap, int maxIteration, bool initDepth) {
    numShifts = 0;
    do {
        extractInfo(maskImage, depthMap, initDepth);
        if (! shift()) {
            return true;
        }
    } while (++numShifts < maxIteration);

    return false;
};
Ejemplo n.º 5
0
void
DraftTube::update(coInteractor *inter)
{
   fprintf(stderr,"DraftTube::update numCS\n");
   int createGridState;

   extractInfo(inter);
   setObj=(coDistributedObject*)inter->getObject();

   inter->getBooleanParam(0, createGridState);
   cover->setButtonState("CreateDraftubeGrid", false);
   cover->setButtonState("RecomputeCSGeom", false);

}
Ejemplo n.º 6
0
//Constructor
readAttributes::readAttributes(string inputFileName){
	
	countNAttributesFieldsInputFile(inputFileName);

	fields = new string[nFields];
	attributes = new string*[nAttributes];
	for (int iAttributes = 0; iAttributes < nAttributes; iAttributes++){
		attributes[iAttributes] = new string[nFields];
	}

	extractInfo(inputFileName, attributes, fields);
	string marketField = "market";
	findIndexMarketField(marketField);
}
Ejemplo n.º 7
0
    Value DocumentSourceCursor::serialize(bool explain) const {
        // we never parse a documentSourceCursor, so we only serialize for explain
        if (!explain)
            return Value();

        Status explainStatus(ErrorCodes::InternalError, "");
        scoped_ptr<TypeExplain> plan;
        {
            Lock::DBRead lk(_ns);
            Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);

            ClientCursorPin pin(_cursorId);
            ClientCursor* cursor = pin.c();

            uassert(17135, "Cursor deleted. Was the collection or database dropped?",
                    cursor);

            Runner* runner = cursor->getRunner();
            runner->restoreState();

            TypeExplain* explainRaw;
            explainStatus = runner->getExplainPlan(&explainRaw);
            if (explainStatus.isOK())
                plan.reset(explainRaw);

            runner->saveState();
        }

        MutableDocument out;
        out["query"] = Value(_query);

        if (!_sort.isEmpty())
            out["sort"] = Value(_sort);

        if (_limit)
            out["limit"] = Value(_limit->getLimit());

        if (!_projection.isEmpty())
            out["fields"] = Value(_projection);

        if (explainStatus.isOK()) {
            out["plan"] = Value(extractInfo(plan));
        } else {
            out["planError"] = Value(explainStatus.toString());
        }


        return out.freezeToValue();
    }
Ejemplo n.º 8
0
// Loads playlist of the day from csv file.
void RadioStation::loadPlaylistOfTheDayFromFile() {

	std::string newTitle, newAuthor, newAlbum, newGenre; 
	unsigned int newID, newYear, newLikes, newDislikes;
	bool newSpecial;

	std::string filename = "playlistOfTheDay.csv";
	std::string line;
	ifstream file(filename);

	if(file.is_open()) {

		playlistOfTheDay.clear();

		getline(file, line); // Gets fields titles.

		while(getline(file, line)) {

			newID = convertStrInt(extractInfo(line));
			newTitle = extractInfo(line);
			newAuthor = extractInfo(line);
			newAlbum = extractInfo(line);
			newGenre = extractInfo(line);
			newYear = convertStrInt(extractInfo(line));
			newLikes = convertStrInt(extractInfo(line));
			newDislikes = convertStrInt(extractInfo(line));
			newSpecial = convertToBool(convertStrInt(extractInfo(line)));

			playlistOfTheDay.push_back(MusicTrack(newID, newTitle, newAuthor, newAlbum, newGenre, newYear, 
				newLikes, newDislikes, newSpecial));
		}
		file.close();
	} else {
		return;
	}
	
}
Ejemplo n.º 9
0
    Value DocumentSourceCursor::serialize(bool explain) const {
        // we never parse a documentSourceCursor, so we only serialize for explain
        if (!explain)
            return Value();

        Status explainStatus(ErrorCodes::InternalError, "");
        scoped_ptr<TypeExplain> plan;
        {
            Lock::DBRead lk(pExpCtx->opCtx->lockState(), _ns);
            Client::Context ctx(pExpCtx->opCtx, _ns, /*doVersion=*/ false);

            massert(17392, "No _runner. Were we disposed before explained?",
                    _runner);

            _runner->restoreState(pExpCtx->opCtx);

            TypeExplain* explainRaw;
            explainStatus = _runner->getInfo(&explainRaw, NULL);
            if (explainStatus.isOK())
                plan.reset(explainRaw);

            _runner->saveState();
        }

        MutableDocument out;
        out["query"] = Value(_query);

        if (!_sort.isEmpty())
            out["sort"] = Value(_sort);

        if (_limit)
            out["limit"] = Value(_limit->getLimit());

        if (!_projection.isEmpty())
            out["fields"] = Value(_projection);

        if (explainStatus.isOK()) {
            out["plan"] = Value(extractInfo(plan));
        } else {
            out["planError"] = Value(explainStatus.toString());
        }

        return Value(DOC(getSourceName() << out.freezeToValue()));
    }
Ejemplo n.º 10
0
  /*
   * @param t             Time                    (input) 
   * @param delta_t       The current value of the time step (input)
   * @param y             Solution vector (input, do not modify)
   * @param ydot          Rate of change of solution vector. (input, do not modify)
   * @param resid         Value of the residual that is computed (output)
   * @param evalType      Type of the residual being computed (defaults to Base_ResidEval)
   * @param id_x          Index of the variable that is being numerically differenced to find
   *                      the jacobian (defaults to -1, which indicates that no variable is being
   *                      differenced or that the residual doesn't take this issue into account)
   * @param delta_x       Value of the delta used in the numerical differencing
   */
  int vcs_PhaseStabilitySolve::optResid(const doublereal tdummy, const doublereal delta_t_dummy,
					 const doublereal * const y,
					 const doublereal * const ySolnDot,
					 doublereal * const resid,
					 const ResidEval_Type_Enum evalType,
					 const int id_x, 
					 const doublereal delta_x)
  {

  
    if (enableExtraPrinting_ && detailedResidPrintFlag_ > 1) {
      printf("\t\t================================================================================================="
	     "==============================\n");
      printf("\t\t  EXTRA PRINTING FROM NONLINEAR RESIDUAL: ");
      if (evalType == Base_ResidEval || evalType == Base_LaggedSolutionComponents) {
	printf(" BASE RESIDUAL");
      } else if (evalType == JacBase_ResidEval) {
	printf(" BASE JAC RESIDUAL");
      } else  if  (evalType == JacDelta_ResidEval) {
	printf(" DELTA JAC RESIDUAL");
	printf(" var = %d delta_x = %12.4e Y_del = %12.4e Y_base = %12.4e", id_x, delta_x, y[id_x], y[id_x] - delta_x);
      } else  if  (evalType == Base_ShowSolution) {
	printf(" BASE RESIDUAL - SHOW SOLUTION");
      }
      printf("\n");
    } 
    /*
     *  Current the solution vector are the nsp -1 mole fractions in multiple phases
     */
    unpackNonlinSolnVector(y);


    extractInfo();


    if (enableExtraPrinting_ && detailedResidPrintFlag_ > 1) {
      printf("\t\t=============================================================="
	     "=================================================================\n");
    }

    return 1;
  }
Ejemplo n.º 11
0
// Checks for users that have a hit on their playlist.
void RadioStation::checkForHitsOnAllUsers() {
	User userObj;
	// Vector that will hold all the user. Backup purposes.
	vector<User> allUsersVec;

	string line;

	unsigned int newID, newAge, newHits;
	string newName, newGender, newPass;
	bool newSpecial;
	
	string filename = "users.csv";
	ifstream file(filename);

	if(file.is_open()) {
		getline(file, line); // Gets fields titles.

		while(getline(file, line)) {

			newID = convertStrInt(extractInfo(line));
			newName = extractInfo(line);
			newAge = convertStrInt(extractInfo(line));
			newGender = extractInfo(line);
			newSpecial = convertToBool(convertStrInt(extractInfo(line)));
			newPass = extractInfo(line);
			newHits = convertStrInt(extractInfo(line));

			allUsersVec.push_back(User(newID, newName, newAge, newGender, newSpecial, newPass, newHits, true));
		}
		file.close();
	} else {
		return;
	}

	for(vector<User>::iterator vecPtr = allUsersVec.begin(); vecPtr != allUsersVec.end(); vecPtr++) {
		vecPtr->checkForHits(playlistOfTheDay);
	}
}
Ejemplo n.º 12
0
void InfoExtractor::reply()
{
    m_replyTimer->stop();

    //Vérification des erreurs
    if (QNetworkReply::NetworkError err = m_reply->error())
    {
        if (err != QNetworkReply::OperationCanceledError)
        {
            sLog->out("InfoExtractor::reply() erreur: %1", m_reply->errorString());
        }
        emit infoUnavailable(m_url, NETWORK_ERROR);
        m_reply->close();
        m_reply->deleteLater();
        m_reply = NULL;
        m_queue.enqueue(m_url);
        QTimer::singleShot(1 * IN_MILLISECONDS, this, SLOT(extractInfo()));
        return;
    }

    //Extraction des données de la réponse
    QByteArray dataHTML = m_reply->readAll();
    QString data = QTextDocumentFragment::fromHtml(dataHTML).toPlainText(); //Interprétation HTML
    m_reply->close();
    m_reply->deleteLater();
    m_reply = NULL;

    if (data.isEmpty())
    {
        sLog->out("InfoExtractor::reply() réponse de taille nulle");
        queue(m_url);
        return;
    }

    if (data.contains(FILE_DELETED_HINT))
    {
        emit infoUnavailable(m_url, FILE_DELETED);
        if (!m_queue.isEmpty())
            extractInfo();
        return;
    }

    if (dataHTML.contains(PREMIUM_ACCOUNT_NEEDED))
    {
        emit infoUnavailable(m_url, PREMIUM_NEEDED);
        if (!m_queue.isEmpty())
            extractInfo();
        return;
    }

    //Extraction des données
    QString fileName, fileDescription, fileSize;
    QStringList splitData = data.split("\n", QString::SkipEmptyParts);
    if (splitData.size() > 4)
    {
        fileName = splitData[2].remove(-1, 1);
        fileSize = splitData[3].remove(-1, 1);
        fileDescription = splitData[4].remove("File description: ").remove(-1, 1);
    }
    else
    {
        sLog->out("InfoExtractor::reply() Données incomplètes. Données: %1", data);
        emit infoUnavailable(m_url, INVALID_DATA);
        queue(m_url);
        return;
    }

    if (fileName.isEmpty())
    {
        sLog->out("InfoExtractor::reply() Lien non trouvé. Données: %1", data);
        emit infoUnavailable(m_url, FILE_DELETED);
        if (!m_queue.isEmpty())
            extractInfo();
        return;
    }

    if (fileDescription == FILE_PASSWORD_PROTECTED_HINT)
    {
        sLog->out("InfoExtractor::reply() Fichier protégé par mot de passe");
        emit infoUnavailable(m_url, FILE_PASSWORD_PROTECTED);
        if (!m_queue.isEmpty())
            extractInfo();
        return;
    }

    emit infoAvailable(m_url, fileName, fileDescription, fileSize);
    if (!m_queue.isEmpty())
        extractInfo();
}
Ejemplo n.º 13
0
void InfoExtractor::queue(const QString &url)
{
    m_queue.enqueue(url);
    if (!m_reply || !m_reply->isOpen())
        extractInfo();
}
Ejemplo n.º 14
0
// Reset (in the ratings file) the rating atributed to a certain music by the user
void RadioStation::resetRatingsFromMusic(unsigned const int musicID) {
	
	std::string filename;
	std::string line;

	for(unsigned int tempID = 0; tempID < numberOfUsers; tempID++)
	{
		filename = createFilenameWithSequence("ratingsUser", ".csv", 3, tempID);
		unsigned int idCounter = 0;

		std::vector < std::vector <int> > ratingsVec;
		vector<int> row;

		ifstream fileLoad(filename);
		fstream fileSave(filename);

		if(fileLoad.is_open()) {

			getline(fileLoad, line);
			while(getline(fileLoad, line)) {

				ratingsVec.push_back(row);
				ratingsVec[idCounter].push_back(convertStrInt(extractInfo(line)));
				ratingsVec[idCounter].push_back(convertStrInt(extractInfo(line)));

				if(ratingsVec[idCounter][0] == musicID) {
					ratingsVec.erase(ratingsVec.begin()+idCounter);
					idCounter--;
				}

				idCounter++;
			}
			fileLoad.close();
		}
		else 
		{
			return;
		}

		// ============================================================
		// ============== Saves vector to file ========================
		// ============================================================

		// Checks if playlist file already exists. If so, removes it.
		if(fileSave.good()) {
			fileSave.close();
			if(remove(filename.c_str()) != 0)
			{
				cout << cantSaveFileMsg() << endl;
				waitForKey();
			}
		}

		// Creates and opens new playlist file and adds fields.
		fileSave.open(filename, ios::out);
		if(fileSave.is_open())
		{
			if(fileSave.end) {
				fileSave << "MUSIC ID, RATE" << endl;
			}

			// Appends music id to text file.
			for(unsigned int i=0; i < ratingsVec.size(); i++)
			{
				fileSave << ratingsVec[i][0] << "," << ratingsVec[i][1] << endl;
			}

			fileSave.close();
		}
		else
		{
			return;
		}
	}

}
Ejemplo n.º 15
0
struct BPTC1969 decodeBPTC1969(bool bits[264]){

        bool *infoBits; //196 info bits
        bool *deInterleavedBits; //196 bits
        static bool *payloadBits; //96  bits
        int blocksToFollow=0,a;
        unsigned char dpf=0,sap=0,bitPadding=0;
	struct BPTC1969 BPTC1969decode;

        infoBits = extractInfo(bits);
        deInterleavedBits = deInterleave(infoBits);
        payloadBits = extractPayload(deInterleavedBits);

        /*printf("Payload bits\n");
        for(a=0;a<96;a++){
                printf("%i",*(payloadBits+a));
        }
        printf("\n");*/
        if(*(payloadBits+1) == 1){
		BPTC1969decode.responseRequested = true;
		 //syslog(LOG_NOTICE,"response requested"); 
	}
	else{
		BPTC1969decode.responseRequested = false;
		//syslog(LOG_NOTICE,"NO response requested");
	}

        for(a=4;a<8;a++){
                if(*(payloadBits + a) == true) dpf = dpf + (char)(8 / pow(2,a-4));
        }
        //syslog(LOG_NOTICE,"Data Packet Format: ");
	BPTC1969decode.dataPacketFormat = dpf;
        switch (dpf){
                case 0:
                //syslog(LOG_NOTICE,"Unified Data Transport\n");
                break;

                case 1:
                //syslog(LOG_NOTICE,"Response packet\n");
                break;

                case 2:
                //syslog(LOG_NOTICE,"Data packet with unconfirmed delivery\n");
                break;

                case 3:
                //syslog(LOG_NOTICE,"Data packet with confirmed delivery\n");
                break;

                case 13:
                //syslog(LOG_NOTICE,"Short Data: Defined\n");
                break;
                case 14:
                //syslog(LOG_NOTICE,"Short Data: Raw or Status/Precoded\n");
                break;

                case 15:
                //syslog(LOG_NOTICE,"Proprietary Data Packet\n");
                break;

        }

        for(a=8;a<12;a++){
                if(*(payloadBits + a) == true) sap = sap + (char)(8 / pow(2,a-8));
        }
		
	//syslog(LOG_NOTICE,"SAP id: ");
	BPTC1969decode.sapId = sap;
        switch (sap){

                case 0:
                //syslog(LOG_NOTICE,"Unified Data Transport\n");
                break;

                case 2:
                //syslog(LOG_NOTICE,"TCP/IP header compression\n");
                break;

                case 3:
                //syslog(LOG_NOTICE,"UDP/IP header compression\n");
                break;

                case 4:
                //syslog(LOG_NOTICE,"IP based Packet data\n");
                break;

                case 5:
                //syslog(LOG_NOTICE,"Address Resolution Protocol(ARP)\n");
                break;

                case 9:
                //syslog(LOG_NOTICE,"Proprietary Packet data\n");
                break;

                case 10:
                //syslog(LOG_NOTICE,"Short Data\n");
                break;

        }
        if (dpf == 13){
                for(a=12;a<16;a++){//only AB in 2nd octet
                         if(*(payloadBits + a) == true) blocksToFollow = blocksToFollow + (char)(8 / pow(2,a-12));
                }
                BPTC1969decode.appendBlocks = blocksToFollow;
		//syslog(LOG_NOTICE,"Appended blocks : %i\n",blocksToFollow);

                for(a=72;a<80;a++){
                         if(*(payloadBits + a) == true) bitPadding = bitPadding + (char)(128 / pow(2,a-12));
                }
        }

        return BPTC1969decode;
}
Ejemplo n.º 16
0
void Bundle::pathChanged()
{
    //qDebug() << "path changed";
    m_isValid = extractInfo();
}
Ejemplo n.º 17
0
void ICQClient::snac_location(unsigned short type, unsigned short seq)
{
    Contact *contact = NULL;
    ICQUserData *data;
    string screen;
    switch (type){
    case ICQ_SNAXxLOC_RIGHTSxGRANTED:
        log(L_DEBUG, "Location rights granted");
        break;
    case ICQ_SNACxLOC_ERROR:
        break;
    case ICQ_SNACxLOC_LOCATIONxINFO:
        screen = m_socket->readBuffer.unpackScreen();
        if (isOwnData(screen.c_str())){
            data = &this->data.owner;
        }else{
            data = findContact(screen.c_str(), NULL, false, contact);
        }
        if (data){
            string charset = "us-ascii";
            m_socket->readBuffer.incReadPos(4);
            TlvList tlvs(m_socket->readBuffer);
            Tlv *tlvInfo = tlvs(0x02);
            if (tlvInfo){
                QString info = convert(tlvInfo, tlvs, 0x01);
                if (info.left(6).upper() == "<HTML>")
                    info = info.mid(6);
                if (info.right(7).upper() == "</HTML>")
                    info = info.left(info.length() - 7);
                if (set_str(&data->About.ptr, info.utf8())){
                    data->ProfileFetch.bValue = true;
                    if (contact){
                        Event e(EventContactChanged, contact);
                        e.process();
                    }else{
                        Event e(EventClientChanged, this);
                        e.process();
                    }
                }
                break;	/* Because we won't find tlv(0x03) which is
                           "since online" instead of encoding... */                            
            }
            Tlv *tlvAway = tlvs(0x04);
            if (tlvAway){
                QString info = convert(tlvAway, tlvs, 0x03);
                set_str(&data->AutoReply.ptr, info.utf8());
                Event e(EventClientChanged, contact);
                e.process();
            }
        }
        break;
    case ICQ_SNACxLOC_DIRxINFO:
        if (isOwnData(screen.c_str())){
            data = &this->data.owner;
        }else{
            data = findInfoRequest(seq, contact);
        }
        if (data){
            bool bChanged = false;
            unsigned country = 0;
            m_socket->readBuffer.incReadPos(4);
            TlvList tlvs(m_socket->readBuffer);
            bChanged |= extractInfo(tlvs, 0x01, &data->FirstName.ptr);
            bChanged |= extractInfo(tlvs, 0x02, &data->LastName.ptr);
            bChanged |= extractInfo(tlvs, 0x03, &data->MiddleName.ptr);
            bChanged |= extractInfo(tlvs, 0x04, &data->Maiden.ptr);
            bChanged |= extractInfo(tlvs, 0x07, &data->State.ptr);
            bChanged |= extractInfo(tlvs, 0x08, &data->City.ptr);
            bChanged |= extractInfo(tlvs, 0x0C, &data->Nick.ptr);
            bChanged |= extractInfo(tlvs, 0x0D, &data->Zip.ptr);
            bChanged |= extractInfo(tlvs, 0x21, &data->Address.ptr);
            Tlv *tlvCountry = tlvs(0x06);
            if (tlvCountry){
                const char *code = *tlvCountry;
                for (const ext_info *c = getCountryCodes(); c->nCode; c++){
                    QString name(c->szName);
                    if (name.upper() == code){
                        country = c->nCode;
                        break;
                    }
                }
            }
            if (country != data->Country.value){
                data->Country.value = country;
                bChanged = true;
            }
            data->ProfileFetch.bValue = true;
            if (bChanged){
                if (contact){
                    Event e(EventContactChanged, contact);
                    e.process();
                }else{
                    Event e(EventClientChanged, this);
                    e.process();
                }
            }
        }
        break;
    case ICQ_SNACxLOC_RESPONSExSETxINFO:
        break;
    default:
        log(L_WARN, "Unknown location family type %04X", type);
    }
}