Ejemplo n.º 1
0
void Battery::update()
{
    BatteryStatus status      = getStatusValue(mPathBatteryStatus);
    BatteryHealth health      = getHealthValue(mPathBatteryHealth);
    bool          ac_online   = getBooleanValue(mPathACOnline);
    bool          usb_online  = getBooleanValue(mPathUSBOnline);
    bool          present     = getBooleanValue(mPathBatteryPresent);
    int           capacity    = getIntegerValue(mPathBatteryCapacity);
    int           voltage     = getIntegerValue(mPathBatteryVoltage) / mVoltageDivisor;
    int           temperature = getIntegerValue(mPathBatteryTemperature);
    QString       technology  = getByteArray(mPathBatteryTechnology);

    bool changed = (status != mStatus || health != mHealth ||
		    ac_online != mACOnline || usb_online != mUSBOnline ||
		    present != mPresent || capacity != mCapacity ||
		    voltage != mVoltage || temperature != mTemperature ||
		    technology != mTechnology );

    if (changed) {
	mStatus      = status;
	mHealth      = health;
	mACOnline    = ac_online;
	mUSBOnline   = usb_online;
	mPresent     = present;
	mCapacity    = capacity;
	mVoltage     = voltage;
	mTemperature = temperature;
	mTechnology  = technology;
	emit dataChanged();
    }
}
void peanoclaw::configurations::PeanoClawConfigurationForSpacetreeGrid::processEntry(
  const std::string& name,
  std::stringstream& values
) {

  if(name == "plot" || name == "plotAtOutputTimes") {
    _plotAtOutputTimes = getBoolValue(values);
  } else if(name == "plotAtEnd") {
    _plotAtEndTime = getBoolValue(values);
  } else if(name == "plotAtSubsteps") {
    _plotSubsteps = getBoolValue(values);
  } else if(name == "restrictStatistics") {
    _restrictStatistics = getBoolValue(values);
  } else if(name == "fluxCorrection") {
    _fluxCorrection = getBoolValue(values);
  } else if(name == "reduceReductions") {
    _reduceReductions = getBoolValue(values);
  } else if(name == "probe") {
    addProbe(values);
  } else if(name == "numberOfThreads") {
    _numberOfThreads = getIntegerValue(values);
  } else if(name == "neighborInducedMaximumTimesteps") {
    _estimateNeighborInducedMaximumTimestep = getBoolValue(values);
  } else if(name == "useDimensionalSplittingOptimization") {
    _useDimensionalSplittingOptimization = getBoolValue(values);
  } else if(name == "nodePoolStrategy") {
    std::string strategyName;
    values >> strategyName;
    if(strategyName == "levelAware") {
      _nodePoolStrategy = LevelAware;
    } else if (strategyName == "treeAware") {
      _nodePoolStrategy = TreeAware;
    }
  } else {
UInt32 Configuration::getIntegerValue(OSDictionary *dict, const char *key, UInt32 defValue)
{
    UInt32 result = defValue;
    if (dict)
        result = getIntegerValue(dict->getObject(key), defValue);
    return result;
}
Result Context::createPooledStringResult(char *s, int len)
{
    POOL_ASSERT(pool, s);

    if (len == -1)
        len = strlen(s);

    PRBool b = (len > 1 || len == 1 && *s != '0');
    PRInt64 i = getIntegerValue(s);

    return Result(RESULT_STRING, b, i, pool, s, len);
}
Result Context::createStringConstantResult(const char *s, int len)
{
    if (s == NULL || len == 0)
        return Result(RESULT_STRING, PR_FALSE, 0, NULL, "", 0);

    if (len == -1)
        len = strlen(s);

    PRBool b = (len > 1 || len == 1 && *s != '0');
    PRInt64 i = getIntegerValue(s);

    return Result(RESULT_STRING, b, i, NULL, s, len);
}
Ejemplo n.º 6
0
void OpcodeNode::installCaseRanges() {
  uint32_t InitialWidth;
  if (!getCaseSelectorWidth(getKid(0), InitialWidth)) {
    Node::Trace.errorSexp("Inside: ", this);
    fatal("Unable to install caches for opcode s-expression");
  }
  for (int i = 1, NumKids = getNumKids(); i < NumKids; ++ i) {
    assert(isa<CaseNode>(Kids[i]));
    const CaseNode *Case = cast<CaseNode>(Kids[i]);
    std::unordered_set<uint32_t> CaseWidths;
    IntType Key = getIntegerValue(Case->getKid(0));
    if (!collectCaseWidths(Key, Case->getKid(1),
                           CaseWidths)) {
      Node::Trace.errorSexp("Inside: ", Case);
      Node::Trace.errorSexp("Inside: ", this);
      fatal("Unable to install caches for opcode s-expression");
    }
    for (uint32_t NestedWidth : CaseWidths) {
      uint32_t Width = InitialWidth + NestedWidth;
      if (Width > MaxOpcodeWidth) {
        Node::Trace.errorSexp("Bit width(s) too big: ", this);
        fatal("Unable to install caches for opcode s-expression");
      }
      IntType Min = Key << NestedWidth;
      IntType Max = Min + getWidthMask(NestedWidth);
      WriteRange Range(Case, Min, Max, NestedWidth);
      CaseRangeVector.push_back(Range);
    }
  }
  // Validate that ranges are not overlapping.
  std::sort(CaseRangeVector.begin(), CaseRangeVector.end());
  for (size_t i = 0, Last=CaseRangeVector.size() - 1; i < Last; ++i) {
    const WriteRange &R1 = CaseRangeVector[i];
    const WriteRange &R2 = CaseRangeVector[i+1];
    if (R1.getMax() >= R2.getMin()) {
      Node::Trace.errorSexp("Range 1: ", R1.getCase());
      Node::Trace.errorSexp("Range 2: ", R2.getCase());
      Node::Trace.errorSexp("Inside: ", this);
      fatal("Opcode case ranges not unique");
    }
  }
}
Result Context::createNewStringResult(const char *s, int len)
{
    if (s == NULL || len == 0)
        return Result(RESULT_STRING, PR_FALSE, 0, NULL, "", 0);

    if (len == -1)
        len = strlen(s);

    char *p = (char *) pool_malloc(pool, len + 1);
    if (p == NULL)
        return Result::out_of_memory;

    memcpy(p, s, len);
    p[len] = '\0';

    PRBool b = (len > 1 || len == 1 && *p != '0');
    PRInt64 i = getIntegerValue(p);

    return Result(RESULT_STRING, b, i, pool, p, len);
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
    // expects no arguments because we are using a particular class file
    if (argc != 1)
    {
        fprintf(stderr, "Usage: heapTest\n");
        exit(-1);
    }

    // initialize: need to use a class with a user class that has at least
    // four fields
    initializeVM(10000, "userClass.class");

    // okay, begin the testing...

    Class A = getIthClass(4);

    Reference objectRef = allocateObject(getObjectClass());
    Reference integerRef = allocateObject(getIntegerClass());
    Reference aRef = allocateObject(A);
    Reference stringRef = allocateString("abcdefghijklmnopqrstuvwxyz");

    if (getObjectClass() != getClass(objectRef))
    {
        fprintf(stderr, "FAIL: getClass from objectRef\n");
    }

    if (getIntegerClass() != getClass(integerRef))
    {
        fprintf(stderr, "FAIL: getClass from integerRef\n");
    }

    if (getStringClass() != getClass(stringRef))
    {
        fprintf(stderr, "FAIL: getClass from stringRef\n");
    }

    if (A != getClass(aRef))
    {
        fprintf(stderr, "FAIL: getClass from aRef\n");
    }

    if (strcmp(getStringValue(stringRef), "abcdefghijklmnopqrstuvwxyz"))
    {
        fprintf(stderr, "FAIL: getStringValue\n");
    }

    putIntegerValue(integerRef, 1066);
    if (getIntegerValue(integerRef) != 1066)
    {
        fprintf(stderr, "FAIL: getIntegerValue\n");
    }

    putField(aRef, 0, integerRef);
    if (getField(aRef, 0) != integerRef)
    {
        fprintf(stderr, "FAIL: getField 0\n");
    }

    putField(aRef, 3, objectRef);
    if (getField(aRef, 3) != objectRef)
    {
        fprintf(stderr, "FAIL: getField 3\n");
    }

    printf("testing complete.\n");

    return 0;
}