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 using Finite State Machine (FSM)
Overview of the Project: (5 to 6 lines)
In this project, controlling the retraction and extension of Airplane’s landing gear can be implemented using Finite State Machine (FSM). FSM is the most efficient algorithm which is mathematical model of computation.
Goals ( 2 to 3 points)
Controlling the direction of Valve.
Controlling the retraction and extension of Airplane’s landing gear.
Key Highlights of the Project: (4 to 5 points)
A direction valve is controlled by the software to allow the hydraulic pressure to either raise or lower the landing gear.
Deliverables of this project: (4 to 5 points)
Implementing the control for the retraction and extension of Airplane’s landing gear using the Finite state machine with the knowledge of various states of switch and gear.
Expected Outcomes: (4 to 5 points)
The student will be getting the Knowledge of Finite State Machine algorithm which is used to achieve the control over the retraction and extension of Airplane’s landing gear using the switch and gear states of Airplane.
Answer
Overview
In this project, the retraction and extension of an airplane’s landing gear are controlled using a Finite State Machine (FSM). FSM is an efficient algorithm that acts as a mathematical model of computation, ideal for managing the different states and transitions of the landing gear system. This project ensures reliable and accurate control, improving the safety and performance of the airplane's landing gear mechanism. By implementing FSM, the system can efficiently handle various conditions and transitions involved in the operation of the landing gear.
Goal
1. Controlling the Direction of the Valve: Ensure precise manipulation of the valve's direction to manage the flow of hydraulic fluid necessary for landing gear operation.
2. Controlling the Retraction and Extension of Airplane’s Landing Gear: Implement accurate control mechanisms to safely retract and extend the landing gear, improving overall safety and performance during takeoff and landing.
Key Highlights of the Project
· Valve Control: Software manages the direction valve to regulate hydraulic pressure for raising or lowering the landing gear.
· Finite State Machine (FSM): Utilizes FSM for efficient state management and transitions of the landing gear system.
· Safety and Reliability: Ensures precise control over landing gear operations, enhancing safety during takeoff and landing.
· Hydraulic System Integration: Seamlessly integrates with the aircraft's hydraulic system for optimal performance.
· Real-Time Monitoring: Provides real-time monitoring and control to handle various operational conditions of the landing gear.
Deliverables of this project
1. FSM Implementation: Develop and implement a Finite State Machine to control the retraction and extension of the airplane's landing gear.
2. State Management: Define and manage various states of the switch and gear for accurate control.
3. Software-Controlled Valve Operation: Ensure the software precisely controls the direction valve to regulate hydraulic pressure.
4. System Integration: Integrate the FSM with the aircraft's hydraulic and control systems for seamless operation.
5. Testing and Validation: Conduct thorough testing and validation to ensure reliable and safe landing gear operations.
Expected Outcomes
Practical Application: Learn how to apply FSM to control the retraction and extension of an airplane's landing gear.
State Management: Acquire knowledge about managing different states of switches and gears in aircraft systems.
Software-Hardware Integration: Develop skills in integrating software control with hydraulic and mechanical systems.
Safety and Reliability: Understand the importance of safety and reliability in aviation control systems.
Code
#include <iostream>
using namespace std;
string lights, lever;
void setLightsRed() {
lights = "Red";
}
void setLightsGreen() {
lights = "Green";
}
void setLightsOff() {
lights = "Off";
}
string getLights() {
return lights;
}
void setLeverUp() {
lever = "Up";
}
void setLeverDown() {
lever = "Down";
}
string getLever() {
return lever;
}
string takeOff() {
if (getLights() != "Red")
return "Can't take off because lights are not red\n";
setLeverUp();
setLightsOff();
return "Take Off Success\n";
}
string landing() {
if (getLights() != "Green")
return "Can't land because lights are not Green\n";
setLeverDown();
return "Landing Success\n";
}
int main() {
setLightsRed();
cout << takeOff();
setLightsGreen();
cout << landing();
return 0;
}
Output:
Explanation
Initialization: The lights and lever variables are initialized to control the landing gear's lights and lever.
Functions: Functions are defined to set and get the status of lights and lever.
FSM Operations: The takeOff and landing functions implement the FSM logic for controlling the landing gear based on the lights' status.
Main Function: Demonstrates a simple sequence of setting lights to red for takeoff and then to green for landing.
Detailed Explanation of the Code
This code simulates the control of an airplane’s landing gear using a Finite State Machine (FSM). It consists of functions to manage the state of the landing gear lights and lever, and to perform takeoff and landing operations based on these states.
1. Global Variables
string lights, lever;
lights: Represents the status of the landing gear lights.
lever: Represents the position of the landing gear lever.
2. Functions to Control Lights
setLightsRed: Sets the lights to "Red".
setLightsGreen: Sets the lights to "Green".
setLightsOff: Turns the lights "Off".
getLights: Returns the current state of the lights.
void setLightsRed() {
lights = "Red";
}
void setLightsGreen() {
lights = "Green";
}
void setLightsOff() {
lights = "Off";
}
string getLights() {
return lights;
}
3. Functions to Control Lever
setLeverUp: Sets the lever position to "Up".
setLeverDown: Sets the lever position to "Down".
getLever: Returns the current position of the lever.
void setLeverUp() {
lever = "Up";
}
void setLeverDown() {
lever = "Down";
}
string getLever() {
return lever;
}
4. Takeoff Function
Checks if the lights are "Red".
If lights are "Red", sets the lever to "Up" and turns off the lights.
Returns a message indicating success or failure.
string takeOff() {
if (getLights() != "Red")
return "Can't take off because lights are not red\n";
setLeverUp();
setLightsOff();
return "Take Off Success\n";
}
5. Landing Function
Checks if the lights are "Green".
If lights are "Green", sets the lever to "Down".
Returns a message indicating success or failure.
string landing() {
if (getLights() != "Green")
return "Can't land because lights are not Green\n";
setLeverDown();
return "Landing Success\n";
}
6. Main Function
Sets the lights to "Red" and attempts to take off.
Sets the lights to "Green" and attempts to land.
Outputs the results of takeoff and landing.
int main() {
setLightsRed();
cout << takeOff();
setLightsGreen();
cout << landing();
return 0;
}
This code demonstrates a simplified model of controlling an airplane's landing gear system using an FSM approach, emphasizing safety and state management.