Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
/*
* project 2.c
*
* Created on: Mar 8, 2023
* Author: Bhaskar G
*/
#include
// Defining the data
int leverState; // Pilots lever state
int squatSwitch; // Squat switch state
int directionValve; // Direction valve state
int lightStatus; // Light status
int limitSwitch; // Limit switch state
int gearState; // Gear state
// Function Prototypes
void checkTakeoff();
void checkLanding();
void raiseGear();
void lowerGear();
int main()
{
// Getting the input for the states
printf("Enter the lever state: ");
fflush(stdout);
scanf("%d", &leverState);
printf("Enter the squat switch state: ");
fflush(stdout);
scanf("%d", &squatSwitch);
printf("Enter the limit switch state: ");
fflush(stdout);
scanf("%d", &limitSwitch);
printf("Enter the direction valve state: ");
fflush(stdout);
scanf("%d", &directionValve);
// Checking the state of the gear
if (limitSwitch == 0)
{
gearState = 0; // Gear is up
printf("Gear is up\n");
}
else
{
gearState = 1; // Gear is down
printf("Gear is down\n");
}
// Decision Making
if (squatSwitch == 0)
{
checkTakeoff();
}
else
{
checkLanding();
}
return 0;
}
void checkTakeoff()
{
// Checking the conditions
if (leverState == 1 && squatSwitch == 1)
{
lightStatus = 1; // Lights are green
printf("lights are green\n");
raiseGear();
}
else
{
lightStatus = 0; // Lights are red
printf("lights are red\n");
lowerGear();
}
}
void checkLanding()
{
// Checking the conditions
if (leverState == 0 && squatSwitch == 1)
{
lightStatus = 1; // Lights are green
printf("lights are green\n");
lowerGear();
}
else
{
lightStatus = 0; // Lights are red
printf("lights are red\n");
raiseGear();
}
}
void raiseGear()
{
directionValve = 1; // Direction valve is up
printf("Raising the gear...\n");
}
void lowerGear()
{
directionValve = 0; // Direction valve is down
printf("Lowering the gear...\n");
}
Overview of the Project: (5 to 6 lines):-
In this project, the code for controlling the retraction and extension of an airplane’s landing gear is implemented. The pilot’s lever, squat switch, direction valve, limit switch, and light status are used as input for the code. The gear state is then determined and the decision is made to either raise or lower the gear accordingly. The code then implements the necessary actions to raise or lower the gear and displays the result.
Goals ( 2 to 3 points):-
• Implement the code to control the retraction and extension of an airplane’s landing gear.
• Determine the gear state and make decisions to raise or lower the gear accordingly.
• Display the results of the code.
Key Highlights of the Project: (4 to 5 points):-
• Pilot’s lever, squat switch, direction valve, limit switch and light status are used as input for the code.
• The gear state is determined by the limit switch.
• The code checks the conditions before taking off and landing and displays the appropriate light status.
• The code implements the necessary actions to raise or lower the gear.
• The code displays the results of the code.
Deliverables of this project: (4 to 5 points):-
• Coding for the retraction and extension of an airplane’s landing gear.
• Decision-making algorithm for the code.
• Inputs and outputs of the code.
• Flowchart or diagram of the code.
• Testing and debugging of the code.
Expected Outcomes: (4 to 5 points):-
• Successful implementation of the code for the retraction and extension of an airplane’s landing gear.
• Accurate decision-making algorithm based on the inputs given.
• Appropriate inputs and outputs of the code.
• Flowchart or diagram to represent the logic of the code.
• Error-free code with successful testing and debugging.