Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
source code:
#include <stdio.h>
#include <stdlib.h>
int stp(int grdwn1,int chk_bf_tkff1,int rsg_gr1,int gr_up1,int chk_bf_ldg1,int lwg_gr1);
void rigr();
int static pl,sw,dv,ls,hd;
typedef enum state{
grdwn ,// 0
chk_bf_tkff ,//1
rsg_gr ,//2
gr_up,//3
chk_bf_ldg,//4
lwg_gr//5
} flsts;
typedef enum ssqt{
open,
close
} ssqt;
typedef enum pilot_lever{
raising,
falling
} plr;
typedef enum hyd_mec{
working,
notworking,
} hdsts;
typedef enum divl{
up,
down,
} divl;
void grdwnd(){
printf("\nGear downed");
stp(0,0,0,0,0,0);
}
void chk_bf_tf(){
printf("\nchecking before Take-off with Delay of 3 secs ");
printf("\nLights green");
stp(1,1,0,0,0,0);
printf("\nEnter the Pilot Lever status Direction valve and squat switch :- ");
scanf("%d %d %d",&pl,&dv,&sw);
if(pl == raising || dv == up){
rigr();
}
else if(sw == close || pl == falling){
grdwnd();
}
}
void lwg_ger(){
printf("\nLowering the gear now ");
stp(1,0,0,0,0,5);
printf("\nEnter the status of piolet lever and limit switch:- ");
scanf("%d %d",&pl,&ls);
if(pl == raising ){
chk_bf_tf();
}
else if(ls == open){
printf("\n Light is Green ");
grdwnd();
}
}
void chk_bf_lg(){
printf("\nChecking before landing\n Lights are RED");
stp(1,0,0,0,4,0);
printf("\nEnter the status of pilot lever and directionn valve:- ");
scanf("%d %d",&pl,&dv);
if(pl == falling && dv == down){
lwg_ger();
}
}
void grup(){
printf("\nFlight Gear is UP Lights are off");
stp(1,0,0,3,0,0);
printf("\nEnter the status of Piolet lever and hydraulic :- ");
scanf("%d %d",&pl,&hd);
if(pl == falling && hd == working){
chk_bf_lg();
}
}
void rigr(){
printf("\nRaising the Gear Lights are RED");
stp(1,0,2,0,0,0);
printf("\nEnter the status of Limit switch,Hydraulic,piolet lever:- ");
scanf("%d %d %d",&ls,&hd,&pl);
if(ls == close || hd == notworking){
grup();
}
else if(pl == falling){
chk_bf_lg();
}
}
void Intilaization(){
printf("\nThe airpalne crusing system enabled, The Fligth is on Ground\n");
}
int main(){
Intilaization();
while(1){
printf("\nEnter the state of Pilot's Lever and Squatt switch:- ");
scanf("%d %d",&pl,&sw);
if(pl==raising && sw == open){
chk_bf_tf();
}
}
}
int stp(int grdwn1,int chk_bf_tkff1,int rsg_gr1,int gr_up1,int chk_bf_ldg1,int lwg_gr1){
if(grdwn == grdwn1){
printf("\nTHE FLIGHT IS oN GROUND!\nSQUAT SWITCH CLOSED::PIOLT'S LEVER FALLING");
}
else if(chk_bf_ldg1==chk_bf_ldg){
printf("\nPIOLT'S LEVER RAISING::SQAUT SWITCH OPENED::GREEN LIGHT");
}
else if(rsg_gr1==rsg_gr){
printf("\nPIOLT'S LEVER UP::DIRECTION VALVE UP::RED LIGHT");
}
else if(gr_up1 == gr_up){
printf("\nLIMIT SWITCH CLOSED::LIGHTS OFF::HYDRAULIC DISABLED");
}
else if(chk_bf_ldg1==chk_bf_ldg){
printf("\nPIOLT'S LEVER FALLING::HYDRAULIC ENABLED::RED LIGHT");
}
else if(lwg_gr1==lwg_gr){
printf("\nPIOLT'S LEVER DOWN::DIRECTION VALVE DOWN");
}
}
output:
