// TElevator.h: interface for the TElevator class.
//
//////////////////////////////////////////////////////////////////////
#include "TBaseObject.h"

#if !defined(AFX_TELEVATOR_H__F5571804_3988_11D6_85F8_0000E87713C4__INCLUDED_)
#define AFX_TELEVATOR_H__F5571804_3988_11D6_85F8_0000E87713C4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define ELEVATOR_XDISTANCE 22
#define ELEVATOR_GROUP_DISTANCE 25
#define ELEVATOR_WIDE      10
#define ELEVATOR_HEIGHT    15
#define ELEVATOR_YCONST    18
#define MAX_FLOOR_NUMBER   28
#define LENGTH_EXTRAS      5

#define OPEN_DOORS_STOP_STEPS 4

enum TDoorsState
{
   ELEV_DOORS_STATE_CLOSE = 0,
   ELEV_DOORS_STATE_OPEN
};

enum TElevState
{
   ELEV_STATE_STOP = 0,
   ELEV_STATE_MOVING_UP,
   ELEV_STATE_MOVING_DOWN
};

enum TElevTask
{
   ELEV_TASK_STOP = 0,
   ELEV_TASK_UP,
   ELEV_TASK_DOWN
};

enum TElevCmd
{
   ELEV_CMD_STOP = 0,
   ELEV_CMD_UP,
   ELEV_CMD_DOWN
};

enum TElevDoorsCmd
{
   ELEV_DOORS_CMD_NONE = 0,
   ELEV_DOORS_CMD_OPEN,
   ELEV_DOORS_CMD_CLOSE
};

class TElevator : public TBaseObject
{
	int number;
	int floorNumbers;

   int floor;   
   
   int buttons[MAX_FLOOR_NUMBER];

// состояние лифта
   int doorsState;
   int state;
   int task;

   int cmd;
   int doorsCmd;

// вспомогательные 
   
   int openDoorsCount;

   int movedFloorsNumber;
   int stepNumber;  
   
public:
   
   int  getMovedFloorsNumber(){ return movedFloorsNumber; }
   int  getStepNumber() { return stepNumber; }
   void setMovedFloorsNumber( int m ){ movedFloorsNumber = m; }
   void setStepNumber( int m ){ stepNumber = m; }

	void draw( CDialog *wnd, CPaintDC *dc );
   TElevator() : floor(1) { movedFloorsNumber = 1; }
	TElevator( int begNumber, int floorNumbers, int begFloor = 1 ); 
	virtual ~TElevator();

   void setFloorNumbers(int fn) {floorNumbers = fn;}
   void setNumber(int n) {number = n;}
   void setFloor(int f) {floor = f;}

   int getFloor() { return floor; }

   int getDoorsState() const { return doorsState; }
   int getState() const { return state; }
   int getTask() const { return task; }
   int getCmd() const { return cmd; }

   void reset();

// интерфейс кнопок
   int  checkButton( int floor ) { return buttons[floor-1]; }
   void pressButton( int floor );
   void unpressButton( int floor ) { buttons[floor-1] = 0; }

   int  checkButtons();
	int  getLowerFloor();
	int  getUpperFloor();

// движение лифта
   void step();

// интерфейс управления лифта
   void setTask( int taskP ) { task = taskP; }
   void setCmd( int cmdP ) { cmd = cmdP; }
   void setDoorsCmd( int doorsCmdP ) { doorsCmd = doorsCmdP; }
};

#endif // !defined(AFX_TELEVATOR_H__F5571804_3988_11D6_85F8_0000E87713C4__INCLUDED_)
