
You are here: MyURC.org > Tools & Prototypes > UCHe > tutorial > Writing a TDM
How to Write a Target Discovery Module (TDM)
Page Content:
- Understand the UCH Architecture
- Write Your TDM
- Make Your TDM a Dynamic Library
- Configure the UCH to Use Your TDM
Understand the UCH Architecture
Please refer to the UCH specification.
Write Your TDM
Your TDM must implement the ITDM interface, and may use any method of the ITDMListener interface.
ITDM has the following methods:
- void init(ITDMListener *tdmListener, map
tdmProps, map uchProps)
init() is called only once by the UCH prior to any other method of TDM. UCH instantiates TDMs for starting discovery of particular device(s) for certain networking platforms.
- void startDiscovery()
Will start the discovery engine for discovering different devices in the network supporting the protocol for which the TDM has been written.
On discovering the device, a targetProps map has to be created with following keys:
- http://myurc.org/ns/res#type: value will be "http://myurc.org/TR/uch/#target" in this case.
- http://myurc.org/ns/res#targetFriendlyName
- http://myurc.org/ns/res#targetPlatform
- http://myurc.org/ns/res#manufacturer
- http://myurc.org/ns/res#modelName
- http://myurc.org/ns/res#deviceType
- http://myurc.org/ns/res#instanceId
This target property map has to be passed to the method - string ITDMListener.targetDiscovered(Map<String, Object> targetProps, Map<String, Object> taProps). Here the 'taProps' are properties of TargetAdapter, if the TDM knows the details of the TargetAdapter already.
The UCH shall return the targetId (string) that it has assigned the newly discovered target. This may be identical to the property ‘http://myurc.org/ns/res#instanceId’ in targetProps, if globally unique. NULL if the UCH does not instantiate a Target Adapter for this target, and does not want to be notified when the target will be discarded.
Using the above properties, UCH will search for the appropriate TA for the discovered target and accordingly initialize the TA and register the discovered target. Also the above target property map will be passed to the TA from the UCH.
TDM also needs to implement proper mechanism for detecting that a target has been discarded from the network. On detection, the TDM has to call the method void ITDMListener.targetDiscarded(string targetId)
- void stopDiscovery()
Stop discovering devices in the network.
- Map getTDMProps()
Get Property Map of the TDM, which was passed to the TDM when initialized.
- void finalize()
Clear the memory held by the TDM.
UCH header files required:
- ITDM.h
- ITDMListener.h
- LoggerUtil.h #if developer wants to use logging system of UCH
Make Your TDM a Dynamic Library
Please refer to How to create a dynamic library.
Configure the UCH to Use Your TDM
Please refer to How to Modify the UCH Configuration File.
Last update: Gottfried Zimmermann, Parikshit Thakur & Team,, 2008-12-03