Exemplo n.º 1
0
errType fltrList::applyFilters(prcList* processes) // Need to do in scanprocesses
{
    errType result=err_not_found;
    char *cmdline;
    fltr* filter;
    prcTask* prc;
    int res=0;
    BYTE sig=SIGKILL;
    bool act=false;
    
    if ((processes->quantity()==0)||(quantity()==0)) return result;
    
    //printf("filters=%d\n", quantity());
    //printf("processes=%p\n", processes);
    
    for (int i=0; i< quantity(); i++)
    {
	//printf("i=%d\n", i);
	filter=getProcFilterByIndex(i);
	cmdline=filter->get_cmdline();
	//printf("filter_cmd_line=%s\n", cmdline);
	prc=processes->searchUserProcessByCmdline(cmdline, strlen(cmdline));
	//printf("comparing...\n");
	//printf("prc=%p", prc);
	
	if (prc) 
	{
	    //printf("prc_cpu=%d\n",prc->get_prc_cpu());
	    //printf("prc_mem=%lu\n",prc->get_prc_rss());
	    //printf("filter_cpu=%d\n",filter->get_filter_cpu());
	    //printf("filter_mem=%lu\n",filter->get_filter_mem());
	
	    if (prc->get_prc_cpu()>=filter->get_filter_cpu()) act=true;
	    if (prc->get_prc_rss()>=filter->get_filter_mem()) act=true;
	    //printf("acting...");
	    if (act){
	    //printf("act!\n");
		switch(filter->action())
		{
		    case 0: // kill
			printf("Процесс №%d (%s) будет завершён\n", prc->get_prc_pid(), prc->get_cmdline());
			res=kill(prc->get_prc_pid(), sig);
			break;
		    case 1: // restart
			printf("Процесс №%d (%s) будет перезапущен\n", prc->get_prc_pid(), prc->get_cmdline());
			res=kill(prc->get_prc_pid(), sig);
			break;
		}
		result=err_result_ok;
		act=false;
	    }
	}
    }
    
    
    return result;
}
Exemplo n.º 2
0
QString BillItemMeasure::quantityStr(){
    QString realFormula = m_d->formula;
    realFormula.remove(" ");
    if( realFormula.isEmpty() ){
        return QString();
    }
    if( m_d->unitMeasure != NULL ){
        return m_d->toString( quantity(), 'f', m_d->unitMeasure->precision() ) ;
    } else {
        return m_d->toString( quantity(), 'f', 6 ) ;
    }
}
Exemplo n.º 3
0
fltr* fltrList::searchProcFilterByCmdline(const char* cmdline, size_t size)
{
    fltr* result=0;
    list<fltr*>::iterator iter;                                                        
    WORD foundCount=0;                                                                    
    bool founded=false;                                                                   
    BYTE res=0;                                                                           
    
    if ((quantity()>0) && (cmdline!=0)) {
	iter=procFilters.begin();                                                              
	iter++;                                                                               
    
	do {                                                                              
	    res=strncmp((*iter)->get_cmdline(), cmdline, size);                       
	    if (res==0) {                                                             
                result=(*iter);                                                       
                founded=true;                                                         
                foundCount++;                                                         
	    }                                                                         
	    iter++;                                                                   
	} while (iter!=procFilters.end());                                                  
//	if (founded) result=(*iter);
    }

    return result;
}
Exemplo n.º 4
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Manifest ResourceBuff::popQty(double qty) {
  if (qty - quantity() > STORE_EPS) {
    throw CycNegQtyException("Removal quantity larger than store tot quantity.");
  }
  if (qty < 0.0) {
    throw CycNegQtyException("Removal quantity cannot be negative.");
  }

  Manifest manifest;
  rsrc_ptr mat, leftover;
  double left = qty;
  double quan;
  while (left > STORE_EPS) {
    mat = mats_.front();
    mats_.pop_front();
    quan = mat->quantity();
    if ((quan - left) > STORE_EPS) {
      // too big - split the mat before pushing
      leftover = mat->clone();
      leftover->setQuantity(quan - left);
      mat->setQuantity(left);
      mats_.push_front(leftover);
    }
    manifest.push_back(mat);
    left -= quan;
  }
  return manifest;
}
Exemplo n.º 5
0
MUPD::allocation MUPD::spending_allocation(const unordered_map<id_t, double> &spending) const {
    allocation a = {};

    auto sim = simulation();

    for (auto &m : spending) {
        if (m.second > 0) {
            if (m.first == 0) {
                // Holding cash
                a.bundle += money_unit * m.second;
                a.quantity[m.first] += m.second;
            }
            else {
                // Otherwise query the market for the resulting quantity
                auto mkt = sim->market(m.first);

                auto q = mkt->quantity(m.second * price_ratio(mkt));

                a.quantity[m.first] = q.quantity;
                a.bundle += mkt->output_unit * q.quantity;

                if (q.constrained) {
                    // The market is constrained, so add any leftover (unspent) money back into the
                    // bundle
                    a.constrained.insert(mkt->id());
                    a.bundle += mkt->price_unit * q.unspent;
                    a.quantity[0] += q.unspent / price_ratio(mkt);
                }
            }
        }
    }

    return a;
} 
Exemplo n.º 6
0
InputParameters validParams<PenetrationAux>()
{
  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");

  InputParameters params = validParams<AuxKernel>();
  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to be penetrated");
  params.addParam<Real>("tangential_tolerance", "Tangential distance to extend edges of contact surfaces");
  params.addParam<Real>("normal_smoothing_distance", "Distance from edge in parametric coordinates over which to smooth contact normal");
  params.addParam<std::string>("normal_smoothing_method","Method to use to smooth normals (edge_based|nodal_normal_based)");
  params.addParam<MooseEnum>("order", orders, "The finite element order");

  params.set<bool>("use_displaced_mesh") = true;

  // To avoid creating a conversion routine we will list the enumeration options in the same order as the class-based enum.
  // Care must be taken to ensure that this list stays in sync with the enum in the .h file.
  MooseEnum quantity(
    "distance tangential_distance normal_x normal_y normal_z closest_point_x closest_point_y "
    "closest_point_z element_id side incremental_slip_magnitude incremental_slip_x "
    "incremental_slip_y incremental_slip_z accumulated_slip force_x force_y force_z "
    "normal_force_magnitude normal_force_x normal_force_y normal_force_z tangential_force_magnitude "
    "tangential_force_x tangential_force_y tangential_force_z frictional_energy lagrange_multiplier "
    "mechanical_status", "distance");

  params.addParam<MooseEnum>("quantity", quantity, "The quantity to recover from the available penetration information");
  return params;
}
Exemplo n.º 7
0
 // Copy Constructor
 Good::Good(const Good& other) {
   upc(other._upc);
   name(other._name);
   price(other._price);
   qtyNeeded(other._qtyNeeded);
   taxed(other._taxed);
   quantity(other._quantity);
 }
Exemplo n.º 8
0
QDomElement RecipeIngredient::toXml(QDomDocument document)
{
    QDomElement element = document.createElement("RecipeIngredient");
    element.appendChild(ingredient()->toXml(document));
    element.appendChild(quantity().toXml(document));
    element.setAttribute("minutes", minutes());
    return element;
}
Exemplo n.º 9
0
 Good::Good(const char* u, const char* n, double p, int q, bool t) {
   upc(u);
   name(n);
   price(p);
   qtyNeeded(q);
   taxed(t);
   quantity(0);
 }
Exemplo n.º 10
0
InputParameters validParams<XFEMCutPlaneAux>()
{
  InputParameters params = validParams<AuxKernel>();
  MooseEnum quantity("origin_x origin_y origin_z normal_x normal_y normal_z");
  params.addRequiredParam<MooseEnum>("quantity", quantity, "The quantity to be extracted.  Choices: "+quantity.getRawNames());
  params.addParam<unsigned int>("plane_id", 0, "The index of the cut plane");
  return params;
}
Exemplo n.º 11
0
QString Resource::filterString() const
{
    std::stringstream completeString;

    completeString <<        name().toStdString()
                   << " " << type().toStdString()
                   << " " << quantity();
    return (QString(completeString.str().c_str()));
}
Exemplo n.º 12
0
  // operator=
   Item& Item::operator=(const Item& RO){
      upc(RO._upc);
      name(RO._name);
      price(RO._price);
      quantity(RO._quantity);
      taxed(RO._taxed);
      qtyNeeded(RO._qtyNeeded);

      return *this;
   }
Exemplo n.º 13
0
		Product::Product(const char* s, const char* n, double x, int i, bool tax) {
				//	Copies the SKU into the corresponding member variable up to MAX_SKU_LEN characters. 
				//still hae to implement  as just does (strcpy(x,y)) right now
				sku(s);
				name(n);
				price(x);
				qtyNeeded(i);
				quantity(0);
				taxed(tax);
		}
Exemplo n.º 14
0
 // Assignment Operator=
 Good& Good::operator=(const Good& other) {
   if (this != &other) {
     upc(other._upc);
     name(other._name);
     price(other._price);
     qtyNeeded(other._qtyNeeded);
     taxed(other._taxed);
     quantity(other._quantity);
   }
   return *this;
 }
Exemplo n.º 15
0
		//copy con
		Product::Product(const Product& other) {
				//
				sku(other.sku_);
				name(other.name_);
				price(other.price_);
				taxed(other.taxed_);
				quantity(other.quantity_);
				qtyNeeded(other.qtyNeeded_);
				

		}
Exemplo n.º 16
0
 MaterialObject::Element::Element(const Element& original, double multiplier) : Element(original.materialType_) {
   if(original.destination.state())
     destination(original.destination());
   if(original.componentName.state())
     componentName(original.componentName());
   elementName(original.elementName());
   service(original.service());
   quantity(original.quantity() * original.scalingMultiplier() * multiplier); //apply the scaling in the copied object
   scaleOnSensor(0);
   unit(original.unit());
   debugInactivate(original.debugInactivate());
 }
Exemplo n.º 17
0
		Product& Product::operator=(const Product& other) {
				//may not need to test this
				if (this != &other) {
						sku(other.sku_);
						name(other.name_);
						price(other.price_);
						taxed(other.taxed_);
						quantity(other.quantity_);
						qtyNeeded(other.qtyNeeded_);
				}
						return *this;
				
		}
Exemplo n.º 18
0
int main()
{
    int number = 0;

    printf("Ведите число\n");
    scanf("%d", &number);
    printf("Простые меньше ведённого:\n");

    if(number >= 2)
    {
        quantity(number);
    }

    return 0;
}
Exemplo n.º 19
0
void InventoryItem::GetItemRow( PyPackedRow* into ) const
{
    into->SetField( "itemID",     new PyLong( itemID() ) );
    into->SetField( "typeID",     new PyInt( typeID() ) );
    into->SetField( "ownerID",    new PyInt( ownerID() ) );
    into->SetField( "locationID", new PyLong( locationID() ) );
    into->SetField( "flagID",     new PyInt( flag() ) );
    into->SetField( "quantity",   new PyInt( singleton() ? -1 : quantity()) );
    into->SetField( "groupID",    new PyInt( groupID() ) );
    into->SetField( "categoryID", new PyInt( categoryID() ) );
    into->SetField( "customInfo", new PyString( customInfo() ) );

    //into->SetField( "singleton",  new PyBool( singleton() ) );
    //into->SetField( "stacksize",  new PyInt (quantity()) );
}
Exemplo n.º 20
0
    //==================================================
    // copyFromSource
    //
    // This function deeps copy data from the source into this object. Can be used for copy constructor and
    // assignment operators
    //==================================================
    Good& Good::copyFromSource (const Good& source) {
        char tmpUpc  [MAX_UPC_LEN + 1];
        char tmpName [2000];

        strncpy (tmpUpc,  source.upc  (), MAX_UPC_LEN);
        strncpy (tmpName, source.name (), 2000);

        upc       (tmpUpc);
        name      (tmpName);
        price     (source.price     ());
        quantity  (source.quantity  ());
        taxed     (source.taxed     ());
        qtyNeeded (source.qtyNeeded ());

        return *this;
    }
Exemplo n.º 21
0
/*
 * Character
 */
Character::Character(
    ItemFactory &_factory,
    uint32 _characterID,
    // InventoryItem stuff:
    const CharacterType &_charType,
    const ItemData &_data,
    // Character stuff:
    const CharacterData &_charData,
    const CorpMemberInfo &_corpData)
: Owner(_factory, _characterID, _charType, _data),
  m_accountID(_charData.accountID),
  m_title(_charData.title),
  m_description(_charData.description),
  m_gender(_charData.gender),
  m_bounty(_charData.bounty),
  m_balance(_charData.balance),
  m_securityRating(_charData.securityRating),
  m_logonMinutes(_charData.logonMinutes),
  m_totalSPtrained(((double)(_charData.skillPoints))),
  m_corporationID(_charData.corporationID),
  m_corpHQ(_corpData.corpHQ),
  m_allianceID(_charData.allianceID),
  m_warFactionID(_charData.warFactionID),
  m_corpRole(_corpData.corpRole),
  m_rolesAtAll(_corpData.rolesAtAll),
  m_rolesAtBase(_corpData.rolesAtBase),
  m_rolesAtHQ(_corpData.rolesAtHQ),
  m_rolesAtOther(_corpData.rolesAtOther),
  m_stationID(_charData.stationID),
  m_solarSystemID(_charData.solarSystemID),
  m_constellationID(_charData.constellationID),
  m_regionID(_charData.regionID),
  m_ancestryID(_charData.ancestryID),
  m_careerID(_charData.careerID),
  m_schoolID(_charData.schoolID),
  m_careerSpecialityID(_charData.careerSpecialityID),
  m_startDateTime(_charData.startDateTime),
  m_createDateTime(_charData.createDateTime),
  m_corporationDateTime(_charData.corporationDateTime)
{
    // allow characters to be only singletons
    assert(singleton() && quantity() == 1);

    // Activate Save Info Timer with somewhat randomized timer value:
    //SetSaveTimerExpiry( MakeRandomInt( (10 * 60), (15 * 60) ) );        // Randomize save timer expiry to between 10 and 15 minutes
    //EnableSaveTimer();
}
Exemplo n.º 22
0
QVariant Resource::data(int role) const
{
    switch(role) {
    case IdRole:
        return (unsigned int)id();
    case NameRole:
        return name();
    case TypeRole:
        return type();
    case QuantityRole:
        return (unsigned int)quantity();
    case FilterStringRole:
        return filterString();
    default:
        return QVariant();
    }
}
/*
 * Character
 */
Character::Character(
    ItemFactory &_factory,
    uint32 _characterID,
    // InventoryItem stuff:
    const CharacterType &_charType,
    const ItemData &_data,
    // Character stuff:
    const CharacterData &_charData,
    const CorpMemberInfo &_corpData)
: Owner(_factory, _characterID, _charType, _data),
  m_accountID(_charData.accountID),
  m_title(_charData.title),
  m_description(_charData.description),
  m_gender(_charData.gender),
  m_bounty(_charData.bounty),
  m_balance(_charData.balance),
  m_securityRating(_charData.securityRating),
  m_logonMinutes(_charData.logonMinutes),
  m_corporationID(_charData.corporationID),
  m_corpHQ(_corpData.corpHQ),
  m_allianceID(_charData.allianceID),
  m_warFactionID(_charData.warFactionID),
  m_corpRole(_corpData.corpRole),
  m_rolesAtAll(_corpData.rolesAtAll),
  m_rolesAtBase(_corpData.rolesAtBase),
  m_rolesAtHQ(_corpData.rolesAtHQ),
  m_rolesAtOther(_corpData.rolesAtOther),
  m_stationID(_charData.stationID),
  m_solarSystemID(_charData.solarSystemID),
  m_constellationID(_charData.constellationID),
  m_regionID(_charData.regionID),
  m_ancestryID(_charData.ancestryID),
  m_careerID(_charData.careerID),
  m_schoolID(_charData.schoolID),
  m_careerSpecialityID(_charData.careerSpecialityID),
  m_startDateTime(_charData.startDateTime),
  m_createDateTime(_charData.createDateTime),
  m_corporationDateTime(_charData.corporationDateTime)
{
    // allow characters to be only singletons
    assert(singleton() && quantity() == 1);
}
Exemplo n.º 24
0
Quantity DataManager::loadQuantity(const QDomDocument& xml_document, const QPixmap& pixmap) {
	// Start document parsing and variables setting
	QDomElement root = xml_document.documentElement();

	Quantity quantity( root.attribute("name"), pixmap);
	quantity.prefixAllowed = (root.attribute("prefixsAllowed") == "yes");

	// Treatment of <baseunit> tag
	Unit baseunit = loadBaseUnit(root.firstChildElement("baseunit"));
	quantity.push_back( baseunit );

	// Treatment of <unit> tags
	QDomElement unit_elem = root.firstChildElement("unit");
	while( !unit_elem.isNull() ) { //for each <unit> tag
		quantity.push_back( loadUnit(unit_elem, baseunit) );
		unit_elem = unit_elem.nextSiblingElement("unit");
	}

	qDebug("Quantity \"%s\" loaded.", qPrintable(root.attribute("name")));
	return quantity;
}
Exemplo n.º 25
0
void InventoryItem::SaveItem()
{
    //_log( ITEM__TRACE, "Saving item %u.", itemID() );

    SaveAttributes();

    m_factory.db().SaveItem(
        itemID(),
        ItemData(
            itemName().c_str(),
            typeID(),
            ownerID(),
            locationID(),
            flag(),
            contraband(),
            singleton(),
            quantity(),
            position(),
            customInfo().c_str()
        )
    );
}
Exemplo n.º 26
0
range::range ()
{
  default_ = quantity ();
}
Exemplo n.º 27
0
QImage ImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    QImage result;
    const QStringList idSegments = id.split(QLatin1Char('/'));
    if (requestedSize.width() < 1 || requestedSize.height() < 1) {
        qDebug() << Q_FUNC_INFO << " requestedSize is invalid!" << requestedSize << id;
        return QImage();
    }
    if (idSegments.count() < 2) {
        qDebug() << Q_FUNC_INFO << "Not enough parameters for the image provider: " << id;
        return QImage();
    }
    const QString &elementId = idSegments.at(1);
    if (idSegments.first() == QStringLiteral("background")) {
        return renderedSvgElement(elementId, designRenderer(), Qt::KeepAspectRatioByExpanding, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("title")) {
        if (elementId == QStringLiteral("textmask"))
            result = renderedSvgElement(idSegments.first(), designRenderer(), Qt::KeepAspectRatio, size, requestedSize);
        else
            result = spectrum(size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("specialbutton")) {
        result = renderedSvgElement(elementId, designRenderer(), Qt::IgnoreAspectRatio, size, requestedSize);
    } else if (idSegments.first() == buttonString) {
        result = renderedDesignElement(DesignElementTypeButton, elementId.toInt(), size, requestedSize);
    } else if (idSegments.first() == frameString) {
        result = renderedDesignElement(DesignElementTypeFrame, 0, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("object")) {
        result = renderedSvgElement(elementId, objectRenderer(), Qt::KeepAspectRatio, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("clock")) {
        if (idSegments.count() != 4) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for clock images:" << id;
            return QImage();
        }
        result = clock(idSegments.at(1).toInt(), idSegments.at(2).toInt(), idSegments.at(3).toInt(), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("notes")) {
        result = notes(elementId.split(QLatin1Char(','), QString::SkipEmptyParts), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("quantity")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for quantity images:" << id;
            return QImage();
        }
        result = quantity(idSegments.at(1).toInt(), idSegments.at(2), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("lessonicon")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for lessonicon:" << id;
            return QImage();
        }
        result = renderedLessonIcon(idSegments.at(1), idSegments.at(2).toInt(), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("color")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for color:" << id;
            return QImage();
        }
        const QColor color(idSegments.at(1));
        result = colorBlot(color, idSegments.at(2).toInt(), size, requestedSize);
    } else {
        qDebug() << Q_FUNC_INFO << "invalid image Id:" << id;
    }
#if 0
    if (idSegments.first() == QStringLiteral("object")) {
        QPainter p(&result);
        QPolygon points;
        for (int i = 0; i < result.width(); i += 2)
            for (int j = 0; j < result.height(); j += 2)
                points.append(QPoint(i, j));
        p.drawPoints(points);
        p.setPen(Qt::white);
        p.translate(1, 1);
        p.drawPoints(points);
    }
#endif
    return result;
}
Exemplo n.º 28
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
double ResourceBuff::space() {
  if (unlimited_) {
    return -1;
  }
  return capacity_ - quantity();
}
Exemplo n.º 29
0
  double MaterialObject::Element::quantityInUnit(const std::string desiredUnit, const double length, const double surface) const {
    double returnVal = 0;
    double density = materialTab_.density(elementName());
    bool invert;
    Unit desiredUnitVal, elementUnitVal, tempUnit;

    //Conversion matrix:
    //            g              g/m                 mm
    //      __________________________________________________
    //  g  |      1             l/1000            rho*S       |
    // g/m |    1000/l            1           (rho*S*1000)/l  |
    //  mm |   1/(rho*S)    l/(rho*S*1000)          1         |
    //
    // rows:    desired unit
    // columns: original unit
    // l:       length
    // rho:     density
    // S:       surface

    /*
    std::map<std::pair<Unit, Unit>, double> conversionMatrix = {
      {{GRAMS, GRAMS}, 1}, {{GRAMS, GRAMS_METER}, length/1000}, {{GRAMS, MILLIMETERS}, density*surface},
      {{GRAMS_METER, GRAMS}, 1000/length}, {{GRAMS_METER, GRAMS_METER}, 1}, {{GRAMS_METER, MILLIMETERS}, (density*surface*1000)/length},
      {{MILLIMETERS, GRAMS}, 1/(density*surface)}, {{MILLIMETERS, GRAMS_METER}, length/(density*surface*1000)}, {{MILLIMETERS, MILLIMETERS}, 1}
    };

    try {
      returnVal = quantity() * conversionMatrix.at({unitStringMap.at(desiredUnit), unitStringMap.at(unit())});
    } catch (const std::out_of_range& ex) {
      logERROR(msg_no_valid_unit + unit() + ", " + desiredUnit + ".");
    }
    */

    try {
      desiredUnitVal = unitStringMap.at(desiredUnit);
      elementUnitVal = unitStringMap.at(unit());
      
      if (desiredUnitVal == elementUnitVal) {
        return quantity();
      } else if (desiredUnitVal > elementUnitVal) {
        invert = true;
        tempUnit = desiredUnitVal;
        desiredUnitVal = elementUnitVal;
        elementUnitVal = tempUnit;
      } else {
        invert = false;
      }
      
      if      ((desiredUnitVal == GRAMS) && (elementUnitVal == GRAMS_METER))
        returnVal = quantity() * length / 1000.;
      else if ((desiredUnitVal == GRAMS) && (elementUnitVal == MILLIMETERS))
        returnVal = quantity() * density * surface;
      else if ((desiredUnitVal == GRAMS_METER) && (elementUnitVal == MILLIMETERS))
        returnVal = quantity() * (density * surface * 1000.) / length;

      if (invert)
        returnVal = 1 / returnVal;
    } catch (const std::out_of_range& ex) {
      logERROR(msg_no_valid_unit + unit() + ", " + desiredUnit + ".");
    }
    return returnVal;
  }
Exemplo n.º 30
0
 std::string str() const { return quantity(amount, units); }