bool AnimalFeed::calculate(const KCalculationInfo& ci, const KLocation & loc, KDataArray * calcResult) { Q_UNUSED(loc); Q_UNUSED(ci); qreal fp = userInputs()->numericValueOf(Srs19::AnnualPastureFraction); KData Cvi = _inpPorts.at(0)->data(Srs19::ConcentrationInVegetation); KData Cpi = _inpPorts.at(1)->data(Srs19::ConcentrationInStoredAnimalFeed); if (Cvi.isValid()) { for(int k = 0; k < Cvi.count(); k++) { const KDataItem & CviItem = Cvi.at(k); qreal vCvi = CviItem.numericValue(); qreal vCpi = Cpi.numericValue(CviItem.name()); qreal Cai = fp * vCvi + (1-fp)*vCpi; calcResult->appendOrMerge(&Srs19::ConcentrationInAnimalFeed, CviItem.name(), Cai, KData::Radionuclide); } } else if (Cpi.isValid()) { for(int k = 0; k < Cpi.count(); k++) { const KDataItem & CpiItem = Cvi.at(k); qreal vCvi = Cvi.numericValue(CpiItem.name()); qreal vCpi = CpiItem.numericValue(); qreal Cai = fp * vCvi + (1-fp)*vCpi; calcResult->appendOrMerge(&Srs19::ConcentrationInAnimalFeed, CpiItem.name(), Cai, KData::Radionuclide); } } return true; }
void DischargeItemTable::setData(const KData& d) { if (d.isEmpty()) return; //set row count this->setRowCount(d.count()+1); //setup data for(int k = 0; k < d.count(); k++) { const KDataItem &item = d.at(k); QTableWidgetItem * cell = new QTableWidgetItem(item.name()); setItem(k, 0, cell); cell = new QTableWidgetItem(item.value().toString()); setItem(k, 1, cell); } }