The ME3Gas Context Manager is a stand-alone software component which is intended to provide applications with context information, for instance the layouts of physical buildings, the location and state of energy consuming devices as well as users in those buildings, user activities and behaviours, and so on.
The context engine takes an object-oriented approach, where the possible content of the context, i.e. the objects themselves is driven and controlled by a simple schema, i.e. a model of what objects can be made available in the context, but also a model of their relations. The engine features a simplified schema with few rules and in a human-readable format. Several schemas can be aggregated, allowing for experts to provide base schemas, perhaps somewhat more complex in their form while still providing power to the end users and the inhabitants, so as to adapt to the specific needs of a household, a building or a custom-made online sensor.
The context engine runs as a web server, providing an open REST based API which allows context information to be queried as well as updated.
A more detailed description of the Context Manager can be found in ME3Gas D4.2 deliverable available on the ME3Gas web site.
A detailed description of the Context Manager API and runtime model can be found here.
The context manager is coded in a programming language called Tcl and requires Tcl 8.5 (at least) to start and run. In addition to Tcl itself, there are a number of modules and libraries that are requested. On a modern linux distribution a number of the core libraries are part of the regular package repository. In a Windows environment, we recommend using the ActiveTcl distribution and to bring in the necessary package using the TEApot. On Mac OSX, most of the libraries can be found on MacPorts, but you might also want to install the ActiveTcl distribution and use the TEApot as on Windows.
The main dependencies are:
In addition, a number of contributed libraries are necessary. For best results, place those under a directory of your choice, one directory per library. The context manager contains an initialisation script that will ensure proper linking of these directories into the main code structure (see below). The libraries are:
Finally, a number of other libraries by the same author as the context manager are necessary. For an easy setup, issue the following commands in a directory of your choice:
svn co http://efr-tools.googlecode.com/svn/trunk/efr-lib lib
svn co http://efr-tools.googlecode.com/svn/trunk/til
svn co http://efr-tools.googlecode.com/svn/trunk/redis
Once you have installed all necessary packages, you should edit the file called makelinks.tcl in the make directory so as to ensure that it will pick up the proper packages and libraries from the proper directories. Then run tclsh8.5 make/makelinks.tcl, assuming that you have a command prompt in the directory hosting the context manager. This Tcl script aims at populating the lib directory with pointers to the directories hosting the necessary libraries. On windows, shortcuts will be created (i.e. files with the extension .lnk) and on the UNIX family of computers (including MAC OSX), symbolic links will be created. The script also copies bootstrapping files necessary to a smooth initialisation. These files are crucial, since one of their purpose is to actually be able to read out the content of windows shortcuts and follow those as if they were symbolic links. The purpose of this rather cumbersome indirection is to keep a directory structure that is the same across all platforms and to abstract all platform discrepancies from the main code base.
Once you have performed those operations, starting the context manager is as simple as running the following command:
tclsh8.5 contextManager.tcl -verbose debug
This will place the context manager in verbose mode, allowing you to detect any problems that might occur. Note that the debug level of verbosity produces quite a lot of output, so you might want to change that at a later time. The context manager host a web server on port 8800 (SSL) and 8802 by default, so might need to open up holes in your firewall for accessing it. The present distribution provides a number of example files meant to ease exploration of the features offered by the context manager. We especially invite the reader to have a look at the following file and directories. In those directories, small README files are available for further comments:
contextManager.arg
contextManager.cfg
models/
cfg/
history/
As the JSON representations output by operations and requests on the web server are compact, we suggest to install a JSON prettifier as an extension to your browser. For example, JSON Formatter for Chrome/Chromium (https://github.com/callumlocke/json-formatter) or JSON View for Firefox (http://jsonview.com/).