by TV
A short page with an important idea in it this time, using bwise to make graphs which represent programmed behaviour, where one wants a block to simply delay the incoming data one step.
Each time the block 'fires', its block.bfunc is eval-ed, the previous input is copied to the output, and the current input remembered.
Therefore this block is a block with an additional state variable, in this case called block.prev, to remember the previous input value with.
Let's as an example or test make the following bwise graph:
most easily by using the right (or middle) mouse button popup menu to create entry, proc and mon blocks, dragging them in place, and clicking on two corresponding pins and pressing the Wire button to connect them.
Because we want non-standard behaviour, we'll have to edit most blocks, which is easily done by using the right mouse button connected popup menu from the yellow parts of the blocks to open the Data window per block.
The monitor blocks will need to not delete their previous content each time new input data arrives, so we cut out the first text delete command, and also remove the newline at the end of each update.
The Proc1 block will contain the delay, which is made by changing the block function into:
set Proc1.out ${Proc1.prev} ; set Proc1.prev ${Proc1.in}
To prevent an error, the block needs an initialisation function, which can be done by filling in the Proc1.bfunc_init value to contain:
set Proc1.prev {}
and calling from the right button popup menu 'Init' before we start to invoke this initialisation of the previous value variable.
Now we can start by filling in a value in the Entry1 block, and subsequently invoke the 'Funprop' popup menu entry on that block, to 'run' the graph connected to it. The we repeat the procedure and see what our Mon-itor blocks record. I used single binary numbers 0 and 1 to test, and subsequently filled in 0, 0, 1, 1 and each time ran 'Funprop' to make the network activated, and indeed it shows that the output recorded from the Proc1 block lags one value behind its input.
The first time the chain of blocks is Funprop-ed, a empty value comes from the freshly initialized Proc1.prev state variable, which shows up at the output.