Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * dcm_utils.cpp - DCM utility functions 00004 * 00005 * Created: Thu Aug 11 11:00:26 2011 00006 * Copyright 2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "dcm_utils.h" 00024 00025 namespace dcm { 00026 #if 0 /* just to make Emacs auto-indent happy */ 00027 } 00028 #endif 00029 00030 void 00031 set_value(AL::ALPtr<AL::DCMProxy> &dcm, 00032 const std::string &device, const std::string &kind, 00033 float value, int time) 00034 { 00035 AL::ALValue cmd, actcmd, actpos; 00036 00037 cmd.arrayPush(device); cmd.arrayPush(kind); 00038 actpos.arrayPush(value); actpos.arrayPush(time); 00039 actcmd.arrayPush(actpos); cmd.arrayPush(actcmd); 00040 00041 dcm->set(cmd); 00042 } 00043 00044 00045 std::vector<std::string> 00046 get_devices(AL::ALPtr<AL::DCMProxy> &dcm, AL::ALPtr<AL::ALMemoryProxy> &almem, 00047 std::string type) 00048 { 00049 AL::ALValue names = almem->getDataListName(); 00050 std::string subd_prefix = dcm->getPrefix()[0]; 00051 00052 std::vector<std::string> rv; 00053 00054 // Walk sub-device tree and extract joints 00055 for (unsigned int i = 0; i < names.getSize(); ++i) { 00056 std::string name = names[i]; 00057 if ( name.compare(0, subd_prefix.length(), subd_prefix) == 0 ) { 00058 if ( name.compare(name.length() - 5, 5, "/Type") == 0 ) { 00059 std::string dtype = almem->getData(name, 0); 00060 std::string base_path = name.substr(0, name.length() - 5); 00061 if ( dtype == type ) { 00062 rv.push_back(base_path); 00063 } 00064 } 00065 } 00066 } 00067 00068 return rv; 00069 } 00070 00071 } // end of namespace dcm