Challenge

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

/*
 * main.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */
#include "states.h"

static void (*state_table[])(void) = {Gear_Down, Checking_Before_Takeoff, Raising_Gear,
		                             Gear_Up, Checking_Before_Landing, Lowering_Gear};

int main()
{
	Init_State_Machine();
	while(1)
	{
		state_table[current_state]();
		break;
	}
}
/*
 * Gear_up.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */

#include "states.h"

void Gear_Up()

{
	current_state = GR_UP;

	printf("enter the pilot lever position: ");
	fflush(stdout);
	scanf("%d",&pilot_lever);
	if(pilot_lever == Falling)
	{
		current_state = CHK_BFR_LND;
		printf("\nCurrent state: %s\n", State_Machine[current_state].current_state_indication);
		printf("light status : %s\n",State_Machine[current_state].light_status);
		printf("hydraulic control for landing gear status: %s\n",State_Machine[current_state].hydraulic_pump_control_status);

	}
	else
	{
		Gear_Up();
	}
}
/*
 * checking_before_landing.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */

#include "states.h"

void Checking_Before_Landing()
{
	current_state = CHK_BFR_LND;

	printf(" Enter the pilot lever position and status of hydraulic mechanism:");
	fflush(stdout);
	scanf("%d %d",&pilot_lever,&hydraulic_mechanism);
	if(pilot_lever == DOWN && hydraulic_mechanism == Working)
	{
		current_state = LWRNG_GR;
		printf("Current state : %s\n",State_Machine[current_state].current_state_indication);
		printf("light is :%s\n",State_Machine[current_state].light_status);
		printf("direction valve status: %s\n",State_Machine[current_state].direction_valve_status);
	}
	else if(pilot_lever == DOWN && hydraulic_mechanism == Malfunctioning)
	{
		current_state = LWRNG_GR;
		printf("\nCurrent state : %s\n",State_Machine[current_state].current_state_indication);
		printf("light status:%s\n",State_Machine[current_state].light_status);
		printf("direction valve status: %s\n",State_Machine[current_state].direction_valve_status);
		printf("Gas Pressurized Spring System Status: %s\n",State_Machine[current_state].gas_pressurized_spring_status[hydraulic_mechanism]);

	}
	if(pilot_lever == (UP || Rising || Falling))
	{
		Checking_Before_Landing();
	}
}


/*
 * lowering_gear.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */

#include "states.h"

void Lowering_Gear()
{
	current_state = LWRNG_GR;

	printf("Enter the limit switch status,pilot leaver status:");
	fflush(stdout);
	scanf("%d %d", &limit_switch, &pilot_lever);
	if(pilot_lever == Rising)
	{
		current_state = CHK_BFR_TKFF;
		printf("\nCurrent state : %s\n", State_Machine[current_state].current_state_indication);
		printf("light status: %s\n", State_Machine[current_state].light_status);
	}
	if (limit_switch == Open)
	{
		current_state = GR_DWN;
		printf("Current state :%s\n",State_Machine[current_state].current_state_indication);
		printf("light status :%s\n",State_Machine[current_state].light_status);
		printf("hydraulic control for landing gear status: %s\n",State_Machine[current_state].hydraulic_pump_control_status);

	}
	if(limit_switch == Close)
	{
		Lowering_Gear();
	}
}
/*
 * gear_down.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */
#include "states.h"

void Gear_Down(void)
{
	current_state = GR_DWN;

	printf("\nEnter the pilot lever position and squat switch status: ");
	fflush(stdout);
	scanf("%d %d",&pilot_lever, &squat_switch);
	if(pilot_lever == Rising && squat_switch ==Open)
	{
		current_state = CHK_BFR_TKFF;
		printf("Current state : %s\n",State_Machine[current_state].current_state_indication);
		printf("light is  : %s\n", State_Machine[current_state].light_status);

	}
	else
	{
		Gear_Down();
	}
}
/*
 * init_state_machine.c
 *
 *  Created on: 23-Apr-2022
 *      Author: sakth
 */

#include "states.h"

void Init_State_Machine()

{

    current_state = GR_DWN;
	printf("\nState Machine is initialized & program is in gear_down state &light status: %s\n",
			State_Machine[current_state].light_status);
}

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.

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.