#include <string>
#include <iostream>

#include "INDIMotion.hpp"
#define	INDI_DRIVER_DEVICE	"Sci_Wheel_2"
#define INDI_DRIVER_VERSION	"0.2"
#define INDI_PROTOCOL_VERSION	"1.23"

int main(int /*argc*/, char* /*argv*/[])
{
  std::string szIndiPath(::getenv("SHARKNIRINDI"));
  std::string svcPath = "DATA.WHEEL.SCI_WHEEL2.SVC";
  int argc = 3;
  const int NUM_STRINGS = 4;
  char* argv[NUM_STRINGS] = {"main\0", 
  			     "--DATA.WHEEL.CONFIG:Endpoint=[NAME=WHEEL_CTRL, PORT=10211]\0", 
  			     "--LOGGER.LEVEL:LogLevel=INFO\0","0\0"};
  
  szIndiPath = (szIndiPath.length() == 0) ? (".") : (szIndiPath);

  pcf::Logger::init(szIndiPath + "/logs/" + INDI_DRIVER_DEVICE, INDI_DRIVER_DEVICE);
  
  int iErr = pcf::Config::init(szIndiPath + "/config/", INDI_DRIVER_DEVICE ".conf");
  if (iErr != pcf::ConfigFile::ErrNone)
    {
      pcf::Logger msgInfo;
      msgInfo << pcf::Logger::enumError << "Config for '" << INDI_DRIVER_DEVICE << "' had an error: "
      	      << pcf::Config::getErrorMsg(iErr) << std::endl;
    }

  INDIMotion driver(INDI_DRIVER_DEVICE, INDI_DRIVER_VERSION, INDI_PROTOCOL_VERSION, svcPath, argc, argv);
  std::cout << driver.getName() << std::endl; 

  
  std::cout << "Service path:" << driver.getSvcPath() << std::endl;

  driver.activate();

  driver.processIndiRequests();

  driver.deactivate();

  return(0);
}
