----------------------------------------------- -- Class: Environment -- Description: Environment class in the VeMo project -----------------------------------------------
public Environment: seqofchar ==> Environment
Environment(filename) ==
(
city := new City();
def mk_(-,input) = io.freadval[InputTP](filename) in
(
inlines := input;
);
--BuildCityMap();
);
private BuildCityMap : () ==> ()
BuildCityMap() ==
( dcl a : Busstop, b : Busstop, c : Busstop, d : Busstop, e : Busstop, f :Busstop; dcl wp1 : Waypoint, wp2 : Waypoint, wp3 : Waypoint, wp4 : Waypoint;
a := city.addBusstop(<A>);
b := city.addBusstop(<B>);
c := city.addBusstop(<C>);
d := city.addBusstop(<D>);
e := city.addBusstop(<E>);
f := city.addBusstop(<F>);
public Events: () ==> ()
Events() ==
( if inlines <> [] then
( dcl done : bool := false,
eventOccurred : bool := false,
curtime : Types`Time := World`timerRef.GetTime();
whilenot done do
( def event = hd inlines in cases event:
mk_Types`BusRoute(-,-,-) ->
( if event.t <= curtime then
(
Printer`OutWithTS("Environment: Bus route "
^ Printer`natToString(event.ID));
let b = city.addBus(event.ID, event.route) in
(
Printer`Out("Waypoints:"); let wps = b.GetWaypoints() in let wpsIds = [wp.GetId() | wp inseq wps] in
IO`print(wpsIds);
Printer`Out("\nStops:");
let wps = b.GetStops() in let wpsIds = [wp.GetId() | wp inseq wps] in
IO`print(wpsIds);
Printer`Out("\n");
if simulating then
( start(b);
);
);
eventOccurred := true;
)
),
mk_Types`Inflow(-,-) ->
( if event.t <= curtime then
(
SetInflow(event.flow);
eventOccurred := true;
)
),
mk_Types`Simulate(-) ->
( if event.t <= curtime then
( ifnot simulating then
(
Printer`OutWithTS("Environment: "
^ "Simulation started");
simulating := true; start(city);
city.WaitForThreadStart(); forall bus inset city.getBuses() do
( start(bus);
bus.WaitForThreadStart();
);
);
eventOccurred := true;
)
),
mk_Types`WasteTime(-) ->
( if event.t <= curtime then
(
Printer`OutWithTS("Environment: Wasting time");
eventOccurred := true;
)
), others -> Printer`OutWithTS("Environment: No match found") end;
if eventOccurred then
(
inlines := tl inlines;
done := len inlines = 0;
) else
done := true;
sync per isFinished => not busy; mutex(handleEvent)
end Environment
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.17Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.