Paradise ponders: life in the country, and seeing old friends edition... Yesterday afternoon, Debbie and I drove down to Ogden to visit with Doug and Dee W. I've known Doug since 1991, when I started working for Stac Electronics. Doug and Dee are starting an LDS mission next month, and they'll be gone (to Rome!) for the two year extent of that mission. We won't have a chance to see them for that period unless we hie ourselves to Rome, and I'm not at all sure we could pull that off. So the purpose of our visit was a bit melancholic – but the visit wasn't at all. Doug's sister Marilyn (whom we've met before) and his mom joined us. We really enjoyed getting to know his mom a bit. She's 92, but still sharp, participating in our conversation. We learned a bit about what Doug and Dee's mission is all about, and poor Marilyn and mom had to suffer through some stories from us. We had a great time! We're gonna miss Doug and Dee, though...
Sunday and the rest of Monday were very “country” days for me. I helped my friend and neighbor move hand line (irrigation pipe), spent some time getting to know another neighbor's mule (Gunner), worked on the irrigation plumbing for a while (more on that below), and worked with the contractor doing our sprinklers. I also fed the dogs, played with them for a while, fed the birds, watered plants, and pulled weeds. All of this stuff is pretty typical for a day in the country. I love it!
Our south field (12 acres) got mowed yesterday afternoon. The windrows of cut alfalfa are huge – Scott N., the fellow leasing that field from us, let the alfalfa grow much bigger than he's ever done before. Much of it had actually gone to seed. He's going to get a lot of hay from this cutting...
The irrigation plumbing efforts had mixed results. You may recall that I had two leaks to fix. The bad PVC joint leak I've now fixed, using the product pictured at right, called “Leak-B-Gone”. Despite the corny name, this product worked exactly as advertised – and it saved me a couple hours of work and around $35 in parts I would have had to discard. The manufacturer's description of the problems it can solve is careful and conservative, not the sort of shrill hawking one might expect to see. I like it. The other leak (the dripping galvanized pipe threaded connections) is not fixed. Or rather, one of the two connections is not fixed. I used Loctite 565 thread sealant on it (the stuff recommended in my web research), but it still drips. Yesterday I got a pair of big pipe wrenches on it, and tightened it to the limits of my ability. I figure I torqued it down to something like 250 ft/lbs. Now I'm letting the thread sealant cure some more; tomorrow I'll test it again. If it still leaks, I think I shall contact the pump vendor for help...
On the subject of leaks, though, yesterday brought some good news. On Friday the contractor who did all the gasoline and diesel plumbing in our little filling station came back and redid the gasoline side. This was after a successful test of a new thread sealant on the diesel side earlier in the week. Yesterday I pressurized the gasoline side to check for leaks – and there wasn't a single drop to be seen anywhere. Hooray! We now have a functionally complete little filling station! I have a few details left to complete: the door closer, the lock, and some wood rub bars to keep the hoses from fraying on concrete. That's all minor stuff. All the hard part is done!
I also got quite a bit of work done in my irrigation supervisory program on Sunday and Monday. After I got my first pass done on the state machine, I thought of a much better implementation method, and yesterday I got that finished and running. This new approach cut the lines of code by almost 50%, and most especially it cut out tons of Java “boilerplate” code. What's left is a spare and understandable state machine, one of the nicest I've ever done in Java.
For the geeks out there, here's what I did. I have an enum that represents the state (one of four: OFF, STARTING, ON, STOPPING). In the enum declaration, I initialized a map that associates strings representing events with an action object. When an event occurs, the state machine calls a method on the current state that looks up the event and calls the associated action. Simple, clear, and performant. Also way easier to maintain than my initial design.
While I was working on that state machine, something occurred to me that probably explains why I like state machines more than most engineers I've worked with. It's a simple explanation, but it didn't register with me right away. I've done a lot of digital hardware design, though most of that was over 30 years ago. That design work often included hardware state machines, which in many ways are easier to design than software state machines. For problems other than the very simplest, the hardware state machine was one of the first design choices. Even in discrete logic, you could implement a state machine with just a few parts and solve fairly complex problems with simple, easy-to-understand designs. I used them often, and most (but certainly not all) hardware engineers I worked with also understood them. I'll bet you that's the source of my attraction to software state machines. Now if I could just convince myself to look at them earlier in the design process... :)