Ejemplo n.º 1
0
bool TLVExecutor::execute(Cmd& cmd)
{ 
    if(cmd.size() < 2)
    {
        log("Error cmd with no params:%s", printCmd(cmd));
        return false;
    }

    const char* key = cmd[0].c_str();
    if(0 == strcasecmp("settag", key))
    {
        CheckParam(2);
        return TLVInterface::setTag(atoi(getp(1)),getp(2));
    }
    else if(0 == strcasecmp("gettag", key))
    {
        CheckParam(2);
        return TLVInterface::getTag(atoi(getp(1)),getp(2));
    }
    else if(0 == strcasecmp("addtag", key))
    {
        CheckParam(2);
        return TLVInterface::addTag(atoi(getp(1)),getp(2));
    }
    
    return false;
}
Ejemplo n.º 2
0
bool CmdsExecutor::doExecute(Cmd& cmd)
{
    if(cmd.size() < 2)
    {
        log("Error cmd with no params:%s", printCmd(cmd));
        return false;
    }

    ExecutorPtr it = m_executors.begin();
    for(; it != m_executors.end(); it++)
    {
        if((*it)->execute(cmd))
        {
            return true;
        }
    }

    log("Command not run: %s", printCmd(cmd));
    return false;
}
Ejemplo n.º 3
0
void
usage( const char *str, int iExitCode )
{
	bool has_cmd_opt = true;
	bool needsID = true;

	if( ! str ) {
		fprintf( stderr, "Use \"-help\" to see usage information\n" );
		exit( iExitCode );
	}
	if( !cmd ) {
		fprintf( stderr, "Usage: %s [command] [options]\n", str );
		fprintf( stderr, "Where [command] is one of:\n" );
		printCmd( CA_REQUEST_CLAIM );
		printCmd( CA_RELEASE_CLAIM );
		printCmd( CA_ACTIVATE_CLAIM );
		printCmd( CA_DEACTIVATE_CLAIM );
		printCmd( CA_SUSPEND_CLAIM );
		printCmd( CA_RESUME_CLAIM );
		printCmd( CA_RENEW_LEASE_FOR_CLAIM );
		printCmd( DELEGATE_GSI_CRED_STARTD );
		fprintf( stderr, "use %s [command] -help for more "
				 "information on a given command\n", str ); 
		exit( iExitCode );
	}

	switch( cmd ) {
	case CA_REQUEST_CLAIM:
		needsID = false;
		break;
	case CA_SUSPEND_CLAIM:
	case CA_RESUME_CLAIM:
		has_cmd_opt = false;
		break;
	}

	fprintf( stderr, "Usage: %s %s[target] [general-opts]%s\n", str,
			 needsID ? " [claimid] " : "",
			 has_cmd_opt ? " [command-opts]" : "");

	printCmd( cmd );
	
	if( needsID ) { 
		fprintf( stderr, "\nWhere [claimid] must be specified as:\n");
		fprintf( stderr, "   -id ClaimId\t\tAct on the given COD claim\n" );
		fprintf( stderr, "   (The startd address may be inferred from this in most cases, but it is better\n"
				         "to specify the address explicitly.\n");
	}

	fprintf( stderr, "\nWhere [target] can be zero or one of:\n" );
	fprintf( stderr, "   -name hostname\tContact the startd on the "
			 "given host\n" ); 
	fprintf( stderr, "   -pool hostname\tUse the given central manager "
			 "to find the startd\n\t\t\trequested with -name\n" );
	fprintf( stderr, "   -addr <ip_addr:port>\tContact the startd at " 
			 "the given \"sinful string\"\n" );
	fprintf( stderr, "   (If no target or claimid is specified, the local "
			 "host is used)\n" );

	fprintf( stderr, "\nWhere [general-opts] can either be one of:\n" );
	fprintf( stderr, "   -help\t\tPrint this usage information and exit\n" );
	fprintf( stderr, "   -version\t\tPrint the version of this tool and "
			 "exit\n" );
	fprintf( stderr, " or it may be zero or more of:\n" );
	fprintf( stderr, "   -debug\t\tPrint verbose debugging information\n" );
	fprintf( stderr, "   -classad file\tPrint the reply ClassAd to "
			 "the given file\n" );
	fprintf( stderr, "   -timeout N\t\tTimeout all network "
			 "operations after N seconds\n" );

	if( has_cmd_opt ) {
		fprintf( stderr,
 				 "\nWhere [command-opts] can be zero or more of:\n" );
	}

	switch( cmd ) {

	case CA_REQUEST_CLAIM:
		fprintf( stderr, "   -requirements expr\tFind a resource "
				 "that matches the boolean expression\n" );
		fprintf( stderr, "   -lease N\t\tNumber of seconds to wait for lease renewal\n");
		break;

	case CA_ACTIVATE_CLAIM:
		fprintf( stderr, "   -keyword string\tUse the keyword to "
				 "find the job in the config file\n" );
		fprintf( stderr, "   -jobad filename\tUse the ClassAd in filename "
				 "to define the job\n" );
		fprintf( stderr, "\t\t\t(if filename is \"-\", read from STDIN)\n" );
		fprintf( stderr, "   -cluster N\t\tStart the job with the "
				 "given cluster ID\n" );
		fprintf( stderr, "   -proc N\t\tStart the job with the "
				 "given proc ID\n" );
		fprintf( stderr, "   -requirements expr\tFind a starter "
				 "that matches the boolean expression\n" );
		break;

	case CA_RELEASE_CLAIM:
	case CA_DEACTIVATE_CLAIM:
		printFast();
		break;

	case DELEGATE_GSI_CRED_STARTD:
		fprintf( stderr, "   -x509proxy filename\tDelegate the proxy in the "
				 "specified file\n" );
		break;
	}

	fprintf(stderr, "\n" );
	exit( iExitCode );
}
Ejemplo n.º 4
0
static void printAllCmd(void){
	int  i = 0;
	for(i=0; i<sizeof(g_send_cmds)/sizeof(struct _sendCmdType); i++){
		printCmd(&g_send_cmds[i]);
	}
}
void AuroraControlWorker::process()  {
    QextSerialPort* port;
    QByteArray rep;
    QList<PortHandle> port_handles;
    int nHandles;
    char cmd[256];

    port = openPort("/dev/ttyUSB0");
    sleep(1);

    writeCommand(port, "TSTOP \r");
    rep = readCommand(port);
    printCmd(rep);

   /* writeCommand(port, "PHF OA\r");
    rep = readCommand(port);
    printCmd(rep);

    writeCommand(port, "PHF 0B\r");
    rep = readCommand(port);
    printCmd(rep);*/

    writeCommand(port, "INIT \r");
    sleep(1);
    rep = readCommand(port);
    printCmd(rep);

    writeCommand(port, "PHSR 00\r");
    sleep(1);
    rep = readCommand(port);
    ParsePHSR(rep, nHandles, port_handles);

    //Init all ports
    for (int i = 0; i < nHandles; i++)  {
        sprintf(cmd, "PINIT %c%c\r", port_handles.at(i).HandleHexCharString[0],
                port_handles.at(i).HandleHexCharString[1]);
        writeCommand(port, cmd);
        rep = readCommand(port);
        printCmd(rep);
    }

    //Enable handles
    for (int i = 0; i < nHandles; i++)  {
        sprintf(cmd, "PENA %c%c\r", port_handles.at(i).HandleHexCharString[0],
                port_handles.at(i).HandleHexCharString[1]);
        writeCommand(port, cmd);
        rep = readCommand(port);
        printCmd(rep);
    }

    //GO TRACK
    writeCommand(port, "TSTART \r");
    rep = readCommand(port);
    printCmd(rep);

    //GETBX
    QElapsedTimer timer;
    timer.start();
    while(!stopped) {
        SystemStatus system_status;
        QList<HandleReply> handle_replys;
        int bx_nHandles;

        writeCommand(port, "BX 0801\r");
        rep = readCommandBX(port);
        ParseBX(rep, bx_nHandles, handle_replys, system_status);
        //printCmdHex(rep);
        /*
            fprintf(f_coord_log, "%f, %f, %f, %f, %f, %f, %f, %f, %u, %u\n",
                    Q0, Qx, Qy, Qz, Tx, Ty, Tz, IndicatorValue, PortStatus,
                    FrameNumber);
            msg.tools.append(tool);*/
/*
       AuroraTickQMessage msg;
       for ( int i = 0; i < bx_nHandles; i++ )  {
            AuroraTool tool;
            tool.Q0 = handle_replys[i].Q0;
            tool.Qx = handle_replys[i].Qx;
            tool.Qy = handle_replys[i].Qy;
            tool.Qz = handle_replys[i].Qz;
            tool.Tx = handle_replys[i].Tx;
            tool.Ty = handle_replys[i].Ty;
            tool.Tz = handle_replys[i].Tz;
            tool.IndicatorValue = handle_replys[i].IndicatorValue;
            tool.PortStatus = handle_replys[i].PortStatus;
            tool.FrameNumber = handle_replys[i].FrameNumber;
            msg.tools.append(tool);

       }
       qint64 te = timer.elapsed();
       if (te < 70)//25
            this->msleep(70 - te);
       emit newFrame(msg);
       timer.start();

   }
    std::cout<<"\nI am done here\n";
    //Release all ports
    writeCommand(port, "PHF 0A\r");
    rep = readCommand(port);
    printCmd(rep);

    writeCommand(port, "PHF 0B\r");
    rep = readCommand(port);
    printCmd(rep);
*/
    emit finished();
}