3.3系统软件架构

电梯控制的软件框架由电梯的模式作为主体框架,以完成模式下的功能为驱动进行设计,各个模式的简介如下:

 

故障修理模式:由管理员手动切换,在故障模式下工程人员可以实现对于电梯的故障检修

 

一般运行模式:由管理员手动切换,一般运行模式是电梯的主要模式,完成电梯的主要功能

直接运行模式:由用户切换或者管理员切换,直接运行模式下,电梯可以从当前层面直接到达底层。当出现火宅或者有病人需要急救时可以避免电梯在中间层停靠,以此争取宝贵的时间

 

3.4 系统软件流程

软件的设计是根据状态机的方式实现的,具体的软件框图如下:

 

 

图3   程序运行流程图

 

3.4 系统预计实现结果

一些头文件的申明

一些变量的申明

 

#define repairMode 00

#define generalrunMode 01

#define direcltyrunMode 10

int setModeR_G(int currentMode int premode);   //负责状态之间的切换

int setModeG_R(int currentMode int premode);   //mode为两位变量,由拨码开关在I/O口读入

int setModeG_D(int currentMode int premode); 

int setModeD_G(int currentMode int premode); 

//状态切换会返回置位bool量 modechange

int getmode()    //读取mode的当前的值,并且刷新mode和premode

Void lcd_initialize(void)   //负责显示屏的初始化

Void port_initalize(void)   //负责端口的初始化

Void motor_initalize(void)  //负责电机的初始化

Void lighting_initalize(void)  //负责照明的初始化

Void elevatordoor_initalize(void) //负责电梯门的初始化

Void lcd_display(int temperature);     //负责温度的显示

Void eledoor_allopen();            //电梯门在检修模式下常开

Void eledoor();                    //电梯门在其他两个模式下的运行方式

Void motor_stop();              

int motor_genrun();

int motor_dirrun();               //返回一个Int值dooropen为1,控制电梯门的开启

//电梯在三种模式下的运行方式

Void light_display(int pressure);              //电灯的开关控制

Void communicate();                         //通信方法

Void repair()     //检修模式下的工作方式

{

While(modechange==0)

{  

    Communicate();

        Eledoor_allopen();

        Light_display();

Lcd_display(int temperature);

Int getmode();

If(premode==01&&mode==00)

setModeG_R();

}

}

Void generalrun()    //一般运行模式下的工作方式

{

While(modechange==0)

{

   Communicate();

    Light_display();

Lcd_display(int temperature);

If(premode==01&&mode==00)

setModeG_R();

If(premode==01&&mode==10)

             setModeG_D();

     }

}

Void directlyrun()     //直接运行下的工作方式

{

While(modechange==0)

{

     Communicate();

     Light_display();

Lcd_display(int temperature);

Int getmode();

If(premode==10&&mode==01)

             setModeD_G();

}

}

Void initialize(void)    //负责总体的初始化

{

    currentMode=generalrunMode;

Lcd_initialize();

Port_initialize();

motor_initalize();

lighting_initalize();

elevatordoor_initalize();

}

Int main()

{

     Initialize();

     While(1)

     {

         Switch(currentMode)

         {

               Case repairMode;

                    Repair();

                    Break;

               Case generalrunMode;

                    Generalrun();

                    Break;

               Case directltyrunMode;

                    Directltyrun();

                    Break;

         }

}

}