date: 2017-04-29
title: Intermission
thumbnail-image-url: http://picture-files.nuke24.net/uri-res/raw/urn:bitprint:3BHGTVNONVYRWF3DLNDG5ZNRVMX33RXK.GFS77UOVT3U7Z3FCTZV5IVDULG36YOPLFT2KC2I/BatteryChargeControllerPanel.jpg
summary: I've been working on a bunch of different stuff lately

Intermission - 2017-04-29 - Entry 22 - TOGoS's Project Log

Updates to Game21 since Random Mazes

Going hard down the 'stuff required to simulate data networks' tech path:

Here's a video (in animated GIF format) of me switching some switches while some decorative box fans run above me:

In this example, toggling a green switch also sends a 1-byte zero or one signal along the wire connected on its top side. When receiving a signal, switches change their own state to match the signal's content (on or off). Much more complex behaviors are possible, and I even have some ethernet switch simulation classes defined, but I haven't figured a good way to integrate them into the demo game yet. Because what good are ethernet frames if you can't put IP data in them? And then you start getting into complexity of ARP tables and how do you configure who a device's peers are, etc. And I'm not sure I really want to deal with all that stuff. So the mind still churns on this as I commute to and from work.

To prevent broadcast storms I cheated a bit in my ethernet switch implementation. My switches don't do spanning tree protocol, but they will drop duplicate frames...using a hash-set of CRC32s of recent frames. It's pretty ghetto.

Home Automation Stuff

I've discovered ESP8266. After some trouble programming the first one with the Arduino IDE (due to a combination of a bad ESP8266 board and a bad USB cable) I got going and started building temperature/humidity sensors and battery charge controllers all over. They both use MQTT for logging, specifically the following format for messages:

[<ISO 8601 timestamp>] {<key>:<value>}* [# <comment>]

e.g.

2017-04-29T15:22:43-05:00 batteryVoltage:13.03 regPowered:1 regConnected:1 time:187746 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:44-05:00 batteryVoltage:13.17 regPowered:1 regConnected:1 time:188754 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:45-05:00 batteryVoltage:13.10 regPowered:1 regConnected:1 time:189761 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:46-05:00 temperature:16.70 humidity:36.00 nodeId:K0-20-K6-04-7N-21/dht0
2017-04-29T15:22:46-05:00 batteryVoltage:12.96 regPowered:1 regConnected:1 time:190769 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:46-05:00 # Increased bogon flux detected...
2017-04-29T15:22:47-05:00 batteryVoltage:12.75 regPowered:1 regConnected:1 time:191777 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:49-05:00 batteryVoltage:12.82 regPowered:1 regConnected:1 time:192785 nodeId:5M-MP-7P-34-44-7L
2017-04-29T15:22:49-05:00 temperature:16.70 humidity:35.90 nodeId:K0-20-K6-04-7N-21/dht0

Node IDs are MAC addresses, if you hadn't already guessed.

I built a couple of 20+3/4"-wide shelves to mount stuff on. 20+3/4" was chosen as the width because with 1+1/2"-thick legs (2x2s or 2x3s) that makes it a 19" rack (gap between rails ('aperture') in a 19" rack is about 17.75"). I don't have any 19" racks or equipment, but I like the idea of them, so decided to make my stuff 'compatible', even though it's all made out of scrap wood.

Here's my battery charge control panel, all hooked up:

It keeps a car battery charged for days when the sun isn't shining. Or on days when the sun is shining, but I haven't yet assembled enough solar panels. Such as today.

Parts (from top-left to bottom-right):

I like to standardize my connectors somewhat:

The pile of parts I've acquired lately is going to require some organizing if I'm going to be able to find things later, or even remember what I have.

The Factory

Since I was spending a lot of my free time trying to re-invent Factorio (that's a simplification; while my ultimate vision for Game21 includes simulated power networks, railroads, automated crafting, and pre-rendered sprites, it is otherwise completely different from Factorio), I e-mailed them and asked if I could work on their thing. If I'm going to be dedicating brainpower to something, may as well have someone pay me for it, right? A few C++ quizzes, several weeks, and a trip to Prague later and it seems we have an arrangement. So that's exciting. Hopefully some of my weird ideas will work their way in. >:-)

Working on Factorio has sparked some thoughts about the different approaches to implementing a simulator (immutable, independent objects vs stateful interlinked ones, scaling out by parallelization vs optimizing by skipping unneeded calculations, and how the different approaches are sometimes at odds with each other), but I think I'll save that essay for later. John Carmack has already gone there.