Пример #1
0
bool AnalogInputs::isConnected(Name name)
{
    if(name == Vbalancer) {
        return getRealValue(VobInfo) == Vbalancer;
    }
    if(getType(name) == Voltage) {
        return getRealValue(name) > CONNECTED_MIN_VOLTAGE;
    }
    return true;
}
Пример #2
0
bool
CCardOperatorBase::isBiggerSingal(const list<int>& lstPer, const list<int>& lstNow){
    int valPer = getValue(lstPer.front());
    int valNow = getValue(lstNow.front());
    
    valPer = getRealValue(valPer);
    valNow = getRealValue(valNow);
    
    return (valNow > valPer);
}
Пример #3
0
bool AnalogInputs::isConnected(Name name)
{
    if(name == Vbalancer) {
        return getRealValue(VobInfo) == Vbalancer;
    }
    AnalogInputs::ValueType x = getRealValue(name);
    switch(getType(name)) {
    case Current:
        return x > CONNECTED_MIN_CURRENT;
    case Voltage:
        return x > CONNECTED_MIN_VOLTAGE;
    default:
        return true;
    }
}
Пример #4
0
// Look for control dependencies on a read.
bool branchesOn(BasicBlock *bb, Value *load,
                ICmpInst **icmpOut, int *outIdx) {
  // XXX: make this platform configured; on some platforms maybe an
  // atomic cmpxchg does /not/ behave like it branches on the old value
  if (isa<AtomicCmpXchgInst>(load) || isa<AtomicRMWInst>(load)) {
    if (icmpOut) *icmpOut = nullptr;
    if (outIdx) *outIdx = 0;
    return true;
  }

  // TODO: we should be able to follow values through phi nodes,
  // since we are path dependent anyways.
  BranchInst *br = dyn_cast<BranchInst>(bb->getTerminator());
  if (!br || !br->isConditional()) return false;
  // TODO: We only check one level of things. Check deeper?

  // We pretty heavily restrict what operations we handle here.
  // Some would just be wrong (like call), but really icmp is
  // the main one, so. Probably we should be able to also
  // pick through casts and wideness changes.
  ICmpInst *icmp = dyn_cast<ICmpInst>(br->getCondition());
  if (!icmp) return false;
  int idx = 0;
  for (auto v : icmp->operand_values()) {
    if (getRealValue(v) == load) {
      if (icmpOut) *icmpOut = icmp;
      if (outIdx) *outIdx = idx;
      return true;
    }
    ++idx;
  }

  return false;
}
Module* PacketStringFilterCfg::getInstance()
{
	if (!instance)
		instance = new StringFilter();

	XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
	for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
	     it != set.end();
	     it++) {
		XMLElement* e = *it;

		if (e->matches("is")) {
			instance->addandFilter(getRealValue(e));
		} else if (e->matches("isnot")) {
			instance->addnotFilter(getRealValue(e));
		} else {
			msg(MSG_FATAL, "Unkown string packet filter config %s\n", e->getName().c_str());
			continue;
		}
	}

	return (Module*)instance;
}
Пример #6
0
bool CachedMeasure::update(bool forceUpdate) {
    uint8_t i;
    float   v;

    if (forceUpdate || _timeNextUpdate == 0 || millis() >= _timeNextUpdate) {
        _value = 0.0;
        for (i = 0; i < _measureSamples; i++) {
            if (!getRealValue(&v))
                return false;
            _value += v;
        }
        _value          /= _measureSamples;
        _timeNextUpdate  = millis() + _expireTime;
    }

    return true;
}
Пример #7
0
int ComboWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = CmdWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = text();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: setText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: updateCombo(); break;
        case 3: updateComboVariableSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: updateComboVariableSafet(); break;
        case 5: updateComboAutofilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: updateComboAutofilterSafet(); break;
        case 7: updateComboRecursivefilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: updateComboRecursivefilterSafet(); break;
        case 9: updateComboListTable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: updateComboListTable(); break;
        case 11: updateComboListLiteral(); break;
        case 12: updateVarGlobal((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 13: updateComboFlow((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: updateComboFlow(); break;
        case 15: updateComboConffileSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: updateComboConffileSafet(); break;
        case 17: updateComboColorSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 18: updateComboColorSafet(); break;
        case 19: viewdoc(); break;
        case 20: selColor(); break;
        case 21: insertAndClose(); break;
        case 22: { QString _r = getRealValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 23: { QString _r = getVarValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: itemsValueList(); break;
        case 25: itemsRealValueList(); break;
        case 26: { QComboBox* _r = combo();
            if (_a[0]) *reinterpret_cast< QComboBox**>(_a[0]) = _r; }  break;
        case 27: { QString _r = findkeyvalue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        }
        _id -= 28;
    }
    return _id;
}
Пример #8
0
// Look for address dependencies on a read.
bool addrDepsOnSearch(Value *pointer, Value *load,
                      PathCache *cache, PathID path,
                      std::vector<Instruction *> *trail) {
  Instruction *instr = dyn_cast<Instruction>(pointer);
  if (!instr) return false;

  if (pointer == load) {
    if (trail) trail->push_back(instr);
    return true;
  } else if (getBSCopyValue(pointer)) {
    bool succ=addrDepsOnSearch(getRealValue(pointer), load, cache, path, trail);
    if (succ && trail) trail->push_back(instr);
    return succ;
  }

  // We trace through GEP, BitCast, IntToPtr.
  // I wish we weren't recursive. Maybe we should restrict how we
  // trace through GEPs?
  // TODO: less heavily restrict what we use?
  if (isa<GetElementPtrInst>(instr) || isa<BitCastInst>(instr) ||
      isa<SExtInst>(instr) || isa<IntToPtrInst>(instr)) {
    for (auto v : instr->operand_values()) {
      if (addrDepsOnSearch(v, load, cache, path, trail)) {
        if (trail) trail->push_back(instr);
        return true;
      }
    }
  }
  // Trace through PHI nodes also, using any information about the
  // path we took to get here
  if (PHINode *phi = dyn_cast<PHINode>(instr)) {
    if (BasicBlock *pred = getPathPred(cache, path, phi->getParent())) {
      bool succ = addrDepsOnSearch(phi->getIncomingValueForBlock(pred),
                                   load, cache, path, trail);
      if (succ && trail) trail->push_back(instr);
      return succ;
    }
  }


  return false;
}
Пример #9
0
AnalogInputs::ValueType AnalogInputs::getIout()
{
    return getRealValue(Iout);
}
Пример #10
0
AnalogInputs::ValueType AnalogInputs::getVout()
{
    return getRealValue(VoutBalancer);
}
Пример #11
0
void ColorBar::paint(QPainter *painter) {
    if (_colorScale==NULL) return;

    QFont f = painter->font();
    f.setPointSizeF(16);
    painter->setFont(f);

    //
    painter->setPen(Qt::black);//NoPen);
    painter->setBrush(QColor(255,255,255,180));
    painter->drawRoundedRect(BAR_START_X-10, BAR_START_Y-10,100,BAR_HEIGHT + 20,10,10);
    //painter->drawRect(BAR_START_X, BAR_START_Y, BAR_START_X+BAR_WIDTH+TICK_WIDTH+4+TEXT_WIDTH, TEXT_HEIGHT+ BAR_START_Y-TEXT_HEIGHT/4-1);

    // Draw rectangle with gradient on widget
    painter->setPen(Qt::black);
    painter->setBrush(_gradient);
    painter->drawRect(BAR_START_X, BAR_START_Y, BAR_WIDTH, BAR_HEIGHT);

    // draw ticks and text
    if (_minReal!=_maxReal) {
        int    stepTick = BAR_HEIGHT/TICKS_NUM;
        //    for (int i=BAR_START_Y; i<=BAR_START_Y+BAR_HEIGHT; i+=stepTick) {
        for (int i=BAR_START_Y+BAR_HEIGHT; i>=BAR_START_Y; i-=stepTick) {
            painter->setPen( Qt::black);
            painter->drawLine(BAR_START_X+BAR_WIDTH, i,
                              BAR_START_X+BAR_WIDTH+TICK_WIDTH, i);

            double val = getRealValue(i);
            painter->setPen( Qt::white);
            painter->setBrush( Qt::white );
            painter->drawText(BAR_START_X+BAR_WIDTH+TICK_WIDTH+3, i-TEXT_HEIGHT/4 - 4, TEXT_WIDTH, TEXT_HEIGHT,
                              Qt::KeepAspectRatio,QString::number(val,'f', 2));

            painter->setPen(Qt::blue);
            painter->setBrush( Qt::black );
            painter->drawText(BAR_START_X+BAR_WIDTH+TICK_WIDTH+4, i-TEXT_HEIGHT/4-5, TEXT_WIDTH, TEXT_HEIGHT,
                              Qt::KeepAspectRatio,QString::number(val,'f', 2));
        }
 
        // draw unit
        if (!this->_unit.isEmpty()) {
          QFontMetrics metrics(painter->font());
          int width = metrics.width(this->_unit);
          painter->save();
          painter->translate(BAR_START_X-metrics.descent()-1, BAR_START_Y+BAR_HEIGHT/2);
          painter->rotate(270);
          painter->setPen(Qt::white);
          painter->drawText(-width/2, 0, this->_unit);
          painter->setPen(Qt::black);
          painter->drawText(-width/2+1, -1, this->_unit);
          painter->restore();
        }
    }

    // draw selection
    if (_minSel!=_maxSel) {
        QRect rect(BAR_START_X-2, _minSel, BAR_WIDTH+5, _maxSel-_minSel);
        painter->setPen(QPen(Qt::black, 2));
        painter->setBrush(QColor(128, 128, 128, 50));
        painter->drawRect(rect);
    }
}