Tuesday, May 26, 2015

RPi Test #5: Separation of Concerns

In the previous example, you may have noticed the beginning of "diagram clutter", where the I/O interface blocks were taking up significantly more space than the actual program logic. This problem can become severe with more complicated logic and a greater amount of I/O, such that it can become extremely difficult to even figure out what the logic is supposed to be doing.
As shown in the current example (GPIO_TEST5), we can solve this problem by applying the principle of Separation of Concerns:
  • First, as shown below, we move all the I/O interface blocks into one or more Resources separate from the program logic (here the resource is named IO for obvious reasons).
  • Then we add Local Multicast blocks to transmit inputs to and receive outputs from other Resources.
  • The Tagged Data design pattern support in the FBDK helps to keep the use of Local Multicast channels consistent among Resources.
Now we add Local Multicast blocks to the LOGIC resource to receive data from inputs and transmit the results of the control logic to outputs. Notice the reduction of diagram clutter:
In the next example, we'll take advantage of this reduced clutter to make room for more complicated control logic.