Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

LinearActTest.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file LinearActTest.cpp
00003 *  \brief Runs Linear Actuators.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.1 $
00006 *  \date    $Date: 2005/09/18 17:14:30 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*!
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 // include communications
00013         extern "C" {
00014         #include "Hardware/satctl.h"
00015         #include "Hardware/common.h"
00016         }
00017 // include standard output
00018         #include <iostream>
00019 
00020 using namespace std; // shortcut for std::cout, std::endl, etc
00021 
00022 // The main routine
00023 int main() {
00024         char la_axis[80];
00025         char *buffer;
00026         char *portfn;         // Port filename 
00027         int portfd;
00028         double param_distance;
00029 
00030         buffer = (char *) malloc(256);
00031 
00032         while(1)
00033         {
00034                 cout << "Enter which linear actuator to move (X,Y, or Z): ";
00035                 cin >> la_axis;
00036                 if(strchr(la_axis,'\n'))
00037                 {
00038                         cout << "Exiting: \n";
00039                         return 0;
00040                 }
00041 
00042                 if(strchr(la_axis,'X'))  portfn = "/dev/ttyUSB0" ;
00043                 if(strchr(la_axis,'Y'))  portfn = "/dev/ttyUSB1" ;
00044                 if(strchr(la_axis,'Z'))  portfn = "/dev/ttyUSB2" ;
00045 
00046                 init_serial(portfn, B9600, &(portfd));
00047                 cout << "portfd = " << portfd << endl;
00048                 hear(portfd, buffer, 80, 0, 300000, 1);    // Clear port buffer 
00049 
00050                 cout << "Enter the distance in inches: ";
00051                 cin >> param_distance;
00052 
00053                 int InchesToSteps=2*25400;
00054                 int DistanceSteps=static_cast<int>(floor(param_distance
00055                                 *static_cast<double>(InchesToSteps)));
00056                 say(portfd, "MR11\r");                    //portfd must be assigned
00057                 say(portfd, "IS\r");
00058                 hear(portfd,buffer,30, 12, 300000, '\r');
00059                 cout << buffer << endl;       
00060  
00061                 if (DistanceSteps < 0)
00062                 {       sprintf(buffer, "\r\r\rDI%d\r\nFL\r\nSS-move", DistanceSteps);
00063                         say(portfd,buffer);
00064                 }
00065 
00066                 else
00067 
00068                 {       sprintf(buffer, "\r\r\rDI%d\rFL\rSS+move", DistanceSteps);
00069                         say(portfd, buffer);
00070                 }
00071         }
00072 }
00073 
00074 // Do not change the comments below - they will be added automatically by CVS
00075 /*****************************************************************************
00076 *       $Log: LinearActTest.cpp,v $
00077 *       Revision 1.1  2005/09/18 17:14:30  jayhawk_hokie
00078 *       Initial Addition of Test programs
00079 *
00080 *       Revision 1.1  2005/06/17 18:07:28  jayhawk_hokie
00081 *       Initial submission.
00082 *
00083 *
00084 ******************************************************************************/
00085 
00086 

Generated on Wed Sep 5 12:54:21 2007 for DSACSS Operational Code by  doxygen 1.3.9.1