本文整理汇总了C++中vle::devs::ExternalEventList::addEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ ExternalEventList::addEvent方法的具体用法?C++ ExternalEventList::addEvent怎么用?C++ ExternalEventList::addEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vle::devs::ExternalEventList
的用法示例。
在下文中一共展示了ExternalEventList::addEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output
virtual void output(const vd::Time& time, vd::ExternalEventList& output) const {
TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - Output at time : " + time.toString());
//Send event on external port (port "OUT")
vd::ExternalEvent* evt = NULL;
evt = new vd::ExternalEvent("bfalse");
if(evt != NULL)
{
vv::Value* val = Logical_toValue(this->bfalse);
if(val != NULL)
{
evt << vd::attribute("bfalse", val);
output.addEvent(evt);
TraceModel(vu::DateTime::simpleCurrentDate() + " - Output port bfalse is changed to " + val->writeToString() + " at time " + time.toString());
}
}
evt = new vd::ExternalEvent("btrue");
if(evt != NULL)
{
vv::Value* val = Logical_toValue(this->btrue);
if(val != NULL)
{
evt << vd::attribute("btrue", val);
output.addEvent(evt);
TraceModel(vu::DateTime::simpleCurrentDate() + " - Output port btrue is changed to " + val->writeToString() + " at time " + time.toString());
}
}
}
示例2: output
void output(const vle::devs::Time& time,
vle::devs::ExternalEventList& output) const
{
if (mPhase == SEND_LOAD) {
vle::devs::ExternalEvent* ee =
new vle::devs::ExternalEvent("load");
std::cout << time << " - [" << getModelName()
<< "] DECISION LOAD: "
<< mSelectedArrivedTransport->toString() << std::endl;
ee << vle::devs::attribute(
"type",mSelectedArrivedTransport->contentType());
ee << vle::devs::attribute("transport",
mSelectedArrivedTransport->toValue());
output.addEvent(ee);
} else if (mPhase == SEND_DEPART) {
Transports::const_iterator it = mReadyTransports.begin();
std::cout << time << " - [" << getModelName()
<< "] DECISION DEPART: { ";
while (it != mReadyTransports.end()) {
vle::devs::ExternalEvent* ee =
new vle::devs::ExternalEvent("depart");
std::cout << (*it)->id() << " ";
ee << vle::devs::attribute("type", (*it)->contentType());
ee << vle::devs::attribute("id", (int)(*it)->id());
output.addEvent(ee);
++it;
}
std::cout << "}" << std::endl;
}
}
示例3: output
void XRay::output(const vd::Time& /*time*/,
vd::ExternalEventList& output) const
{
if (mPhase == SEND) {
vd::RequestEvent * request = new vd::RequestEvent ("status?");
request << vd::attribute ("modelName", std::string (getModelName()));
output.addEvent (request);
}
if ((mPhase == RECEIVE)and
(getModel().existOutputPort("observations"))) {
vd::ExternalEvent * ev = new vd::ExternalEvent ("observations");
ev << vd::attribute ("value", buildDouble(mPrevalence));
output.addEvent (ev);
}
if ((mPhase == RECEIVE)and
(getModel().existOutputPort("control"))) {
vd::ExternalEvent * ev = new vd::ExternalEvent ("control");
vv::Map* nodeObservations = vv::Map::create();
typedef std::map<std::string, std::string>::const_iterator mapit;
for (mapit it = mapResult.begin(); it != mapResult.end(); it++) {
if (it->second == "I")
nodeObservations->addString(it->first, it->second);
}
ev << vd::attribute ("infectedNodes", nodeObservations);
output.addEvent (ev);
}
if ((mPhase == RECEIVE)and
(getModel().existOutputPort("info_center"))) {
vd::ExternalEvent * ev = new vd::ExternalEvent ("info_center");
vv::Map* nodeObservations = vv::Map::create();
typedef std::map<std::string, std::string>::const_iterator mapit;
for (mapit it = mapResult.begin(); it != mapResult.end(); it++) {
nodeObservations->addString(it->first, it->second);
}
ev << vd::attribute ("nodesStates", nodeObservations);
output.addEvent (ev);
}
if ((mPhase == RECEIVE or mPhase == INIT)
and getModel().existOutputPort("connectTo")) {
vd::ExternalEvent* connectionRequest =
new vd::ExternalEvent("connectTo");
vv::Set linkTo;
std::vector <int> sample;
int i=0;
while (sample.size()<mNbModel) {
sample.push_back(i);
i++;
}
for (int j = 0; j < sample.size(); j++) {
int k = rand().getInt(0,sample.size()-1);
int temp = sample[j];
sample[j]=sample[k];
sample[k]=temp;
}
while (sample.size()>mSampleSize)
sample.pop_back();
for (std::vector<int>::iterator i = sample.begin(); i!=sample.end(); ++i) {
std::string vetName =
mPrefix + "-" + boost::lexical_cast<std::string>(*i);
linkTo.addString(vetName);
}
connectionRequest << vd::attribute("modelName",
std::string (getModelName()));
connectionRequest << vd::attribute("linkTo", linkTo);
output.addEvent(connectionRequest);
}
}