Lets continue extending our basic circuit, this time we will ‘consume’ a message from within the circuit its ‘produced’ in.
I covered the initial overview of HouseMon circuits/gadgets etc in this post. I covered installation of a small circuit management tool I call ‘cirget’ that I will use in these tutorials in this post.
Change to your housemon folder and display the circuit tutorial information:
cd ~/housemon ./cirget status
Load and display the 'clock2.yaml' circuit:
$ ./cirget circuit 3 $ ./cirget -y
Here is the circuit:
#A Clock sending its output to console line printer. --- init: gadgets: - name: "dummy" type: "Pipe" - name: "c" type: "Clock" - name: "p" type: "Printer" wires: - from: "c.Out" to: "p.In" feeds: - data: "1s" to: "c.In" labels: - external: "In" internal: "dummy.In" - external: "Out" internal: "dummy.Out"
Here are the important additions:
- We have added another gadget of type "Printer" and called it "p"
- We have added another new section, called 'wires' (Line 14)
- the 'wires' section has a 'from' and 'to' and as you can expect they hook a gadget/circuits' .Out (from) pin with a corresponding (to) .In pin.
The 'Printer' gadget actually just prints the message it receives onto the console and can be confused at first with a 'Lost' message, because they are also printed to the console. There is a key difference here in that the 'Printer' gadget is specifically receiving this Clock message and displaying it as it needs to on the console.
Go ahead and run the circuit in HouseMon for a few seconds (ctrl+c to stop):
Lets take a moment to discuss the naming of the sections within a circuit. So far we have seen the following circuit sections:
these are ALL sections within the 'init' circuit.
You will note that the names of these sections are all lower case. This is important, as circuits are case sensitive, and can be the cause of difficult to debug problems.
Talking of debugging; in vanilla HouseMon, there is little in the way of debug tools at the moment, we are working on this. For now, you can use the console output, specifically 'Lost' messages and the console 'Printer' to help you. A rotational log file is also produced in your o/s's temporary folder (/tmp for linux systems) and can be refined with command line parameters which I'll discuss in a future post.
I'd also like to say a little about the 'gadget' section. Again case sensitivity is important. Gadgets have a 'type' which is specifically tied to what the gadget registers itself as. HouseMon uses a 'Registry' that holds all available gadgets. You must use the 'type' that the gadget has registered itself as. For vanilla Housemon these can be found here or my version here.
Currently, the HouseMon registry is not exposed via the in built api, however I intend to submit a patch shortly to allow the user to query the binary to determine what gadgets are compiled and included in each HouseMon installation.
A final word about the gadgets 'name'. This is normally lowercase, and used to shorten the name of a gadgets pins when referenced within the circuit, so Clock is shortened to 'c' in the above circuit, and its pins then can be referred to as c.Out etc. The Clock could have been named 'a_very_long_clock_gadget' but then you would need to use 'a_very_long_clock_gadget.Out' as a pin assignment. Additionally, it is possible (and common) to use the same gadget multiple times in the same circuit. This is where 'name' has its second and most important use, to differentiate multiple gadget instances. Using the example above, 2 Clocks could be named 'c1' and 'c2' and referenced c1.Out and c2.Out respectively. Gadget 'names' should be unique within a circuit. If you have used 'c' for Clock in the 'init' circuit, you would not use the name 'c' for the 'Counter' gadget, perhaps using 'ct' would be more appropriate. Don't start your gadget 'names' with uppercase, this will protect you from potential namespace collisions with the gadgets present in the internal 'registry'.
In the next tutorial, we will start to look at a few gadgets and how they can be made to work together to achieve a goal.
Until then, if you want to get the original setup file installed again, stop housemon (with a ctrl+c) and issue the following cirget command:
$ ./cirget circuit 0
Now restart housemon: