Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

Chapter 14 — A channel that loses or delays: the wireless button

In the entrance hall a wire cannot be laid; the button is therefore wireless and sends a radio message to a receiver installed next to the lamp. A radio message may be lost or arrive late. This chapter describes how to represent a medium of this kind and how to write a boundary external to the entity.

The channel

A channel is a medium that carries messages from one system to another and that may lose them, delay them or reorder them. Its behaviour is described in a boundary of its own, with its own CSC.

If the wireless button provided Comando directly to the lamp, the button's guarantee “each press is followed by an accendi within 0.1 s” would be violated every time a message is lost, without any line stating so. Loss and delay are observed on the radio link, between the button and the receiver: the guarantees that concern them are written in the CSC of that link.

The concrete characteristics of the medium (frequency, radio protocol, message format) are not written here (chapter 25).

The CSCs and the entities of the wireless button

The radio channel is described by the CSC Trasmissione, written from the side of the provider, that is, the button:

-- The wireless channel between the button and the receiver.

CSC Trasmissione VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The wireless button sends radio messages to the receiver next to the lamp"

  EVENT OUT  messaggio

  GUARANTEE t1: VERBAL "A sent message arrives within 0.3 s or is lost"
                VERIFY BY INSPECTION "the messages recorded on sending and on reception"
  GUARANTEE t2: VERBAL "Two messages may arrive in an order different from the order of sending"
                VERIFY BY INSPECTION "the messages recorded on sending and on reception"
  GUARANTEE t3: VERBAL "A message that has not been sent never arrives"
                VERIFY BY INSPECTION "the messages recorded on sending and on reception"
END

The guarantees of Trasmissione establish what the consumer of the transmission can count on. A message may be lost; if it arrives, it arrives within 0.3 s. The order of arrival is not guaranteed. No message arrives that nobody has sent. They are guarantees that commit the provider to little, but they are precise.

The wireless button provides the press and the transmission, and reduces the effect of losses by sending three messages for each press:

-- The wireless button.

ENTITY PulsanteRadio VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The wireless button receives the press and transmits it to the receiver"

  OFFERS Pressione
  OFFERS Trasmissione

  GUARANTEE pr1: VERBAL "At each press the button sends three messages, 50 ms apart"
                 VERIFY BY INSPECTION "the recorded presses and messages"
END

The receiver uses the transmission and provides the command to the lamp:

-- The receiver next to the lamp.

ENTITY Ricevitore VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The receiver receives the messages of the wireless button and commands the lamp"

  USES   Trasmissione
  USES   Alimentazione
  OFFERS Comando

  GUARANTEE ri1: VERBAL "A received message produces an accendi within 0.05 s; messages received in the following 0.2 s produce no others"
                 VERIFY BY INSPECTION "the received messages and the recorded commands"
END

A boundary external to the entity

The lamp and its receiver form an entity, LampadaRadio. The transmission is provided by the button, which is not part of this entity: it is therefore an external boundary and it is declared on the entity with USES. Inside, the USES line of the receiver is satisfied by the USES line of the entity (from outside):

-- The lamp with its receiver.

ENTITY LampadaRadio VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The lamp receives the messages of the wireless button, switches on and switches off by itself"

  USES   Trasmissione
  USES   Alimentazione
  OFFERS Luce

  COMPOSED OF
    ricevitore : Ricevitore
    lampada    : Lampada

  GUARANTEE lr1: VERBAL "After a received message the light switches on within 0.6 s"
                 VERIFY BY JUDGEMENT "a person who observes the lamp while a message is sent"
END
$ bcdd check --strict LampadaRadio.csc
bcdd check --strict LampadaRadio.csc
lines: 17 (recognised 12, comments 1, blank 4, unrecognised 0)
blocks: 1
  line 3: ENTITY LampadaRadio VERSION 0.1, STATUS HYPOTHESIS
    line 7: USES Trasmissione in Trasmissione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 8: USES Alimentazione in Alimentazione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 9: OFFERS Luce in Luce.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 12: ricevitore : Ricevitore in Ricevitore.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 13: lampada : Lampada in Lampada.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 1
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 15: GUARANTEE lr1 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 1
  line 15: GUARANTEE lr1

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

8. USES WITHIN ENTITIES: 4
  line 12: ricevitore uses Trasmissione: LampadaRadio uses it from outside (line 7)
  line 12: ricevitore uses Alimentazione: LampadaRadio uses it from outside (line 8)
  line 13: lampada uses Comando: it is provided by ricevitore (line 12)
  line 13: lampada uses Alimentazione: LampadaRadio uses it from outside (line 8)

outcome: no errors

Section 8 reports ricevitore uses Trasmissione: LampadaRadio uses it from outside (line 7). The boundary Comando is internal to LampadaRadio: the USES Comando line of the lamp is satisfied by the receiver, which provides it.

The complete entity, LuceSenzaFili, contains the wireless button and the lamp with its receiver:

-- The staircase light with the wireless button.

ENTITY LuceSenzaFili VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The person on the stairs presses the wireless button and has light to go up or down"

  OFFERS Pressione
  OFFERS Luce
  USES   Alimentazione

  COMPOSED OF
    pulsante : PulsanteRadio
    lampada  : LampadaRadio

  GUARANTEE lf1: VERBAL "When someone presses the button, the light switches on within 1 s, unless all three messages are lost"
                 VERIFY BY JUDGEMENT "a person who presses the button and watches"
END
$ bcdd check --strict LuceSenzaFili.csc
…
8. USES WITHIN ENTITIES: 2
  line 13: lampada uses Trasmissione: it is provided by pulsante (line 12)
  line 13: lampada uses Alimentazione: LuceSenzaFili uses it from outside (line 9)

outcome: no errors

In LuceSenzaFili the boundary Comando does not appear: it is internal to LampadaRadio, and of a part bcdd reads only the OFFERS and USES lines (chapter 13).

The entity guarantee lf1 takes the losses of the channel into account: the light switches on within one second, unless all three messages are lost. A guarantee that ignored losses would guarantee more than the channel allows.

Summary

Special cases

External boundary not declared. If the line USES Trasmissione is missing in LampadaRadio, the receiver uses a CSC that no part provides:

1. ERRORS: 1
  line 11: [E14] the part ricevitore uses connector Trasmissione: no other part of LampadaRadio provides it, nor does LampadaRadio use it from outside

The missing line also affects the entity that contains LampadaRadio: in LuceSenzaFili the transmission provided by the button is no longer used by any part.

1. ERRORS: 1
  line 12: [E17] the part pulsante provides connector Trasmissione: no other part of LuceSenzaFili uses it, nor does LuceSenzaFili provide it from outside

Channel not written. If the wireless button declares OFFERS Comando and the lamp uses Comando directly, without receiver or Trasmissione, the report shows no errors. bcdd checks the match between uses and offers, not that the medium is described: establishing that the radio link may lose messages is the responsibility of whoever writes the CSC.