Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 6e1d433a14
Fetching contributors…

Cannot retrieve contributors at this time

77 lines (48 sloc) 2.295 kB
#ifndef ELEVATOR_H
#define ELEVATOR_H
#include <vector>
#include <list>
#include "passenger.h"
#include "instruction.h"
/* 电梯基类 */
class Elevator
{
friend class Controller;
friend class Emulator;
protected:
int pos;
double fpos;
bool doorStatus; /* 0: close, 1: open, 2: in toggle door */
int toggleDoorCounter; /* 计算开/关门已花费时间,用以控制门的状态过渡 */
static int timeToggleDoor; /* 开/关门所需时间 */
static int timeMove; /* 电梯移动所需时间 */
static int capacity; /* 电梯最大容量 */
static int throughput; /* 所有电梯总吞吐量 */
char dir; /* 电梯运动方向 */
static double acceleration; /* 电梯加速度 */
std::list<Passenger*> passengers; /* 电梯内乘客 */
std::list<Instruction*> instructions; /* 电梯现有指令栈 */
double speed;
void Letout();
void Letin(int cancelCode);
void OpenDoor();
void CloseDoor();
public:
void LetThemMove();
Elevator(); /* Constructor */
int Get_pos(); /* Get current position */
double Get_fpos();
static int defaultDir; /* 电梯默认接客方向 */
int Get_nPassenger(); /* Get current passenger number */
char Dir(); /* Get current direction. ^: upwards, v: downwards, -: stopping */
void ToggleDoor(); /* Toggle door's status, open if closed, close if opened */
virtual void Move(); /* 继承具有不同算法的电梯,添加所需的成员及方法,实现自己的 Move, Move 将在主函数中被调用 */
void PushInst(Instruction*); /* 添加指令 */
std::list<Instruction*> *Get_inst();/* 得到指令栈的指针 */
static int AverThrput(); /* Calculate and return AverThrput */
static int Get_capacity(); /* Get method for static member capacity */
void Set_defaultDir(int dir);
int Get_defaultDir();
};
typedef std::vector<Elevator*>::iterator EleIter;
#endif
Jump to Line
Something went wrong with that request. Please try again.