Dependencies:   PinDetect mbed Servo

actions.cpp

Committer:
Rufaida
Date:
2012-06-18
Revision:
0:81f78497df4e

File content as of revision 0:81f78497df4e:

#include "actions.h"
int call_to_top=0;
int call_to_bottom=0;
/*The action for stopping the motor and starting the ding at bottom*/
void act_stop_motor_ding_bottom (void) {
    motor(stopped,0);
    start_ding ();
    state = st_Wait_For_Ding_Bottom;
}
/*The action for stopping the motor and starting the ding at top*/
void act_stop_motor_ding_top (void) {
    motor (stopped,0);
    start_ding ();
    state = st_Wait_For_Ding_Top;
}
/*action for closing and opening the doors at bottom*/
void act_open_close_Bottom_door (void) {
    Open_Close_Door (0);
    state = st_Wait_For_door_Bottom;

}
/*action for closing and opening the doors at top*/
void act_open_close_Top_door (void) {
    Open_Close_Door (1);
    state = st_Wait_For_door_Top;

}
/*action slowing the speed of the motor to bottom switch*/
void act_slow_speed_down (void) {
    motor(down_slow,1000);
    state = st_Wait_For_Bottom;
}
/*action slowing the speed of the motor to top switch*/
void act_slow_speed_up (void) {
    motor(up_slow,1000);
    state = st_Wait_For_Top;
}
/*action to ramp motor to full speed down*/
void act_ramp_motor_down (void) {
    motor(down_full,2000);
    state = st_Going_Bottom;
}
/*action to ramp motor to full speed up*/
void act_ramp_motor_up (void) {
    motor(up_full,2000);
    state = st_Going_Up;
}
/*action when the lift is at bottom and doors are closed*/
void act_bottom_close (void) {
    state = st_At_Bottom_Closed;
    call_to_bottom=0;
    if (call_to_top) {
        state = st_Going_Up;
        motor(up_full,2000);
    }
}
/*action when the lift is at top and doors are closed*/
void act_top_close (void) {
    state = st_At_Top_Closed;
    call_to_top=0;
    if (call_to_bottom) {
        state = st_Going_Bottom;
        motor(down_full,2000);
    }
}
/*action for doing nothing*/
void do_nothing (void) {
}
/*slowing down the speed and moving the lift to bottom after hitting the safety switch*/
void act_slow_to_dowm (void) {
    motor(down_slow,0);
    state = st_Wait_For_Bottom_Floor;
    printf("act_slow_to_dowm   ");
}