A LocalResource acts as a virtually seamless interface for a Till to a Channel.
Thus it provides the same calling interface as a CentralResource, except that
its operations are able toreturn the value <Fail> to represent a communication
failure.
\begin{vdm_al} class LocalResource
\end{vdm_al}
A LocalResource has only one instance variable: a reference to a Channel.
\begin{vdm_al} instancevariables
c : Channel := new Channel();
operations
\end{vdm_al}
The Create operation is used to initialize the Channel.
\begin{vdm_al} public LocalResource : Channel ==> LocalResource
LocalResource(nc) ==
c := nc;
\end{vdm_al}
The operation GetBalance shadows the corresponding operation in CentralResource.
The argument received by the method is converted into a value of type Channel`ReqData, andthen a request is constructed. This is sent to the channel andthen the Wait
operation is called.
\begin{vdm_al} public GetBalance : Account`AccountId ==> [nat]| <Fail>
GetBalance(accountId) == letreq = mk_Channel`Request(<GetBalance>,
{mk_Channel`AccountId(accountId)}) in
(c.SendRequest(req);
Wait(<GetBalance>));
\end{vdm_al}
The Wait operation waits for a particular response from the channel. If the
response isnilor does not match the expected result, a failure is signalled
(corresponding to a timeout in the Channel). Otherwise the data value in the
response is returned.
\begin{vdm_al}
Wait : Channel`Command ==> Channel`RespData | <Fail>
Wait(comm) ==
(c.Wait(); let resp = c.ReceiveResponse() in if resp = nil thenreturn <Fail> elseif resp.command <> comm thenreturn <Fail> elsereturn resp.data);
\end{vdm_al}
The remaining operations follow the same basic approach as that of GetBalance, and need no further explanation.
public PostStatement : Account`AccountId * Card`CardId ==> bool | <Fail>
PostStatement(accountId,cardId) == letreq = mk_Channel`Request(<PostStmt>,
{mk_Channel`AccountId(accountId),
mk_Channel`CardId(cardId)}) in
(c.SendRequest(req);
Wait(<PostStmt>));
public IsLegalCard : Account`AccountId * Card`CardId ==> bool | <Fail>
IsLegalCard(accountId,cardId) == letreq = mk_Channel`Request(<IsLegalCard>,
{mk_Channel`AccountId(accountId),
mk_Channel`CardId(cardId)}) in
(c.SendRequest(req);
Wait(<IsLegalCard>));
public NumberOfTriesExceeded : Card`CardId ==> bool | <Fail>
NumberOfTriesExceeded(cardId) == letreq = mk_Channel`Request(<TriesExceeded>,
{mk_Channel`CardId(cardId)}) in
(c.SendRequest(req);
Wait(<TriesExceeded>));
public ResetNumberOfTries : Card`CardId ==> [<Fail>]
ResetNumberOfTries(cardId) == letreq = mk_Channel`Request(<ResetTries>,
{mk_Channel`CardId(cardId)}) in
(c.SendRequest(req);
Wait(<ResetTries>));
public IncrNumberOfTries : Card`CardId ==> [<Fail>]
IncrNumberOfTries(cardId) == letreq = mk_Channel`Request(<IncTries>,
{mk_Channel`CardId(cardId)}) in
(c.SendRequest(req);
Wait(<IncTries>));
end LocalResource
\end{vdm_al}
Messung V0.5 in Prozent
¤ 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.10Bemerkung:
(vorverarbeitet am 2026-09-29)
¤
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 und die Messung sind noch experimentell.