Sink中如何获取serviceTime?
How to obtain serviceTime in Sink?
我在处理消息时需要在Sink中模拟使用serviceTime。我怎样才能恢复它?我正在尝试不同的方式,但没有奏效。例如,以与服务器组件检索值相同的方式恢复,但出现错误:
Sink.h
Job *jobServiced;
Sink.cc
void Sink::handleMessage(cMessage *msg)
{
jobServiced = check_and_cast<Job *>(msg);
simtime_t serviceTime = par("serviceTime");
在尝试此选项之前,我没有获得正确的值来获取服务时间和服务率的平均值:
sink.cc
void Sink::handleMessage(cMessage *msg)
{
num_jobs++;
serviceTime = (serviceTime + job->getTotalServiceTime())/num_jobs;
serviceRate= (1/serviceTime);
}
void Sink::finish()
{ recordScalar("ServiceTime", serviceTime);
recordScalar("ServiceRate", serviceRate);
}
我得到:
Service Time Service Rate
0.50 1.99
0.43 2.29
0.25 3.99
0.11 8.49
0.10 9.38
0.05 17.815
0.13 7.403
0.003 30.485
在运行中,有一点我得到一个错误无法将 1.0336e+007 转换为 simtime_t:超出比例指数 -12 允许的范围 (-922337203685477)。
谢谢
...
看看Sink.cc:
void Sink::handleMessage(cMessage *msg)
{
Job *job = check_and_cast<Job *>(msg);
// gather statistics
emit(lifeTimeSignal, simTime()- job->getCreationTime());
emit(totalQueueingTimeSignal, job->getTotalQueueingTime());
emit(queuesVisitedSignal, job->getQueueCount());
emit(totalServiceTimeSignal, job->getTotalServiceTime());
emit(totalDelayTimeSignal, job->getTotalDelayTime());
emit(delaysVisitedSignal, job->getDelayCount());
emit(generationSignal, job->getGeneration());
if (!keepJobs)
delete msg;
}
这就是可以访问作业中所有累积统计信息的方式。即使用:
job->getTotalServiceTime()
我在处理消息时需要在Sink中模拟使用serviceTime。我怎样才能恢复它?我正在尝试不同的方式,但没有奏效。例如,以与服务器组件检索值相同的方式恢复,但出现错误: Sink.h
Job *jobServiced;
Sink.cc
void Sink::handleMessage(cMessage *msg)
{
jobServiced = check_and_cast<Job *>(msg);
simtime_t serviceTime = par("serviceTime");
在尝试此选项之前,我没有获得正确的值来获取服务时间和服务率的平均值:
sink.cc
void Sink::handleMessage(cMessage *msg)
{
num_jobs++;
serviceTime = (serviceTime + job->getTotalServiceTime())/num_jobs;
serviceRate= (1/serviceTime);
}
void Sink::finish()
{ recordScalar("ServiceTime", serviceTime);
recordScalar("ServiceRate", serviceRate);
}
我得到:
Service Time Service Rate
0.50 1.99
0.43 2.29
0.25 3.99
0.11 8.49
0.10 9.38
0.05 17.815
0.13 7.403
0.003 30.485
在运行中,有一点我得到一个错误无法将 1.0336e+007 转换为 simtime_t:超出比例指数 -12 允许的范围 (-922337203685477)。
谢谢
...
看看Sink.cc:
void Sink::handleMessage(cMessage *msg)
{
Job *job = check_and_cast<Job *>(msg);
// gather statistics
emit(lifeTimeSignal, simTime()- job->getCreationTime());
emit(totalQueueingTimeSignal, job->getTotalQueueingTime());
emit(queuesVisitedSignal, job->getQueueCount());
emit(totalServiceTimeSignal, job->getTotalServiceTime());
emit(totalDelayTimeSignal, job->getTotalDelayTime());
emit(delaysVisitedSignal, job->getDelayCount());
emit(generationSignal, job->getGeneration());
if (!keepJobs)
delete msg;
}
这就是可以访问作业中所有累积统计信息的方式。即使用:
job->getTotalServiceTime()