Lets say your first button is the inlet water valve, the second starts the engine, the third opens the outlet valve, and the fourth runs a particular seqence.
Your code should contain control functions such as:
ControlInletValve(BOOL on_or_off);
ControlOutletValve(BOOL on_or_off);
ControlEngine((BOOL on_or_off);
In your button event handlers and timer handler, you will have the basic skeleton code like this (you understand this is not compilable code but rather the correct code structure for your problem):
static int phase;
void CBlaBla::OnButtonClickedButton1()
{
ControlInletValve(TRUE); }
void CBlaBla::OnButtonClickedButton2()
{
ControlEngine(TRUE); }
void CBlaBla::OnButtonClickedButton3()
{
ControlOutletValve(TRUE); }
void CBlaBla::OnButtonClickedButton4()
{
phase = 0; }
void CBlaBla::InitTimer()
{
phase = LAST_PHASE;
SetTimer(...);
}
void CBlaBla::OnTimer()
{
switch (phase)
{
case 0:
ControlOutletValve(TRUE);
phase++;
break;
case 1:
ControlInletValve(TRUE);
phase++;
break;
case LAST_PHASE:
break;
}
}