scj7t4/FREEDM — pull request #270 by Catanzaro (2013-07-30 15:58:40+00:00)
Title: Plug n play

Changes to Broker in PnP outside of the devices folder. I've attempted to be fairly exhaustive:

* Support builds with srcdir != builddir; this accounts for most of the changes to CMakeList. The top-level .gitignore has been tweaked accordingly. (Note that it is still impossible to install the DGI; as with master it has to be run from the builddir.)
* A (long) while ago I put nbproject into the top-level .gitignore. This is removed because it belongs in user-specific configuration.
* A few less significant changes to CMakeLists: notably, Doxygen does not run if it's not installed (the option to disable it if installed remains), and we now explicitly enforce a minimum version of Boost (1.47: this is the version that master already depends on).
* Many of the sample configuration files have been updated, sometimes as necessary to support PnP, sometimes to work as well together out-of-the-box as possible. (E.g. there's no point in having mismatched ports between DGI/controller or DGI/simserv.)
* CBroker now starts and stops the adapter factory.
* CBroker catches SIGTERM to perform clean shutdown, in addition to SIGINT.
* CBroker owns its own ioservice, rather than receiving it from main.
* CBroker no longer receives address/port in its constructor, but looks them up in CGlobalConfiguration, since they are already stored there.
* CGlobalConfiguration now stores a few new settings introduced by PnP.
* CGlobalConfiguration::instance renamed to CGlobalConfiguration::Instance, to respect our method naming standard.
* A few new timings have been introduced by PnP; CTimings.[ch]pp has been regenerated and the samples updated accordingly.
* version.h removed; BROKER_VERSION macro is still available but has been moved to config.hpp, where configuration belongs.
* After CBroker::Stop is called, modules' attempts to schedule will be dropped. We used to have code to inform modules that it's time to quit, but it's been dropped until such time as a module chooses to make use of it. (CBroker::Schedule should probably return an int to indicate success or failure!)
* CBroker::HandleSignal now posts a call to CBroker::Stop instead of calling it directly. This fixes bugginess that results from attempting to do anything significant (e.g. use an iostream) inside of a signal handler.
* CBroker::HandleStop now removes every signal from its signal set, so that sending the same signal again from this point in the clean shutdown will trigger the default handler. (This should probably be done in CBroker::HandleSignal instead!)
* CBroker::HandleStop now reraises any signal that triggered the Stop (if the Stop is indeed in response to a signal, as opposed to an exception). It's wrong to catch a signal and not reraise it if we want to quit on it.
* The clock synchronizer is now (probably properly?) stopped in CBroker::HandleStop instead of CBroker::Stop.
* The logger is now thread-safe. (This is important because the devices subsystem now runs on a separate thread.)
* CMakeLists now again builds recursively, i.e. the top-level CMakeLists does not call the devices CMakeLists; rather the CMakeLists in src does. For sanity.
* DeviceRegistrationGenerator.py is now a CMake template (to support srcdir != builddir)
* LBAgent's empty destructor has been removed.
* LBAgent's default constructor has been removed.
* LBAgent::CollectState has been modified to support multiple device state collection.
* LBAgent will no longer initiate migrations with peers who have no devices. :)
* It looks like the very first CDeviceLogger in the system learns the gateway and the total number of devices. (?)
* LBAgent::HandleCollectedState now always calls LBAgent::SendNormal. This probably fixed something.
* PosixMain.cpp -> main.cpp since we don't have any alternate mains. Also remove the #ifdef __unix__ around main. This stuff only makes sense if we provide an alternative main for other systems.
* main has learned the --factory-port option for accepting PnP connections.
* main no longer returns successfully when something goes wrong.
* main no longer attempts to run the ioservice to flush it since we agreed that shouldn't be necessary anymore. (But do we still think that's the case?)
* A comment has been added to the bottom of main to explain that we can stop either by catching an exception or a signal. main now ends in assert(false) since this point should never be reached.
* main has otherwise been cleaned up a bit. Feel free to check the diff.
* SCAgent's empty destructor has been removed.
* SCAgent has changed quite a bit to perform multi-device state collection.
* Broker has gained a testing subdirectory, with lots of testing stuff. (Some results have moved to here from Docs.)
* Instructions on how to use CMake have moved from CMakeLists to the README, so that you don't have to read basic CMake instructions every time you use it.

Though many of these changes were only needed for PnP, most should have been done in master instead; my apologies for contributing to "PnP bloat."