00001 #include "SIGEL_Robot/SIG_Drive.h" 00002 00003 namespace SIGEL_Robot { 00004 SIG_Drive::SIG_Drive (SIG_Robot *par, QString n, int nr = -1) 00005 : parent (par), number (nr), name (n), theJoint (0), minforce (0.0), maxforce (1.0) 00006 { } 00007 00008 SIG_Drive::SIG_Drive (SIG_Robot *par, QTextStream & tx) 00009 : parent (par), number (-1), name (), theJoint (0), minforce (0.0), maxforce (1.0) 00010 { 00011 QString buf; 00012 00013 tx >> buf; 00014 if (buf == "force") 00015 mode = tForceMode; 00016 else if (buf == "relative") 00017 mode = tRelativeMode; 00018 else if (buf == "absolute") 00019 mode = tAbsoluteMode; 00020 tx >> name >> number >> minforce >> maxforce >> buf; 00021 theJoint = parent->lookupJoint (buf); 00022 } 00023 00024 SIG_Drive::~SIG_Drive (void) 00025 { } 00026 00027 QString SIG_Drive::getName (void) const 00028 { 00029 return name; 00030 } 00031 00032 int SIG_Drive::getNumber (void) const 00033 { 00034 return number; 00035 } 00036 00037 void SIG_Drive::setJoint (SIG_Joint *j) 00038 { 00039 theJoint = j; 00040 } 00041 00042 void SIG_Drive::setMode (SIG_Drive::DriveMode dm) 00043 { 00044 mode = dm; 00045 } 00046 00047 SIG_Joint const *SIG_Drive::getJoint (void) const 00048 { 00049 return theJoint; 00050 } 00051 00052 SIG_Drive::DriveMode SIG_Drive::getMode (void) const 00053 { 00054 return mode; 00055 } 00056 00057 void SIG_Drive::setForces(DL_Scalar mn, DL_Scalar mx) 00058 { 00059 minforce = mn; 00060 maxforce = mx; 00061 } 00062 00063 DL_Scalar SIG_Drive::getMinForce (void) const 00064 { 00065 return minforce; 00066 } 00067 00068 DL_Scalar SIG_Drive::getMaxForce (void) const 00069 { 00070 return maxforce; 00071 } 00072 00073 void SIG_Drive::writeToFileTransfer (QTextStream & tx) 00074 { 00075 tx << "Drive "; 00076 if (mode == tForceMode) 00077 tx << "force "; 00078 else if (mode == tRelativeMode) 00079 tx << "relative"; 00080 else if (mode == tAbsoluteMode) 00081 tx << "absolute"; 00082 else 00083 tx << "huh_grumpf"; 00084 tx << name << ' ' << number << ' ' 00085 << minforce << ' ' << maxforce << ' ' 00086 << theJoint->getName () << '\n'; 00087 } 00088 }