Dependencies:   PinDetect mbed Servo

Committer:
Rufaida
Date:
Mon Jun 18 17:47:17 2012 +0000
Revision:
0:81f78497df4e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rufaida 0:81f78497df4e 1 #include "actions.h"
Rufaida 0:81f78497df4e 2 int call_to_top=0;
Rufaida 0:81f78497df4e 3 int call_to_bottom=0;
Rufaida 0:81f78497df4e 4 /*The action for stopping the motor and starting the ding at bottom*/
Rufaida 0:81f78497df4e 5 void act_stop_motor_ding_bottom (void) {
Rufaida 0:81f78497df4e 6 motor(stopped,0);
Rufaida 0:81f78497df4e 7 start_ding ();
Rufaida 0:81f78497df4e 8 state = st_Wait_For_Ding_Bottom;
Rufaida 0:81f78497df4e 9 }
Rufaida 0:81f78497df4e 10 /*The action for stopping the motor and starting the ding at top*/
Rufaida 0:81f78497df4e 11 void act_stop_motor_ding_top (void) {
Rufaida 0:81f78497df4e 12 motor (stopped,0);
Rufaida 0:81f78497df4e 13 start_ding ();
Rufaida 0:81f78497df4e 14 state = st_Wait_For_Ding_Top;
Rufaida 0:81f78497df4e 15 }
Rufaida 0:81f78497df4e 16 /*action for closing and opening the doors at bottom*/
Rufaida 0:81f78497df4e 17 void act_open_close_Bottom_door (void) {
Rufaida 0:81f78497df4e 18 Open_Close_Door (0);
Rufaida 0:81f78497df4e 19 state = st_Wait_For_door_Bottom;
Rufaida 0:81f78497df4e 20
Rufaida 0:81f78497df4e 21 }
Rufaida 0:81f78497df4e 22 /*action for closing and opening the doors at top*/
Rufaida 0:81f78497df4e 23 void act_open_close_Top_door (void) {
Rufaida 0:81f78497df4e 24 Open_Close_Door (1);
Rufaida 0:81f78497df4e 25 state = st_Wait_For_door_Top;
Rufaida 0:81f78497df4e 26
Rufaida 0:81f78497df4e 27 }
Rufaida 0:81f78497df4e 28 /*action slowing the speed of the motor to bottom switch*/
Rufaida 0:81f78497df4e 29 void act_slow_speed_down (void) {
Rufaida 0:81f78497df4e 30 motor(down_slow,1000);
Rufaida 0:81f78497df4e 31 state = st_Wait_For_Bottom;
Rufaida 0:81f78497df4e 32 }
Rufaida 0:81f78497df4e 33 /*action slowing the speed of the motor to top switch*/
Rufaida 0:81f78497df4e 34 void act_slow_speed_up (void) {
Rufaida 0:81f78497df4e 35 motor(up_slow,1000);
Rufaida 0:81f78497df4e 36 state = st_Wait_For_Top;
Rufaida 0:81f78497df4e 37 }
Rufaida 0:81f78497df4e 38 /*action to ramp motor to full speed down*/
Rufaida 0:81f78497df4e 39 void act_ramp_motor_down (void) {
Rufaida 0:81f78497df4e 40 motor(down_full,2000);
Rufaida 0:81f78497df4e 41 state = st_Going_Bottom;
Rufaida 0:81f78497df4e 42 }
Rufaida 0:81f78497df4e 43 /*action to ramp motor to full speed up*/
Rufaida 0:81f78497df4e 44 void act_ramp_motor_up (void) {
Rufaida 0:81f78497df4e 45 motor(up_full,2000);
Rufaida 0:81f78497df4e 46 state = st_Going_Up;
Rufaida 0:81f78497df4e 47 }
Rufaida 0:81f78497df4e 48 /*action when the lift is at bottom and doors are closed*/
Rufaida 0:81f78497df4e 49 void act_bottom_close (void) {
Rufaida 0:81f78497df4e 50 state = st_At_Bottom_Closed;
Rufaida 0:81f78497df4e 51 call_to_bottom=0;
Rufaida 0:81f78497df4e 52 if (call_to_top) {
Rufaida 0:81f78497df4e 53 state = st_Going_Up;
Rufaida 0:81f78497df4e 54 motor(up_full,2000);
Rufaida 0:81f78497df4e 55 }
Rufaida 0:81f78497df4e 56 }
Rufaida 0:81f78497df4e 57 /*action when the lift is at top and doors are closed*/
Rufaida 0:81f78497df4e 58 void act_top_close (void) {
Rufaida 0:81f78497df4e 59 state = st_At_Top_Closed;
Rufaida 0:81f78497df4e 60 call_to_top=0;
Rufaida 0:81f78497df4e 61 if (call_to_bottom) {
Rufaida 0:81f78497df4e 62 state = st_Going_Bottom;
Rufaida 0:81f78497df4e 63 motor(down_full,2000);
Rufaida 0:81f78497df4e 64 }
Rufaida 0:81f78497df4e 65 }
Rufaida 0:81f78497df4e 66 /*action for doing nothing*/
Rufaida 0:81f78497df4e 67 void do_nothing (void) {
Rufaida 0:81f78497df4e 68 }
Rufaida 0:81f78497df4e 69 /*slowing down the speed and moving the lift to bottom after hitting the safety switch*/
Rufaida 0:81f78497df4e 70 void act_slow_to_dowm (void) {
Rufaida 0:81f78497df4e 71 motor(down_slow,0);
Rufaida 0:81f78497df4e 72 state = st_Wait_For_Bottom_Floor;
Rufaida 0:81f78497df4e 73 printf("act_slow_to_dowm ");
Rufaida 0:81f78497df4e 74 }