The environment classis the class responsible for read a file containing inputs labelled bytimeand deliver them to the correct system sensor at the right time. It also collects the (re)actions from the systemand provides functionality to enable the inspection of them.
\begin{vdm_al} class Environment issubclassof GLOBAL, BaseThread
types public InputTP = (Time * seqof Inpline) inv inp == forall line insetelems inp.#2 & inp.#1 >= line.#4;
public Inpline = (Sense * Chamber * ActivityData * Time);
-- Amount of time we want to simulate
simtime : Time;
\end{vdm_al}
Then we define the sensors attachment place where the physician will screw the leads and where the accelerometer isset up.
\begin{vdm_al} instancevariables -- Sensors
-- Leads
leads : map Chamber to Lead := {|->};
-- Accelerometer
accelerometer : Accelerometer;
\end{vdm_al}
The environment constructor reads the test file which name is provided in the variable fname, extracting the amount oftime we want to simulate and the inputs in that amount oftime.
The isFinished operation is redefined and blocks until the simulation is finished because of a permission predicate defined below.
\begin{vdm_al} public
isFinished: () ==> ()
isFinished () == skip;
public Step: () ==> ()
Step() ==
(if busy then createSignal();
if World`timerRef.GetTime() >= simtime then (Pacemaker`heartController.finish();
Pacemaker`rateController.finish()
);
);
\end{vdm_al}
The Run function it's substituted by a thread definition.
\begin{vdm_al} --thread -- ( -- while true do -- ( if busy -- then createSignal(); -- if World`timerRef.GetTime() >= simtime -- then (Pacemaker`heartController.finish(); -- Pacemaker`rateController.finish()); -- World`timerRef.WaitRelative(1); -- );
-- );
\end{vdm_al}
Because of the concurrency introduction handleEvent and showResult that both manipulate the outlines instance variable are made mutex. The operation isFinished is released just when the Environment isnot busy (no more inputs tobe delivered) and the whole amount of simulation timeisequal or above the desired.
\begin{vdm_al} sync
mutex (handleEvent,showResult);
per isFinished => not busy;
end Environment
\end{vdm_al}
¤ Dauer der Verarbeitung: 0.1 Sekunden
(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.