#ifndef THREE_PI_LIB_PACK_H
#define THREE_PI_LIB_PACK_H

#include "3pifunctions.h"
#include "loadConfig.h"
#include "servermessage.h"

void setConnection()
{
    config.loadFile("3pi.ini");
    gConnectionAddress = config.getValue("ip");
    gConnectionPort = config.getIntValue("port");
    gRobotName = "3pi";
}

bool initialization()
{
    setConnection();
    globalTimer.start();

    if(startClient() == false)
        return false;

    setPosition(config.getIntValue("defaultPosX"), config.getIntValue("defaultPosY"));
    setRotation(config.getIntValue("defaultRotZ"));
    setRGBColor(config.getIntValue("Rcolor"), config.getIntValue("Gcolor"), config.getIntValue("Bcolor"));

    return true;
}

void run();

void finish()
{
    endClient();
}

int main()
{
    std::cout << "YuniminClien - start\n" << std::endl;

    if( !initialization() )
    {
        std::cout << "Inicialization failed" << std::endl;
        return 0;
    }

    std::cout << "\n\t3pi robot is running...\n" << std::endl
              << "=======================================" << std::endl;

    run();

    std::cout << "=======================================" << std::endl
              << "\n\tProgram finished..." << std::endl;

    finish();
    return 0;
}

#endif // THREE_PI_LIB_PACK_H
