Question:
how is washing machine an event driven application?
2009-05-04 08:53:51 UTC
can you tell me how suitable an event driven language might be to handle this event.
thanks
Three answers:
2009-05-04 09:27:00 UTC
First, it doesn't do anything until a user lifts (or pushes?) the dial. It then has to check the buttons to see what the user wants to do (look at the various settings on the dial).



Second, as the timer goes along (the dial moves) it will hit trigger points. It then has to figure out where the dial is and what the next action is. It could poll the dial to see if it is in the next stage but that would not be very effective.



Third, at any time the user can stop the processing by pulling out the dial. It has to stop what it was doing immediately. The user may push the button in again at a totally different spot.



Fourth, as it fills, spins, etc. it must do so based on current load and settings. It cannot be a fixed value so the washer must trigger based on right volume of water.



Finally, and most important, when the lid opens it has to stop immediately. This can happen at any time so it is best to have a trigger and then the washer react to the trigger.



Basically a washer cannot be designed to assume it will always go through a fixed set of stages. It cannot be designed to assume it will always use the same amout of water (extra clothes can mean less water).
?
2009-05-04 16:30:14 UTC
:-)!

Most things in life are "event driven"...

A washing machine?

Events:

- Door open button pressed;

- level of water reaches the desired level;

- Emptying: water level reaches the minimum

- User turns the "program button"

etc, etc

When "something" happens (an "event"), the program MUST act accordingly, whether it is in the middle of other things...

Take the door open button:

EVENT: user presses the button.

function:

Open_Door_sw()

if (spinning) do nothing

if (waterlevel high) do nothing

if (waterlevel = 0 and not spinning and not heating and temperature < 20 deg C and and and...)

open the door.



You live through "event driven"!

You are watching TV.

The phone rings? You pick it up! YOU are event driven!!!

Event driven means that you interrupt whatever you are doing to RESPOND to an event.

Technically, it is a response to an INTERRUPT (which says what it does: interrupting the current task, and gosh, the phone can be an interrupt pest!)

EDIT: Arnack and the other are explaining "sequential programming", NOT Event Driven. A SEQUENCE of events that happen in a given order. The fact that is can be conditional does not affect the sequence...
Arnak
2009-05-04 16:29:40 UTC
Hi,



If you consider what a washing machine actually qorks you can see that it is governed by events.



First when it starts it needs to load water and soap, (event 1)



Then it has to heat up the water, (event 2)



Then a wash cycle for a set period of time and most washers have a reverse action, (event 3)



Then after a set time, rinse, (event 4)



Now empty the machine, (event 5)



How does that sound?



Arnak


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...