How To Work With Metadata Entries

<< Back to the SharedPhidgets 3 page

The metadata functionality provides you an easy-to-use method to add custom tags to your hardware devices, and use them in every of your developed applications.


  1. Metadata tags are key-value pairs with string values; e.g. key="appliance", value="saul's home".
  2. There are two ways to work with metadata: 1) you use the connector tool OR 2) you work with metadata in your programs with the API.
  3. When you add, modify, or delete metadata entries, then the equivalent Shared Dictionary entry will be updated immediately. This ensures the synchronous use of metadata at the complete architecture.
  4. The following two sections explain at first how you can use the metadata config dialog, and then how you can access and modify metadata in your software using the API.

Metadata in the connector tool

1) Start the SharedPhidgets Server and then the Connector.

2) Attach a few hardware devices to you computer. Switch to the Metadata tab in the Connector window, and you can see the following dialog:

3) There you can see a list of all attached and detached hardware devices

4) Three different colours indicate the status of the hardware device: Green for attached, Red for detached, and Orange for devices that are saved in the XML file, but that have not recently been used.

5) You can click each of these entries, to see the specified metadata on the right side of the screen.

6) This is the info box with the phidget type, the serial, as well as the pre-defined metadata tags: location, owner, and keywords.

7) You can override each of the pre-defined tags by clicking the button Override next to the entry.

8) In the lower right corner of the dialog window you see the list of all metadata tags applied to this Phidget device.

9) You can for example click the Add... button to create a new tag...

10) Or you can modify and delete existing entries. All the entries are saved in a local XML file on the computer where the Connector tool is running. These XML files can also modified manually, or exhanged with another computer as well.

Metadata API

1) Besides using the Connector tool, you can also use the API directly in your programs to create and read metadata tags.

2) The functionality to work with metadata is encapsulated in the DeviceDescription object. Each of the hardware components has this object as a property, so you can access it directly. The way to work with metadata is identically for all hardware devices (in this example here we use a servo).

3) Read a metadata tag:

string val = this.servo.DeviceDescription.GetMetadata("applicance");

4) Add or modify a metadata tag:

this.servo.DeviceDescription.AddMetadata("NewTag", "some value");

5) Check if a metadata key is available:

bool val = this.servo.DeviceDescription.ContainsMetadataKey("NewTag");

6) Get Hashtable with ALL metadata entries of this device: This is useful if you want to iterate through all metadata entries of this device.

Hashtable table = this.servo.DeviceDescription.GetMetadataHashtable();

Metadata in the Shared Dictionary

  • As described above, all the metadata key-value-pairs that you add with one of the both methods explained are saved in the Shared Dictionary as well
  • An entry in the dictionary looks like this:
/sharedphidgets/servo/1882/metadata/appliance/ = "home"
  • Therefore it is also very easy to add or change entries there in the Shared Dictionary directly
  • You can for example iterate over all metadata entries with the following pattern:
  • Note: Please be aware, that if you add a metadata entry directly to the dictionary, there is no instance that saves this entry persitently. This means, the Connector tool saves ONLY the entries that the user is added directly in the tool. This ensures, that not every connected application can change the locally stored entries.