Challenge

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

#include

typedef enum state
{
Gear_Down_State,
Checking_before_Take_off_Delay_3s_State,
Raising_Gear_State,
Gear_Up_State,
Checking_before_landing_State,
Lowering_Gear_State,
}state_type;
typedef enum switch_state
{
on,
off
}switch_status;
typedef enum pilot_lever
{
raising,
falling

}pilot_lever ;

typedef enum hydraulic_mechanism
{
working,
not_working

}hydraulic_mechanism;

static volatile switch_status squart_switch;
static volatile switch_status limit_switch;
static volatile pilot_lever pilote_lever;
static volatile hydraulic_mechanism hydrauli_mechanism;

state_type current_state;

typedef struct
{
   char* surrent_state_indication;
   char* light;
   char* direction_valve_status;
   char* gas_pressurized_spring_system_ststus[2];
   char* landing_gear_hydraulic_control;

}state_table;

static state_table state_machine[6]=
										{{"GearDown","Green","Down","Enable",{NULL,NULL}}
										{"Checking_before_Take_off_Delay_3s_State","Green","Down","Enable",{NULL,NULL}}
										{"Raising_Gear_State","Red","Up","Enable",{"Disable","Enable"}}
										{"Gear_Up_State","off","NULL","Disable",{NULL,NULL}}
										{"Checking_before_landing_State","red","Down","Enable",{NULL,NULL}}
										{"Lowering_Gear_State","Green","Down","Enable",{"Disable","Enable"}};



int man()
{
  initiate_state_machine();
	while(1)
	{
		state_table state_machine[current_state];

	}


	}
void Gear_Down(void)
{

    current_state= Gear_Down_State;
	printf("Enter the status of pilot's lever and squat switch and:");
	fflush(stdout);
	scanf("%d%d",&pilot_lever, &squat_switch);
	if(pilot_lever ==raising && squat_switch==on)
	{
		        current_state=Checking_before_Take_off_Delay_3s_State;
				printf("current state:%s\n", State_Machine[current_state].current_state_indication);
				printf("light is :%s\n", State_Machine[current_state].light);

	}
	else
	{

		Gear_Down();-+
		
	}

void CheckingBeforeTakeOFF (void)

{
current_state= Checking_before_Take_off_Delay_3s_State;
printf("Enter the status of pilot's lever and squat switch and hydraulic mechanism:");
fflush(stdout);
scanf("%d%d",pilot_lever, &squat_switch,&hydraulic_mechanism);
if (pilot_lever==falling & squat_switch==off)
{
Gearbown();
}
else if(pilot_lever==raising && squat_switch==on && hydraulic_mechanism== working)
{
	current_state= Raising_Gear_State

;
printf("current state:%s\n", State_Machine[current_state].current_state_indication);
printf("light is :%s\n", State_Machine[current_state].light);
printf("Status of Direction valve :%s\n",State_Machine[current_state].direction_valve_status);

}
else if(pilot_lever== raising && squat_switch==on & hydraulic_mechanisn== not_working)
{
        current_state=Raising_Gear_State;
		printf("current state:%s\n", State_Machine[current_state].current_state_indication);
		printf("light is :%s\n", State_Machine[current_state].light);
		printf("Status of Direction valve :%s\n",State_Machine[current_state].direction_valve_status);
}
}

int Raising_Gear()
{
	current_state= Raising_Gear_State;
	printf("Enter the status of pilot's lever and squat switch and hydraulic mechanism:");
	fflush(stdout);
	scanf("%d%d",&pilot_lever, &limit_switch);
	if(pilot_lever ==falling && limit_switch==on)
	{
		        current_state=Checking_before_landing_State;
				printf("current state:%s\n", State_Machine[current_state].current_state_indication);
				printf("light is :%s\n", State_Machine[current_state].light);
				printf("landing gear hydraulic control :%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
	}
	else if(pilot_lever ==raising && limit_switch==off)
	{
         current_state=Gear_Up_State;
printf("current state:%s\n", State_Machine[current_state].current_state_indication);
printf("light is :%s\n", State_Machine[current_state].light);
printf("landing gear hydraulic control:%s\n",State_Machine[current_state].landing_gear_hydraulic_control);

	}
	else
	{

		Raising_Gear();
	}
}
int Gear_UP()
	{
	current_state= Gear_Up_State;
	printf("Enter the status of pilot's lever and squat switch and hydraulic mechanism:");
	fflush(stdout);
	scanf("%d",&pilot_lever);
	if(pilot_lever ==falling )
	{
	current_state=Checking_before_landing_State;
	printf("current state:%s\n", State_Machine[current_state].current_state_indication);
	printf("light is :%s\n", State_Machine[current_state].light);
	printf("landing gear hydraulic control :%s\n",State_Machine[current_state].landing_gear_hydraulic_control);
   }
	else
	{
	Gear_UP();
	}

}
void checkingBeforelanding()
{
	        current_state= Checking_before_landing_State;
			printf("Enter the status of pilot's lever  and hydraulic mechanism:");
			fflush(stdout);
			scanf("%d %d",&pilot_lever,&hydraulic_mechanism);
			if(pilot_lever ==falling && hydraulic_mechanism==working)
			{
			current_state=Lowering_Gear_State;
			printf("current state:%s\n", State_Machine[current_state].current_state_indication);
			printf("light is :%s\n", State_Machine[current_state].light);
			printf("Status of Direction valve  :%s\n",State_Machine[current_state].direction_valve_status);
         }
		else if(pilot_lever==raising && squat_switch==on && hydraulic_mechanism== working)
		{


			current_state=Lowering_Gear_State;
			printf("current state:%s\n", State_Machine[current_state].current_state_indication);
			printf("light is :%s\n", State_Machine[current_state].light);
			printf("Status of Direction valve  :%s\n",State_Machine[current_state].direction_valve_status);

			printf("Status of gas presserised spring system  :%s\n",State_Machine[current_state].gas_pressurized_spring_system_ststus);
		}
		if(pilot_lever==(raising || falling ))
		{
			checkingBeforelanding();
		}
}

void loweringGear()
{

	    current_state= Lowering_Gear_State;
		printf("Enter the status of pilot's lever and squat switch and hydraulic mechanism:");
		fflush(stdout);
		scanf("%d%d",&pilot_lever,&limit_switch);
		if(pilot_lever ==raising && limit_switch==on )
		{
		current_state=Checking_before_Take_off_Delay_3s_State;
		printf("current state:%s\n", State_Machine[current_state].current_state_indication);
		printf("light is :%s\n", State_Machine[current_state].light);

	   }
		if(pilot_lever ==raising && limit_switch==off)
		{

		current_state=Gear_Down_State;
		printf("current state:%s\n", State_Machine[current_state].current_state_indication);
		printf("light is :%s\n", State_Machine[current_state].light);
		printf("light is :%s\n", State_Machine[current_state].light);
		printf("landing gear hydraulic control :%s\n", State_Machine[current_state]. landing_gear_hydraulic_control);

		}
		if(limit_switch==off)
		{
			loweringGear();
		}
}

void initiate_state_machine()
{


	        current_state=Gear_Down_State;
printf("the finite state machine is initikised and current the program is in gear dowm :%s\n", State_Machine[current_state].light);



}
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.