OverviewAllRadars: () ==> map FOId to FO
OverviewAllRadars() == returnmerge {r.getDetectedMap() | r inset radars};
private getDirectionVectors : FOId ==> seqof Vector
getDirectionVectors(id) == let hist = history(id),
p1 = hist(3),
p2 = hist(2),
p3 = hist(1) in return [mk_Vector(p1.coord.X - p2.coord.X,
p1.coord.Y - p2.coord.Y),
mk_Vector(p2.coord.X - p3.coord.X,
p2.coord.Y - p3.coord.Y)] pre id insetdom history andlen history(id) = 3;
public getAltitudeHistory : FOId ==> seqofnat
getAltitudeHistory(id) == let hist = history(id),
lastHist = hist(1,...,2) in return [lastHist(i).altitude | i insetinds lastHist] pre id insetdom history andlen history(id) = 3;
public updateHistory : () ==> ()
updateHistory() ==
(
cleanUpHistory(); forall r inset radars do
(forall fo inset r.getDetected() do
registerHistory(fo);
)
);
private registerHistory : FO ==> ()
registerHistory(fo) ==
(let id = fo.getId() in if id insetdom history then history := history ++ {id |-> addHistory(history(id),
fo.getCoordinates(),
fo.getAltitude())} else history := history munion {id |-> addHistory([],
fo.getCoordinates(),
fo.getAltitude())}
);
private cleanUpHistory : () ==> ()
cleanUpHistory() ==
(let alldetected = dunion {r.getDetected() | r inset radars},
allids = { fo.getId() | fo inset alldetected } in
history := allids <: history
);
functions private addHistory : History * Coordinates * Altitude -> History
addHistory(hist,coord,alt) == iflen hist > 0 then let lastValue = last(hist) in if lastValue = mk_Position(coord,alt) then hist else if(len hist < 3) then hist ^ [mk_Position(coord,alt)] elsetl hist ^ [mk_Position(coord,alt)] else hist ^ [mk_Position(coord,alt)];
private last : History -> Position
last(hist) ==
hist(len hist) prelen hist > 0;
operations
public addRadar : Radar ==> ()
addRadar(r) ==
radars := {r} union radars;
public addObstacle : Obstacle ==> ()
addObstacle(ob) ==
obstacles := {ob} union obstacles;
public findThreats : () ==> ()
findThreats() == let allFOs = dunion { r.getDetected() | r inset radars } in
(forall fo inset allFOs do forall ob inset obstacles do ifnot isFOSafe(ob,fo.getPosition()) then writeObjectWarning(ob,fo) else if fo.getId() insetdom history andlen history(fo.getId()) = 3 then willFObeSafe(ob,fo); forall r inset radars do if r.saturatedRadar() then writeRadarWarning(r)
);
public UpdatesPresent:() ==> ()
UpdatesPresent() ==
busy := true;
functions
public detectedByTwoRadars : setof Radar -> setof FO
detectedByTwoRadars(radars) == dunion {a.getDetected() inter b.getDetected()
| a,b inset radars & a <> b};
public detectedByAllRadars : setof Radar -> setof FO
detectedByAllRadars(radars) == dinter {r.getDetected() | r inset radars};
functions
isFOSafe : Obstacle * Position -> bool
isFOSafe(obs,pos) == let obsloc = obs.getCoordinates(),
secureRange = obs.getSecureRange(),
foloc = pos.coord in
isPointInRange(obsloc,secureRange,foloc) =>
isFOatSafeAltitude(obs.getMSA(),pos);
isFOatSafeAltitude : MinimumSafetyAltitude * Position -> bool
isFOatSafeAltitude(msa,pos) ==
msa <> <NotAllowed> and msa < pos.altitude;
operations
willFObeSafe : Obstacle * FO ==> ()
willFObeSafe(obs,fo) == let pred = isPredictPossible(fo) in forall p inset pred do ifnot isFOSafe(obs,p) then let id = fo.getId(),
cs = fo.getCoordinates(),
alt = fo.getAltitude(),
type = <EstimationWarning>,
msa = obs.getMSA(),
t = time in
(World`env.handleFOWarningEvent(id, cs, alt, type, msa, t); return
) pre fo.getId() insetdom history andlen history(fo.getId()) = 3;
private writeObjectWarning : Obstacle * FO ==> ()
writeObjectWarning(obs,fo) == let id = fo.getId(),
cs = fo.getCoordinates(),
alt = fo.getAltitude(),
type = obs.getType(),
msa = obs.getMSA(),
t = time in
World`env.handleFOWarningEvent(id, cs, alt, type, msa, t);
private writeRadarWarning : Radar ==> ()
writeRadarWarning(r) == let coord = r.getLocation(),
range = r.getRange(),
radWarn = <Saturated>,
num = card r.getDetected(),
t = time in
World`env.handleRadarWarningEvent(coord,range,radWarn,num,t);
private isPredictPossible : FO ==> [setof Position]
isPredictPossible(fo)== let hist = history(fo.getId()) in iflen hist < 3 thenreturnnil elsereturn predictPosition(fo) pre fo.getId() insetdom history ;
private predictPosition : FO ==> setof Position
predictPosition(fo) == let foid = fo.getId(),
vs = getDirectionVectors(foid),
estVec = vectorRotate(vs(1),signedVectorAngle(vs(2),vs(1))),
estAlt = predictAltitude(getAltitudeHistory(foid)),
estCoo = addVectorToPoint(estVec,history(foid)(3)),
estPos = mk_Position(estCoo,estAlt)
in return calculateNeighborhood(estPos) pre fo.getId() insetdom history andlen history(fo.getId()) = 3;
functions private calculateNeighborhood : Position -> setof Position
calculateNeighborhood(pos) ==
{pos,
mk_Position(addVectorToPoint(mk_Vector(2,0),pos),pos.altitude),
mk_Position(addVectorToPoint(mk_Vector(-2,0),pos),pos.altitude),
mk_Position(addVectorToPoint(mk_Vector(0,2),pos),pos.altitude),
mk_Position(addVectorToPoint(mk_Vector(0,-2),pos),pos.altitude)
};
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.