Question

Your supervisor has assigned you to build a finite state machine (FSM) in C code to control the operation of a gas pump. You

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Following is the custom type created using the keyword typedef in C. If the combination of these states and triggered event match, the corresponding event handler is called..

//Different states of Gas Pump using typedef


typedef enum
{
Idle_State,
Payment_Card_Verifying_State,
Payment_Approved,
Payment_Denied,
Nozzle_Removed,
Waiting_Grade_Selection,
Pumping,
Finalizing_Transaction,
Emergency
}sysState;

//Prototype of event handlers
sysState IdleStateHandler(void)
{
return Idle_State;
}
sysState PaymentCardVerifyingStateHandler(void)
{
return Payment_Card_Verifying_State;
}

sysState PaymentApprovedHandler(void)
{
return Payment_Approved;
}

sysState PaymentDeniedHandler(void)
{
return Payment_Denied;
}

sysState NozzleRemovedHandler(void)
{
return Nozzle_Removed;
}

sysState WaitingGradeSelectionHandler(void)
{
return Waiting_Grade_Selection;
}
sysState PumpingHandler(void)
{
return Pumping;
}
sysState FinalizingTransactionHandler(void)
{
return Finalizing_Transaction;
}
sysState EmergencyHandler(void)
{
return Emergency;
}   

Add a comment
Know the answer?
Add Answer to:
Your supervisor has assigned you to build a finite state machine (FSM) in C code to control the o...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT