Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
Overview
In this project, controlling the retraction and extension of Airplane’s landing gear is implemented using Finite State Machine (FSM) concept.
FSM is the most efficient algorithm which is mathematical model of computation.
About Airplane’s landing gear
The purpose of the landing gear in an aircraft is to provide a suspension system during taxi, take-off and landing. It is designed to absorb and dissipate the kinetic energy of landing impact, thereby reducing the impact loads transmitted to the airframe. It also consists of the shock absorber, wheel, brake system, turning system,etc.
Program working
This program taking Pilot,s lever position and Squat Switch Status from end user than according to inputs some of the actions are printed. This program is a mathematical model of working of Airplane’s landing gear.
#include<stdio.h>
typedef enum //Declaring data type to show status of state machine.
{
Steady_state,
Rising_up,
lowering_down,
} Landing_Gear_status; // showing status of landing gear
typedef enum
{
steady,
up,
down,
} Valve_status; //// showing status of Valves
typedef struct
{
Landing_Gear_status arr1[3];
char* state_signal[3];
Valve_status arr3[3];
char* valve[3];
int time;
} State;
State state_machine[2] = {
{{Steady_state,Rising_up,lowering_down},{"Steady_state","Raising_Up","Lowering_down"},{steady,up,down},{"steady_state","Closing","Opening"},10}
};
// Global variables
int current_status;
int pilot_lever_signal;
int squat_switch_signal;
// This function is checking feedback i.e end user inputs.
void plan_status(int a, int b)
{
if(a == 0 && b == 0)
{
printf("Plan is on land\n");
printf("Checking all feedback before take off\n");
}
if(a == 0 && b == 1)
{
printf("Checking all feedback before take off\n");
printf("Pilot lever feedback is 0.Check Pilot lever feedback\n");
}
if(a == 1 && b == 0)
{
printf("Checking all feedback before take off\n");
printf("limiting switch is Disable.Please Enable\n");
}
if(a == 1 && b == 1)
{
printf("Plan is taking off\n");
}
if(a == 2 && b == 0)
{
printf("Checking all feedback before Landing\n");
printf("limiting switch is Disable.Please Enable\n");
}
if(a == 0 && b == 2)
{
printf("Checking all feedback before Landing\n");
printf("Pilot lever feedback is 0.Check Pilot lever feedback\n");
}
if(a == 2 && b == 2)
{
printf("Plan is landing\n");
}
}
int main()
{
current_status = Steady_state;
while(1)
{
printf("Enter Pilot Lever Position and Squat Switch Status\n"); // These two inputs user has to put.
fflush(stdout);
scanf("%d %d",&pilot_lever_signal,&squat_switch_signal);
plan_status(pilot_lever_signal,squat_switch_signal);
// Printing Actions of landing Gear accourding to inputs
if(pilot_lever_signal == 0 && squat_switch_signal == 0)
{
printf("Valve State : %s\n",state_machine[current_status].valve[pilot_lever_signal]);
printf("Time Taken by Landing Gear : %d sec\n",state_machine[current_status].time);
printf("Landing Gear: %s\n",state_machine[current_status].state_signal[pilot_lever_signal]);
}
if(pilot_lever_signal == 1 && squat_switch_signal == 1)
{
printf("Valve State : %s\n",state_machine[current_status].valve[pilot_lever_signal]);
printf("Time Taken by Landing Gear : %d sec\n",state_machine[current_status].time);
printf("Landing Gear: %s\n",state_machine[current_status].state_signal[pilot_lever_signal]);
}
if(pilot_lever_signal == 2 && squat_switch_signal == 2)
{
printf("Valve State : %s\n",state_machine[current_status].valve[pilot_lever_signal]);
printf("Time Taken by Landing Gear : %d sec\n",state_machine[current_status].time);
printf("Landing Gear: %s\n",state_machine[current_status].state_signal[pilot_lever_signal]);
}
}
}
