示例#1
0
    virtual std::unique_ptr<value::Value>
    observation(const devs::ObservationEvent &ev) const override
    {
        if (ev.onPort("c")) {
            if (m_counter > 100 and m_counter < 500)
                return {};
            return value::Double::create(m_counter);
        }

        if (ev.onPort("value"))
            return value::Integer::create(0);

        return {};
    }
示例#2
0
    virtual std::unique_ptr<value::Value>
    observation(const devs::ObservationEvent &ev) const override
    {
        if (ev.onPort("nbmodel"))
            return value::Integer::create(get_nb_model());

        if (ev.onPort("structure")) {
            std::ostringstream out;
            coupledmodel().writeXML(out);
            return value::String::create(out.str());
        }

        if (ev.onPort("adjacency_matrix")) {
            auto set = value::Set::create();
            set->toSet().add(value::Integer::create(1));
            if (get_nb_model() > 0 and ev.getTime() < 50.0) {
                set->toSet().add(value::String::create("add"));
                std::string name =
                    (boost::format("MyBeep_%1%") % m_stacknames.size()).str();
                set->toSet().add(value::String::create(name));
                set->toSet().add(value::String::create("2"));
                std::string edge = name + std::string(" counter ");
                set->toSet().add(value::String::create(edge));
            }
            else if (get_nb_model() > 0) {
                set->toSet().add(value::String::create("delete"));
                std::string name =
                    (boost::format("MyBeep_%1%") % (get_nb_model())).str();
                set->toSet().add(value::String::create(name));
            }

            return set;
        }

        if (ev.onPort("value"))
            return value::Integer::create(1);

        return devs::Executive::observation(ev);
    }
示例#3
0
 virtual std::unique_ptr<value::Value> observation(
     const devs::ObservationEvent& e) const override
 {   return e.onPort("date") ?
            value::Double::create(mDate) :
            value::Double::create(mNumber);
 }