tResult StateControllerNew::SendValue(cOutputPin &pin, stateCar state, tInt16 maneuver) { if (!pin.IsConnected()) { RETURN_NOERROR; } cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid **) &mediaSample)); cObjectPtr<IMediaSerializer> driverSerializer; driveStructDescription->GetMediaSampleSerializer(&driverSerializer); tInt nSize = driverSerializer->GetDeserializedSize(); RETURN_IF_FAILED(mediaSample->AllocBuffer(nSize)); tInt8 carState = tInt8(state); { __adtf_sample_write_lock_mediadescription(driveStructDescription, mediaSample, pCoder); pCoder->Set("i8StateID", (tVoid *) &carState); pCoder->Set("i16ManeuverEntry", (tVoid *) &maneuver); } mediaSample->SetTime(_clock->GetStreamTime()); RETURN_IF_FAILED(pin.Transmit(mediaSample)); RETURN_NOERROR; }
tResult cDriverModule::OnSendState(stateCar stateID, tInt16 i16ManeuverEntry) { cObjectPtr<IMediaSample> pMediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pMediaSample)); cObjectPtr<IMediaSerializer> pSerializer; m_pDescDriverStruct->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); tInt8 value = tInt8(stateID); RETURN_IF_FAILED(pMediaSample->AllocBuffer(nSize)); { // focus for sample write lock __adtf_sample_write_lock_mediadescription(m_pDescDriverStruct,pMediaSample,pCoder); // get the IDs for the items in the media sample if(!m_bIDsDriverStructSet) { pCoder->GetID("i8StateID", m_szIDDriverStructI8StateID); pCoder->GetID("i16ManeuverEntry", m_szIDDriverStructI16ManeuverEntry); m_bIDsDriverStructSet = tTrue; } pCoder->Set(m_szIDDriverStructI8StateID, (tVoid*)&value); pCoder->Set(m_szIDDriverStructI16ManeuverEntry, (tVoid*)&i16ManeuverEntry); } pMediaSample->SetTime(_clock->GetStreamTime()); m_DriverStructOutputPin.Transmit(pMediaSample); if(m_bDebugModeEnabled) { switch (stateID) { case stateCar_READY: LOG_INFO(cString::Format("Driver Module: Send state: READY, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_RUNNING: LOG_INFO(cString::Format("Driver Module: Send state: RUNNING, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_COMPLETE: LOG_INFO(cString::Format("Driver Module: Send state: COMPLETE, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_ERROR: LOG_INFO(cString::Format("Driver Module: Send state: ERROR, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_STARTUP: break; } } RETURN_NOERROR; }