Beispiel #1
0
			bool  SocketSession::check(){

				time_t now = time(NULL);
				//检查不活跃期超时(activity)
				if(now - getLastActivity() > getWait()){
					LOG_DEBUG("SocketSession::check => del a session : sid = " << getSessionId() << " userId = " << getUserId());
					LOG_TRACE_ACTION(" sockSessionTimeOut"<<" | "<<getUserId()<<" | "<<getSessionId()<<" | "<<getCAppId()<<" | "<<"000000");
					internalClose();
					return 1;
				} 			
				return 0;
			}
void GuideManager::nextStep(int step)
{
    CCLOG("step = %d",step);

    const StepInfo& stepInfo = m_vecStep.at(step);
    
    if (getWait())
    {
        return;
    }
    
    if (isLimit(stepInfo))
    {
        return;
    }
    
    m_guideLayer->removeFromParent();
    getParent()->addChild(m_guideLayer, GUIDE_LAYER_ZORDER);
    
    if (stepInfo.getNextStepId() == END)
    {
        endGuide();
        return;
    }
    else if (stepInfo.getNextStepId() == WAIT)
    {
        setWait(true);
    }
    else if (stepInfo.getNextStepId() == SLEEP)
    {
        getGuideLayer()->sleep();
    }
    else if (stepInfo.getNextStepId() == WAKE)
    {
        getGuideLayer()->wake();
    }
    
    
    // by order
    checkDialog(stepInfo);
    checkRect(stepInfo);
    checkTalk(stepInfo);
    checkHand(stepInfo);
    checkEvent(stepInfo);
    
    setNextStepId(step + 1);
}
Beispiel #3
0
	// return true if a refresh was done
	bool objectLifeTimeManager::refreshAnimation() {
		if (startTime == 0) {
			start();
			return false;
		}
		float t = ofGetElapsedTimef() - startTime;

		if (t < getWait()) {
			return false;// waiting to start
		}
		//wait = 0; // skip all future usage of wait once we start
				  // check for expired flag 
		if (getObjectLifetime() > 0 && t > getObjectLifetime()) {
			expired = true; // duration of 0 means no expiration
			return false;
		}
		// at this point we can start the time over w/o a wait
		if (t > getRefreshRate()) {
			startTime = ofGetElapsedTimeMillis();
			return true;
		}
		return false;
	}
/**-------------------------------------------------------------------------------------------
// reads a dictionary entry
// description:
//      reads a dictionary entry from an other canopen device.
//------------------------------------------------------------------------------------------*/
void CANFestivalGui::canopenDictRead( )
{
    unsigned short tempIndex;
    char            tempSubIndex;
    char            data[SDO_MAX_DOMAIN_LEN];

    // sets all values to 0
    for( int i=0; i<SDO_MAX_DOMAIN_LEN; i++ )
        data[i] = 0;

    // converts the data filds from the gui into integer values
    // as far as i know: when reading dict. entries no values are sent to the slave...
//    for( int i=0; i<getLength( canopenDictDataList ); i++ ) {
//        if( canopenDictHexFormat->isChecked( ) ) {
//            data[i] = strtol( canopenDictDataList.at( i )->text( ), NULL, 16 );
//        } else if( canopenDictBinFormat->isChecked( ) ) {
//            data[i] = strtol( canopenDictDataList.at( i )->text( ), NULL, 2 );
//        } else {
//            data[i] = canopenDictDataList.at( i )->text( ).toInt( );
//        }
//    }

    // gets and converts the indexnumber of the dictionary entry
    if( ui->canopenDictHexFormat->isChecked( ) ) {
        tempIndex = strtol( ui->canopenDictIndex->text( ).toStdString().c_str(), NULL, 16 );
    } else if( ui->canopenDictBinFormat->isChecked( ) ) {
        tempIndex = strtol( ui->canopenDictIndex->text( ).toStdString().c_str(), NULL, 2 );
    } else {
        tempIndex = ui->canopenDictIndex->text( ).toInt( );
    }

    // gets and converts the subindexnumber of the dictionary entry
    if( ui->canopenDictHexFormat->isChecked( ) ) {
        tempSubIndex = strtol( ui->canopenDictSubIndex->text( ).toStdString().c_str(), NULL, 16 );
    } else if( ui->canopenDictBinFormat->isChecked( ) ) {
        tempSubIndex = strtol( ui->canopenDictSubIndex->text( ).toStdString().c_str(), NULL, 2 );
    } else {
        tempSubIndex = ui->canopenDictSubIndex->text( ).toInt( );
    }

    // temporary stops the thread which sniffes the can-bus (this thread reads all received can-bus
    // messages and shows them in the logwindow)
    if( mLogThread )
        mLogThread->getSem( );
    // set f_can_receive to block (so reading the canbus blocks until a message was received)
    int tempWait = getWait( );
    setWait( 1 );

    // calls the function of canopenmatic which performs the rest for us...
    if( ReadDictionaryEntry( 0,
                         ui->canopenDictDeviceId->text( ).toInt( ),
                         tempIndex,
                         tempSubIndex,
                         data ) == 0 )
    {   // if read of dictionary entry was successful...
        QString intValue;
        QString textValue;
        QString hexValue;

        textValue = "Text: ";
        intValue = "Int: ";
        hexValue = "Hex: ";

        char text[5];

        // processes the received data, so it is useful for the user. after processing the data are shown in the gui
        //
        for( int i=0; i<SDO_MAX_DOMAIN_LEN; i++ ) {
            sprintf( text, "%.2d|", data[i] );
            intValue.append( text );
            sprintf( text, "%c", data[i] );
            textValue.append( text );
            sprintf( text, "%.2x|", data[i] );
            hexValue.append( text );
        }
        QMessageBox::information( this, "Dictionary Read Result (integer)", intValue + "\n" + textValue + "\n" + hexValue );
    }
    // sets the read/write flag (blocking or non-blocking) to the previous value
    setWait( tempWait );
    if( mLogThread )
        mLogThread->putSem( );
}