Updated 2013-03-21 01:19:26 by RLE

By Theo Verelst

Pages making use of the bwise package/library/application (new page probably will appear at the bottom):

Most pages come with images/window dumps.

I've changed the place of this list from distributed linked bwise.

Feel free to add bwise uses of your own, its all free and open source at the moment, so why hold back...

See this list of my diary pages [1] and more recently the local diary pages (on a secure tclhttpd based server) [2] (this [3] is a recent one with pictures), while this one contains Bwise:
` http://www.theover.org//Diary/ldiary6.html#bwise.`

I'll start making a list of bwise examples and applications, the first being shown above as an important gedanken experiment. Don't think eigenvalues here, we're not getting into that now. Here we do that: eigenvalues and electronics

I made a generator block for AND gate blocks on the bwise canvas, which is a block that generates new blocks when it is fired (Eval-ed). This is the command (can be executed on the console or a bwise shell) for making the generator block:
``` set n 1;
newproc "newproc \"set proc\\${genproc.n}.q \\\[expr !(\\\\${proc\\${genproc.n}.a} && \\\\${proc\\${genproc.n}.b})\\\]\" proc\\${genproc.n} {a b} q  ;set genproc.nlast \\${genproc.n}" genproc n nlast```

Which (evaluated but not executed ends up in the genproc.bfunc as:
` newproc "set proc\${genproc.n}.q \[expr !(\\${proc\${genproc.n}.a} && \\${proc\${genproc.n}.b})\]" proc\${genproc.n} {a b} q  ;set genproc.nlast \${genproc.n}`

Which can also be seen here:

The proc1 and proc2 blocks were made by executing 'funprop' from the block menu (middle mouse button on the yellow part of a block), which evaluates the block, passes the current proc index from genproc.nlast to tcl variable Proc1.in, evaluates the Proc1 block function that is stored in tcl variable Proc1.bfunc, which sets Proc1.out to one higher, and finally transfers this values to genproc.n, at which point the funprop functional propagator function stops because it detects it is back where it started.

Of course more basic circuits with nand circuits can be made, such as just one, for instance with an alarm sensor at the door and a window, issueing a 1 when the door or window is open, and 0 otherwise, and a buzzer or siren or silent alarm connected to the output. For that, one would need to read signals from the outside world, and one would have to periodically or when one or more of those signals changes values, recompute the outcome of the AND function, and trigger following blocks dealing with the new alarm state. Of course simply filling in values in the infowindow (use the data popup menu on the and block)

One may want to arm or disable the alarm, or one of the inputs by using another and. At this terminal, I don't have bwise running, so the connections are left as an exercise to the reader.

As an illustration of the problems that also occur in let's call it real life large scale networks, when they are supposed to aid in the computation of things in which real people have interest, let's use the bwise 0.3 supplied procedure
` newarray 5 5`

which generates an array of blocks with two inputs and a certain interconnection pattern, which basically concatenates the two inputs to the output.

I added a term (inal) block to generate input and read output from the block array, and which allows one to press a button or <return> to start a funprop (functional propagate), "firing" each block as its inputs become available from previous blocks.

- Canvas after creating an array, a terminal and a shell -

Look at the firing pattern to understand how computation possibility numbers increase first when block connection patterns widen, and in the end narrow down until the final block is reached.

The reverse case, where first information is gathered to one central block, and then expands into many others depending on it is also thinkable, hang on, I'll cut and paste a bwise net for it when I made an example.

The array doesn't do anything particularly useful at the moment, but it could for instance do image processing (where the links indicate neighbouring communication in 2D), or stand for steps in a matrix multiplication or what else there is. One could also process a list in a piecewise way.

Simple applications

Make this graph by using the middle (or right) mouse button on the gray canvas to make a proc, and entry and a monitor.

The wires can be connected by clicking on the pins with the left mouse button to make them green. When two pins are green, press the button on top the canvas names Wire in green, to make a wire between the green pins.

Then select the next two pins and connect them, until the whole diagram is made.

Now put the cursor in the block called Entry, and type some symbols, numbers or text, and press return, or use the middle mouse button on the small yellow part of the entry block to get a popup menu and select 'funprop'.

Depending on the speed of your machine, and the OS of your choice, the blocks will fire in order quite quickly or invisibly quickly, turning the pins where data passes green shortly.

The things you typed in the entry block will appear in the mon block unchanged.

To 'do something' with the data you typed in, you can use the menu on the proc block block which is called 'data' to open a window with entries for each of the variables associated with the proc block, which includes the pins (in and out), and the procXX.bfunc variable.

That variable contains the function (procedure, or simply some tcl(/tk) commands) which is executed when the block is 'fired', that is when it is activated because it has its inputs available during a 'funprop' invokation for instance.

Pressing the 'eval' button in the data window also effectively fires the block, that is the variable starting with the block name and ending with .bfunc is taken to contain a tcl command which is executed. One may want to call a procedure here, or simply put in the tcl code which is needed directy.

In principle, one could even call another bwise network activity, which is rather intricate without clear rules, though.

Say we change the function associated with proc1 to
` set proc1.out [expr \$proc1.in + 1]`

that wouldn't work, but
` set proc1.out [expr \${proc1.in} + 1]`

would as is to be expected generate a number at the output pin and associated variable of the block which has a numerical value of one higher than the supplied input number.

Feeding the block with a non-numerical value will generate an error, which however is not desastrous, as it could be in after scripts calling each other.

More Pages on Bwise programming:

Lars H (4 Jun 2003): I think the text between the last two divider lines well illustrate a problem with some of the pages you create, TV -- the title does not match the contents. They often start out with some important general thingie in computer science that more or less matches the title, but then they quickly digress into discussions of fairly low-level electronics only vaguely connected to the matter suggested by the title. Such a specialized point of view might be appropriate on an "Electronics Wiki", but as this is The Tcler's Wiki it just makes everything look very off-topic and thus uninteresting.

All is not lost, however, since rather small modifications of the titles can make the contents seem much more appropriate. For example, had the above Traveling Salesman Problem page instead been named Bwise Traveling Salesman Problem then the point of view would be explained in the title. eigenvalues and electronics is another page with a curious title that comes to mind. While there is no Web interface for renaming Wiki pages, it is fairly simply to copy the contents of one page to a new page with the new name if one has two browser windows open simultaneously.

TV The point is that the popularity of tcl (/tk) and maybe some of the reason that it is not so well spread as it could be IS illustrated quite well by these examples. The 'put things on a canvas'approach from above is, just like examples on the last tcl conference, a god way to make clear what one actually does while programming complicated things, which are not always programmed all too well, in contemporary software often very big and inefficient, and these type of pages show why, for the bit over average intelligent reader with some software background (I hope).

So VERY much a tcl issue.

The language comes from designing chip layouts, I even seem to recall.

The eigenvalues page is about the issue of objects sending each other messages.

This is not a new problem. In fact, in electronics the differential equations for two parts of a very basic circuit which also for tcl is the physical foundation of memory do the same, and consistently so for a continuous problem. So if one wants to illustrate that the message sending in many OO extensions (which can be fine to use) can be seen in certain ways much more advanced and secure than the usually very undocumented software X or Y (in that sense), electronics of a simple two functions connected together is a nice and relevant example.

Also, in most programs, also OO ones, the programming type is essentially very much like a functional decomposition, which is also a recurrent theme in this tcl wiki, and important. Two simple functions, as part of an object method, connecting up as on the example bwise diagram, form a memory loop.

Very relevant example. Prevents bugs and conceptual errors. And bwise is written in tcl/tk and a good discussion vehicle. im(nsh)o..