Language: C++

The COSMOS namespace provides access to a large number of commonly used devices. For each of these devices, as for example the GPS gpsstruc, items are defined in an internal structure that represent the most commonly used values for this device. These internal values are then mapped to names in the COSMOS Namespace.

If some device is not in the COSMOS namespace then it can be added by extending the code and recompiling. However, one of the driving principles of COSMOS is to provide a generic environment that avoids the necessity of changing and/or recompiling the code to support something new. In the case where changes to the code are not desirable, or the amount of new information does not warrant changes, a telemstruc has been provided. This generic telemetry device allows the assignment of a single value of any type, which then can be accessed as the appropriate type through standard names in the namespace. For further flexibility, these internally defined names can be mapped to user friendly names through aliases.

The example code shows how to use a generic device so that new information can be added without much effort. Another approach would be to create or add the piece of information directly into the namespace. This approach, although encouraged, requires more work. Please see add new device. The self contained example can be compiled and run using Qt creator from the folder cosmos/source/core/tutorials/namespace/generic-device. First open and compile the file in Qt Creator (this will compile agent_generic_device_neighbour.cpp) then open also in Qt Creator (this will compile agent_generic_device_test.cpp).

If you would like to print all available namespaces

string sohtemp = json_list_of_all(agent->cinfo).c_str();
printf("Devices: %s\n", sohtemp.c_str());

SOH namespaces

Devices: {

To view if a specific entry is within the COSMOS namespace, search for the device within core/libraries/support/jsonlib.cpp. Devices are indexed by this entry, an underscore, and a three digit ID (e.g . 000, 001, 002, …).

A TeX document is available on core/tutorials/namespace, which details much of the motivation and background behind the namespace itself.