Challenge

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

/*
====================================.h========================================
Name : project1.c
Author : siva perumal
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/

#include<stdio.h>
#include<stdlib.h>
void Init_State_Machine();
void Gear_Down();
void Checking_Before_Takeoff();
void Raising_Gear();
void Gear_up();
void Checking_Before_Landing();
void Lowering_Gear();
typedef enum state
{
GR_DWN,
CHK_BFRTKFF,
RSING_GR,
GR_UP,
CHK_BFR_LND,
LWRNG_GR
}
state_Type;
typedef enum Switch
{
open,
close

}
switch_status;
typedef enum Hydraulic_Mechanism
{
working,
Malfunctioning
}
Hydraulic Mechanism_Status;
static volatile Switch_Status squat_switch;
static volatile Switch_Status limit_Switch;
static volatile pilot_lever__Status pilot_lever;
static volatile Hydraulic_Mechanism_status hydraulic_mechanism;

State_Type current_state;
typedef struct
{
char*current_state_indication;
char*light_status;
char*direction_value_status;
char*hydraulic_pump_control_status;
char*gas_pressurized_spring_status[2];
}
State_Table;

static State_Table State_Machine[6] = {
{"Gear Down", "Green","Down","Enabled", (NULL,NULL}},
["Checking Before Take Off","Green","Down","Enabled", (NULL,NULL}},
{"Raising Gear","Red","Up","Enabled", {"Disabled","Enabled"}},
{"Gear Up","Off","Null","Disabled", {NULL,NULL}},
{"Checking Before Landing","Red","Down","Enabled", (NULL,NULL}},
{"Lowering Gear","Green","Down","Enabled", {"Disabled","Enabled"}}
};
void Gear Down(void)
{
printf("in gear down state\n");
current state = GR DWN;

state GR DWN;
//printf("\nCurrent State: %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position and Squat Switch Status:");
fflush(stdout);
scanf("%d %d",&pilot lever,& squat_switch);
if(pilot_lever Rising && squat_switch ---- Open)
1
}
else
{
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);
Gear_Down();
void Checking Before Takeoff()
{
current state CHK_BFR TKFF:
printf("\nEnter the Pilot's Lever Position,Squat Switch Status and Hydraulic Mechanism Status:");
fflush(stdout);
Malfunctioning)
scanf("%d %d %d",&pilot lever.&squat switch,&hydraulic_mechanism);
printf("\nWait for 2 secs\n");
if(pilot_lever Falling | squat_switch == Close)
Gear Down();
1
else if(pilot_lever-UP && squat_switch Open && hydraulic_mechanism - Working)
{
Status:%s\n\n", State
}
current_state= RSING 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
Machine[current_state].direction_valve_status);
else if(pilot_lever-UP && squat_switch-Open && hydraulic_mechanism
1
current state = RSING_GR;
printf("\nCurrent State:
%s\n",State_Machine[current_state].current_state_indication);
printf("Lightatus: % 1",Stat Machir curren state].lt_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]);
}
pri
void Raising Gear()
{
se racconcin_stancj.ngi status)
current state - RSING_GR;
//printf("\nCurrent State: %s\n", State Machine[current_state].current_state_indication);
printf("\nEnter the Limit Switch Status,Pilots Leaver Status:");
flush(stdout);
scanf("%d %d",&limit_switch,&pilot_lever);
printf("\nWait for 1 sec\n");
if(pilot lever Falling && limit_switch Open)
1
current state-CHK_BFR LND;
printf("\nCurrent State: %s\n",Stare 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 if(limit_switch-Close && pilot_lever-UP)
1
current_state=GR_UP;
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
{
}
}
void Gear Up()
{
}
void
{
Raising_Gear();
current_state = GR_UP;
//printf("Current State: %s\n",State_Machine[current_state].current_state_indication);
printf("\nEnter the Pilot's Lever Position:");
fflush(stdout);
scanf("%d",&pilot lever);
4
if(pilot_lever Falling)
{
Status:%s\n", State Machine[current_state].hydraulic pump_control_status);
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
}
else
{
Gear Up();
Checking_Before_Landing()
current_state=CHK_BFR LND;
void Lowering Gear()
{
current_state= LWRNG_GR;
//printf("\nCurrent State: %s\n", State_Machine[current_state].current_state_indication);
printf("\nEnter the Limit Switch Status, Pilots Leaver Status::");
fflush(stdout);
Checking_Before_Landing();
scanf("%d %d",&limit_switch,&pilot lever);
if(pilot_lever Rising)
{
{
}
if(limit_switch
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);
=
- Open&& pilot_lever- DOWN)
current_state=GR_DWN;
void Init State Machine()
{
}
Lowering Gear();
//System Initialized and its in State A
current_state=GR_DWN;
I
printf("\nState Machine is initialized & Program is in Gear_Down State & Light Status is Green \n");
int main()
{
Init State Machine();
while(1)
{
switch (current_state)
{
case 0: Gear_Down();
break;
case 1: Checking_Before_Takeoff();
break;
case 2: Raising Gear();
ase 3: Gear_Up();
break;
case 4: Checking Before_Landing();
case 5: Lowering_Gear();
break;
default: break;
}
}
}

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.