HouseMon Circuits Tutorial-1.02

In this post, we will extend our ‘init’ circuit to start ‘producing’ messages.

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.

Lets continue…

Change to your housemon folder and display the circuit tutorial information:

cd ~/housemon
./cirget status

Load and display the 'clock1.yaml' circuit:

$ ./cirget circuit 2
$ ./cirget -y

Here is the circuit:

#A Clock losing its output.
---
  init:
    gadgets:
      -
        name: "dummy"
        type: "Pipe"
      -
        name: "c"
        type: "Clock"
    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 one of the in built gadgets called 'Clock' and given it an name/alias of "c". (Lines 9-10)
  • We include a new section called 'feeds', which allows us to create gadget 'initialization' messages. (Line 11)
  • We create a message ("data") that has a string parameter of "1s" which for a 'Clock' represents a duration of 1 second. (Line 13)
  • We specify that this "data" message should be placed into the Clock's (c) .In pin when the circuit is started.

If you cannot guess already, this is going to ask the Clock to send a message on its .Out pin every 1 second, until the circuit is shutdown.

The key lesson here is that we are not placing anything 'into' the circuit from outside, i.e nothing is going into the circuits .In pin (dummy.In). Nothing is being sent to the circuits .Out pin (dummy.Out) The Clock is sending (generating) messages, but the circuit has not been told to handle them. The result is that the messages will again exit the circuit as un-handled, (Lost "Message") and they 'hit the bumper' as discussed in the previous post.

Start housemon to see what happens:

./housemon
Starting webserver for http://0.0.0.0:5561/
Lost flow.Tag: { init}
Lost time.Time: 2014-05-10 15:29:46.353314337 +0100 BST
Lost time.Time: 2014-05-10 15:29:47.343366158 +0100 BST
Lost time.Time: 2014-05-10 15:29:48.343369866 +0100 BST

Circuits do not need inputs from 'outside' to function, so long as a gadget/circuit can do the work required by generating its own messages. Neither do circuits/gadgets have to handle their own messages, they can let their messages get 'Lost' if needed, but its usually more useful if a gadget/circuit does something with a message it receives.

In the next tutorial, we will build on 'clock1.yaml' and handle the message Clock produces within the circuit that produces it.

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:

$ ./housemon
Tagged with:
Posted in cirget, housemon, housemon tutorials, soft-circuits

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: