Exemple #1
0
void cJuryModule::OnDriverState(int state, int entryId)
{
    // set the driver state
    SetDriverManeuverID(entryId);    
    switch (stateCar(state))
    {
    case stateCar_ERROR:
        SetDriverStateError();
        break;
    case stateCar_READY:        
        SetDriverStateReady();
        break;
    case stateCar_RUNNING:
        SetDriverStateRun();
        break;
    case stateCar_COMPLETE:
        SetDriverStateComplete();
        break;
    case stateCar_STARTUP:
        break;
    }
}
tResult cJuryTransmitter::OnPinEvent(IPin* pSource, tInt nEventCode, tInt nParam1, tInt nParam2, IMediaSample* pMediaSample)
{
    RETURN_IF_POINTER_NULL(pMediaSample);
    RETURN_IF_POINTER_NULL(pSource);

    if (nEventCode == IPinEventSink::PE_MediaSampleReceived && pSource == &m_DriverStructInputPin)
    {
        tInt8 stateDriver = 0;
        tInt16 entry = -1;
        
        {   // focus for sample read lock
            // read-out the incoming Media Sample
            __adtf_sample_read_lock_mediadescription(m_pCoderDescDriverStruct,pMediaSample,pCoder);

            pCoder->Get("i8StateID", (tVoid*)&stateDriver);
            pCoder->Get("i16ManeuverEntry", (tVoid*)&entry);
        }

        //update the gui
        emit sendDriverState(stateDriver, entry);
        
        // set the first entry manually
        if (m_last_timestamp==0)
        {
            m_last_timestamp = pMediaSample->GetTime();
            m_last_entryId = entry;
        }

        //update the timeline
        if (m_last_entryId < entry || m_last_entryId == -1 || stateDriver == -1 || stateDriver == 2)
        {
            tTimeStamp timeDiff = (pMediaSample->GetTime() - m_last_timestamp)/1000;  //time in milliseconds
            QString Message;
            switch (stateCar(stateDriver))
            {
            case stateCar_READY:
                Message = "from " + QString::number(m_last_entryId) + " to " + QString::number(entry) + ": " + QString::number(timeDiff) + " msec: Ready";
                break;
            case stateCar_RUNNING:
                Message = "from " + QString::number(m_last_entryId) + " to " + QString::number(entry) + ": " + QString::number(timeDiff) + " msec: OK";
                break;
            case stateCar_COMPLETE:
                Message = "from " + QString::number(m_last_entryId) + " to " + QString::number(entry) + ": " + QString::number(timeDiff) + " msec: Complete";
                break;
            case stateCar_ERROR:
                Message = "from " + QString::number(m_last_entryId) + " to " + QString::number(entry) + ": " + QString::number(timeDiff) + " msec: Error";
                break;
            case stateCar_STARTUP:
                break;
            }
            m_last_timestamp = pMediaSample->GetTime();
            m_last_entryId = entry;
            //update the gui
            sendMessage(Message);
        }
        if(m_bDebugModeEnabled) LOG_INFO(cString::Format("Jury Module: State value: %i with index %i",stateDriver,entry));

    }
    RETURN_NOERROR;

}
Exemple #3
0
tResult cJuryModule::OnDataUpdate(const tString& strName, const tVoid* pData, const tSize& szSize)
{
    // called from the connection lib on new data

    // check data size
    RETURN_IF_POINTER_NULL(pData);
    if (szSize <= 0)
    {
        RETURN_ERROR(ERR_INVALID_ARG);
    }

    // check the name of the data
    if (strName == CONLIB_IN_PORT_NAME_DRIVER_STRUCT)
    {     
        // data from driver
        const tDriverStruct* sDriverData = (const tDriverStruct*) pData;
        
        //update the gui
        emit SetDriverState(sDriverData->i8StateID, sDriverData->i16ManeuverEntry);


        //update the timeline
        if (m_i16LastDriverEntryId < sDriverData->i16ManeuverEntry || m_i16LastDriverEntryId == -1 || sDriverData->i8StateID == -1 || sDriverData->i8StateID == 2)
        {
            // set the first time manually
            if (m_oLastReceiveTimestamp.isNull())
            {
                m_oLastReceiveTimestamp = QTime::currentTime();
                m_i16LastDriverEntryId = sDriverData->i16ManeuverEntry;
            }

            // calc the time diff
            tTimeStamp timeDiff = (m_oLastReceiveTimestamp.msecsTo(QTime::currentTime()));  //time in milliseconds
            QString Message;
            switch (stateCar(sDriverData->i8StateID))
            {
            case stateCar_READY:
                Message = "from " + QString::number(m_i16LastDriverEntryId) + " to " + QString::number(sDriverData->i16ManeuverEntry) + ": " + QString::number(timeDiff) + " msec: Ready";
                break;
            case stateCar_RUNNING:
                Message = "from " + QString::number(m_i16LastDriverEntryId) + " to " + QString::number(sDriverData->i16ManeuverEntry) + ": " + QString::number(timeDiff) + " msec: OK";
                break;
            case stateCar_COMPLETE:
                Message = "from " + QString::number(m_i16LastDriverEntryId) + " to " + QString::number(sDriverData->i16ManeuverEntry) + ": " + QString::number(timeDiff) + " msec: Complete";
                break;
            case stateCar_ERROR:
                Message = "from " + QString::number(m_i16LastDriverEntryId) + " to " + QString::number(sDriverData->i16ManeuverEntry) + ": " + QString::number(timeDiff) + " msec: Error";
                break;
            case stateCar_STARTUP:
                break;
            }
            // set the last time
            m_oLastReceiveTimestamp = QTime::currentTime();             
            m_i16LastDriverEntryId = sDriverData->i16ManeuverEntry;
            //update the ui
            SetLogText(Message);
        }

    }
    else if (strName == CONLIB_IN_PORT_NAME_JURY_STRUCT_LOOPBACK)
    {
        // data from jury loopback
        const tJuryStruct* sJuryLoopbackData = (const tJuryStruct*) pData;

        QString strText = QString("Loopback Jury: Received jury struct loopback with action ");
        switch(juryActions(sJuryLoopbackData->i8ActionID))
        {
        case action_GETREADY:
            strText += "GETREADY ";
            break;
        case action_START:
            strText += "START ";
            break;
        case action_STOP:
            strText += "STOP ";
            break;
        default:
            strText += "UNKNOWN ";
            break;
        }

        strText += QString(" and maneuver ") + QString::number(sJuryLoopbackData->i16ManeuverEntry);

        // write text to log (just for checking the connection)
        SetLogText(strText);
        //QMetaObject::invokeMethod(this, "OnAppendText", Qt::AutoConnection, Q_ARG(QString, strText));
    }
    else if (strName == CONLIB_IN_PORT_NAME_EMERGENCY_STOP_LOOPBACK)
    {
        // data from emergency loopback
        const tJuryEmergencyStop* sJuryLoopbackData = (const tJuryEmergencyStop*) pData;

        QString strText = QString("Loopback Emergency: Received emergency loopback with "); 
        strText += (sJuryLoopbackData->bEmergencyStop == true) ? QString("true") : QString("false");
        
        // write text to log (just for checking the connection)
        SetLogText(strText);
        //QMetaObject::invokeMethod(this, "OnAppendText", Qt::AutoConnection, Q_ARG(QString, strText));
    }
    else if (strName == CONLIB_IN_PORT_NAME_MANEUVER_LIST)
    {
        // data from maneuverlist loopback
        const tInt32* i32DataSize = (const tInt32*) pData;
        const tChar* pcString = (const tChar*) ((tChar*)pData + sizeof(tInt32));
        tString strManeuver(pcString);
        QString strText = QString("Loopback ManeuverList received"); 

        // check the data content
        if(*i32DataSize != (m_strManeuverList.size() + sizeof(char)))
        {
            strText += QString(" size does not match"); 
        }
        if(strManeuver != m_strManeuverList)
        {
            strText += QString(" content does not match"); 
        }
        
        strText += "!!!";

        // write text to log (just for checking the connection)
        SetLogText(strText);
        //QMetaObject::invokeMethod(this, "OnAppendText", Qt::AutoConnection, Q_ARG(QString, strText));
    }
    RETURN_NOERROR;

}