From iLab Cookbook

Toolkits: HowToGetInformationFromASharedPhidgetsDictionaryPath

<< Back to the SharedPhidgets page


You can use the SharedPhidgets Util class, that provides a variety of static methods to get information from a shared dictionary path expression (or you can still parse the path string by yourself):


// Use one of the paths in the shared dictionary
string mypath = "/sharedphidgets/phidgetservo/148/attached";

int serial          = GroupLab.SharedPhidgets.Util.getSerialFromPath(mypath);
string type         = GroupLab.SharedPhidgets.Util.getTypeFromPath(mypath);
Array pathElements  = GroupLab.SharedPhidgets.Util.getPathElements(mypath);

 



// You can also use the filter methods to verify if a
// path expression matches to a particular device

bool test;
test = GroupLab.SharedPhidgets.Util.filterPhidgetType(mypath,
  GroupLab.SharedPhidgets.Constants.PHIDGET_IF); // false

test = GroupLab.SharedPhidgets.Util.filterPhidgetType(mypath,
  GroupLab.SharedPhidgets.Constants.PHIDGET_SERVO); //true

test = GroupLab.SharedPhidgets.Util.filterSerial(mypath, 921); // false

test = GroupLab.SharedPhidgets.Util.filterSerial(mypath, 148); // true

 



Retrieved from http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/Toolkits/HowToGetInformationFromASharedPhidgetsDictionaryPath
Page last modified on January 24, 2006, at 03:05 PM