示例#1
0
QStringList InspectionDetailsView::listWarnings(Warnings &warnings, const QVariantMap &circuit_attributes,
                                                const QVariantMap &nominal_ins, const QVariantMap &inspection)
{
    QStringList warnings_list;
    while (warnings.next()) {
        if (warnings.value("delay").toInt())
            continue;

        if (checkWarningConditions(warnings, circuit_attributes, nominal_ins, inspection))
            warnings_list << warnings.value("name").toString();
    }
    return warnings_list;
}
示例#2
0
bool InspectionDetailsView::checkWarningConditions(Warnings &warnings, const QVariantMap &circuit_attributes, const QVariantMap &nominal_ins, const QVariantMap &inspection)
{
    int id = warnings.value("id").toInt();
    int num_conditions = warnings.warningConditionFunctionCount(id);
    for (int i = 0; i < num_conditions; ++i) {
        bool ok = true;

        double ins_value = evaluateExpression(inspection, warnings.warningConditionValueIns(id, i), circuit_attributes, &ok);
        if (!ok)
            return false;

        double nom_value = evaluateExpression(nominal_ins, warnings.warningConditionValueNom(id, i), circuit_attributes, &ok);
        if (!ok)
            return false;

        QString function = warnings.warningConditionFunction(id, i);
        if (function == "=" && ins_value == nom_value) {}
        else if (function == "!=" && ins_value != nom_value) {}
        else if (function == ">" && ins_value > nom_value) {}
        else if (function == ">=" && ins_value >= nom_value) {}
        else if (function == "<" && ins_value < nom_value) {}
        else if (function == "<=" && ins_value <= nom_value) {}
        else return false;
    }
    return true;
}