Ejemplo n.º 1
0
 virtual void externalTransition(
     const devs::ExternalEventList&  event ,
     const devs::Time& time)
 {
     for (vd::ExternalEventList::const_iterator it = event.begin();
          it != event.end(); ++it) {
         if ((*it)->onPort("surveillance")) {
             Intervention newIntervention;
             value::Map infNodes = (*it)->getMapAttributeValue("infectedNodes");
             for (vv::MapValue::const_iterator node = infNodes.begin();
                  node != infNodes.end(); node++) {
                 m_nodeStates[node->first] = node->second->toString().value();
                 newIntervention.second.push_back(node->first);
             }
             newIntervention.first = time.getValue() + m_delay;
             m_interventions.push_back(newIntervention);
             if (m_phase == IDLE)
                 m_phase = CONTROL;
             /*
             else {
                 vle::utils::InternalError error(
                     "\nControler must recieve only one surveillance repport in this version\n");
                 throw error;
                 }
             */
         }
     }
     m_current_time = time.getValue();
 }
Ejemplo n.º 2
0
void Moore::externalTransition(const devs::ExternalEventList& events,
			       devs::Time /* time */)
{
    // mNewStates.clear();
    if (events.size() > 1) {
        devs::ExternalEventList sortedEvents = select(events);
        devs::ExternalEventList* clonedEvents =
            new devs::ExternalEventList;
        devs::ExternalEventList::const_iterator it = sortedEvents.begin();

        while (it != sortedEvents.end()) {
            clonedEvents->emplace_back(it->getPortName());
            devs::ExternalEvent& e = clonedEvents->back();
            copyExternalEventAttrs(*it, e);
            ++it;
        }
        mToProcessEvents.push_back(clonedEvents);
    } else {
        devs::ExternalEventList::const_iterator it = events.begin();
        devs::ExternalEventList* clonedEvents =
            new devs::ExternalEventList;
        clonedEvents->emplace_back(it->getPortName());
        devs::ExternalEvent& e = clonedEvents->back();
        copyExternalEventAttrs(*it, e);
        mToProcessEvents.push_back(clonedEvents);
    }
    mPhase = PROCESSING;
}
Ejemplo n.º 3
0
void Agent::externalTransition(
    const devs::ExternalEventList& events,
    const devs::Time& time)
{
    mCurrentTime = time;

    for (devs::ExternalEventList::const_iterator it = events.begin();
            it != events.end(); ++it) {
        const std::string& port((*it)->getPortName());
        const value::Map& atts = (*it)->getAttributes();

        if (port == "ack") {
            const std::string& activity(atts.getString("name"));
            const std::string& order(atts.getString("value"));

            if (order == "done") {
                setActivityDone(activity, time);
            } else if (order == "fail") {
                setActivityFailed(activity, time);
            } else {
                throw utils::ModellingError(
                    fmt(_("Decision: unknown order `%1%'")) % order);
            }
        } else {
            value::Map::const_iterator jt = atts.value().find("value");
            if (jt == atts.end()) {
                jt = atts.value().find("init");
            }

            if (jt == atts.end() or not jt->second) {
                throw utils::ModellingError(
                    fmt(_("Decision: no value in this message: `%1%'")) %
                    (*it));
            }

            if (mPortMode) {
                applyFact(port, *jt->second);
            } else {
                const std::string& fact((*it)->getStringAttributeValue("name"));
                applyFact(fact, *jt->second);
            }
        }
    }

    mState = UpdateFact;
}
Ejemplo n.º 4
0
 void externalTransition(const devs::ExternalEventList& event,
                                 devs::Time time) override
 {
     last_wake_up_time = time;
     a = event.begin()->attributes()->toDouble().value();
 }