\begin{vdm_al} class MissileDetector issubclassof GLOBAL, BaseThread
-- the primary task of the MissileDetector is to -- collect all sensor data and dispatch each event -- to the appropriate FlareController
instancevariables
-- maintain a link to each controller
ranges : mapnatto (Angle * Angle) := {|->};
controllers : mapnatto FlareController := {|->}; invdom ranges = dom controllers;
-- collects the observations from all attached sensors
threats : seqof (EventId * MissileType * Angle * Time) := [];
-- status of the missile detector
busy : bool := false
operations
public MissileDetector: [ThreadDef] ==> MissileDetector
MissileDetector(tDef)==
(if tDef <> nil then (period := tDef.p;
isPeriodic := tDef.isP;
);
BaseThread(self);
);
-- addController is only used to instantiate the model public addController: FlareController ==> ()
addController (pctrl) ==
(dcl nid : nat := carddom ranges + 1; atomic
(ranges := ranges munion {nid |-> pctrl.getAperture()};
controllers := controllers munion {nid |-> pctrl}
);
);
-- addThreat is a helper operation to modify the event -- list. currently events are stored first come first served. -- one could imagine using a different ordering instead. public addThreat: EventId * MissileType * Angle * Time ==> ()
addThreat (evid,pmt,pa,pt) ==
(threats := threats ^ [mk_ (evid,pmt,pa,pt)];
busy := true );
-- getThreat is a local helper operation to modify the event list private getThreat: () ==> EventId * MissileType * Angle * Time
getThreat () ==
(dcl res : EventId * MissileType * Angle * Time := hd threats;
threats := tl threats; return res );
public isFinished: () ==> ()
isFinished () == forall id insetdom controllers do
controllers(id).isFinished();
protected Step: () ==> ()
Step() ==
( if threats <> [] then (def mk_ (evid,pmt, pa, pt) = getThreat() in forall id insetdom ranges do def mk_(papplhs, pappsize) = ranges(id) in if canObserve(pa, papplhs, pappsize) then controllers(id).addThreat(evid,pmt,pa,pt);
busy := len threats > 0);
);
sync
mutex (Step);
-- addThreat and getThreat modify the same instance variables -- therefore they need to be declared mutual exclusive mutex (addThreat,getThreat);
-- getThreat is used as a 'blocking read' from the main -- thread of control of the missile detector per getThreat => len threats > 0; per isFinished => not busy
end MissileDetector
\end{vdm_al}
¤ Dauer der Verarbeitung: 0.12 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.