本文整理汇总了C++中vle::devs::ExternalEventList类的典型用法代码示例。如果您正苦于以下问题:C++ ExternalEventList类的具体用法?C++ ExternalEventList怎么用?C++ ExternalEventList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExternalEventList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output
virtual void output(vle::devs::Time /*time*/,
vle::devs::ExternalEventList &output) const override
{
output.emplace_back("out");
output.back().addMap().addDouble("value",
static_cast<double>(m_neighborhood));
}
示例2: out
void out(const vle::devs::Time& /*time*/, vle::devs::ExternalEventList& output) const
{
output.emplace_back("a");
value::Map& map = output.back().addMap();
map.addString("name","a");
map.addDouble("value",a+3);
}
示例3: externalTransition
void externalTransition(
const vle::devs::ExternalEventList& events,
const vle::devs::Time& time)
{
vle::devs::ExternalEventList::const_iterator it = events.begin();
while (it != events.end()) {
if ((*it)->onPort("available")) {
bool available =
(*it)->getBooleanAttributeValue("available");
unsigned int number =
(*it)->getIntegerAttributeValue("number");
std::string type = (*it)->getStringAttributeValue("type");
if (available) {
mAvailableResourceNumber += number;
} else {
mUnavailableResources[type] =
mResourceConstraints->quantity(type) - number;
}
++mResponseNumber;
TraceModel(
vle::fmt(" [%1%:%2%] at %3% -> available: %4% / %5%")
% getModel().getParentName() % getModelName() %
time % mAvailableResourceNumber %
mResourceConstraints->quantity());
if (mAvailableResourceNumber ==
mResourceConstraints->quantity()) {
mPhase = SEND_ASSIGN;
} else {
if (mResponseNumber == mResourceConstraints->size()) {
clearDemand();
mPhase = SEND_UNAVAILABLE;
} else {
mPhase = WAIT_AVAILABLE;
}
}
} else if ((*it)->onPort("demand")) {
mResourceConstraints =
ResourceConstraints::build(Resources::get(*it));
TraceModel(vle::fmt(" [%1%:%2%] at %3% -> demand: %4%") %
getModel().getParentName() % getModelName() %
time % mResourceConstraints->quantity());
mPhase = SEND_DEMAND;
} else if ((*it)->onPort("release")) {
mReleasedResources = Resources::build(Resources::get(*it));
TraceModel(vle::fmt(" [%1%:%2%] at %3% -> release: %4%") %
getModel().getParentName() % getModelName() %
time % *mReleasedResources);
mPhase = SEND_RELEASE;
}
++it;
}
}
示例4: externalTransition
void externalTransition(
const vle::devs::ExternalEventList& events,
const vle::devs::Time& time)
{
vle::devs::ExternalEventList::const_iterator it = events.begin();
while (it != events.end()) {
if ((*it)->onPort("start")) {
if (mPhase == INIT) {
mActivities.starting(time);
if (mActivities.startingActivities().empty()) {
mPhase = WAIT;
} else {
mPhase = SEND;
}
}
} else if ((*it)->onPort("done")) {
Activity* a = Activity::build(Activity::get(*it));
TraceModel(vle::fmt(" [%1%:%2%] at %3% -> %4% DONE") %
getModel().getParentName() % getModelName() %
time % a->name());
mDoneActivities.push_back(a);
}
++it;
}
if (mSigma > 0) {
mSigma -= (time - mLastTime);
mLastTime = time;
}
}
示例5: 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());
}
}
}
示例6: output
void output(vd::Time time, vd::ExternalEventList& output) const override
{
if (m_has_output_port) {
const double out_val = m_val + m_trend * time;
output.emplace_back(m_output_port_label);
output.back().addMap().addDouble("d_val", out_val);
}
}
示例7: output
virtual void output(vd::Time /*time*/,
vd::ExternalEventList &output) const override
{
if (m_has_output_port) {
output.emplace_back(m_output_port_label);
auto& m = output.back().addMap();
m.addDouble("up", m_upthreshold);
m.addDouble("down", m_downthreshold);
}
}
示例8: out2
void out2(const vle::devs::Time& /* time */, vle::devs::ExternalEventList& output) const
{
vle::devs::ExternalEvent* e = new vle::devs::ExternalEvent("g");
e->attributes().addString("name","g");
e->attributes().addDouble("value",0);
output.push_back(e);
e = new vle::devs::ExternalEvent("b");
e->attributes().addString("name","b");
e->attributes().addDouble("value",0);
output.push_back(e);
}
示例9: out1
void out1(const vle::devs::Time& /*time*/, vle::devs::ExternalEventList& output) const
{
output.emplace_back("g");
value::Map& map = output.back().addMap();
map.addString("name","g");
map.addDouble("value",10);
output.emplace_back("b");
value::Map& map2 = output.back().addMap();//TODO pas compris error qaund ion utilise la meme ref map (sur unique_ptr<Value>)
map2.addString("name","b");
map2.addDouble("value",10);
}
示例10: externalTransition
void XRay::externalTransition(
const vd::ExternalEventList& event,
const vd::Time& time)
{
if (mPhase == RECEIVE) {
if (!mapResult.empty())
mapResult.clear();
for (vd::ExternalEventList::const_iterator it = event.begin();
it != event.end(); ++it) {
double randValue = rand().getDouble();
if ((*it) -> getPortName() == "status") {
std::string value =
(*it)-> getStringAttributeValue ("value");
std::string modelName =
(*it)-> getStringAttributeValue ("modelName");
if (value == "S" || value == "R") {
// probability of a wrong interpretation
if (randValue > mProbabilityRightSR) {
value = "I";
}
} else if (value == "I") {
if (randValue > mProbabilityRightI) {
value = "S";
}
}
mapResult[modelName] = value;
}
}
mCurrentTime = vd::Time(time);
int nbInfected = 0;
//int nbNonInfected = 0;
std::map<std::string, std::string>::iterator node;
for (node=mapResult.begin(); node!=mapResult.end();node++){
if (node->second == "I")
nbInfected++;
//else
// nbNonInfected++;
}
//std::cout<<"xray recieve: "<<nbNonInfected<<" non infecteds and: "<< nbInfected
// <<" infecteds at time: "<<time.getValue()<<"\n";
double tempPrev = ((double) nbInfected) / mSampleSize;
//std::cout<<"tempPrev: "<<tempPrev<<"\n";
mIncidence = (tempPrev - mPrevalence)/mObservationTimeStep;
mPrevalence = tempPrev;
}
}
示例11: outputVar
/**
* @brief Output function that fills the value of state variables
* @param time, time of the output
* @param extEvtList, the list of external event
*/
void outputVar(const vd::Time& /*time*/,
vd::ExternalEventList& extEvtList) const
{
Variables::const_iterator itb = vars().begin();
Variables::const_iterator ite = vars().end();
for (; itb != ite; itb++) {
const Variable& v = *itb->second;
if (getModel().existOutputPort(itb->first)) {
extEvtList.emplace_back(itb->first);
value::Double& val = extEvtList.back().addDouble();
val = v.getVal();
}
}
}
示例12: treat
void treat(const std::string& /*name*/, const ved::Activity& /*activity*/,
vd::ExternalEventList& output)
{
output.emplace_back("x");
value::Map& m = output.back().addMap();
m.addString("name","x");
m.addDouble("value",
plantlouse_population * (1-treatment_effect_on_plantlouse));
output.emplace_back("y");
value::Map& m2 = output.back().addMap();
m2.addString("name","y");
m2.addDouble("value",
ladybird_population * (1-treatment_effect_on_ladybird));
}
示例13: output
virtual void output(const vle::devs::Time &time,
vle::devs::ExternalEventList &output) const
{
(void)time;
DTraceModel(vle::fmt("CompareDateAI: output at %1%") % time);
if (date.empty() || index >= date.size())
return;
auto low = std::lower_bound(date.begin() + index, date.end(),
(*(date.begin() + index)).dmin,
[] (const data& d, vle::devs::Time value)
{
return d.dmin <= value;
});
DTraceModel(vle::fmt("CompareDateAI: need to send %1% start message"
" (%2%)") % (std::distance(date.begin() + index,
low)) % index);
std::for_each(date.begin() + index, low,
[&output] (const data& d)
{
vle::devs::ExternalEvent *ret =
new vle::devs::ExternalEvent("start");
ret->putAttribute("specie_name",
new vle::value::String(
d.name));
ret->putAttribute("landunit_id",
new vle::value::Integer(
d.id));
output.push_back(ret);
});
}
示例14: aout
void aout(const std::string& /*name*/, const vmd::Activity& activity,
vd::ExternalEventList& out)
{
if (activity.isInStartedState()) {
out.emplace_back("out");
}
}
示例15: aout
void aout(const std::string& /*name*/, const vmd::Activity& activity,
vd::ExternalEventList& out)
{
if (activity.isInStartedState()) {
vd::ExternalEvent* evt = new vd::ExternalEvent("out");
out.push_back(evt);
}
}