Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleIselLinearControlTwoAxis.cpp

Example for using the Isel iMC-S8 linear controller, defines a command line interface

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExampleIselLinearControlTwoAxis.cpp
@relates IselLinearControlTwoAxis
@ingroup g_examples
@brief Example for using the Isel iMC-S8 linear controller,
defines a command line interface
@author MIP
*/
#include <PanTilt/IselLinearControlTwoAxis.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
char menuChoice;
int input, input2;
float f, f2;
string s;
if(argc != 2) {
cout << "Usage: ./ExampleIselLinearControlTwoAxis <PortName>" << endl;
return -1;
}
if (control.Init(argv[1]) != 0) {
cout << "Initialising IGOR unit on serial port x failed!" << endl;
return -1;
}
control.SetSpeed(1, 1);
cout << "bla" << endl;
while(true) {
cout << "============================" << endl;
cout << "(1) move x-axis" << endl;
cout << "(2) move y-axis" << endl;
cout << "(3) status output" << endl;
cout << "(4) set speed" << endl;
cout << "(5) reference movement" << endl;
cout << "(6) move free" << endl;
cout << "(7) position output" << endl;
cout << "(8) set position" << endl;
cout << "(9) send command" << endl;
cout << "(Q) quit" << endl;
cin >> menuChoice;
switch (menuChoice) {
case '1':
cout << "move distance (mm):" << endl;
cin >> input;
control.Move(input,0);
break;
case '2':
cout << "move distance (mm):" << endl;
cin >> input;
control.Move(0,input);
break;
case '3':
control.SendRawCommand("@0h\r");
while (control.ReadRawLine(s) == 0) {}
cout << s << endl;
break;
case '4':
cout << "set speed on x-axis (mm/sec) to:" << endl;
cin >> input;
cout << "set speed on y-axis (mm/sec) to:" << endl;
cin >> input2;
control.SetSpeed(input, input2);
break;
case '5':
control.Reset();
break;
case '6':
control.SendRawCommand("@0F1\r");
control.SendRawCommand("@03\r");
break;
case '7':
control.GetCurrentPosition(f, f2);
cout << "position (mm): " << f <<", " << f2 << endl;
break;
case '8':
cout << "set position on x-axis (mm) to:" << endl;
cin >> input;
cout << "set position on y-axis (mm) to:" << endl;
cin >> input2;
control.SetPosition(input, input2);
break;
case '9':
cout << "enter command:" << endl;
cin >> s;
control.SendRawCommand(s + "\r");
while (control.ReadRawLine(s) == 0) {}
cout << "return: " << s << endl;
break;
case 'Q':
case 'q':
return 0;
default:
cout << "unknown input!" << endl;
}
}
}