/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#include "../headers/system_config.h"

#ifdef PLATFORM_APERIOS
#include <Types.h>
#endif

#include "../headers/Config.h"
#include "../headers/Dictionary.h"

Config config;

void
Config::init() {
  spoutConfig.dumpVisionColorArea=0;
  spoutConfig.dumpVisionAvgColor =0;
  spoutConfig.dumpVisionRaw      =0;
  spoutConfig.dumpVisionRLE      =0;
  spoutConfig.dumpVisionObj      =0;
  spoutConfig.dumpVisionRadialMap=0;
  spoutConfig.dumpModelObj       =0;
  spoutConfig.dumpTracker        =0;
  spoutConfig.dumpWMDebug        =0;
  spoutConfig.dumpBehAct         =0;
  spoutConfig.dumpLocalization   =0;
  spoutConfig.dumpGSensor        =0;
  spoutConfig.dumpFootSensor     =0;
  spoutConfig.dumpDutyCycle      =0;
  spoutConfig.dumpTeamMsgMgrObj  =0;
  spoutConfig.dumpBehaviorNames  =0;
  spoutConfig.dumpBehaviorTrace  =0;
  spoutConfig.dumpRate           =true;
  spoutConfig.dumpProfile        =false;
}

void
Config::config(const char *filename) {
  Dictionary cfg_dict;
  cfg_dict.read(filename);

  const char *spout_cfg_file="";
  if(cfg_dict.getValueString("spout_cfg",spout_cfg_file))
    configSPOut(spout_cfg_file);
}

void
Config::configSPOut(const char *filename) {
  Dictionary spout_dict;
  spout_dict.read(filename);

  int enable=0;
  if(spout_dict.getValueInt("dump_vision_avg_color",enable))
    spoutConfig.dumpVisionAvgColor = enable;
  if(spout_dict.getValueInt("dump_vision_color_area",enable))
    spoutConfig.dumpVisionColorArea = enable;
  if(spout_dict.getValueInt("dump_vision_raw",enable))
    spoutConfig.dumpVisionRaw = enable;
  if(spout_dict.getValueInt("dump_vision_rle",enable))
    spoutConfig.dumpVisionRLE = enable;
  if(spout_dict.getValueInt("dump_vision_obj",enable))
    spoutConfig.dumpVisionObj = enable;
  if(spout_dict.getValueInt("dump_vision_radial_map",enable))
    spoutConfig.dumpVisionRadialMap = enable;
  if(spout_dict.getValueInt("dump_model_obj",enable))
    spoutConfig.dumpModelObj = enable;
  if(spout_dict.getValueInt("dump_tracker",enable))
    spoutConfig.dumpTracker = enable;
  if(spout_dict.getValueInt("dump_wmdebug",enable))
    spoutConfig.dumpWMDebug = enable;
  if(spout_dict.getValueInt("dump_beh_act",enable))
    spoutConfig.dumpBehAct = enable;
  if(spout_dict.getValueInt("dump_localization",enable))
    spoutConfig.dumpLocalization = enable;
  if(spout_dict.getValueInt("dump_move_update",enable))
    spoutConfig.dumpMoveUpdate = enable;
  if(spout_dict.getValueInt("dump_rate",enable))
    spoutConfig.dumpRate = (enable != 0);
  if(spout_dict.getValueInt("dump_profile",enable))
    spoutConfig.dumpProfile = (enable != 0);
  if(spout_dict.getValueInt("dump_g_sensor",enable))
    spoutConfig.dumpGSensor = enable;
  if(spout_dict.getValueInt("dump_foot_sensor",enable))
    spoutConfig.dumpFootSensor = enable;
  if(spout_dict.getValueInt("dump_duty_cycle",enable))
    spoutConfig.dumpDutyCycle = enable;
  if(spout_dict.getValueInt("dump_team_msg_mgr_obj",enable))
    spoutConfig.dumpTeamMsgMgrObj = enable;
  if(spout_dict.getValueInt("dump_behavior_names",enable))
    spoutConfig.dumpBehaviorNames = enable;
  if(spout_dict.getValueInt("dump_behavior_trace",enable))
    spoutConfig.dumpBehaviorTrace = enable;
}
