How to Traverse ABB’s Aspect Directory Structure

The utility that I’ve explained in the previous article (i.e. the OPCGUID.EXE) has some limitations because it just provides indication whether the supplied query returns the appropriate objects. The prerequisite is that I have to know at least partial information about the objects I sought for.

So here, I will explain some methods to perform basic function to traverse (i.e. to list out) available objects inside the Aspect Directory Structure.

The basic architecture of this kind of task is accomplished by server and client model, i.e. the client perform the request and the servers provides the feedback or response to the client.

When I activates the opcguid.exe utility to get the object ids of *t13* for example, my utility actually send the request to the available servers on ABB PPA’s framework. You can refer to the previous articles about some of these servers.

To handle the task of finding the GUID of the names, or vice versa, is carried out by AfwSNSrv.Exe server that gets activated when the ABB’s services is running. In this case, the client will send request command to this server using socket API and receive the response and show the result to the screen.

OPCGUID utility relies on methods provided in IAfwTranslate to perform its task, but there are no methods to perform traversing or browsing of the tree structure.

This task is actually resides in IAfwStructureServer inteface. You can peform QueryInterface method to IAfwObjectManager object to obtain pointer to instance of this interface.

There are some basic function to perform some traversal such as ListDescendants, but one method that will provide comprehensive information of the structure is obtained via GetBrowser method.

The GetBrowser methods will give the IUnknown interface of the object. The actual browser object is obtained by calling QueryInterface to this unknown interface object to get IAfwBrowsingSupport.

Now before this object can be useful, you have to provides some initialization information to AfwSNSrv.exe so that the server acknowledges and can carry out the browsing task.

To perform the initialization, you have to call SetEnvironment by providing the relevant information in the parameters to the server. The functional prototype of this method is :

SetEnvironment([in] long countNameCats, [in] AfwAspectCategoryId* nameCategoryIds, [in] long useWeakBinding, [in] IAfwBrowsingCallback* callback);

The first parameter is the number of name category id that get passed to the method, the second parameter is the actual id, the third one is some unknown internal flag, the fourth is used when you require a callback of what happens to the server. The third and fourth parameter can be ignored by setting them to null value.

If you forget to call the above method, you will get 0x8ABB0A25 error code, which is an E_AFW_SNS_NO_BROWSER each time you call one of the traversal methods.

The name category is actually the file in the format of {GUID}.dat that contains all the names for the object id. Usually the GUID of this file is {9879EB4B-87FA-11D1-B1E0-0060B017F346}. Depending on the setup information, this file resides in Categories folder. In my case, it is precisely in C:\OperateITData1\AspDir\Categories folder, with {9879EB4B-87FA-11D1-B1E0-0060B017F346}.dat as its file name.

So for the second parameter, you can pass this GUID to let this method returns appropriate name of each object. Actually you can pass any other of the GUID inside the directory, but of course when the server can’t find the name by looking up into this file, it just returns null value for name pointer string. As it is implies in the countNameCats, you can pass an array of this id for name look up.

After this, you are free to call any relevant method in this interface, for example GetRoots or GetSubtree.

Oh, and don’t forget to call the ClearEnvironment method after you’ve finish the browsing session to let the server to free some allocated resources 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: