' break;' newline
}
' default:' newline
' break;' newline
' }' newline
}
' default:
break;
}
button = None; /* follow buttonless transitions */
if (oldState != state) handleEvent();
}'
typedef enum { Start, Running, Stopped, Stop } States;
typedef enum { None, Down, Mode, Up } Buttons;
int state = Start;
int button = None; /* pseudo-button for buttonless transitions */
void runWatch()
{
while (state != Stop)
{
handleEvent();
button = getButton(); /* waits for and returns next
button press */
}
}
void handleEvent()
{
int oldState = state;
switch (state)
{
case Start:
switch (button)
{
case None:
state = Stopped;
break;
default:
break;
}
case Running:
switch (button)
CODE GENERATION FOR WATCH MODELS 219
9.6 THE DOMAIN FRAMEWORK
From the point of view of the DSM environment, the domain framework consists of
everything below the code generator: the hardware, operating system, programming
languages and software tools, libraries, and any additional components or
code on top of these. However, in order to understand the set of requirements for
the framework to meet the needs of a complete DSM environment, we have to
separate the domain-speci?¬?c parts of the framework from the general platformrelated
parts.
break;
case Down:
stopTime = startTime - startTime;
break;
case Up:
startTime = sysTime - stopTime;
}
break;
}
button = None; /* follow transitions that do not require
buttons */
if (oldState != state) handleEvent();
icon (1, stopwatch);
state = Running;
break;
default:
break;
}
default:
case Up:
stopTime = sysTime - startTime;
icon (0, stopwatch);
state = Stopped;
break;
case Mode:
state = Stop;
break;
default:
break;
}
case Stopped:
switch (button)
{
case Mode:
state = Stop;
{
220 DIGITAL WRISTWATCH
In many cases, the demarcation between the platform and the domain-speci?¬?c part
of the framework remains unclear.
Pages:
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401