#include <iostream>
#include "NewGon.h"

int parse(std::string str, NewGon myGon) {
    if (str[0]=='Q' || str[0]=='q') // Q: End program
       return 0;

    if (str[0] == 'A' || str[0]== 'a') 
       if (str[1] == '1')
          std::cout << "axis[1].name: " << myGon.axis[1].name << "\n"; 
       if (str[1] == '2')
          std::cout << "axis[2].name: " << myGon.axis[2].name << "\n";
       if (str[1] == '3')
          std::cout << "axis[3].name: " << myGon.axis[3].name << "\n";
       if (str[1] == '4')
          std::cout << "axis[4].name: " << myGon.axis[4].name << "\n";
       if (str[1] == '5')
          std::cout << "axis[5].name: " << myGon.axis[5].name << "\n";
       if (str[1] == '6')
          std::cout << "axis[6].name: " << myGon.axis[6].name << "\n";
    if (str[0]== 'S'|| str[0]=='s')
    {
        myGon.runstep();
        std::cout << "axis[1].x: " << myGon.axis[1].pos << "\n"; 
    }

    return 1;
}

int main ()
{
    int ret;
    //Define Goniometer
    NewGon myGon; //create Goniometer object

    //Configure Goniometer
    myGon.setName("Wayne's NewGon");
    myGon.axis[1].setName("s1");
    myGon.axis[2].setName("s2");
    myGon.axis[3].setName("s3");
    myGon.axis[4].setName("s4");
    myGon.axis[5].setName("s5");
    myGon.axis[6].setName("s6");
    myGon.axis[1].setUnitUsr("mm");
    myGon.axis[1].setUnitCtr("nm");
   
    
    //User Feedback
    std::cout << "=============================" << "\n";
    std::cout << "PROGRAM TO DEBUG NewGon class" << "\n";
    std::cout << "-----------------------------" << "\n";
    std::cout << "myGon.name : '" << myGon.name << "'\n";
    std::cout << "myGon.MODE : " << myGon.MODE  << "\n";
    std::cout << "myGon.naxes: " << myGon.naxes << "\n";
/*    for (int i=1; i<=myGon.naxes; i++) {
       std::cout << "---------------------------------" << "\n";
        std::cout << "myGon.axis["<<i<<"].name    : '"  << myGon.axis[i].name << "'\n";
        std::cout << "myGon.axis["<<i<<"].unit_usr: '"  << myGon.axis[i].unit_usr << "'\n";
        std::cout << "myGon.axis["<<i<<"].unit_ctr: '"  << myGon.axis[i].unit_ctr << "'\n";
        std::cout << "myGon.axis["<<i<<"].scale   : "   << myGon.axis[i].scale << "\n";
        std::cout << "myGon.axis["<<i<<"].offset  : "   << myGon.axis[i].offset << "\n";
        std::cout << "myGon.axis["<<i<<"].LimNeg  : "   << myGon.axis[i].LimNeg << "\n";
        std::cout << "myGon.axis["<<i<<"].LimPos  : "   << myGon.axis[i].LimPos << "\n";
        std::cout << "myGon.axis["<<i<<"].maxSpeed: "   << myGon.axis[i].maxSpeed << "\n";
        std::cout << "myGon.axis["<<i<<"].minSpeed: "   << myGon.axis[i].minSpeed << "\n";
        std::cout << "myGon.axis["<<i<<"].maxJogSpeed: "<< myGon.axis[i].maxJogSpeed << "\n";
        std::cout << "myGon.axis["<<i<<"].minJogSpeed: "<< myGon.axis[i].minJogSpeed << "\n";
        std::cout << "myGon.axis["<<i<<"].moveSpeed: "  << myGon.axis[i].moveSpeed << "\n";
        std::cout << "myGon.axis["<<i<<"].jogSpeed: "   << myGon.axis[i].jogSpeed << "\n";  
    }
*/
    std::string strCommand;
    int loop = 1;
    while (loop) {
        std::cout << "> ";
        std::cin >> strCommand;
        loop = parse(strCommand, myGon);
    }
    return 0;
}


