void PhyxCompoundUnit::compoundSimplify(int index) { PhyxUnit *unit = m_compounds.at(index).unit; PhyxFloatDataType power = m_compounds.at(index).power; //qDebug() << static_cast<double>(power) << unit->symbol() << static_cast<double>(unit->scaleFactor()) << static_cast<double>(unit->offset()) << index; emit scaleValue(pow(unit->scaleFactor(), power)); emit offsetValue(-unit->offset()); if (power == PHYX_FLOAT_NULL) //if unit is 1 remove it { m_compounds[index].power = PHYX_FLOAT_NULL; } else { PhyxUnit *tmpUnit = new PhyxUnit(); copyUnit(unit,tmpUnit); tmpUnit->setOffset(PHYX_FLOAT_NULL); tmpUnit->setScaleFactor(PHYX_FLOAT_ONE); PhyxUnit *newUnit = m_unitSystem->verifyUnit(tmpUnit); if (newUnit != NULL) { compoundDivide(unit, power); //remove old unit compoundMultiply(newUnit, PHYX_FLOAT_ONE); //add new unit } else { compoundStrip(index); //strip compound } tmpUnit->deleteLater(); } }
void countfsChargs(FILE* fw, bus_shift* bss, int num, int base, int b, int comp, int c, int boffset, int coffset) { int powerBase[3] = {100, 100, 100}; int i; int fc = 0; int fct = 0; int sc = 0; int sct = 0; for( i = 0 ; i < num ; i++) { int pe = bss[i].e[0]; subPower(bss, i, 0, &powerBase[i]); offsetValue(&pe, i, 0, base, b, comp, c, boffset, coffset); int j; for( j = 1 ; j < bss[i].len ; j++) { debug("%c, powerBase:%d\n", i + 'a', powerBase[i]); int cs = bss[i].s[j]; offsetValue(&cs, i, j, base, b, comp, c, boffset, coffset); if(cs - pe >= 60) { sc++; sct = sct + cs - pe; powerBase[i] = 100; } else if(cs - pe >= 20) { fc++; fct = fct + cs - pe; powerBase[i] += ((cs - pe) / 10) * 8; } else { ; } pe = bss[i].e[j]; subPower(bss, i, j, &powerBase[i]); offsetValue(&pe, i, j, base, b, comp, c, boffset, coffset); } } myprintf(fw, "\nFast Charges: %d , total time:%d minutes\n", fc, fct); myprintf(fw, "Slow Charges: %d , total time:%d minutes\n", sc, sct); myprintf(fw, "\nPower Remind: a:%d, b:%d, c:%d \n", powerBase[0], powerBase[1], powerBase[2]); }
QJsonObject DmxAddress::toJson() const { QJsonValue universeValue(universe); QJsonValue offsetValue(offset); QJsonObject obj; obj.insert("universe", universeValue); obj.insert("offset", offsetValue); return obj; }
bool PhyxCompoundUnit::convertTo(PhyxCompoundUnit *unit) { this->simplify(); for (int i = 0; i < unit->compounds().size(); i++) { // make the inverse galilean transformation x = (y+b)/a offsetValue(unit->compounds().at(i).unit->offset()); scaleValue(pow(unit->compounds().at(i).unit->scaleFactor(), -unit->compounds().at(i).power)); } this->compoundsSetNull(); this->compoundsMultiply(unit->compounds()); return true; }