Coronavirus (Covid-19): Latest updates and information
Skip to main content Skip to navigation

LSD account of a telephone

agent user(U,S) {
oracle  (int) tone[S], (bool) ringing[S]
handle  (bool) onhook[S], (int) dialled_number[S]
protocol
        not onhook[S] -> onhook[S]= true; dialled_number[S]=@,
        not onhook[S] & (tone[S] == D) -> dialled_number[S]=N,
        not onhook[S] & (tone[S] == C) -> <speak>,
        onhook[S] and not ringing[S] -> onhook[S] = false ; dial(S),
        onhook[S] and ringing[S] -> onhook[S] = false ; <speak>
}

agent telephone(S) {
oracle	(bool) onhook[S], connecting[S,*], dialling[S],
        (int)  dialled_number[S],
        (bool) connected[S,*], engaged[S,*]
state	(bool) onhook[S] = true,
        (int)  dialled_number[S],
        (bool) connecting[S,*] = false,
        (bool) dialling[S] = false,
        (char) tone[S]
derivate
        (char) tone[S] = D if dialling[S]:
                         E if connecting[S, dialled_number[S]]
                           and engaged[S, dialled_number[S]]:
                         R if connecting[S, dialled_number[S]]
                           and not engaged[S, dialled_number[S]]:
                         C if connected[S,?] and connected[?,S]:
                         @ otherwise
}

agent exchange() {
oracle	(bool) onhook[*], connected[*,*], connecting[*,*], answered[*]
state	(bool) onhook[*], connected[*,*] = false, answered[*] = false
        (bool) ringing[*], engaged[S,*],
        (time) Tdial , Tcall
derivate
        (bool) ringing[*] = connected[?,*] and onhook[*] and not answered[*],
        (bool) engaged[S,*] = connecting[S,*] and (ringing[*] and not onhook[*]),
        (time) Tdial = <timeout for dialling>,
        (time) Tcall  = <timeout for calling>
}

agent dial(S) {
oracle
        (int)  dialled_number[S],
        (time) Tdial, time,
        (bool) onhook[S],
        (bool) connecting[S,*] = false
handle	(time) tstart
state	(time) tstart = |time|,
        (bool) valid = <dialled_number[S] is valid>
derivate
        (bool) dialling[S] = not onhook[S] and ((time - tstart) < Tdial),
        (bool) LIVE = dialling[S] and not connecting[S, dialled_number[S]]
protocol
        dialling[S] and valid -> connect(S, dialled_number[S])

}

agent connect(S,D) {
oracle	(bool) onhook[S], onhook[D], ringing[D], engaged[S,D],
        (time) Tcall , time
handle	(time) tcall ,
        (bool) connected[S,D], answered[D]
state	(time) tcall  = |time|,
        (bool) connected[S,D] = false,
        (bool) answered[D] = false
derivate
        (bool) connecting[S,D] = not connected[S,D],
        (bool) LIVE = not onhook[S] and
            (	(connecting[S,D] and (time-tcall )<Tcall)
                 and ringing[D] and
                (connected[S,D] and (not answered[D] and not onhook[D]))
             )
protocol
        not engaged[S,D] and not connected[S,D] -> connected[S,D] = true,
        not onhook[D] and not answered[S,D] and connected[S,D -> answered[D] = true,
        engaged[S,D] -> delete connect(S,D)
}

agent environment() {
handle time
state time = 0
protocol
      true -> time = |time| + 1
}