void Behavior2(){ // bere 20 konvic if (nalozenychKonvic<20 && konvic ){ konvic--; nalozenychKonvic++; scheduleAt(Time()+Uniform(1,2), SLOT(Auto::Behavior2)); // nalozi ji return; } if ( !konvic ) scheduleAt(Time() + 1.0/60.0, SLOT(Auto::Behavior2)); // kazdu sekundu else scheduleAt(Time(), SLOT(Auto::Behavior3)); }
void OMNeTBattery::initialize(int stage) { if(stage == 0) { notificationBoard = NotificationBoardAccess().get(); checkCompatibilityToRadioState(); voltageInVolts = par("voltage"); double capacityInMilliAmpereHours = par("capacity"); capacityInMilliWattSeconds = capacityInMilliAmpereHours * 60 * 60 * voltageInVolts; residualCapacityInMilliWattSeconds = capacityInMilliWattSeconds; energyVectorDelta = par("energyVectorDelta"); lastStoredResidualEnergyInMilliWattSeconds = residualCapacityInMilliWattSeconds; updateInterval = par("updateInterval"); if (updateInterval > 0) { lastUpdateTime = simTime(); publishMessage = new cMessage("Update energy"); publishMessage->setSchedulingPriority(2000); scheduleAt(updateInterval, publishMessage); } else { EV << "Warning: Battery is disabled (updateInterval is <= 0)" << std::endl; } residualEnergyOutVector.setName("energyLevel"); residualEnergyOutVector.record(residualCapacityInMilliWattSeconds); WATCH(residualCapacityInMilliWattSeconds); updateBatteryIcon(); } }
void Behavior3(){ // doba dojeni double time; if (Random()<=0.1) time = Exponential(15); else time = Exponential(8); scheduleAt(Time() + time, SLOT(Krava::Behavior4)); }
void Txc13::initialize() { if (getIndex() == 0) { // Boot the process scheduling the initial message as self message. TicTocMsg13 *msg = generateMessage(); scheduleAt(0.0, msg); } }
void OMNeTBattery::handleMessage(cMessage* message) { if (message->isSelfMessage() == false) { error("Can not handle any external messages"); } updateResidualEnergy(); if(residualCapacityInMilliWattSeconds > 0) { scheduleAt(simTime() + updateInterval, publishMessage); } }
virtual void initialize() override { // Get delay time as random value from exponential distribution as set in omnetpp.ini. //simtime_t delay = par("delayTime"); currentNumber=1; currentNumber=randGenerator.generateNumber(currentNumber); currentUniformValue= Dist.uniformValue(0,1,currentNumber); //Map random number into uniform function simtime_t delay = expDist.expValue(1,currentUniformValue); //Get x where exponential cumulative function is the random value scheduleAt(simTime() + delay, new cMessage("selfmsg")); }
virtual void handleMessage(cMessage *msg) override { delete msg; //simtime_t delay = par("delayTime"); currentNumber=randGenerator.generateNumber(currentNumber); currentUniformValue= Dist.uniformValue(0,1,currentNumber); //Map random number into cumulative function simtime_t delay = expDist.expValue(1,currentUniformValue); //Get x where exponential cumulative function is the random value EV << "Delay expired, sending another message. New delay is: " << delay << endl; // Send out a message to the reciever. send(new cMessage("msg"), "out"); // Schedule a self message after delay. scheduleAt(simTime() + delay, new cMessage("selfmsg")); }
void Txc14::initialize() { // Initialize variables. sentPkgs = 0; receivedPkgs = 0; // Make them observable. WATCH(sentPkgs); WATCH(receivedPkgs); if (getIndex() == 0) { // Boot the process scheduling the initial message as self message. TicTocMsg14 *msg = generateMessage(); scheduleAt(0.0, msg); } }
void Detector::handleMessage(cMessage *msg) { if (msg->arrivedOn("clock")) { // Schedule evaluation just a bit later, so that we have all sketches scheduleAt( simTime() + simtime_t(getParentModule()->par("interval")) * .8, msg); } else if (msg->isSelfMessage()) { evaluateCores(); delete msg; clearReports(); } else if (msg->arrivedOn("graphServerIn")) { updateCores(check_and_cast<CoresUpdate*>(msg)); } else if (msg->arrivedOn("reportsIn")) { updateReports(check_and_cast<Report*>(msg)); } else { delete msg; } }
void SimpleGen::handleMessage(cMessage* msg) { if (msg == event) { // Calculate delay double delay = getDelay(); emit(eventSignal, delay); if (canSendMessage()) { // It's time to send message, so prepare new one and send send(generateMessage(), "out"); } // Send next message after delay scheduleAt(simTime() + delay, event); } else { // This should never happen, but for sure delete delete msg; } }
void Behavior3(){ Release(rampa); nalozeni.Record(Time()-time); scheduleAt(Time()+60, SLOT(Auto::Behavior)); }
void Behavior4(){ konvic++; // dalsi hotova konvice Leave(dojicky, 1); // uvolneni dojicky /* infinite loop */ scheduleAt(Time(), SLOT(Krava::Behavior)); }
void Behavior() { // zivotni cyklus scheduleAt(Time() + Exponential(15*60), SLOT(Krava::Behavior2) ); // 15hod }
void SimpleGen::initialize() { eventSignal = registerSignal("event"); // Start sending messages after 1s scheduleAt(1.0, event); }
void Clock::handleMessage(cMessage *msg) { for (int i = 0; i < gateSize("out"); i++) send(msg->dup(), "out",i); scheduleAt(simTime()+ interval, msg); }
void Clock::initialize() { interval = par("interval"); timer = new cMessage(); scheduleAt(par("waitTime"), timer); }