コード例 #1
0
/**
 * Resolve the difference between RPMs in the first and second transaction item
 *  and create a ItemPair of Upgrade, Downgrade or reinstall.
 * Method is called when original package is being removed and than installed again.
 * \param previousItemPair original item pair
 * \param mTransItem new transaction item
 */
void
MergedTransaction::resolveRPMDifference(ItemPair &previousItemPair,
                                        TransactionItemBasePtr mTransItem)
{
    auto firstItem = previousItemPair.first->getItem();
    auto secondItem = mTransItem->getItem();

    auto firstRPM = std::dynamic_pointer_cast< RPMItem >(firstItem);
    auto secondRPM = std::dynamic_pointer_cast< RPMItem >(secondItem);

    if (firstRPM->getVersion() == secondRPM->getVersion() &&
        firstRPM->getEpoch() == secondRPM->getEpoch()) {
        // reinstall
        mTransItem->setAction(TransactionItemAction::REINSTALL);
        previousItemPair.first = mTransItem;
        previousItemPair.second = nullptr;
        return;
    } else if ((*firstRPM) < (*secondRPM)) {
        // Upgrade to secondRPM
        previousItemPair.first->setAction(TransactionItemAction::UPGRADED);
        mTransItem->setAction(TransactionItemAction::UPGRADE);
    } else {
        // Downgrade to secondRPM
        previousItemPair.first->setAction(TransactionItemAction::DOWNGRADED);
        mTransItem->setAction(TransactionItemAction::DOWNGRADE);
    }
    previousItemPair.second = mTransItem;
}
コード例 #2
0
				bool ShouldAbort(ContentionManager *enemy) 
				{
					stm::scheduler::BiModalScheduler::instance()->increaseConflictCounter();
					std::cout << "conflict\n";
					BiModalCM* b = dynamic_cast<BiModalCM*>(enemy);

					/*
					 * If two transactions with different epoch ids have a conflict
					 * the transaction with the bigger epoch number is aborted
					 */
					  
					if (getEpoch() != b->getEpoch()) {
						/*
						 * in this case, the aborted transaction should restart on the same core
						 * where it executed before
						 */
						
						if (getEpoch() < b->getEpoch()) {
							m_reschedule = false;
							return true;
						} else {
							b->m_reschedule = false;
							return false;
						}
					}
					
					m_reschedule = true;
					b->m_reschedule = true;
					if (IS_READING(getEpoch()))
						stm::scheduler::BiModalScheduler::instance()->increaseFalsePositiveCounter();
					/*
					 * If two writing transactions have a conflict, the transaction
					 * with the bigger (i.e. younger) timestamp is aborted
					 */
					if (!isReadOnly() && !b->isReadOnly())
						return (b->getTimestamp() < getTimestamp());
						
					/*
					 * If we are in a Reading epoch, the writing transaction is aborted
					 */
					if (IS_READING(getEpoch()))
						return !isReadOnly();
						
						
					/*
					 * If we are in a Writing epoch, the read-only transaction is aborted
					 */
					 return isReadOnly();
						
					
				}
コード例 #3
0
void modCalcAzel::slotComputeCoords()
{
	SkyPoint sp;
	double epoch0 = getEpoch( epochName->text() );
	KStarsDateTime dt;
	dt.setFromEpoch( epoch0 );
	long double jd = getDateTime().djd();
	long double jd0 = dt.djd();

	dms LST( getDateTime().gst().Degrees() + getLongitude().Degrees() );

	if(radioApCoords->isChecked()) {
		sp = getEquCoords();
		sp.apparentCoord(jd0, jd);
		dms lat(getLatitude());
		sp.EquatorialToHorizontal( &LST, &lat );
		showHorCoords( sp );

	} else {
		sp = getHorCoords();
		dms lat(getLatitude());
		sp.HorizontalToEquatorial( &LST, &lat );
		showEquCoords( sp );
	}

}
コード例 #4
0
void
UwTDMA_frame::changeStatus()
{
	packet_sent_curr_slot_ = 0;
	if (slot_status == UW_TDMA_STATUS_NOT_MY_SLOT) {
		my_slots_counter++;
		if (debug_)
			std::cout << NOW << " ID:" << addr
					  << ", my_slots_counter:" << my_slots_counter << std::endl;
	}
	if (slot_status == UW_TDMA_STATUS_MY_SLOT) {
		slot_status = UW_TDMA_STATUS_NOT_MY_SLOT;
		int num_jumping_slots =
				getNextMySlot()->first - getCurrentSlot()->first;
		num_jumping_slots = num_jumping_slots > 0
				? num_jumping_slots
				: num_jumping_slots + tot_slots;
		double nextSlotTime =
				(num_jumping_slots - 1) * slot_duration + guard_time;
		tdma_timer.resched(nextSlotTime);

		if (debug_ < -5)
			std::cout << NOW << " Off ID " << addr << " " << nextSlotTime << ""
					  << std::endl;
		if (sea_trial_)
			out_file_stats << left << "[" << getEpoch() << "]::" << NOW
						   << "::TDMA_node(" << addr << ")::Off timeslot "
						   << getCurrentSlot()->first << std::endl;
	} else
		UwTDMA::changeStatus();
}
コード例 #5
0
ファイル: Timestamp.cpp プロジェクト: vchernov/timeutil
void Timestamp::getBrokenTimeLocal(tm& brokenTime) const {
    time_t timer = getEpoch();
#ifdef __WIN32__
    // less safe
    brokenTime = *localtime(&timer);
#else
    localtime_r(&timer, &brokenTime);
#endif
}
コード例 #6
0
static RPMItemPtr
nevraToRPMItem(SQLite3Ptr conn, std::string nevra)
{
    auto nevraObject = new Nevra;
    if (hy_nevra_possibility(nevra.c_str(), HY_FORM_NEVRA, nevraObject)) {
        return nullptr;
    }
    if (nevraObject->getEpoch() < 0) {
        nevraObject->setEpoch(0);
    }

    auto rpm = std::make_shared< RPMItem >(conn);
    rpm->setName(nevraObject->getName());
    rpm->setEpoch(nevraObject->getEpoch());
    rpm->setVersion(nevraObject->getVersion());
    rpm->setRelease(nevraObject->getRelease());
    rpm->setArch(nevraObject->getArch());
    return rpm;
}
コード例 #7
0
ファイル: nevra-py.cpp プロジェクト: edynox/libhif
static PyObject *
iter(_NevraObject *self)
{
    PyObject *res;
    auto nevra = self->nevra;
    if (nevra->getEpoch() == -1) {
        Py_INCREF(Py_None);
        res = Py_BuildValue("zOzzz",
                            nevra->getName().c_str(),
                            Py_None,
                            nevra->getVersion().c_str(),
                            nevra->getRelease().c_str(),
                            nevra->getArch().c_str());
    } else
        res = Py_BuildValue("zizzz",
                            nevra->getName().c_str(),
                            nevra->getEpoch(),
                            nevra->getVersion().c_str(),
                            nevra->getRelease().c_str(),
                            nevra->getArch().c_str());
    PyObject *iter = PyObject_GetIter(res);
    Py_DECREF(res);
    return iter;
}
コード例 #8
0
void modCalcAzel::processLines( QTextStream &istream ) {

	// we open the output file

//	QTextStream istream(&fIn);
	QString outputFileName;
	outputFileName = OutputLineEditBatch->text();
	QFile fOut( outputFileName );
	fOut.open(IO_WriteOnly);
	QTextStream ostream(&fOut);

	QString line;
	QString space = " ";
	int i = 0;
	long double jd0, jdf;
	dms LST;
	SkyPoint sp;
	dms raB, decB, latB, longB, azB, elB;
	double epoch0B;
	QTime utB;
	ExtDate dtB;

	while ( ! istream.eof() ) {
		line = istream.readLine();
		line.stripWhiteSpace();

		//Go through the line, looking for parameters

		QStringList fields = QStringList::split( " ", line );

		i = 0;

		// Read Ut and write in ostream if corresponds
		
		if(utCheckBatch->isChecked() ) {
			utB = QTime::fromString( fields[i] );
			i++;
		} else
			utB = utBoxBatch->time();
		
		if ( allRadioBatch->isChecked() )
			ostream << utB.toString() << space;
		else
			if(utCheckBatch->isChecked() )
				ostream << utB.toString() << space;
			
		// Read date and write in ostream if corresponds
		
		if(dateCheckBatch->isChecked() ) {
			 dtB = ExtDate::fromString( fields[i] );
			 i++;
		} else
			dtB = dateBoxBatch->date();
		if ( allRadioBatch->isChecked() )
			ostream << dtB.toString().append(space);
		else
			if(dateCheckBatch->isChecked() )
			 	ostream << dtB.toString().append(space);
		
		// Read Longitude and write in ostream if corresponds
		
		if (longCheckBatch->isChecked() ) {
			longB = dms::fromString( fields[i],TRUE);
			i++;
		} else
			longB = longBoxBatch->createDms(TRUE);
		
		if ( allRadioBatch->isChecked() )
			ostream << longB.toDMSString() << space;
		else
			if (longCheckBatch->isChecked() )
				ostream << longB.toDMSString() << space;
		
		// Read Latitude


		if (latCheckBatch->isChecked() ) {
			latB = dms::fromString( fields[i], TRUE);
			i++;
		} else
			latB = latBoxBatch->createDms(TRUE);
		if ( allRadioBatch->isChecked() )
			ostream << latB.toDMSString() << space;
		else
			if (latCheckBatch->isChecked() )
				ostream << latB.toDMSString() << space;
		
		// Read Epoch and write in ostream if corresponds
	
		if(epochCheckBatch->isChecked() ) {
			epoch0B = fields[i].toDouble();
			i++;
		} else
			epoch0B = getEpoch( epochBoxBatch->text() );

		if ( allRadioBatch->isChecked() )
			ostream << epoch0B << space;
		else
			if(epochCheckBatch->isChecked() )
				ostream << epoch0B << space;

		// We make the first calculations
		KStarsDateTime dt;
		dt.setFromEpoch( epoch0B );
		jdf = KStarsDateTime(dtB,utB).djd();
		jd0 = dt.djd();

		LST = KStarsDateTime(dtB,utB).gst().Degrees() + longB.Degrees();
		
		// Equatorial coordinates are the input coords.
		if (!horInputCoords) {
		// Read RA and write in ostream if corresponds

			if(raCheckBatch->isChecked() ) {
				raB = dms::fromString( fields[i],FALSE);
				i++;
			} else
				raB = raBoxBatch->createDms(FALSE);

			if ( allRadioBatch->isChecked() )
				ostream << raB.toHMSString() << space;
			else
				if(raCheckBatch->isChecked() )
					ostream << raB.toHMSString() << space;

			// Read DEC and write in ostream if corresponds

			if(decCheckBatch->isChecked() ) {
				decB = dms::fromString( fields[i], TRUE);
				i++;
			} else
				decB = decBoxBatch->createDms();

			if ( allRadioBatch->isChecked() )
				ostream << decB.toDMSString() << space;
			else
				if(decCheckBatch->isChecked() )
					ostream << decB.toDMSString() << space;

			sp = SkyPoint (raB, decB);
			sp.apparentCoord(jd0, jdf);
			sp.EquatorialToHorizontal( &LST, &latB );
			ostream << sp.az()->toDMSString() << space << sp.alt()->toDMSString() << endl;

		// Input coords are horizontal coordinates
		
		} else {
			if(azCheckBatch->isChecked() ) {
				azB = dms::fromString( fields[i],FALSE);
				i++;
			} else
				azB = azBoxBatch->createDms();

			if ( allRadioBatch->isChecked() )
				ostream << azB.toHMSString() << space;
			else
				if(raCheckBatch->isChecked() )
					ostream << azB.toHMSString() << space;

			// Read DEC and write in ostream if corresponds

			if(elCheckBatch->isChecked() ) {
				elB = dms::fromString( fields[i], TRUE);
				i++;
			} else
				elB = decBoxBatch->createDms();

			if ( allRadioBatch->isChecked() )
				ostream << elB.toDMSString() << space;
			else
				if(elCheckBatch->isChecked() )
					ostream << elB.toDMSString() << space;

			sp.setAz(azB);
			sp.setAlt(elB);
			sp.HorizontalToEquatorial( &LST, &latB );
			ostream << sp.ra()->toHMSString() << space << sp.dec()->toDMSString() << endl;
		}

	}


	fOut.close();
}