KatanaNativeInterface  $VERSION$
kmlFactories.h
Go to the documentation of this file.
1 
2 #ifndef KMLFACTORIES_H
3 #define KMLFACTORIES_H
4 
5 #include "common/exception.h"
6 
7 #include "KNI/kmlBase.h"
8 #include "KNI/kmlMotBase.h"
9 #include "KNI/kmlSctBase.h"
10 
11 #include <string>
12 #include <fstream>
13 
18 
23 public:
25  Exception("ConfigFile is not open or other failure", -41) {}
26 };
27 
32 public:
33  ConfigFileSectionNotFoundException(const std::string & attribute) throw ():
34  Exception("Could not find section '" + attribute + "' in configfile", -42) {}
35 };
36 
41 public:
42  ConfigFileSubsectionNotFoundException(const std::string & attribute) throw ():
43  Exception("Could not find subsection '" + attribute + "' in configfile", -43) {}
44 };
45 
50 public:
51  ConfigFileEntryNotFoundException(const std::string & attribute) throw ():
52  Exception("Could not find entry '" + attribute + "' in configfile", -44) {}
53 };
54 
59 public:
60  ConfigFileSyntaxErrorException(const std::string & line) throw ():
61  Exception("Syntax error in this line: '" + line + "'", -45) {}
62 };
63 
67 
68 
69 namespace KNI {
70 
76  private:
77  std::ifstream _configfile;
78  void _readEntry(char* dest, int destsz, const char* section, const char* subsection, const char* entry);
79  public:
80 
82 
83  bool openFile(const char* filepath) {
84  _configfile.open(filepath);
85  return _configfile.fail() ? false : true;
86  }
87 #ifdef _UNICODE
88  bool openFile(const wchar_t* filepath) {
89  _configfile.open(filepath);
90  return _configfile.fail() ? false : true;
91  }
92 #endif
93 
98  TMotDesc* getMotDesc(short count);
99  TSctDesc* getSctDesc(short count);
100 
101  TMotCLB getMotCLB(short number);
102  TMotSCP getMotSCP(short number);
103  TMotDYL getMotDYL(short number);
106  int getType();
107 
108  TMotInit getMotInit(short number);
109 
110  void getGripperParameters(bool& isPresent, int& openEncoders, int& closeEncoders);
111  };
112 
113 
114 
115 }
116 
117 #endif
ConfigFileStateException::ConfigFileStateException
ConfigFileStateException()
Definition: kmlFactories.h:24
KNI::kmlFactory::getMotDYL
TMotDYL getMotDYL(short number)
KNI::kmlFactory::getEFF
TKatEFF getEFF()
KNI::kmlFactory::openFile
bool openFile(const char *filepath)
Definition: kmlFactories.h:83
KNI::kmlFactory::getMotDesc
TMotDesc * getMotDesc(short count)
KNI::kmlFactory::_configfile
std::ifstream _configfile
Definition: kmlFactories.h:77
kmlSctBase.h
KNI::kmlFactory
This class is for internal use only It may change at any time It shields the configuration file parsi...
Definition: kmlFactories.h:75
ConfigFileSectionNotFoundException
The requested section could not be found.
Definition: kmlFactories.h:31
ConfigFileSyntaxErrorException
There was a syntax error in the configuration file.
Definition: kmlFactories.h:58
KNI::kmlFactory::getMotCLB
TMotCLB getMotCLB(short number)
TMotInit
Initial motor parameters.
Definition: kmlMotBase.h:198
ConfigFileSectionNotFoundException::ConfigFileSectionNotFoundException
ConfigFileSectionNotFoundException(const std::string &attribute)
Definition: kmlFactories.h:33
KNI::kmlFactory::getMotSCP
TMotSCP getMotSCP(short number)
TMotSCP
[SCP] static controller parameters
Definition: kmlMotBase.h:109
kmlBase.h
ConfigFileEntryNotFoundException::ConfigFileEntryNotFoundException
ConfigFileEntryNotFoundException(const std::string &attribute)
Definition: kmlFactories.h:51
TKatEFF
Inverse Kinematics structure of the endeffektor.
Definition: kmlBase.h:113
TMotDYL
[DYL] dynamic limits
Definition: kmlMotBase.h:137
TMotCLB
Calibration structure for single motors.
Definition: kmlMotBase.h:181
ConfigFileSyntaxErrorException::ConfigFileSyntaxErrorException
ConfigFileSyntaxErrorException(const std::string &line)
Definition: kmlFactories.h:60
ConfigFileStateException
The state of the configuration file wasn't "good".
Definition: kmlFactories.h:22
KNI
Definition: Timer.h:30
ConfigFileSubsectionNotFoundException::ConfigFileSubsectionNotFoundException
ConfigFileSubsectionNotFoundException(const std::string &attribute)
Definition: kmlFactories.h:42
ConfigFileSubsectionNotFoundException
The requested subsection could not be found.
Definition: kmlFactories.h:40
Exception::Exception
Exception(const std::string &message, const int error_number)
Definition: exception.h:85
Exception
Definition: exception.h:79
KNI::kmlFactory::getGripperParameters
void getGripperParameters(bool &isPresent, int &openEncoders, int &closeEncoders)
TSctDesc
sensor controller description (partly)
Definition: kmlSctBase.h:33
KNI::kmlFactory::getSctDesc
TSctDesc * getSctDesc(short count)
KNI::kmlFactory::getMotInit
TMotInit getMotInit(short number)
TKatMOT
[MOT] every motor's attributes
Definition: kmlMotBase.h:40
KNI::kmlFactory::getType
int getType()
returns the Katana type
TKatSCT
[SCT] every sens ctrl's attributes
Definition: kmlSctBase.h:41
TKatGNL
[GNL] general robot attributes
Definition: kmlBase.h:67
KNI::kmlFactory::getGNL
TKatGNL getGNL()
KNI::kmlFactory::getMOT
TKatMOT getMOT()
KNI::kmlFactory::kmlFactory
kmlFactory()
TMotDesc
motor description (partly)
Definition: kmlMotBase.h:34
ConfigFileEntryNotFoundException
The requested entry could not be found.
Definition: kmlFactories.h:49
DLLDIR
#define DLLDIR
Definition: dllexport.h:30
KNI::kmlFactory::getSCT
TKatSCT getSCT()
exception.h
KNI::kmlFactory::_readEntry
void _readEntry(char *dest, int destsz, const char *section, const char *subsection, const char *entry)
kmlMotBase.h