|
DEMOS programs are written in a
process oriented discrete event style.
Consider the classic first example:
A port has 2 jetties each of which can be used
for unloading by one
boat at a time. Boats arrive at the port periodically and
must wait if no jetty is currently free. When a jetty is available,
a boat may dock and start to unload. When this activity
has been completed, the boat leaves the jetty and sails
away. The port authority has a pool of 3 tugs. Two are required for
docking: only one when a boat leaves its jetty.
This model would be written in Demos
as follows:
class boat=
{getR(jetties,1);
getR(tugs,2);
hold(2.0);
putR(tugs,2);
hold(14.0);
getR(tugs,1);
hold(2.0);
putR(tugs,1);
putR(jetties,1);
} (***boat***)
Res(tugs, 3);
Res(jetties, 2);
Entity(boat,boat,0.0);
Entity(boat,boat,1.0);
Entity(boat,boat,15.0);
hold(36.0);
Close;
|