How To Get Information About A Shared Phidgets Dictionary Path

<< Back to the SharedPhidgets 3 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 dictionary path manually):


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

string 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.FilterDeviceType(mypath,
  GroupLab.SharedPhidgets.Constants.PHIDGET_IF); // false

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

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

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