Best practice question

I am rewriting a desktop application that reads electric submeters, displays the logged info and allows the property owner to bill his tenants for the power they used. The new version will be a web app that will run on an Alix 3D3 computer with an AMD LX800 processor. While this is underpowered by today’s standards (500Mhz, single core, similar to an Intel Atom), I am hoping it has sufficient capability to read the meters and handle one or two users at a time. I would like some input as to whether a single program with the web interface plus the meter reading routines would be better than separate programs. Some of the things I am thinking about:

The meters are either read automatically on a schedule stored in the database or on demand by a user (only administrators, so probably never more that one online at a time). Because they are read through a serial port, only one can happen at a time so an “in use” flag needs to be set whenever the meters are being read.

Other threads in this forum indicate that one program should run the user interface and another any background tasks (reading the meters). I don’t know if that will be true with my LX800 processor. I am afraid the user interface is going to be interrupted whenever that meters are being read in either scenario. Is Linux better at task sharing than a thread in a single program? Depending on the number of meters in the system, it may take several minutes to read them all.

It is important that all the meter readings occur at the scheduled times. This seems to favor two separate programs as the meter reader would continue to run if the web app should crash for some reason.

I already have a ServiceApplication that runs along side the desktop program that reads the meters on the schedule. I have not looked into modifying it so the web app could send messages to it and receive responses, but it should not be too hard to implement. If I go with the separate application, should it be a ServiceApplication or a WebApplication? What would be the best method for communicating between the two programs?

Following the scheme of the desktop application, my web app now has the meter reading class as a property of a WebContainer. If I go with a single program, it will have to be moved to the app or the “in use” flag will have to be an app property. This last one is most likely not viable as the flag could be left set if a user ended his session while the meters were being read.

Your thoughts on how I should approach this will be greatly appreciated.

What about a background app that reads the meters and saves the output to files, each with a name based on the date/time of the reading. The main app would only need to look for those files and, if it needs a fresh reading, would launch the app, wait for it to quit, then read the data in the latest file. The reading app could be a cron job so it reads at given times regardless of what else is happening on the system.

That’s essentially what the service application I have now does. But running it with cron would be a lot better than having it running all the time. The main application can create and modify the crontab. Thanks for the great suggestion.