Thursday, March 6, 2008

SEL Relay Password Changing Utility

The Password Changing Utility was as the name suggests. SEL's electric relays and communication processors are communicated with through either serial or ethernet (or some jumping through hoops with old-school modems), but the interface is pure command line. Changing the password on a relay -- a single relay -- requires something like 6-10 commands + connection configurations. Changing 20 of them is somewhat cringe inducing.

So, written in wxWidgets, C++, and teraterm script, and calling on Teraterm and PWGen to do some work for it, this utility was meant to fill a need. =)

Now... because so much of programming is procedural in nature, and easiest to explain as if it was a procedure, here's how it works:

1) The user, with the same settings they would use if doing things the "old" way, enter the information needed to communicate/change the password of a relay, then add that job to the queue.

2) According to the parameters selected -- such as the Method of connection and the Relay to change the settings of, the program, using a number of Teraterm template scripts I created, mixes and matches together the appropriate script to get the job done.

3) After the user has added all jobs to the queue, they press Go. And presumably leave the program for a while.

4) The program flashes rather annoyingly (like AIM or IRC clients do on a new message) when the tasks are done. It also provides a log file of whether or not each password was successfully changed.


Programmer's note: This was my first wxWidgets project, and after using it I concluded that Win32 (now the Windows API) should never be used again, if possible. There's something to be said for not having to reinvent the wheel every time you make a gui app.

note2: Because wxWidgets executables are enormously gigantic (no single word in the english language can properly describe a 1.5 MB Hello World program), this project led me to the brilliant little program UPX, which shrinks the bloated exe quite nicely back down to something more acceptable.

PHP Web HMI

The PHP Web HMI was the first project I made last summer as an intern at SEL. The basic idea, given to me by my boss/coworker Roger, was to create a web interface to report and interact with the status of a series of relays connected to a SEL 33xx device in (something like) real time.

The SEL 33xx (3351, 3332 ...) are specialized, hardy computers running software that can be communicated with using a number of different protocols -- such as Modbus. From a previous project at SEL that was done during the previous summer, I had experience with Modbus.

So, using PHP to act as a TCP client, I wrote the program. It runs in IE, Firefox, and Opera, and is probably maybe standards compliant, though I don't think I made sure. (oops)


Essentially, here's how it works:
  1. Page loads. PHP HMI runs...
  2. Using Modbus, the HMI gets the appropriate data from the Modbus server (the 33xx device).
  3. The data comes as a number of 16 bit registers. According to those, the breakers are displayed as open or closed. The values correspond to current or voltage, depending on what the end user wants to see.
  4. Page uses an HTTP header to trigger a refresh every 3-5 seconds. Go back to #1.

After this was working, I was asked if I could make clicking on the individual breakers send a message that would open or close them respectively.

That required:
  • a relatively secure PHP login. (if the page is public, allowing everyone who can find it to mess with the breakers seems, at minimum, a nuisance)
  • Javascript to confirm the action (avoiding catastrophic accidental clicks ;P)
  • JSON to make the open/close action occur while still staying on the same page.

Anyway, I did it, it worked, there was much rejoicing. This project is and/or will be, I am told, something used to visualize and operate parts of electrical power systems.