Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Void Init_State_Machine();
- void Gear_Down();
- void Checking_Before_Takeoff();
- void Raising_Gear();
- void Gear_Up();
- void Checking_Before_Landing();
- void Lowering_Gear();
ENUM
|
State_Type |
Switch States |
Hydraulic_Mechanism_status |
|
|
SQUAT AND LIMIT SWITCH |
Pilot _Lever Status |
||
|
State_Type |
Open,….0 |
Rising,…0 |
Malfunctioning,..1 |
|
GR_DWN,..0 |
Close,..1 |
Falling,..1 |
Working..0 |
|
CHK_BFR_TKFF,1 |
Up,..2 |
||
|
RSING_GR,2 |
DOWN…3 |
||
|
GR_UP,3 |
|||
|
CHK_BFR_LND,4 |
|||
|
LWRNG_GR..5 |
#include "States.h"
#include
void Checking_Before_Landing()
{
current_state = CHK_BFR_LND;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position and Status of Hydraulic Mechanism:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&hydraulic_mechanism);
if(pilot_lever == DOWN && hydraulic_mechanism == Working)
{
current_state = LWRNG_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_valve_status);
}
else if(pilot_lever == DOWN && hydraulic_mechanism == Malfunctioning)
{
current_state = LWRNG_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_valve_status);
printf("Gas Pressurized Spring System Status:%s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
if(pilot_lever == (UP || Rising || Falling))
{
Checking_Before_Landing();
}
}
1) GEAR DOWN
#include
#include "States.h"
void Gear_Down(void)
{
current_state = GR_DWN;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position and Squat Switch Status:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&squat_switch);
if(pilot_lever == Rising && squat_switch == Open)
{
current_state = CHK_BFR_TKFF;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
}
else
{
Gear_Down();
}
}
2)Checking_Before_Takeoff
#include
#include "States.h"
void Checking_Before_Takeoff()
{
current_state = CHK_BFR_TKFF;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:");
fflush(stdout);
scanf("%d %d %d",&pilot_lever,&squat_switch,&hydraulic_mechanism);
printf("\nWait for 2 secs\n");
if(pilot_lever == Falling || squat_switch == Close)
{
Gear_Down();
}
else if(pilot_lever == UP && squat_switch == Open && hydraulic_mechanism == Working)
{
current_state = RSING_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n\n",State_Machine[current_state].direction_valve_status);
}
else if(pilot_lever == UP && squat_switch == Open && hydraulic_mechanism == Malfunctioning)
{
current_state = RSING_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_valve_status);
printf("Gas Pressurized Spring System Status:%s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
}
3) Raising _Gear
#include
#include "States.h"
void Raising_Gear()
{
current_state = RSING_GR;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Limit Switch Status,Pilots Leaver Status:");
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever);
printf("\nWait for 1 sec\n");
if(pilot_lever == Falling && limit_switch == Open)
{
current_state = CHK_BFR_LND;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else if(limit_switch == Close && pilot_lever == UP)
{
current_state = GR_UP;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Raising_Gear();
}
}
4) Gear UP
#include
#include "States.h"
void Gear_Up()
{
current_state = GR_UP;
//printf("Current State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position:");
fflush(stdout);
scanf("%d",&pilot_lever);
if(pilot_lever == Falling)
{
current_state = CHK_BFR_LND;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Gear_Up();
}
}
5) Checking Before Landing :
#include "States.h"
#include
void Checking_Before_Landing()
{
current_state = CHK_BFR_LND;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position and Status of Hydraulic Mechanism:");
fflush(stdout);
scanf("%d %d",&pilot_lever,&hydraulic_mechanism);
if(pilot_lever == DOWN && hydraulic_mechanism == Working)
{
current_state = LWRNG_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_valve_status);
}
else if(pilot_lever == DOWN && hydraulic_mechanism == Malfunctioning)
{
current_state = LWRNG_GR;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Direction Valve Status:%s\n",State_Machine[current_state].direction_valve_status);
printf("Gas Pressurized Spring System Status:%s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);
}
if(pilot_lever == (UP || Rising || Falling))
{
Checking_Before_Landing();
}
}
6) Lowering Gear
#include
#include "States.h"
void Lowering_Gear()
{
current_state = LWRNG_GR;
//printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Limit Switch Status,Pilots Leaver Status::");
fflush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever);
if( limit_switch == Close && pilot_lever == Rising )
{
current_state = CHK_BFR_TKFF;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
}
if(limit_switch == Open && pilot_lever == DOWN)
{
current_state = GR_DWN;
printf("\nCurrent State : %s\n",State_Machine[current_state].current_state_indication);
printf("Light Status:%s\n",State_Machine[current_state].light_status);
printf("Hydraulic Control for Landing Gear Status:%s\n",State_Machine[current_state].hydraulic_pump_control_status);
}
else
{
Lowering_Gear();
}
}
Init_ State Machine
#include
#include "States.h"
void Init_State_Machine()
{
//System Initialized and its in State_A
current_state = GR_DWN;
printf("\nState Machine is initialized & Program is in Gear_Down State & Light Status : %s\n"
,State_Machine[current_state].light_status);
}
RUN AS:
State Machine is initialized & Program is in Gear_Down State & Light Status : Green
Enter the Pilot's Lever Position and Squat Switch Status:0 0
Current State : Checking Before Take Off
Light Status:Green
Enter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:1
2
3
Wait for 2 secs
Enter the Pilot's Lever Position and Squat Switch Status:4