/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#include "../h/rccl.h"
#include "../rccl/testSync.h"

adjustFxn (arg)
int arg;
{       
	ADJUST_CTRL *cbk;
	MANIP *vmp;
	static int command = 0;

	if ((cbk = (ADJUST_CTRL*)getMemByAddr((void*)arg)) == NULL)
	 { rciAbort (0, "adjustFxn() -- can't find control block\n");
	 }
	vmp = getManipByAddr(cbk->vmpAddr);

	if (!command)
	 { switch (cbk->cmd)
	    { case DO_SPEED:
	       { adjustSpeed (cbk->mid, cbk->value, cbk->trans);
		 command = 1;
		 break;
	       }
	      case DO_STOP:
	       { adjustStopTime (cbk->mid, cbk->value, cbk->trans);
		 command = 1;
		 break;
	       }
	      default:
	       { break;
	       }
	    }
	   if (command)
	    { getActiveMotionCounts (vmp, NULL, &cbk->oldSigma);
	      cbk->time = rcclSysTime();
	    }
	 }
	else
	 { getActiveMotionCounts (vmp, NULL, &cbk->newSigma);
	   cbk->cmd = 0;
	   command = 0;
	 }	   
}
