Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
reututy committed May 4, 2018
1 parent 6029e30 commit e787627
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions docs/source/example-hot-cold.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ This program models a system that fills a bath with six parts water: three cold,
.. literalinclude:: Examples_code/HC_listing1.js
:linenos:
:language: javascript

``Listing 1. A naive implementation of bath-filling controller.``

The code in Listing 1 is not incorrect, but it also does not use the power of behavioral programming: it leaves no decision room for the event selection mechanism. Thus, when read as a specification, it is over-restrictive. An improved b-program is shown at Listing 2.

.. literalinclude:: Examples_code/HC_listing2.js
:linenos:
:language: javascript

``Listing 2. A more lenient version of the bath-filling controller.``

The code in Listing 2 consists of two b-threads: add-hot, which adds the hot water, and add-cold, hich adds the cold water. This improves on the previous version in a number of ways. First, any order in which the water parts are added is supported, as the event selection mechanism of the b-program
Expand All @@ -28,7 +26,6 @@ To prevent these unbalanced scenarios, we can add an additional b-thread, that w
.. literalinclude:: Examples_code/HC_listing3.js
:linenos:
:language: javascript

``Listing 3. A b-thread that ensures safe water temperature by ensuring cold water are added before hot water are.``

As a useful exercise, we invite the reader to further elaborate the hot-cold example, e.g. by upporting the insertion of the baby while filling the bath (which would require blocking of the BABY_IN event when the water temperature is too high), or by altering control-temp to be more permissive.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Topics:
extendBPjs/index
glossary
examples



Indices and tables
Expand Down

0 comments on commit e787627

Please sign in to comment.