⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppsink.cpp

📁 very beautifull programm test for onmet++
💻 CPP
字号:
//
// This file is part of an OMNeT++/OMNEST simulation example.
//
// Copyright (C) 1992-2005 Andras Varga
//
// This file is distributed WITHOUT ANY WARRANTY. See the file
// `license' for details on this and other legal matters.
//


#include <omnetpp.h>


/**
 * Packet sink; see NED file for more info.
 */
class PPSink : public cSimpleModule
{
  private:
    cStdDev qstats;
    cOutVector qtime;

  protected:
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);
    virtual void finish();
};

Define_Module( PPSink );

void PPSink::initialize()
{
    qstats.setName("queuing time stats");
    qtime.setName("queueing time vector");
}

void PPSink::handleMessage(cMessage *msg)
{
    // update statistics and delete message
    double d = simTime()-msg->timestamp();
    ev << "Received " << msg->name() << ", queueing time: " << d << "sec" << endl;
    qstats.collect( d );
    qtime.record( d );
    delete msg;

    // update status string above icon
    char txt[32];
    sprintf(txt, "received: %ld", qstats.samples());
    displayString().setTagArg("t",0, txt);
}

void PPSink::finish()
{
    ev << "Total jobs processed: " << qstats.samples() << endl;
    ev << "Avg queueing time:    " << qstats.mean() << endl;
    ev << "Max queueing time:    " << qstats.max() << endl;
    ev << "Standard deviation:   " << qstats.stddev() << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -