void cJuryModule::OnManeuverListSelected() { // get the maneuver file from edit field QString strManeuverFile = m_pWidget->m_edtManeuverFile->text(); if (!strManeuverFile.isEmpty()) { // check if file exists if (QFile::exists(strManeuverFile) && strManeuverFile.contains(".xml")) { // load the file m_strManeuverFile = strManeuverFile; LoadManeuverList(); } else { // file not found, show message box QMessageBox::critical(this, tr("File not found or valid"), tr("The given Maneuver List can not be found or is not valid.")); m_pWidget->m_edtManeuverFile->setFocus(); } } else { // do nothing } }
tHandle cDriverModule::CreateView() { QWidget* pWidget = (QWidget*)m_pViewport->VP_GetWindow(); m_pWidget = new DisplayWidgetDriver(pWidget); connect(m_pWidget, SIGNAL(sendStruct(stateCar, tInt16)), this, SLOT(OnSendState(stateCar, tInt16))); connect(this, SIGNAL(SendRun(int)), m_pWidget, SLOT(OnDriverGo(int))); connect(this, SIGNAL(SendStop(int)), m_pWidget, SLOT(OnDriverStop(int))); connect(this, SIGNAL(SendRequestReady(int)), m_pWidget, SLOT(OnDriverRequestReady(int))); connect(this, SIGNAL(TriggerLoadManeuverList()), this, SLOT(LoadManeuverList())); return (tHandle)m_pWidget; }
void StateControllerNew::EvaluatePin(IPin *sourcePin, IMediaSample *mediaSample) { if (sourcePin == &maneuverListInput) { cString maneuverFileString; { __adtf_sample_read_lock_mediadescription(maneuverListDescription, mediaSample, pCoder); std::vector<tSize> vecDynamicIDs; // retrieve number of elements by providing NULL as first parameter tSize bufferSize = 0; if (IS_OK(pCoder->GetDynamicBufferIDs(NULL, bufferSize))) { // create a buffer depending on the size element tChar pcBuffer[bufferSize]; vecDynamicIDs.resize(bufferSize); // get the dynamic ids (we already got the first "static" size element) if (IS_OK(pCoder->GetDynamicBufferIDs(&(vecDynamicIDs.front()), bufferSize))) { // iterate over all elements for (tUInt32 nIdx = 0; nIdx < vecDynamicIDs.size(); ++nIdx) { // get the value and put it into the buffer pCoder->Get(vecDynamicIDs[nIdx], (tVoid *) &pcBuffer[nIdx]); } maneuverFileString = (const tChar *) pcBuffer; } } } LoadManeuverList(maneuverFileString); return; } if (sourcePin == &juryInput) { tInt8 juryActionId = -2; tInt16 maneuverId = -1; { __adtf_sample_read_lock_mediadescription(juryDescription, mediaSample, pCoder); pCoder->Get("i8ActionID", (tVoid *) &juryActionId); pCoder->Get("i16ManeuverEntry", (tVoid *) &maneuverId); } switch (juryActions(juryActionId)) { case action_GETREADY: JuryGetReady(maneuverId); break; case action_START: JuryStart(maneuverId); break; case action_STOP: JuryStop(maneuverId); break; } return; } if (sourcePin == &errorInput) { tBool isError = tFalse; { __adtf_sample_read_lock_mediadescription(boolDescription, mediaSample, pCoder); pCoder->Get("bValue", (tVoid *) &isError); } if (isError) { logger.Log("Received Error"); SetState(tCarState::Error); } return; } if (sourcePin == &emergencyStopInput) { tBool isEmergencyStop = tFalse; { __adtf_sample_read_lock_mediadescription(boolDescription, mediaSample, pCoder); pCoder->Get("bEmergencyStop", (tVoid *) &isEmergencyStop); } if (isEmergencyStop) { logger.Log("Received EmergencyStop"); SetState(tCarState::Startup); } return; } if (sourcePin == &incrementManeuverInput) { tBool incrementManeuver = tFalse; { __adtf_sample_read_lock_mediadescription(boolDescription, mediaSample, pCoder); pCoder->Get("bValue", (tVoid *) &incrementManeuver); } if (incrementManeuver) { IncrementManeuver(); } return; } if (sourcePin == &readyInput) { tReadyModule::ReadyModuleEnum module = tReadyModule::Nothing; { __adtf_sample_read_lock_mediadescription(enumDescription, mediaSample, pCoder); pCoder->Get("tEnumValue", (tVoid *) &module); } logger.Log(cString::Format("Received ready from %s", tReadyModule::ToString(module).c_str()).GetPtr()); modulesReady.push_back(module); if (tCarState::GetReady == carState && AreAllModulesReady()) { logger.Log("All modules ready"); SetState(tCarState::Ready); } return; } }