00001
00002 #ifndef INCLUDED_Config_h
00003 #define INCLUDED_Config_h
00004
00005 #include <vector>
00006 #include <string>
00007
00008
00009 class Config {
00010 public:
00011
00012 Config(const char* filename)
00013 : wireless(), vision(), main(), behaviors(), controller(), motion(),
00014 worldmodel2(), sound()
00015 { readConfig(filename); }
00016
00017 ~Config() {}
00018
00019
00020 enum section_t {
00021 sec_wireless=0,
00022 sec_vision,
00023 sec_main,
00024 sec_behaviors,
00025 sec_controller,
00026 sec_motion,
00027 sec_worldmodel2,
00028 sec_sound,
00029 sec_invalid
00030 };
00031
00032
00033 struct wireless_config {
00034 int id;
00035
00036 wireless_config () : id(1) {}
00037 } wireless;
00038
00039
00040 struct vision_config {
00041 int white_balance;
00042 int gain;
00043 int shutter_speed;
00044 int resolution;
00045 char thresh[30];
00046 char colors[30];
00047 int raw_port;
00048 int rle_port;
00049 int obj_port;
00050
00051
00052 vision_config() : white_balance(3), gain(2), shutter_speed(2), resolution(2), thresh(), colors(), raw_port(0), rle_port(0), obj_port(0) {}
00053 } vision;
00054
00055
00056 struct main_config {
00057 int console_port;
00058 int stderr_port;
00059 int error_level;
00060 int debug_level;
00061 int verbose_level;
00062 int wsjoints_port;
00063 int wspids_port;
00064 int headControl_port;
00065 int walkControl_port;
00066 int estopControl_port;
00067 int aibo3d_port;
00068 bool use_VT100;
00069
00070
00071 main_config()
00072 : console_port(0), stderr_port(0), error_level(0), debug_level(0),
00073 verbose_level(0),wsjoints_port(0),wspids_port(0),headControl_port(0),
00074 walkControl_port(0),estopControl_port(0),aibo3d_port(0), use_VT100(true)
00075 { }
00076 } main;
00077
00078
00079 struct behaviors_config {
00080 } behaviors;
00081
00082
00083 struct controller_config {
00084 int gui_port;
00085 char select_snd[50];
00086 char next_snd[50];
00087 char prev_snd[50];
00088 char read_snd[50];
00089 char cancel_snd[50];
00090
00091
00092 controller_config() : gui_port(0) {
00093 select_snd[0]=next_snd[0]=prev_snd[0]=read_snd[0]=cancel_snd[0]='\0';
00094 }
00095 } controller;
00096
00097
00098 struct motion_config {
00099 std::string root;
00100 char estop_on_snd[50];
00101 char estop_off_snd[50];
00102
00103
00104 std::string makePath(std::string name) {
00105 return (name[0]!='/')?root+"/"+name:name;
00106 }
00107
00108
00109 motion_config() : root() {
00110 estop_on_snd[0]=estop_off_snd[0]='\0';
00111 }
00112 } motion;
00113
00114
00115 struct worldmodel2_config {
00116
00117
00118 int dm_port, hm_port, gm_port, fs_port;
00119
00120
00121 worldmodel2_config() : dm_port(0), hm_port(0), gm_port(0), fs_port(0) {}
00122 } worldmodel2;
00123
00124
00125 struct sound_config {
00126 std::string root;
00127 unsigned int sample_rate;
00128 unsigned int sample_bits;
00129 std::vector<std::string> preload;
00130
00131
00132 std::string makePath(std::string name) {
00133 return (name[0]!='/')?root+"/"+name:name;
00134 }
00135
00136
00137 sound_config() : root(), sample_rate(0), sample_bits(0), preload() {}
00138 } sound;
00139
00140
00141 void readConfig(const char* filename);
00142
00143 protected:
00144
00145
00146 static bool extractBool(const char* value);
00147 };
00148
00149
00150 extern Config* config;
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 #endif