The SensorShell is designed to support the following requirements of sensors.
A primary requirement for any Hackystat sensor, aside from actually collecting sensor data, is transmitting it to the Hackystat server. This involves converting the data to a specific XML format and sending it to the server via the SOAP protocol.
The SensorShell implements the Hackystat SOAP/XML transmission protocol and provides an abstract interface for tool developers so that they are insulated from these implementation details.
A sensor frequently needs to buffer a set of individual sensor data instances for later transmission to the server. This is because it would incur too much overhead (both on client and server) to send each individual sensor data instance in its own SOAP request.
For example, an editor sensor might generate a sensor data instance every few seconds. The overhead of setting up a SOAP request might take a second or more, while the overhead of sending each individual sensor data instance to the server is a small fraction of that. Without buffering, the overhead of sensor data transmission will be high, and this overhead will be primarily due to client-server transmission setup overhead, not the actual sensor data itself. Buffering sensor data instances and sending many of them in a single SOAP request minimizes the overall overhead of transmission.
The SensorShell automatically buffers sensor data provided to it by a tool.
While buffering sensor data is important to reduce overhead, it is also important to not buffer too much sensor data, and to not buffer sensor data for too long. For example, an editor session might last for many hours or even days. If one buffered all of the sensor data until the session finally ended, then the server-side analyses would be inaccurate for the time intervals during which the data was held locally. Worse, if the tool crashed unexpectedly, the buffered data would be lost.
To solve this problem, sensors for tools with long sessions should periodically send their buffered data. A reasonable default value is once every 10 minutes.
The SensorShell provides periodic background data transmission that is user-controllable via the HackyInstaller application.
Not all Hackystat users are connected to the Internet at all times. Developers work on planes, trains, and automobiles. To accomodate such intermittent connectivity, it is helpful for sensors to cache sensor data locally when no connection to the Hackystat server can be made, and then send that data off once a connection is re-established. Of course, the sensor data must retain the timestamps associated with their original collection point, as opposed to the time at which they can finally be sent to the server.
The SensorShell checks for the presence of the user's Hackystat server on startup, and automatically caches sensor data in the user's .hackystat/offline directory if the server is not available. Each time the SensorShell starts up and successfully contacts the server, it checks to see if any offline data has been previously stored, and if so, sends it to the server.
For debugging and development purposes, it is useful for a sensor to provide log files containing information about the sensor data obtained and transmittted on the client side.
The SensorShell provides automatic logging of sensor data collection and transmission events. These files are created and stored in the user's .hackystat/logs directory.
Each sensor should validate the data that it collects as appropriate for the type of sensor data it intends to represent it as. ("Validation" in this sense means checking that all of the required fields associated with the sensor data type are provided and that the types of those fields are correct.) If the collected data is not valid, then steps should be taken on the client-side to correct or improve it before transmission to the server.
The SensorShell checks for sensor data validity each time a tool provides data to it, and signals an error if invalid data was supplied.