const int TIMEOUT = 20;
const int SERVICE = 10;
long ncount = 0;
Facility Box("Box");
Histogram Table("Table", 0, 1, SERVICE+TIMEOUT+1);
class Timeout : public Event {
Process *ptr;
public:
Timeout(
double t, Process *p): ptr(p) {
}
void Behavior() {
delete ptr;
ncount++;
}
};
class Customer : public Process {
double ArrivalTime;
void Behavior() {
Event *timeout = new Timeout(TIMEOUT,this);
Seize(Box);
delete timeout;
Wait(SERVICE);
Release(Box);
Table(Time-ArrivalTime);
}
};
class Generator : public Event {
void Behavior() {
}
};
Print(
"model2-timeout -- SIMLIB/C++ example\n");
Print(
"Number of impatient customers: %d \n", ncount);
Box.Output();
Table.Output();
}
void Activate(Entity *e)
activate entity e
const double & Time
model time (is NOT the block)
void SetOutput(const char *name)
redirects Output(), Print() to file
void Run()
run simulation experiment
int Print(const char *fmt,...)
for Output methods, can be redirected
double Exponential(double mv)
Exponential distribution generator.
void Init(double t0, double t1=SIMLIB_MAXTIME)
Initialize simulator and model time.
const SIMLIB_statistics_t & SIMLIB_statistics
interface to internal run-time statistics structure
Main SIMLIB/C++ interface.
void Output() const
print run-time statistics to output