#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <vector>
#include <time.h>
#include <sys/time.h>
{
return((float)qc*3/3700);
}
{
return((long int)(dg*3700/3));
}
long int li;
int i;
cout << " Velocity: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Velocity Sensor Actual: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Velocity Demand: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Velocity Actual: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Position: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Encoder Counter: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Encoder Counter @ index pulse: " << hex << "0x" << li << " , " << dec << li << endl;
cout << " Current: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Current Averaged: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Current Demanded: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " StatusWord: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Hall Sensor Pattern: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Following Error: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Version Hardware: " << hex << "0x" << i << " , " << dec << i << endl;
cout << " Version Software: " << hex << "0x" << i << " , " << dec << i << endl;
}
long int value;
char ui_r;
bool opcio_target=true;
switch(type){
case 'a':
cout << " ConfigTest Absolute Movement\n\n";
case 'r':
cout << " ConfigTest Relative Movement\n\n";
break;
case 'w':
cout << " ConfigTest Profle Velocity\n\n";
break;
case 'v':
cout << " ConfigTest Velocity\n\n";
break;
case 'k':
opcio_target = false;
break;
}
if(opcio_target)
{
cout << " Is this your desired target? (Y,n) " << value << endl;
cin >> ui_r;
cout << endl;
if(ui_r=='n'){
cout << " Type your desired target " << endl;
cin >> value;
}
}
switch(type){
case 'a':
case 'r':
cout << " Starting Profile Position to:" << value;
}
}
cout << "\n Profile Position Movement Finished" << endl;
break;
case 'w':
int wcounter;
cout << " Starting Profile Velocity to:" << value;
cout << " during 5 seconds" << endl;
wcounter=0;
cout << " TARGET VELOCITY REACHED - Press 's' to stop'" << endl;
while(wcounter<100){
wcounter++;
}
cout << "\n Profile Position Movement Finished" << endl;
break;
case 'v':
char ui_v_stop;
cout << " VELOCITY - Press 's' to stop'" << endl;
cin >> ui_v_stop;
while(ui_v_stop!='s'){
cin >> ui_v_stop;
}
cout << " Velocity Movement Finished" << endl;
break;
case 'k':
cout << " 4 profile position with change wait without blocking" << endl;
cout << " Start Relative not blocking not waiting" << endl;
sleep(2);
cout << " Relative blocking waiting" << endl;
cout << " End Test" << endl;
}
}
{
char cs;
switch( action ){
case 'a':
case 'r':
case 'w':
case 'v':
case 'k':
break;
case 'h':
cout << " ConfigTest Set Home\n\n";
break;
break;
case '1':
cout << " ConfigTest Configure Profile Parameters\n\n";
long prof[7];
epos2->
getProfileData(prof[0],prof[1],prof[2],prof[3],prof[4],prof[5],prof[6]);
cout
<< " PROFILE DATA" << endl
<< " "
<< dec << endl
<< " Velocity: " << prof[0] << "[rpm]" << endl
<< " Max Velocity: " << prof[1] << "[rpm]" << endl
<< " Acceleration: " << prof[2] << "[rpm/s]" << endl
<< " Deceleration: " << prof[3] << "[rpm/s]" << endl
<< " QS Decel: " << prof[4] << "[rpm/s]" << endl
<< " Max Accel: " << prof[5] << "[rpm/s]" << endl
<< " Type: " << prof[6] << endl<<endl;
cout << " Profile: Do you want to configure? (y,n): " ;
cin >> cs;
while(cs!='y' && cs!='n')
{
cout << endl << " Input Error. press 'y' or 'n': ";
cin >> cs;
}
cout << endl;
if(cs=='y'){
cout << " Velocity [rpm] " << endl;
cin >> prof[0]; cout << endl;
cout << " Max Velocity [rpm] " << endl;
cin >> prof[1]; cout << endl;
cout << " Acceleration [rpm/s] " << endl;
cin >> prof[2]; cout << endl;
cout << " Deceleration [rpm/s] " << endl;
cin >> prof[3]; cout << endl;
cout << " QS Decel [rpm/s] " << endl;
cin >> prof[4]; cout << endl;
cout << " Max acc [rpm/s] " << endl;
cin >> prof[5]; cout << endl;
cout << " Type " << endl;
cin >> prof[6]; cout << endl;
epos2->
setProfileData(prof[0],prof[1],prof[2],prof[3],prof[4],prof[5],prof[6]);
}
break;
case '2':
cout << " ConfigTest Configure Control Parameters\n\n";
long conpar[10];
conpar[5],conpar[6],conpar[7],conpar[8],conpar[9]);
cout
<< " CONTROL PARAMETERS DATA" << endl
<< dec << endl
<< " Current P: " << conpar[0] << endl
<< " Current I: " << conpar[1] << endl
<< " Velocity P: " << conpar[2] << endl
<< " Velocity I: " << conpar[3] << endl
<< " Velocity SPF: " << conpar[4] << endl
<< " Position P: " << conpar[5] << endl
<< " Position I: " << conpar[6] << endl
<< " Position D: " << conpar[7] << endl
<< " Position Vff: " << conpar[8] << endl
<< " Position Aff: " << conpar[9] << endl
<< endl;
cout << " Profile: Do you want to configure? (y,n): " ;
cin >> cs;
while(cs!='y' && cs!='n')
{
cout << endl << " Input Error. press 'y' or 'n': ";
cin >> cs;
}
cout << endl;
if(cs=='y'){
cout << " Current P: " << endl;
cin >> conpar[0]; cout << endl;
cout << " Current I: " << endl;
cin >> conpar[1]; cout << endl;
cout << " Velocity P: " << endl;
cin >> conpar[2]; cout << endl;
cout << " Velocity I: " << endl;
cin >> conpar[3]; cout << endl;
cout << " Velocity SPF: " << endl;
cin >> conpar[4]; cout << endl;
cout << " Position P: " << endl;
cin >> conpar[5]; cout << endl;
cout << " Position I: " << endl;
cin >> conpar[6]; cout << endl;
cout << " Position D: " << endl;
cin >> conpar[7]; cout << endl;
cout << " Position Vff: " << endl;
cin >> conpar[8]; cout << endl;
cout << " Position Aff: " << endl;
cin >> conpar[9]; cout << endl;
conpar[5],conpar[6],conpar[7],conpar[8],conpar[9]);
}
break;
case '3':
cout << " ConfigTest Configure Sensor Parameters\n\n";
break;
case '4':
cout << " ConfigTest Configure Motor Parameters\n\n";
break;
case '5':
cout << " ConfigTest Configure Position Parameters\n\n";
break;
case '6':
cout << " ConfigTest Configure Unit Dimensions\n\n";
break;
case '7':
cout << " ConfigTest Configure Communication Parameters\n\n";
break;
case '8':
cout << " ConfigTest Saving Parameters\n\n";
cout << " Are you sure you want to save parameters? (Y,n) " << endl;
char sure8;
cin >> sure8;
if(sure8=='Y'){
cout << " Parameters Saved" << endl;
}else{
cout << " parameters not saved" << endl;
}
break;
case '9':
cout << " ConfigTest Restore Default Parameters\n\n";
cout << " Are you sure you want to restore parameters? (Y,n) " <<
endl;
char sure9;
cin >> sure9;
if(sure9=='Y'){
cout << " Parameters Restored" << endl;
}else{
cout << " parameters not restored" << endl;
}
break;
case 'E':
cout << " ConfigTest Read Errors\n\n";
long *errors;
break;
case 'S':
cout << " ConfigTest Read Status Word\n\n";
break;
case 'D':
cout << " ConfigTest Read Data\n\n";
break;
case 'x':
case 'X':
break;
default:
cout << " Choose another option" << endl << endl;
break;
}
}
int main(
int argc,
char **argv)
{
char action;
bool verbose = false;
int opt;
cout << "\n EPOS2 CONFIG&TEST \n\n";
while ((opt = getopt(argc, argv, "biphv")) != -1)
{
switch (opt)
{
case 'b':
break;
case 'i':
break;
case 'p':
break;
case 'v':
verbose=true;
break;
case '?':
case 'h':
default:
cout << " USAGE" << endl << "\n"
<< " " << argv[0] << " [options]" << endl << endl
<< " OPTIONS" << endl <<
"\n"
<< " -i Interrupt Movements" <<
"\tin profile position.\n" << endl
<< " -v Verbose" <<
"\tShows all information\n" << endl << endl;
return 1;
}
}
cout << " MENU" << endl <<
"\n"
<< " ▾ Do a movement" << endl
<< " a" <<
"\tProfile Position Absolute\n"
<< " r" <<
"\tProfile Position Relative\n"
<< " w" <<
"\tProfile Velocity\n"
<< " v" <<
"\tVelocity\n"
<< " k" <<
"\tKombo\n"
<< " h" <<
"\tSet Home\n" << endl
<< " Configure Parameters" << endl
<< " 1" <<
"\tProfile\n"
<< " 2" <<
"\tControl\n"
<< " 3" <<
"\tSensor\n"
<< " 4" <<
"\tMotor (not done)\n"
<< " 5" <<
"\tPosition (not done)\n"
<< " 6" <<
"\tUnits dimension (not done)\n"
<< " 7" <<
"\tCommunication (not done)\n"
<< " 8" <<
"\tSave All Parameters\n"
<< " 9" <<
"\tRestore Default\n" << endl
<< " Read" << endl
<< " E" <<
"\tError\n"
<< " S" <<
"\tStatusword\n"
<< " D" <<
"\tData\n"
<< endl
<< " x" <<
"\tExit Program\n"
<< endl << endl;
try
{
cout << " ConfigTest init EPOS2\n\n";
long *errors;
cout << " ConfigTest enable controller\n\n";
cout << " ConfigTest enable motor\n\n";
cout << " ConfigTest disable operation\n\n";
cout << " ? ";
cin >> action;
cout << endl;
}
}catch(std::exception &exc)
{
cout << "EPOS2 Exception: " << exc.what() << endl;
return(-1);
}
return(0);
}