Exemplo n.º 1
0
void
vleSmDT::setInitialValue(const QString& varName,
        const vle::value::Value& val)
{
    QDomNode var = nodeVariable(varName);
    if (var.isNull()) {
        return;
    }
    undoStackSm->snapshot(var);
    QDomNodeList initList = var.toElement().elementsByTagName("initial_value");
    if (initList.length() == 0) {
        //TODO see vpz management of vle values
        QDomElement dble = mDocSm->createElement("double");
        dble.appendChild(mDocSm->createTextNode(
                val.writeToString().c_str()));
        QDomElement el = mDocSm->createElement("initial_value");
        el.appendChild(dble);
        var.appendChild(el);
    } else {
        QDomNode init_value = initList.at(0);
        init_value = var.toElement().elementsByTagName("double").at(0);
        if (init_value.nodeName() == "double") {
            QDomText dbleval = init_value.childNodes().item(0).toText();
            dbleval.setData(val.writeToString().c_str());
        }
    }
}
Exemplo n.º 2
0
void
check_user_value(vle::value::Value& to_check)
{
    EnsuresEqual(to_check.getType(), vle::value::Value::USER);

    auto& user = to_check.toUser();
    EnsuresEqual(user.getType(), vle::value::Value::USER);
    EnsuresEqual(user.id(), 15978462u);

    test::MyData* mydata = dynamic_cast<test::MyData*>(&user);
    Ensures(mydata);

    if (not mydata)
        return;

    EnsuresEqual(mydata->x, 1.);
    EnsuresEqual(mydata->y, 2.);
    EnsuresEqual(mydata->z, 3.);
    EnsuresEqual(mydata->name, "test-vle");
}
Exemplo n.º 3
0
 static bool performs_one_test(const std::string& precision,
         const std::string& valExpected, vv::Value& res)
 {
     if (precision == "NA") {
         if (res.toString().value() != valExpected) {
             return false;
         }
     } else {
         double prec = boost::lexical_cast<double>(precision);
         double valSim = res.toDouble().value();
         if (std::isnan(valSim)) {
             return (valExpected == "nan");
         }
         double valExpect = boost::lexical_cast<double>(valExpected);
         if ((valSim < valExpect - prec) || (valSim > valExpect + prec)) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
void
vleSmDT::setPortCondValue(const QString& portName,
                          const vle::value::Value& val)
{
    QDomNode port = nodeCondPort(portName);
    if (port.isNull()) {
        return;
    }

    QDomElement dble = mDocSm->createElement("double");
    dble.appendChild(mDocSm->createTextNode(
                         val.writeToString().c_str()));
    port.appendChild(dble);
}
Exemplo n.º 5
0
 void date(const vle::value::Value& val)
 {
     yesterday = today;
     today = val.toDouble().value();
 }
Exemplo n.º 6
0
 void y(const vv::Value& value)
 {
     ladybird_population = value.toDouble().value();
 }
Exemplo n.º 7
0
 void x(const vv::Value& value)
 {
     plantlouse_population = value.toDouble().value();
 }