Control: [LogCom] * setof LampId ==> Message * Errors * Trace
Control(com,failures) == let newstate = NormalTrans(com) in
ErrorCorrection(com,newstate,failures) pre AllowedCommand(com,lampstate);
functions
AllowedCommand: [LogCom] * Signal +> bool
AllowedCommand(com,signal) ==
(com = <dark> => signal inset {stoplamps,darklamps}) and
(com inset {<warning>,<drive>} => signal <> darklamps);
types
Trace = seqofsetof LampId
state Dwarf of
trace : Trace
lampstate : Signal inv mk_Dwarf(t,s) ==
MaxOneLampChange(t) and
StopToDriveOrWarning(t) and
ToAndFromDark(t) and
AlwaysDefinedState(s) -- this may change when errors are -- taken into account init s == s = mk_Dwarf([stoplamps],stoplamps) end
operations
NormalTrans: [LogCom] ==> Dwarf
NormalTrans(command) == cases command: nil -> return mk_Dwarf([],lampstate),
<dark> -> let t = if lampstate = stoplamps then [{<L1>},darklamps] else [] -- already in darksignals state in return mk_Dwarf(t,darklamps),
<stop> -> let t = if lampstate = darklamps then [{<L1>},stoplamps] elseif lampstate = warninglamps then [{<L1>},stoplamps] elseif lampstate = drivelamps then [{<L2>},stoplamps] else [] -- already in stoplamps state in return mk_Dwarf(t,stoplamps),
<warning> -> let t = if lampstate = drivelamps then [{<L3>},warninglamps] elseif lampstate = stoplamps then [{<L1>},warninglamps] else [] -- already in warninglamps state in return mk_Dwarf(t,warninglamps),
<drive> -> let t = if lampstate = warninglamps then [{<L3>},drivelamps] elseif lampstate = stoplamps then [{<L2>},drivelamps] else [] -- already in drivelamps state in return mk_Dwarf(t,drivelamps), others -> error end pre AllowedCommand(command,lampstate);
ErrorCorrection: [LogCom] * Dwarf * setof LampId ==>
Message * Errors * Trace
ErrorCorrection(com,dwarf,failures) == if failures = {<L2>} then (cases com: nil -> if <L2> inset lampstate thenlet errdwarf = NormalTrans(<warning>) in
NoCorrection(com,errdwarf,failures) else NoCorrection(com,dwarf,failures),
<dark> -> NoCorrection(com,dwarf,failures),
<stop> -> let errdwarf = NormalTrans(<warning>) in
NoCorrection(com,errdwarf,failures),
<warning> -> NoCorrection(com,dwarf,failures),
<drive> -> let errdwarf = NormalTrans(<warning>) in
NoCorrection(com,errdwarf,failures), others -> error end;
) else (-- other error sitiuations have not yet been coped with
NoCorrection(com,dwarf,failures));
NoCorrection: [LogCom] * Dwarf * setof LampId ==>
Message * Errors * Trace
NoCorrection(com,mk_Dwarf(newtr,newsignals),failures) ==
(trace := trace ^ newtr;
lampstate := newsignals; let m = if failures <> {} then <port_failure> elseif com = nil then <unknown> else com in return mk_(m,{},newtr));
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.