Exemple #1
0
int memcheck(void){
    //Make sure the compiler did not pad the memory or mangle the structs

    printf("Checking status of some register bits\n");
    statusRegister.byte = 0x1;
    if(!statusRegister.C) return 0;
    statusRegister.byte = 0x4;
    if(!statusRegister.I) return 0;
    statusRegister.byte = 0x80;
    if(!statusRegister.N) return 0;

    resetFlags();

    printf("Checking status of some register raw\n");
    statusRegister.C = 1;
    statusRegister.I = 1;
    statusRegister.B = 1;
    statusRegister.N = 1;
    if(statusRegister.byte != 0xb5) return 0;

    printf("Checking RAM offsets\n");

    if(memory->APUIO - memory->raw != 0x4000) return 0;
    if(memory->PGROM - memory->raw != 0x8000) return 0;

    //This one isnt very important
    if(sizeof(union memory) != 0x10000) return 0;

    printf("Passed all compile tests\n");
    resetFlags();

    return 1;
}
static gboolean
time_handler(GtkWidget *widget)
{
    if (widget->window == NULL) return FALSE;
    GtkWidget *imgWebcam;
    imgWebcam = GTK_WIDGET (gtk_builder_get_object (builder, "imgWebcam"));

    GdkPixbuf *pixbuf = NULL;
    pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE,8,IMAGE_WIDTH,IMAGE_HEIGHT);
    unsigned char *gdata;
    if (pixbuf!=NULL)
    {
        gdata = gdk_pixbuf_get_pixels(pixbuf);
        int m,n,o;
        for (n=0;n<IMAGE_HEIGHT;n++)
        {
            for (m= 0;m<IMAGE_WIDTH;m++)
            {
                gdata[n*IMAGE_WIDTH*3 + m*3 +0]=(unsigned char)*(shared + m*3 + 2+ n*IMAGE_WIDTH*3);
                gdata[n*IMAGE_WIDTH*3 + m*3 +1]=(unsigned char)*(shared + m*3 + 1+ n*IMAGE_WIDTH*3);
                gdata[n*IMAGE_WIDTH*3 + m*3 +2]=(unsigned char)*(shared + m*3 + 0+ n*IMAGE_WIDTH*3);
            }
        }
        gtk_image_set_from_pixbuf(imgWebcam, pixbuf);
        g_object_unref (pixbuf);
    }

    if (*commAuth==EXIT_GUI)
    {
        resetFlags();
        gtk_main_quit();
    }
    return TRUE;
}
Exemple #3
0
RttStatisticsGraph::RttStatisticsGraph(QWidget *parent)
        : RSGraphWidget(parent)
{
    RttGraphSource *src = new RttGraphSource() ;

    src->setCollectionTimeLimit(10*60*1000) ; // 10 mins
    src->setCollectionTimePeriod(1000) ;     // collect every second
    src->setDigits(1) ;
    src->start() ;

    addSource(src) ;

    setTimeScale(2.0f) ; // 1 pixels per second of time.

    resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
    resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
    setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
}
Exemple #4
0
void clearCPU(void){
    rA = 0;
    rX = 0;
    rY = 0;
    programCounter = 0;
    stackPointer = 0;
    resetFlags();
    memset(memory, 0, 0x800);
}
bool AgentController::tryToWake()
{
  if(config_->agentInfoConfig().CurrentDay_ < static_cast<unsigned int>(QDateTime::currentDateTime().date().day()))
  {
    // It is next day. Time to clear all prev flags.
    resetFlags();
    return true;
  }
  return false;
}
Exemple #6
0
void APL_Certifs::loadCard()
{
	APL_Certif *cert;

	for(unsigned long i=0;i<countFromCard();i++)
	{
		cert=getCertFromCard(i);
	}

	resetFlags();
}
HRESULT CAVIOutputPin::Active()
{
	resetFlags();

	HRESULT hr = S_OK;
	if (IsConnected())
	{
		hr = CBaseOutputPin::Active();
	
	}
	return hr;
}
void setup() {
	/* reset flags */
	resetFlags();

	/* set up xbee */
	xbee.init();
	xbee.setDelimiter(DELIMITER);
	xbee.setEOL(EOL);
	
	/*set up hardware UART */
	Serial.begin(COMP_BAUD);
		
}
AgentController::AgentController(std::shared_ptr<Config> config, std::shared_ptr<ApplicationLogger> log, std::shared_ptr<NeuralNet> neurnet, std::shared_ptr<AssetsManager> assets)
: config_(config), log_(log), neurnet_(neurnet), assets_(assets)
{
  this->isFreshSystemPrice_ = false;
  this->isFreshPriceData_ = false;

  // Wouldn't want to reset various flags if program was restarted for some reason.
  if(config_->agentInfoConfig().ResetFlagsOnStartup_)
    resetFlags();

  // track days gone past, and use it to become more aggressive after a while.
  dateStarted_ = QDateTime::currentDateTime();
}
void DensityMapsManager::resetFlags(const std::string &commandLine) {
  std::vector<std::string> v;
  std::istringstream is(commandLine);
  std::string tmp;
  while (is >> tmp)
    v.push_back(tmp);
  char **argv = new char *[v.size() + 1];
  for (int i = 0; i < v.size(); ++i) {
    argv[i] = &v[i][0];
  }
  argv[v.size()] = NULL;
  resetFlags(v.size() + 1, argv);
  delete[] argv;
}
int
main (int argc, char *argv[])
{

  //  setuid(getuid());
    GtkWidget               *window;
    GtkWidget *imgWebcam;

    FILE *file;

    if (gtk_init_check(&argc, &argv)==FALSE)
    {

        /* RUN CANCEL CLICK CODE */
        *commAuth=CANCEL;
        return -1;
    }



    ipcStart();
    resetFlags();
    gtk_init (&argc, &argv);
    builder = gtk_builder_new ();
    gtk_builder_add_from_file (builder, XML_GTK_BUILDER_FACE_AUTHENTICATE, NULL);
    window = GTK_WIDGET (gtk_builder_get_object (builder, "gtk-faceauthenticate"));
    imgWebcam = GTK_WIDGET (gtk_builder_get_object (builder, "imgWebcam"));
   /* IplImage *zeroFrame=cvCreateImage( cvSize(IMAGE_WIDTH,IMAGE_HEIGHT),IPL_DEPTH_8U,3);
    cvZero(zeroFrame);
    loadCVPIXBUF(imgWebcam,zeroFrame);
    */
    gtk_builder_connect_signals (builder, NULL);

    g_timeout_add(100, (GSourceFunc) time_handler, (gpointer) window);
    gtk_widget_show (window);

    gtk_main ();

    g_object_unref (G_OBJECT (builder));
    return 0;
}
BWGraph::BWGraph(QWidget *parent) : RSGraphWidget(parent)
{
    _local_source = new BWGraphSource() ;

    std::cerr << "creaitng new BWGraph Source " << (void*)_local_source << std::endl;
    _local_source->setCollectionTimeLimit(30*60*1000) ; // 30  mins
    _local_source->setCollectionTimePeriod(1000) ;      // collect every second
    _local_source->setDigits(2) ;
    _local_source->start() ;
    _local_source->setUnit(BWGraphSource::UNIT_KILOBYTES) ;
    _local_source->setDirection(BWGraphSource::DIRECTION_UP) ;
    _local_source->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_ALL) ;
    _local_source->setSelector(BWGraphSource::SELECTOR_TYPE_SERVICE,BWGraphSource::GRAPH_TYPE_SUM) ;

    setSource(_local_source) ;

    setTimeScale(1.0f) ; // 1 pixels per second of time.

    setFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
    resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;

    setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
}
PrivMgr::~PrivMgr() 
{
  resetFlags();
}
/*!
  Compute and return the interaction matrix \f$ L \f$ associated to a subset
  of the possible 3D point features \f$(X,Y,Z)\f$ that
  represent the 3D point coordinates expressed in the camera frame.

  \f[
  L = \left[
  \begin{array}{rrrrrr}
  -1 &  0 &  0 &  0 & -Z &  Y \\
   0 & -1 &  0 &  Z &  0 & -X \\
   0 &  0 & -1 & -Y &  X &  0 \\
  \end{array}
  \right]
  \f]


  \param select : Selection of a subset of the possible 3D point coordinate
  features. 
  - To compute the interaction matrix for all the three 
    subset features \f$(X,Y,Z)\f$ use vpBasicFeature::FEATURE_ALL. In
    that case the dimension of the interaction matrix is \f$ [3 \times
    6] \f$
  - To compute the interaction matrix for only one of the 
    subset (\f$X, Y,Z\f$) use
    one of the corresponding function selectX(), selectY() or
    selectZ(). In that case the returned interaction matrix is \f$ [1
    \times 6] \f$ dimension.

  \return The interaction matrix computed from the 3D point coordinate
  features.

  The code below shows how to compute the interaction matrix
  associated to the visual feature \f$s = X \f$. 

  \code
  vpPoint point;
  ... 
  // Creation of the current feature s
  vpFeaturePoint3D s;
  s.buildFrom(point);

  vpMatrix L_X = s.interaction( vpFeaturePoint3D::selectX() );
  \endcode

  The code below shows how to compute the interaction matrix
  associated to the \f$s = (X,Y) \f$
  subset visual feature:

  \code
  vpMatrix L_XY = s.interaction( vpFeaturePoint3D::selectX() | vpFeaturePoint3D::selectY() );
  \endcode

  L_XY is here now a 2 by 6 matrix. The first line corresponds to
  the \f$ X \f$ visual feature while the second one to the \f$
  Y \f$ visual feature.

  It is also possible to build the interaction matrix from all the
  3D point coordinates by:

  \code
  vpMatrix L_XYZ = s.interaction( vpBasicFeature::FEATURE_ALL );
  \endcode

  In that case, L_XYZ is a 3 by 6 interaction matrix where the last
  line corresponds to the \f$ Z \f$ visual feature.

*/
vpMatrix
vpFeaturePoint3D::interaction(const unsigned int select)
{
  vpMatrix L ;

  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user)
  {
    for (unsigned int i = 0; i < nbParameters; i++)
    {
      if (flags[i] == false)
      {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but X was not set yet");
        break;
        case 1:
          vpTRACE("Warning !!!  The interaction matrix is computed but Y was not set yet");
        break;
        case 2:
          vpTRACE("Warning !!!  The interaction matrix is computed but Z was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  double X = get_X() ;
  double Y = get_Y() ;
  double Z = get_Z() ;

  if (vpFeaturePoint3D::selectX() & select )
  {
    vpMatrix Lx(1,6) ; Lx = 0;

    Lx[0][0] = -1  ;
    Lx[0][1] = 0 ;
    Lx[0][2] = 0 ;
    Lx[0][3] = 0 ;
    Lx[0][4] = -Z ;
    Lx[0][5] = Y ;

    L = vpMatrix::stackMatrices(L,Lx) ;
  }

  if (vpFeaturePoint3D::selectY() & select )
  {
    vpMatrix Ly(1,6) ; Ly = 0;

    Ly[0][0] = 0 ;
    Ly[0][1] = -1 ;
    Ly[0][2] = 0 ;
    Ly[0][3] = Z ;
    Ly[0][4] = 0 ;
    Ly[0][5] = -X ;

    L = vpMatrix::stackMatrices(L,Ly) ;
  }
  if (vpFeaturePoint3D::selectZ() & select )
  {
    vpMatrix Lz(1,6) ; Lz = 0;

    Lz[0][0] = 0 ;
    Lz[0][1] = 0 ;
    Lz[0][2] = -1 ;
    Lz[0][3] = -Y ;
    Lz[0][4] = X ;
    Lz[0][5] = 0 ;

    L = vpMatrix::stackMatrices(L,Lz) ;
  }
  return L ;
}
HRESULT CAVIOutputPin::DeliverEndFlush()
{
    HRESULT hr = CBaseOutputPin::DeliverEndFlush();
	resetFlags();
	return hr;
}
Exemple #16
0
/*!
  Compute and return the interaction matrix \f$ L \f$ associated to a
  subset of the possible 2D image point features with polar
  coordinates \f$(\rho,\theta)\f$.

  \f[
  L = \left[
  \begin{array}{l}
  L_{\rho} \\
  \; \\
  L_{\theta}\\
  \end{array}
  \right]
  =
  \left[
  \begin{array}{cccccc}
  \frac{-\cos \theta}{Z} & \frac{-\sin \theta}{Z}  &  \frac{\rho}{Z} & (1+\rho^2)\sin\theta  & -(1+\rho^2)\cos\theta &  0 \\
  \; \\
   \frac{\sin\theta}{\rho Z} & \frac{-\cos\theta}{\rho Z} &  0 &  \cos\theta /\rho &  \sin\theta/\rho & -1 \\
  \end{array}
  \right]
  \f]

  where \f$Z\f$ is the 3D depth of the considered point.

  \param select : Selection of a subset of the possible polar
  point coordinate features.
  - To compute the interaction matrix for all the two 
    subset features \f$(\rho,\theta)\f$ use vpBasicFeature::FEATURE_ALL. In
    that case the dimension of the interaction matrix is \f$ [2 \times
    6] \f$
  - To compute the interaction matrix for only one of the subset
    (\f$\rho,\theta\f$) use one of the corresponding function
    selectRho() or selectTheta(). In that case the returned
    interaction matrix is \f$ [1 \times 6] \f$ dimension.

  \return The interaction matrix computed from the 2D point
  polar coordinate features.

  \exception vpFeatureException::badInitializationError : If the point
  is behind the camera \f$(Z < 0)\f$, or if the 3D depth is null \f$(Z
  = 0)\f$, or if the \f$\rho\f$ polar coordinate of the point is null.

  The code below shows how to compute the interaction matrix associated to 
  the visual feature \f$s = (\rho,\theta)\f$.
  \code
  vpFeaturePointPolar s;
  double rho   = 0.3;
  double theta = M_PI;
  double Z     = 1;
  // Creation of the current feature s
  s.buildFrom(rho, theta, Z);
  // Build the interaction matrix L_s
  vpMatrix L = s.interaction();
  \endcode

  The interaction matrix could also be build by:
  \code
  vpMatrix L = s.interaction( vpBasicFeature::FEATURE_ALL );
  \endcode

  In both cases, L is a 2 by 6 matrix. The first line corresponds to
  the \f$\rho\f$ visual feature while the second one to the
  \f$\theta\f$ visual feature.

  It is also possible to build the interaction matrix associated to
  one of the possible features. The code below shows how to consider
  only the \f$\theta\f$ component.

  \code
  vpMatrix L_theta = s.interaction( vpFeaturePointPolar::selectTheta() );
  \endcode

  In that case, L_theta is a 1 by 6 matrix.
*/
vpMatrix
vpFeaturePointPolar::interaction(const unsigned int select)
{
  vpMatrix L ;

  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user)
  {
    for (unsigned int i = 0; i < nbParameters; i++)
    {
      if (flags[i] == false)
      {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but rho was not set yet");
        break;
        case 1:
          vpTRACE("Warning !!!  The interaction matrix is computed but theta was not set yet");
        break;
        case 2:
          vpTRACE("Warning !!!  The interaction matrix is computed but Z was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  double rho   = get_rho() ;
  double theta = get_theta() ;
  double Z_    = get_Z() ;

  double c_ = cos(theta);
  double s_ = sin(theta);

  double rho2 = rho*rho;

  if (fabs(rho) < 1e-6) {
    vpERROR_TRACE("rho polar coordinate of the point is null") ;
    std::cout <<"rho = " << rho << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "rho polar coordinate of the point is null")) ;
  }

  if (Z_ < 0)
  {
    vpERROR_TRACE("Point is behind the camera ") ;
    std::cout <<"Z = " << Z_ << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "Point is behind the camera ")) ;
  }

  if (fabs(Z_) < 1e-6)
  {
    vpERROR_TRACE("Point Z coordinates is null ") ;
    std::cout <<"Z = " << Z_ << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "Point Z coordinates is null")) ;
  }

  if (vpFeaturePointPolar::selectRho() & select )
  {
    vpMatrix Lrho(1,6) ; Lrho = 0;

    Lrho[0][0] = -c_/Z_  ;
    Lrho[0][1] = -s_/Z_ ;
    Lrho[0][2] = rho/Z_ ;
    Lrho[0][3] = (1+rho2)*s_ ;
    Lrho[0][4] = -(1+rho2)*c_ ;
    Lrho[0][5] = 0 ;

//     printf("Lrho: rho %f theta %f Z %f\n", rho, theta, Z);
//     std::cout << "Lrho: " << Lrho << std::endl;

    L = vpMatrix::stackMatrices(L,Lrho) ;
  }

  if (vpFeaturePointPolar::selectTheta() & select )
  {
    vpMatrix Ltheta(1,6) ; Ltheta = 0;

    Ltheta[0][0] = s_/(rho*Z_) ;
    Ltheta[0][1]  = -c_/(rho*Z_) ;
    Ltheta[0][2] = 0 ;
    Ltheta[0][3] = c_/rho ;
    Ltheta[0][4] = s_/rho ;
    Ltheta[0][5] = -1 ;

//     printf("Ltheta: rho %f theta %f Z %f\n", rho, theta, Z);
//     std::cout << "Ltheta: " << Ltheta << std::endl;
    L = vpMatrix::stackMatrices(L,Ltheta) ;
  }
  return L ;
}
	int DeviceHandler::deviceConnection()
	{
		libusb_device** devs; //pointer to pointer of device, used to retrieve a list of devices
		libusb_context* contex = NULL; //a libusb session

		int r; //return values
		ssize_t listCount; //Number of devices in list

		//Intialize Library Session
		r = libusb_init(&contex);
		if (r < 0)
		{
			//Intialization Error
			return -1;
		}

		//Get the list of devices
		listCount = libusb_get_device_list(contex, &devs);
		if (listCount < 0)
		{
			return (int)listCount;
		}

		libusb_device* dev;

		int i = 0, j = 0;
		while ((dev = devs[i++]) != NULL)
		{
			struct libusb_device_descriptor desc;
			int r = libusb_get_device_descriptor(dev, &desc);
			if (r < 0)
			{
				//Error
				return -1;
			}

			uint16_t vendorid = desc.idVendor;
			uint16_t productid = desc.idProduct;

			if (vendorid == vendorList[0])
			{
				leapConnectedFlag = 1;
			}
			multiTouchConnectedFlag = 1;
			if (vendorid == vendorList[2])
			{
				eyeXConnectedFlag = 1;
			}
			if (productid == vendorList[3])
			{
				realSenseConnectedFlag = 1;
			}
		}

		stateCounter = 0;

		stateCounter = stateCounter + (setLeapState());

		stateCounter = stateCounter + (setMultiTouchState());

		stateCounter = stateCounter + (setEyeXState());

		stateCounter = stateCounter + (setRealSenseState());

		resetFlags();

		libusb_free_device_list(devs, 1);

		libusb_exit(NULL);

		return stateCounter;
	}
void loop() {
	
	/* establish connection with Blimp */
	if (!isOnline)
		Serial.println("Waiting for Blimp to appear online...");
	
	while (!isOnline) {
		if (xbee.parse(xbee.receive()) && (xbee.header() == "BGN") ) {
			Serial.println("Blimp is online, awaiting further instruction...");
			xbee.send("ACK BGN");
			
			/* start the time to ping at intervals */
			refTime = millis();	
			isOnline = true;
		}
	}
	
	
	
	/* ping for connectivity */
	if (pingFailure()) {
		Serial.println("Blimp disconnected.  Please reconnect.");
		resetFlags();									//reset all flags
		isOnline = false;
	}
	/*
	communicate(4000, "LDR 0", "ACK", "LDR 0");
	delay(500);
	communicate(4000, "LDR 1", "ACK", "LDR 1");
	delay(500);
	*/
	
	/* begin the key tracking sequence */
	if (Serial.available()) {
		keyPressed = Serial.read();
		
		if ((keyPressed == ']') && 
			(!FLAG_LED_STATE) && 
			(communicate(PACKET_TIMEOUT, "LDR 1", "ACK", "LDR 1"))) {
			
			FLAG_LED_STATE = true;
			
		} else if ((keyPressed == '[') && 
			(FLAG_LED_STATE) && 
			(communicate(PACKET_TIMEOUT, "LDR 0", "ACK", "LDR 0"))) {	
			
			FLAG_LED_STATE = false;
			
		} else if ((keyPressed == 'p') &&  
			(communicate(PACKET_TIMEOUT, "REQ UPT", "UPT", "*"))) {	
			Serial.println( xbee.payload() );
			
		} else if (keyPressed == 'w') {
			keyLastPressed = millis();	//this is to allow some lag time to register next keypress and not list it as a key-not-pressed event.  Even if forward flag is set.
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_MOVE_FWD) && (communicate(PACKET_TIMEOUT, "MOV FWD", "ACK", "MOV FWD"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_MOVE_FWD;
				
			}
			
		}  else if (keyPressed == 's') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_MOVE_REV) && (communicate(PACKET_TIMEOUT, "MOV REV", "ACK", "MOV REV"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_MOVE_REV;
				
			}
			
		} else if (keyPressed == 'a') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_TURN_LEFT) && (communicate(PACKET_TIMEOUT, "MOV LEFT", "ACK", "MOV LEFT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_TURN_LEFT;
				
			}
			
		} else if (keyPressed == 'd') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_TURN_RIGHT) && (communicate(PACKET_TIMEOUT, "MOV RIGHT", "ACK", "MOV RIGHT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_TURN_RIGHT;
				
			}
			
		} else if (keyPressed == 'q') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_STRAFE_FWD_LEFT) && (communicate(PACKET_TIMEOUT, "MOV STRAFE_FWD_LEFT", "ACK", "MOV STRAFE_FWD_LEFT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_STRAFE_FWD_LEFT;
				
			}
			
		} else if (keyPressed == 'e') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_STRAFE_FWD_RIGHT) && (communicate(PACKET_TIMEOUT, "MOV STRAFE_FWD_RIGHT", "ACK", "MOV STRAFE_FWD_RIGHT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_STRAFE_FWD_RIGHT;
				
			}
			
		} else if (keyPressed == 'z') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_STRAFE_REV_LEFT) && (communicate(PACKET_TIMEOUT, "MOV STRAFE_REV_LEFT", "ACK", "MOV STRAFE_REV_LEFT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_STRAFE_REV_LEFT;
				
			}
			
		} else if (keyPressed == 'c') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_STRAFE_REV_RIGHT) && (communicate(PACKET_TIMEOUT, "MOV STRAFE_REV_RIGHT", "ACK", "MOV STRAFE_REV_RIGHT"))) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_STRAFE_REV_RIGHT;
				
			}
			
		} else if (keyPressed == 'x') {
			keyLastPressed = millis();
			if( (FLAG_MOTOR_ABSTRACT_STATE != OP_STOP) && communicate(PACKET_TIMEOUT, "MOV STOP", "ACK", "MOV STOP") ) {
				FLAG_MOTOR_ABSTRACT_STATE = OP_STOP;
				Serial.println("stopping now");
			}
			
		} 
			
	}
			
	
}
Exemple #19
0
/*!

  Compute and return the interaction matrix \f$ L \f$ from
  a subset (\f$ \theta u_x, \theta u_y, \theta u_z\f$) of the possible
  \f$ \theta u \f$ features that represent the 3D rotation
  \f$^{c^*}R_c\f$ or \f$^{c}R_{c^*}\f$, with

  \f[ L = [ 0_3 \; L_{\theta u}] \f] 

  See the vpFeatureThetaU class description for the equations of
  \f$L_{\theta u}\f$.

  \param select : Selection of a subset of the possible \f$ \theta u \f$
  features. 
  - To compute the interaction matrix for all the three \f$ \theta u \f$ 
    features use vpBasicFeature::FEATURE_ALL. In that case the dimension of the
    interaction matrix is \f$ [3 \times 6] \f$
  - To compute the interaction matrix for only one of the \f$ \theta u \f$ 
    component feature (\f$\theta u_x, \theta u_y, \theta u_z\f$) use one of the
    corresponding function selectTUx(), selectTUy() or selectTUz(). In
    that case the returned interaction matrix is \f$ [1 \times 6] \f$
    dimension.

  \return The interaction matrix computed from the \f$ \theta u \f$
  features that represent either the rotation \f$^{c^*}R_c\f$ or the
  rotation \f$^{c}R_{c^*}\f$.

  The code below shows how to compute the interaction matrix
  associated to the visual feature \f$s = \theta u_x \f$. 

  \code
  vpRotationMatrix cdMc;

  // Creation of the current feature s
  vpFeatureThetaU s(vpFeatureThetaU::cdRc);
  s.buildFrom(cdMc);

  vpMatrix L_x = s.interaction( vpFeatureThetaU::selectTUx() );
  \endcode

  The code below shows how to compute the interaction matrix
  associated to the \f$s = (\theta u_x, \theta u_y) \f$
  subset visual feature:

  \code
  vpMatrix L_xy = s.interaction( vpFeatureThetaU::selectTUx() | vpFeatureThetaU::selectTUy() );
  \endcode

  L_xy is here now a 2 by 6 matrix. The first line corresponds to
  the \f$ \theta u_x \f$ visual feature while the second one to the \f$
  \theta u_y \f$ visual feature.

  It is also possible to build the interaction matrix from all the \f$
  \theta u \f$ components by:

  \code
  vpMatrix L_xyz = s.interaction( vpBasicFeature::FEATURE_ALL );
  \endcode

  In that case, L_xyz is a 3 by 6 interaction matrix where the last
  line corresponds to the \f$ \theta u_z \f$ visual feature.

*/
vpMatrix
vpFeatureThetaU::interaction(const unsigned int select)
{

  vpMatrix L ;
  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user)
  {
    for (unsigned int i = 0; i < nbParameters; i++)
    {
      if (flags[i] == false)
      {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but Tu_x was not set yet");
        break;
        case 1:
          vpTRACE("Warning !!!  The interaction matrix is computed but Tu_y was not set yet");
        break;
        case 2:
          vpTRACE("Warning !!!  The interaction matrix is computed but Tu_z was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  // Lw computed using Lw = [theta/2 u]_x +/- (I + alpha [u]_x [u]_x)
  vpColVector u(3)  ;
  for (unsigned int i=0 ; i < 3 ; i++) {
    u[i] = s[i]/2.0 ; 
  }
  
  vpMatrix Lw(3,3) ;
  Lw = vpColVector::skew(u) ;  /* [theta/2  u]_x */

  vpMatrix U2(3,3) ;
  U2.eye() ;
  
  double  theta = sqrt(s.sumSquare()) ;
  if (theta >= 1e-6) {
    for (unsigned int i=0 ; i < 3 ; i++) 
      u[i] = s[i]/theta ;

    vpMatrix skew_u ;
    skew_u = vpColVector::skew(u) ; 
    U2 += (1-vpMath::sinc(theta)/vpMath::sqr(vpMath::sinc(theta/2.0)))*skew_u*skew_u ;
  }
 
  if (rotation == cdRc) {
    Lw += U2; 
  }
  else { 
    Lw -=  U2; 
  }

  //This version is a simplification
  if (vpFeatureThetaU::selectTUx() & select )
    {
      vpMatrix Lx(1,6) ;

      Lx[0][0] = 0 ;    Lx[0][1] = 0 ;    Lx[0][2] = 0 ;
      for (int i=0 ; i < 3 ; i++) Lx[0][i+3] = Lw[0][i] ;


      L = vpMatrix::stack(L,Lx) ;
    }

  if (vpFeatureThetaU::selectTUy() & select )
    {
      vpMatrix Ly(1,6) ;

      Ly[0][0] = 0 ;    Ly[0][1] = 0 ;    Ly[0][2] = 0 ;
      for (int i=0 ; i < 3 ; i++) Ly[0][i+3] = Lw[1][i] ;

      L = vpMatrix::stack(L,Ly) ;
    }

  if (vpFeatureThetaU::selectTUz() & select )
    {
      vpMatrix Lz(1,6) ;

      Lz[0][0] = 0 ;    Lz[0][1] = 0 ;    Lz[0][2] = 0 ;
      for (int i=0 ; i < 3 ; i++) Lz[0][i+3] = Lw[2][i] ;

      L = vpMatrix::stack(L,Lz) ;
    }

  return L ;
}
Exemple #20
0
//! compute the interaction matrix from a subset a the possible features
vpMatrix
vpFeatureEllipse::interaction(const unsigned int select)
{
  vpMatrix L ;

  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user)
  {
    for (unsigned int i = 0; i < nbParameters; i++)
    {
      if (flags[i] == false)
      {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but x was not set yet");
        break;
        case 1:
          vpTRACE("Warning !!!  The interaction matrix is computed but y was not set yet");
        break;
        case 2:
          vpTRACE("Warning !!!  The interaction matrix is computed but mu20 was not set yet");
        break;
        case 3:
          vpTRACE("Warning !!!  The interaction matrix is computed but mu11 was not set yet");
        break;
        case 4:
          vpTRACE("Warning !!!  The interaction matrix is computed but mu02 was not set yet");
        break;
        case 5:
          vpTRACE("Warning !!!  The interaction matrix is computed but A was not set yet");
        break;
        case 6:
          vpTRACE("Warning !!!  The interaction matrix is computed but B was not set yet");
        break;
        case 7:
          vpTRACE("Warning !!!  The interaction matrix is computed but C was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  double xc = s[0] ;
  double yc = s[1] ;
  double mu20 = s[2] ;
  double mu11 = s[3] ;
  double mu02 = s[4] ;

  //eq 39
  double Z = 1/(A*xc + B*yc + C) ;



  if (vpFeatureEllipse::selectX() & select )
  {
    vpMatrix H(1,6) ; H = 0;


    H[0][0] = -1/Z;
    H[0][1] = 0 ;
    H[0][2] = xc/Z + A*mu20 + B*mu11;
    H[0][3] = xc*yc + mu11;
    H[0][4] = -1-vpMath::sqr(xc)-mu20;
    H[0][5] = yc;


    L = vpMatrix::stackMatrices(L,H) ;
  }

  if (vpFeatureEllipse::selectY() & select )
  {
    vpMatrix H(1,6) ; H = 0;


    H[0][0] = 0 ;
    H[0][1] = -1/Z;
    H[0][2] = yc/Z + A*mu11 + B*mu02;
    H[0][3] = 1+vpMath::sqr(yc)+mu02;
    H[0][4] = -xc*yc - mu11;
    H[0][5] = -xc;

    L = vpMatrix::stackMatrices(L,H) ;
  }

  if (vpFeatureEllipse::selectMu20() & select )
  {
    vpMatrix H(1,6) ; H = 0;

    H[0][0] = -2*(A*mu20+B*mu11);
    H[0][1] = 0 ;
    H[0][2] = 2*((1/Z+A*xc)*mu20+B*xc*mu11) ;
    H[0][3] = 2*(yc*mu20+xc*mu11);
    H[0][4] = -4*mu20*xc;
    H[0][5] = 2*mu11;

    L = vpMatrix::stackMatrices(L,H) ;
  }

  if (vpFeatureEllipse::selectMu11() & select )
  {
    vpMatrix H(1,6) ; H = 0;

    H[0][0] = -A*mu11-B*mu02;
    H[0][1] = -A*mu20-B*mu11;
    H[0][2] = A*yc*mu20+(3/Z-C)*mu11+B*xc*mu02;
    H[0][3] = 3*yc*mu11+xc*mu02;
    H[0][4] = -yc*mu20-3*xc*mu11;
    H[0][5] = mu02-mu20;

    L = vpMatrix::stackMatrices(L,H) ;
  }

  if (vpFeatureEllipse::selectMu02() & select )
  {
    vpMatrix H(1,6) ; H = 0;

    H[0][0] = 0 ;
    H[0][1] = -2*(A*mu11+B*mu02);
    H[0][2] = 2*((1/Z+B*yc)*mu02+A*yc*mu11);
    H[0][3] = 4*yc*mu02;
    H[0][4] = -2*(yc*mu11 +xc*mu02) ;
    H[0][5] = -2*mu11 ;
    L = vpMatrix::stackMatrices(L,H) ;
  }


  return L ;
}
/*!

  Compute and return the interaction matrix \f$ L \f$ from a subset
  \f$(t_x, t_y, t_z)\f$ of the possible translation features that
  represent the 3D transformation \f$ ^{{\cal{F}}_2}M_{{\cal{F}}_1} \f$.

  As it exists three different features, the computation of the
  interaction matrix is diferent for each one.

  - With the feature type cdMc:

  \f[ L = [ ^{c^*}R_c \;\; 0_3] \f] 

  where \f$^{c^*}R_c\f$ is the rotation the camera has to achieve to
  move from the desired camera frame to the current camera frame.

  - With the feature type cMcd:

  \f[ L = [ -I_3 \;\; [^{c}t_{c^*}]_\times] \f]

  where \f$^{c}R_{c^*}\f$ is the rotation the camera has to achieve to
  move from the current camera frame to the desired camera frame.

  - With the feature type cMo:

  \f[ L = [ -I_3 \;\; [^{c}t_o]_\times] \f]

  where \f$^{c}t_o \f$ is the position of
  the object frame relative to the current camera frame.

  \param select : Selection of a subset of the possible translation
  features. 
  - To compute the interaction matrix for all the three translation
    subset features \f$(t_x,t_y,t_y)\f$ use vpBasicFeature::FEATURE_ALL. In
    that case the dimension of the interaction matrix is \f$ [3 \times
    6] \f$
  - To compute the interaction matrix for only one of the translation
    subset (\f$t_x, t_y, t_z\f$) use
    one of the corresponding function selectTx(), selectTy() or
    selectTz(). In that case the returned interaction matrix is \f$ [1
    \times 6] \f$ dimension.

  \return The interaction matrix computed from the translation
  features.

  The code below shows how to compute the interaction matrix
  associated to the visual feature \f$s = t_x \f$ using the cdMc feature type.

  \code
  vpHomogeneousMatrix cdMc;
  ... 
  // Creation of the current feature s
  vpFeatureTranslation s(vpFeatureTranslation::cdMc);
  s.buildFrom(cdMc);

  vpMatrix L_x = s.interaction( vpFeatureTranslation::selectTx() );
  \endcode

  The code below shows how to compute the interaction matrix
  associated to the \f$s = (t_x, t_y) \f$
  subset visual feature:

  \code
  vpMatrix L_xy = s.interaction( vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy() );
  \endcode

  L_xy is here now a 2 by 6 matrix. The first line corresponds to
  the \f$ t_x \f$ visual feature while the second one to the \f$
  t_y \f$ visual feature.

  It is also possible to build the interaction matrix from all the
  translation components by:

  \code
  vpMatrix L_xyz = s.interaction( vpBasicFeature::FEATURE_ALL );
  \endcode

  In that case, L_xyz is a 3 by 6 interaction matrix where the last
  line corresponds to the \f$ t_z \f$ visual feature.

*/
vpMatrix
vpFeatureTranslation::interaction(const unsigned int select)
{

  vpMatrix L ;
  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user) {
    for (unsigned int i = 0; i < nbParameters; i++) {
      if (flags[i] == false) {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but f2Mf1 was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  if (translation == cdMc) {
    //This version is a simplification
    if (vpFeatureTranslation::selectTx() & select ) {
      vpMatrix Lx(1,6) ;

      for (int i=0 ; i < 3 ; i++)
	Lx[0][i] = f2Mf1[0][i] ;
      Lx[0][3] = 0 ;    Lx[0][4] = 0 ;    Lx[0][5] = 0 ;

      L = vpMatrix::stackMatrices(L,Lx) ;
    }

    if (vpFeatureTranslation::selectTy() & select ) {
      vpMatrix Ly(1,6) ;

      for (int i=0 ; i < 3 ; i++)
	Ly[0][i] = f2Mf1[1][i] ;
      Ly[0][3] = 0 ;    Ly[0][4] = 0 ;    Ly[0][5] = 0 ;

      L = vpMatrix::stackMatrices(L,Ly) ;
    }

    if (vpFeatureTranslation::selectTz() & select ) {
      vpMatrix Lz(1,6) ;

      for (int i=0 ; i < 3 ; i++)
	Lz[0][i] = f2Mf1[2][i] ;
      Lz[0][3] = 0 ;    Lz[0][4] = 0 ;    Lz[0][5] = 0 ;

      L = vpMatrix::stackMatrices(L,Lz) ;
    }
  }
  if (translation == cMcd) {
    //This version is a simplification
    if (vpFeatureTranslation::selectTx() & select ) {
      vpMatrix Lx(1,6) ;
      Lx[0][0] = -1 ;    Lx[0][1] = 0 ;    Lx[0][2] = 0 ;
      Lx[0][3] = 0 ;    Lx[0][4] = -s[2] ;    Lx[0][5] = s[1] ;

      L = vpMatrix::stackMatrices(L,Lx) ;
    }

    if (vpFeatureTranslation::selectTy() & select ) {
      vpMatrix Ly(1,6) ;
      Ly[0][0] = 0 ;    Ly[0][1] = -1 ;    Ly[0][2] = 0 ;
      Ly[0][3] = s[2] ;    Ly[0][4] = 0 ;    Ly[0][5] = -s[0] ;

      L = vpMatrix::stackMatrices(L,Ly) ;
    }

    if (vpFeatureTranslation::selectTz() & select ) {
      vpMatrix Lz(1,6) ;
      Lz[0][0] = 0 ;    Lz[0][1] = 0 ;    Lz[0][2] = -1 ;
      Lz[0][3] = -s[1] ;    Lz[0][4] = s[0] ;    Lz[0][5] = 0 ;

      L = vpMatrix::stackMatrices(L,Lz) ;
    }
  }

  if (translation == cMo) {
    //This version is a simplification
    if (vpFeatureTranslation::selectTx() & select ) {
      vpMatrix Lx(1,6) ;
      Lx[0][0] = -1 ;    Lx[0][1] = 0 ;    Lx[0][2] = 0 ;
      Lx[0][3] = 0 ;    Lx[0][4] = -s[2] ;    Lx[0][5] = s[1] ;

      L = vpMatrix::stackMatrices(L,Lx) ;
    }

    if (vpFeatureTranslation::selectTy() & select ) {
      vpMatrix Ly(1,6) ;
      Ly[0][0] = 0 ;    Ly[0][1] = -1 ;    Ly[0][2] = 0 ;
      Ly[0][3] = s[2] ;    Ly[0][4] = 0 ;    Ly[0][5] = -s[0] ;

      L = vpMatrix::stackMatrices(L,Ly) ;
    }

    if (vpFeatureTranslation::selectTz() & select ) {
      vpMatrix Lz(1,6) ;
      Lz[0][0] = 0 ;    Lz[0][1] = 0 ;    Lz[0][2] = -1 ;
      Lz[0][3] = -s[1] ;    Lz[0][4] = s[0] ;    Lz[0][5] = 0 ;

      L = vpMatrix::stackMatrices(L,Lz) ;
    }
  }

  return L ;
}
Exemple #22
0
/* This function makes repeated passes over the board looking for empty points to assign to a player as 
   territory.  Counting ends if the algorithm finds no new points on a complete pass over the board.
   On each pass empty sapces that are adjacent to a single player are marked as belonging to that 
   player and empty spaces adjacent to both players (which are not territory) are marked as visited
   so that their status won't be checked again.  Spaces marked as territory in previous completed passes 
   are treated as pieces.  Each players territorial points are added to their captured pieces count and a 
   final score is displayed.
   */
bool gameBoard::score(bool display)
{
   bool done;           // No more territory to be found
   int neighborColor;   // Color of a group adjoining an empty space
   int generation = 2;  // Prevents spaces marked as territory in the same pass over the board
                                  // from interfering  

   resetFlags();
   do
   {
      done = true;
      for (int i = 1; i < 10; ++i)
      {
	 for (int j = 1; j < 10; ++j)
	 {
	    if (!pieces[i][j].visited && !pieces[i][j].color) 
	    //If a space is empty and the point hasn't been marked as shared
	    {
	       neighborColor = 0;

	       //Check the four neighbors of an empty space, unless that space is on an edge.
	       //If exactly one neighboring color from a previous generation of the board is
	       //found the space will be marked as territory for that color.
	       //Black territory > 0, white territory < 0.  If a space is found to have 
	       //neighbors of both colors the visited flag is set.
	       if (i > 1 && pieces[i-1][j].color && abs(pieces[i-1][j].color) < generation)
	       {            
		  if (pieces[i-1][j].color > 0)
		     neighborColor = generation;
		  else
		     neighborColor = -1 * generation;                 
	       }
	       if (i < 9 && pieces[i+1][j].color && abs(pieces[i+1][j].color) < generation)
	       {           
		  if (neighborColor)
		  {
		     if ((neighborColor > 0 && pieces[i+1][j].color < 0) || (neighborColor < 0 && pieces[i+1][j].color > 0))
			pieces[i][j].visited = true;
		  }
		  else 
		  {
		     if (pieces[i+1][j].color > 0)
			neighborColor = generation;
		     else
			neighborColor = -1 * generation;
		  }
	       }
	       if (j > 1 && pieces[i][j-1].color && !pieces[i][j].visited && abs(pieces[i][j-1].color) < generation)
	       {          
		  if (neighborColor)
		  {
		     if ((neighborColor > 0 && pieces[i][j-1].color < 0) || (neighborColor < 0 && pieces[i][j-1].color > 0))
			pieces[i][j].visited = true;
		  }
		  else 
		  {
		     if (pieces[i][j-1].color > 0)
			neighborColor = generation;
		     else 
			neighborColor = -1 * generation;
		  }
	       }
	       if (j < 9 && pieces[i][j+1].color && !pieces[i][j].visited && abs(pieces[i][j+1].color) < generation) 
	       {         
		  if (neighborColor)
		  {
		     if ((neighborColor > 0 && pieces[i][j+1].color < 0) || (neighborColor < 0 && pieces[i][j+1].color > 0))
			pieces[i][j].visited = true;
		  }
		  else 
		  {
		     if (pieces[i][j+1].color > 0)
			neighborColor = generation;
		     else neighborColor = -1 * generation;
		  }
	       }
	       
	       if (neighborColor && !pieces[i][j].visited)
	       {
		  // Territory is added to the count of captured opponents.
		  if (neighborColor < 0)
		     ++dead[0];
		  else
		     ++dead[1];
		  pieces[i][j].color = neighborColor;
		  done = false;
	       }
	    }
	 }
      }
      ++generation;
   }
   while (!done);
   if (display)
      drawScored();
   if (dead[1] - dead[0] > 0)
      return true;
   return false;
}
bool sendPageQA ( TcpSocket *sock , HttpRequest *hr ) {
	char pbuf[32768];
	SafeBuf sb(pbuf, 32768);

	//char format = hr->getReplyFormat();

	// set this. also sets gr->m_hr
	GigablastRequest gr;
	// this will fill in GigablastRequest so all the parms we need are set
	g_parms.setGigablastRequest ( sock , hr , &gr );


	//
	// . handle a request to update the crc for this test
	// . test id identified by "ajaxUrlHash" which is the hash of the test's url
	//   and the test name, QATest::m_testName
	long ajax = hr->getLong("ajax",0);
	unsigned long ajaxUrlHash ;
	ajaxUrlHash = (unsigned long long)hr->getLongLong("uh",0LL);
	unsigned long ajaxCrc ;
	ajaxCrc = (unsigned long long)hr->getLongLong("crc",0LL);

	if ( ajax ) {
		// make sure it is initialized
		if ( s_ht.m_ks ) {
			// overwrite current value with provided one because 
			// the user click on an override checkbox to update 
			// the crc
			s_ht.addKey ( &ajaxUrlHash , &ajaxCrc );
			saveHashTable();
		}
		// send back the urlhash so the checkbox can turn the
		// bg color of the "diff" gray
		SafeBuf sb3;
		sb3.safePrintf("%lu",ajaxUrlHash);
		g_httpServer.sendDynamicPage(sock,
					     sb3.getBufStart(),
					     sb3.length(),
					     -1/*cachetime*/);
		return true;
	}
		

	// if they hit the submit button, begin the tests
	long submit = hr->hasField("action");

	long n = sizeof(s_qatests)/sizeof(QATest);


	if ( submit && g_qaInProgress ) {
		g_errno = EINPROGRESS;
		g_httpServer.sendErrorReply(sock,g_errno,mstrerror(g_errno));
		return true;
	}

	// set m_doTest
	for ( long i = 0 ; submit && i < n ; i++ ) {
		QATest *qt = &s_qatests[i];
		char tmp[10];
		sprintf(tmp,"test%li",i);
		qt->m_doTest = hr->getLong(tmp,0);
	}

	if ( submit ) {
		// reset all the static thingies
		resetFlags();
		// save socket
		g_qaSock = sock;
		g_numErrors = 0;
		g_qaOutput.reset();
		g_qaOutput.safePrintf("<html><body>"
				      "<title>QA Test Results</title>\n");

		g_qaOutput.safePrintf("<SCRIPT LANGUAGE=\"javascript\">\n"
				      // update s_ht with the new crc for this test
				      "function submitchanges(urlhash,crc) "
				      "{\n "
				      "var client=new XMLHttpRequest();\n"
				      "client.onreadystatechange=gotsubmitreplyhandler;"
				      "var "
				      "u='/admin/qa?ajax=1&uh='+urlhash+'&crc='+crc;\n"
				      "client.open('GET',u);\n"
				      "client.send();\n"
				      
				      // use that to fix background to gray
				      "var w=document.getElementById(urlhash);\n"
				      // set background color
				      "w.style.backgroundColor = '0xe0e0e0';\n"

				      // gear spinning after checkbox
				      "}\n\n "

				      // call this when we got the reply that the 
				      // checkbox went through
				      "function gotsubmitreplyhandler() {\n"
				      // return if reply is not fully ready
				      "if(this.readyState != 4 )return;\n"
				      // if error or empty reply then do nothing
				      "if(!this.responseText)return;\n"
				      // response text is the urlhash32, unsigned long
				      "var id=this.responseText;\n"
				      // use that to fix background to gray
				      "var w=document.getElementById(id);\n"
				      // set background color
				      "w.style.backgroundColor = '0xe0e0e0';\n"
				      "}\n\n"

				      "</SCRIPT> ");
		// and run the qa test loop
		if ( ! qatest( ) ) return false;
		// what happened?
		log("qa: qatest completed without blocking");
	}

	// show tests, all checked by default, to perform

	g_pages.printAdminTop ( &sb , sock , hr );

	sb.safePrintf("<SCRIPT LANGUAGE=\"javascript\">\n"
		     "function checkAll(name, num)\n "
		      "{ "
		      "    for (var i = 0; i < num; i++) {\n"
		      "      var e = document.getElementById(name + i);\n"
		      //"alert(name+i);"
		      "      e.checked = !e.checked ;\n "
		      "  }\n"
		      "}\n\n "

		      "</SCRIPT> ");

	//sb.safePrintf("<form name=\"fo\">");

	sb.safePrintf("\n<table %s>\n",TABLE_STYLE);
	sb.safePrintf("<tr class=hdrow><td colspan=2>"
		      "<center><b>QA Tests</b></center>"
		      "</td></tr>");

	// header row
	sb.safePrintf("<tr><td><b>Do Test?</b> <a style=cursor:hand;"
		      "cursor:pointer; "
		      "onclick=\"checkAll('test', %li);\">(toggle)</a>",n);
	sb.safePrintf("</td><td><b>Test Name</b></td></tr>\n");
	
	// . we keep the ptr to each test in an array
	// . print out each qa function
	for ( long i = 0 ; i < n ; i++ ) {
		QATest *qt = &s_qatests[i];
		char *bg;
		if ( i % 2 == 0 ) bg = LIGHT_BLUE;
		else              bg = DARK_BLUE;
		sb.safePrintf("<tr bgcolor=#%s>"
			      "<td><input type=checkbox value=1 name=test%li "
			      "id=test%li></td>"
			      "<td>%s"
			      "<br>"
			      "<font color=gray size=-1>%s</font>"
			      "</td>"
			      "</tr>\n"
			      , bg
			      , i
			      , i
			      , qt->m_testName
			      , qt->m_testDesc
			      );
	}

	sb.safePrintf("</table>\n<br>\n");
	//	      "</form>\n");

	g_pages.printAdminBottom ( &sb , hr );


	g_httpServer.sendDynamicPage(sock,
				     sb.getBufStart(),
				     sb.length(),
				     -1/*cachetime*/);

	return true;
}