Exemple #1
0
// move a specifed distance in mm
McoStatus TCR::moveDistance(double dx,double dy)
{
char st[500];
int32 dx_i,dy_i;
int32 pos[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

getLocation(pos,0);

dx_i = (40*(dx)+0.5);
dy_i = (40*(dy)+0.5);

pos[0] += dx_i;
pos[1] += dy_i;

pos[0] = MaxVal(pos[0],min_x);
pos[0] = MinVal(pos[0],max_x);

pos[1] = MaxVal(pos[1],min_y);
pos[1] = MinVal(pos[1],max_y);

sprintf(st,"PA %ld %ld;",pos[0],pos[1]);

current_x = pos[0];
current_y = pos[1];

sp->sendData(st,strlen(st));
waitTenthSec();

return MCO_SUCCESS;
}
Exemple #2
0
McoStatus SpectroChart::moveToPatch(int32 patchNum,int ref)
{
char st[500];
int32 dx_i,dy_i;
double dist;
int tc;
int waitTime;
int32	table[2];
int error;
McoStatus state;

if (sp == 0L) return MCO_SERIAL_ERROR;

// turn online
state = turnOnline();
if (state != MCO_SUCCESS) return state;

translateToTable(&pointArray[patchNum*2],table);

table[0] = MaxVal(table[0],min_x);
table[0] = MinVal(table[0],max_x);

table[1] = MaxVal(table[1],min_y);
table[1] = MinVal(table[1],max_y);

sprintf(st,"; 208 0 %d %ld %ld\r\n",ref,(long)table[0],(long)table[1]);

dx_i = table[0]-current_x;
dy_i = table[1]-current_y;


sp->sendData(st,strlen(st));
state = CheckErrorChart();
return state;
}
Exemple #3
0
McoStatus TCR::moveToPatch(int32 patchNum, int ref)
{
char st[500];
int32 dx_i,dy_i;
double dist;
long tc;
int waitTime;
int32	table[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

translateToTable(&pointArray[patchNum*2],table);

//dx_i = table[0]-current_x;
//dy_i = table[1]-current_y;

//sprintf(st,"PR %ld %ld;",dx_i,dy_i);	// the move command

table[0] = MaxVal(table[0],min_x);
table[0] = MinVal(table[0],max_x);

table[1] = MaxVal(table[1],min_y);
table[1] = MinVal(table[1],max_y);

sprintf(st,"PA %ld %ld;",(long)table[0],(long)table[1]);	// the move command

sp->sendData(st,strlen(st));


dx_i = table[0]-current_x;
dy_i = table[1]-current_y;

// wait a time that is determined by the distance moved
dist = sqrt((double)(dx_i*dx_i+dy_i*dy_i))*0.025;

// assume that it moves 250mm/sec

waitTime = 36+(int)(60.0*dist/150.0);

tc = TickCount();
while (TickCount() - tc < waitTime) {}

//current_x = pointArray[patchNum*2];
//current_y = pointArray[patchNum*2+1];

current_x += dx_i;
current_y += dy_i;

return MCO_SUCCESS;
}
Exemple #4
0
// translate a patch location to 
void Table::translateToTable(int patchnum, int32 *table)
{
	double x,y;

	x = pointArray[patchnum*2];
	y = pointArray[patchnum*2+1];

	table[0] = a*x+b*y+Tx+0.5;
	table[1] = c*x+d*y+Ty+0.5;

	table[0] = MaxVal(table[0],min_x);
	table[0] = MinVal(table[0],max_x);
	table[1] = MaxVal(table[1],min_y);
	table[1] = MinVal(table[1],max_y);
}
Exemple #5
0
// move a specifed distance in mm
McoStatus SpectroChart::moveDistance(double dx,double dy)
{
char st[5000];
int32 dx_i,dy_i;
int	error;
McoStatus state;
int32 pos[2];

if (sp == 0L) return MCO_SERIAL_ERROR;

getLocation(pos,1);

dx_i = (10*(dx)+0.5);
dy_i = (-10*(dy)+0.5);

pos[0] += dx_i;
pos[1] += dy_i;

pos[0] = MaxVal(pos[0],min_x);
pos[0] = MinVal(pos[0],max_x);

pos[1] = MaxVal(pos[1],min_y);
pos[1] = MinVal(pos[1],max_y);

// turn online
state = turnOnline();
if (state != MCO_SUCCESS) return state;

sprintf(st,"; 208 0 %ld %ld\r\n",pos[0],pos[1]);

sp->sendData(st,strlen(st));
waitTenthSec();
state = CheckErrorChart();

current_x = pos[0];
current_y = pos[1];
return state;
}
Exemple #6
0
void TYPBLK<TYPE>::SetValue(PSZ p, int n)
  {
  ChkIndx(n);

  if (Check) {
    PGLOBAL& g = Global;
    strcpy(g->Message, MSG(BAD_SET_STRING));
    longjmp(g->jumper[g->jump_level], Type);
    } // endif Check

  bool      minus;
  ulonglong maxval = MaxVal();
  ulonglong val = CharToNumber(p, strlen(p), maxval, Unsigned, &minus); 
    
  if (minus && val < maxval)
    Typp[n] = (TYPE)(-(signed)val);
  else
    Typp[n] = (TYPE)val;

  SetNull(n, false);
  } // end of SetValue
Exemple #7
0
   SpiceDouble vrelg_c ( ConstSpiceDouble * v1,
                         ConstSpiceDouble * v2,
                         SpiceInt           ndim  )

/*

-Brief_I/O

   Variable  I/O  Description
   --------  ---  --------------------------------------------------
    v1,v2     I   Input vectors.
    ndim      I   Dimension of v1 and v2.

-Detailed_Input

    v1, v2        are two vectors for which the relative difference
                  is to be computed.

    ndim          is the dimension of v1 and v2.

-Detailed_Output

    vrelg_c       is the relative difference between v1 and v2.
                  It is defined as:
                                              || v1 - v2 ||
                            vrelg_c  =   ----------------------
                                       max ( ||v1||, ||v2|| )

                  where || x || indicates the euclidean norm of
                  the vector x ( ||x|| = sqrt( x . x ) ).

                  vrelg_c assumes values in the range [0,2]. If both
                  v1 and v2 are zero vectors then vrelg_c is defined
                  to be zero.

-Parameters

   None.

-Exceptions

   Error free.

   If both v1 and v2 are zero vectors then vrelg_c is defined to be
   zero.

-Files

   None.

-Particulars

   This function computes the relative difference between two vectors
   of general dimension as defined above.

   The function vrel_c may be used to find the relative difference
   for two 3-dimensional vectors.

-Examples

   This example determines if the state of Jupiter, with respect
   to Voyager 2, for a set of times is the same for two different
   ephemeris files. Instead of insisting on absolute equality
   between the state vectors, the program will check if the relative
   difference between the vectors is greater than a fixed tolerance.

         #include "SpiceUsr.h"
               .
               .
               .
         /.
         The NAIF code for Jupiter is 599 and for Voyager 2 is -32.
         Set the tolerance to be 0.0005.
         ./

         #define            NUM   500
         #define            JUP   599
         #define            VG2   -32
         #define            TOL   .0005

         /.
         Local variables
         ./
         SpiceDouble        state1 [6][NUM];
         SpiceDouble        state2 [6][NUM];
         SpiceDouble        et     [NUM];
         SpiceDouble        lt;
         SpiceDouble        diff;

         SpiceInt           i;

         .
         .
         .

         /.
         Load  the first SPK file.
         ./
         furnsh_c ( "VG2_SOURCE_1.BSP" );


         /.
         Find the states for each time in the array ET.
         This example assumes that the SPK file can
         provide states for all of the times in the array.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            spkez_c ( JUP, et[i], "J2000", "lt", VG2,
                                   state1[1][i], &lt  );
            }


         /.
         Unload the first file and load the second one.
         ./
         unload_c ( "VG2_SOURCE_1.BSP" );

         furnsh_c ( "VG2_SOURCE_2.BSP" );


         /.
         Find the states from the new file.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            spkez_c ( JUP, et[i], "J2000", "lt",
                      VG2, state2[1][i], &lt  );
            }


         /.
         Now compare the two state vectors for each time.
         ./
         for ( i = 0; i < NUM; i++ )
            {
            diff = vrelg_c ( state1[1][i], state2[1][i], 6 );

            if ( diff > TOL )
               {
                 ...
               }


-Restrictions

   None.

-Literature_References

   None.

-Author_and_Institution

   J.M. Lynch     (JPL)
   E.D. Wright    (JPL)

-Version

   -CSPICE Version 1.1.0, 28-AUG-2001 (NJB) 
   
      Include interface macro definition file SpiceZim.h. 
      Made some minor updates and corrections in the code example.
      
   -CSPICE Version 1.0.0, 6-JUL-1999

-Index_Entries

   relative difference of n-dimensional vectors

-&
*/

{ /* Begin vrelg_c */

   /*
   Local variables
   */
   SpiceDouble       nunorm;
   SpiceDouble       denorm;



   /* If the vectors are both zero or equivalent, return 0. */

   nunorm = vdistg_c ( v1, v2, ndim );

   if ( nunorm == 0. )
      {
      return 0.;
      }
   else
      {
      denorm = MaxVal( vnormg_c( v1, ndim ), vnormg_c( v2, ndim ) );
      return ( nunorm/denorm );
      }


} /* End vrelg_c */