HI, dear users
I'm writing a new agent and I declared some data member in my AgentDISK.h
...private: double idle_time_disk;...
But when I Make the .o file
And the error message said these variables was not declared
I'm so confused Because in another new Agent written by myself
I used the same way to declared the variables, and it works without any problem.
Did anyone have experience like this?
Here I attached my files
#include "packet.h"
#include "random.h"
#include "ip.h"
#include "AgentDISK.h"
//double idle_time_disk=0.0;
//double total_time_disk=0.0;
//double packet_send_time_disk=0.0;
//double check=0.0;
static class DISKClass : public TclClass {
public:
DISKClass() : TclClass("Agent/AgentDISK") {}
TclObject* create(int, const char*const*) {
return (new AgentDISK());
}
}class_cpu_agent;
AgentDISK::AgentDISK() : Agent(PT_TASK)
{
// double idle_time_disk=0.0;
// AgentDISK::hi=0;
// packet_send_time_disk=0.0;
// total_time_disk=0.0;
// idle_time_disk=0.0;
bind("total_time_disk",&total_time_disk);
bind("idle_time_disk",&idle_time_disk);
bind("check",&check);
}
void AgentDISK::recv(Packet* pkt, Handler*) // å°æªç´éCPUçbusytime
{
double local_time = Scheduler::instance().clock();
printf("recv by disk\n");
if(packet_send_time_disk!=0.0)
{
if(local_time>packet_send_time_disk)
idle_time_disk += local_time-packet_send_time_disk;
}
hdr_task* task=(hdr_task*) hdr_task::access(pkt);
hdr_ip* ip=(hdr_ip*) hdr_ip::access(pkt);
double temp = task->total_time;
// printf("recv disk\n");
double hold_time =Random::exponential(0.2);
temp=temp+hold_time;
check +=temp;
packet_send_time_disk=local_time+hold_time;
printf("daddr is %d\n",ip->daddr());
Scheduler& s =Scheduler::instance();
//double delay = Random::exponential(0.2);
Packet *p = allocpkt();
hdr_task* taskp=(hdr_task*) hdr_task::access(p);
taskp->total_time=temp;
taskp->number=task->number;
Packet::free(pkt);
s.schedule(target_,p,hold_time);
}
#ifndef ns_disk_h
#define ns_disk_h
#include <tclcl.h>
#include "agent.h"
#include "config.h"
#include "packet.h"
#include "timer-handler.h"
#include "app.h"
#include "trafgen.h"
#include "myAgent/AgentCPU.h"
//#include "udp.h"
/*class AgentDISK;
class pkt_timer::public TimerHandler {
public:
pkt_timer[AgentDISK* agent]:TimerHandler()
{
agent_=agent;
}
inline virtual void expire (Event* e);
protected:
AgentDISK* agent_;
}*//*
struct hdr_task {
float execute_time;
int total_time;
int size_;
int number;
int& size() { return size_;}
static int offset_;
inline static int& offset() { return offset_; }
inline static hdr_task* access (const Packet* p) {
return (hdr_task*) p->access(offset_);
}
};*/
class AgentDISK : public Agent {
public:
AgentDISK();
// void send_pkt();
virtual void recv(Packet *, Handler *);
private:
double busy_time_;
double execute_time_;
double execute_time_exp;
double record_packet_Time_;
int npkts_;
};
#endif
#ifndef pkt_task_h_
#define pkt_task_h_
#include <packet.h>
#define HDR_TASK(p) hdr_task::access(p)
struct hdr_task {
double total_time;
double number;
int state;
int size_;
int& size() { return size_;}
static int offset_;
inline static int& offset() { return offset_; }
inline static hdr_task* access (const Packet* p) {
return (hdr_task*) p->access(offset_);
}
};
#endif