Challenge

Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear

/*
* geare.c
*
* Created on: 12-Jan-2023
* Author: Ashtabhuja
*/

#include<stdio.h>

//system state declaration

typedef enum
{

Gear_Leaver_up,
Gear_Leaver_Down,
Plane_Takeoff,
Plane_Landing,

} State_Type;
//State stable declaration

typedef struct

{

char* door[2];
int time;
char* hyrolic_pump[2];
char* Landing[2];
State_Type landing_state[2];
char* current_state_indication[2];


}state;

// State table formation

state state_machine[2]={
{{"CLOSE","OPEN"},1,{"DISABLE","ENABLE"},{"Plane_Takeoff","Plane_Landing"},{Gear_Leaver_up, Gear_Leaver_Down,},{"GEAR_LEAVER_UP","GEAR_LEAVER_DOWN"}},
{{"CLOSE","OPEN"},1,{"DISABLE","ENABLE"},{"Plane_Takeoff","Plane_Landing"},{Gear_Leaver_up, Gear_Leaver_Down,},{"GEAR_LEAVER_UP","GEAR_LEAVER_DOWN"}}

};

State_Type current_state;
static int control_input;

int main()
{
current_state=Gear_Leaver_up;

while(1)
{
printf(" Enter The control_input: ");
fflush(stdout);
scanf("%d", &control_input);
printf("\n Current status : %s",state_machine[current_state].current_state_indication[control_input]);
printf("\n Status Door : %s",state_machine[current_state].door[control_input]);
printf("\n Delay time : %d",state_machine[current_state].time);
printf("\n status of plane : %s",state_machine[current_state].Landing[control_input]);
printf("\n Status of Gear_leaver : %s\n",state_machine[current_state].hyrolic_pump[control_input]);
current_state = state_machine[current_state].landing_state[control_input];

}
}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.