예제 #1
0
tResult cJuryModule::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cBaseQtFilter::Init(eStage, __exception_ptr));

    // pins need to be created at StageFirst
    if (eStage == StageFirst)
    {

        cObjectPtr<IMediaDescriptionManager> pDescManager;
        RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER,
            IID_ADTF_MEDIA_DESCRIPTION_MANAGER,
            (tVoid**)&pDescManager,
            __exception_ptr));
        /*
        * the MediaDescription for <struct name="tJuryNotAusFlag" .../> has to exist in a description file (e.g. in $ADTF_DIR\description\ or $ADTF_DIR\src\examples\src\description
        * before (!) you start adtf_devenv !! if not: the Filter-Plugin will not loaded because cPin.Create() and so ::Init() failes !
        */
        // Select Output
        tChar const * strDesc2 = pDescManager->GetMediaDescription("tJuryStruct");
        RETURN_IF_POINTER_NULL(strDesc2);
        cObjectPtr<IMediaType> pType2 = new cMediaType(0, 0, 0, "tJuryStruct", strDesc2, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_JuryStructOutputPin.Create("Jury_Struct", pType2, this));
        RETURN_IF_FAILED(RegisterPin(&m_JuryStructOutputPin));
        RETURN_IF_FAILED(pType2->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescJuryStruct));

        // NotAus Output
        tChar const * strDesc1 = pDescManager->GetMediaDescription("tJuryEmergencyStop");
        RETURN_IF_POINTER_NULL(strDesc1);
        cObjectPtr<IMediaType> pType1 = new cMediaType(0, 0, 0, "tJuryEmergencyStop", strDesc1,IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_NotAusOutputPin.Create("Emergency_Stop", pType1, this));
        RETURN_IF_FAILED(RegisterPin(&m_NotAusOutputPin));
        RETURN_IF_FAILED(pType1->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescNotAus));      

        // input Pin
        tChar const * strDesc4 = pDescManager->GetMediaDescription("tDriverStruct");
        RETURN_IF_POINTER_NULL(strDesc4);
        cObjectPtr<IMediaType> pType4 = new cMediaType(0, 0, 0, "tDriverStruct", strDesc4, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_DriverStructInputPin.Create("Driver_Struct", pType4, this));
        RETURN_IF_FAILED(RegisterPin(&m_DriverStructInputPin));
        RETURN_IF_FAILED(pType4->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescDriverStruct));      

        m_bDebugModeEnabled = GetPropertyBool("Debug Output to Console");
    }
    else if(eStage == StageNormal)
    {

    }
    else if(eStage == StageGraphReady)
    {
        loadManeuverList();
        m_pWidget->SetManeuverList(m_sectorList);
        m_pWidget->FillComboBox();
        m_bIDNotAusSet = tFalse;
        m_bIDsJuryStructSet = tFalse;
        m_bIDsDriverStructSet = tFalse;
    }
    RETURN_NOERROR;
}
예제 #2
0
tResult LightMessageLogger::Init(tInitStage eStage, __exception) {
	RETURN_IF_FAILED(cAsyncDataTriggeredFilter::Init(eStage, __exception_ptr));
	if (eStage == StageFirst)
	{

		RETURN_IF_FAILED(tActionStruct_object.StageFirst(__exception_ptr));
		RETURN_IF_FAILED(tFeedbackStruct_object.StageFirst(__exception_ptr));

		// create and register the input and output pin
		RETURN_IF_FAILED(CreateInputPins(__exception_ptr));
		RETURN_IF_FAILED(CreateOutputPins(__exception_ptr));


	} else if (eStage == StageNormal) {

		/* read property whether debug mode is required */
		debugModeEnabled = tBool(GetPropertyBool(LMLO_DEBUG_TO_CONSOLE));
		carIsCarOne = tBool(GetPropertyBool(LMLO_CAR_NAME));

		// invert car names if protperty is enabled
		if(!carIsCarOne) {
			cString tmp_own_car_name = own_car_name;
			own_car_name = respondent_car_name;
			respondent_car_name = tmp_own_car_name;
		}

		// clear file content
		logfile_content.content.clear();
		new_content_counter = 1;

		// clear file
		fstream chat_file;
		chat_file.open("/home/aadc/AADC/utilities/Kuer/data.json", ios::out | ios::trunc);
		chat_file << "";
		chat_file.close();

	} else if (eStage == StageGraphReady) {
		// get size of media samples that has to be assigned later
		RETURN_IF_FAILED(tActionStruct_object.StageGraphReady());
		RETURN_IF_FAILED(tFeedbackStruct_object.StageGraphReady());

	}
	RETURN_NOERROR;
}
// -------------------------------------------------------------------------------------------------
tResult EmergencyFilter::Init(tInitStage stage, __exception) {
// -------------------------------------------------------------------------------------------------
  RETURN_IF_FAILED(cFilter::Init(stage, __exception_ptr));
  
	if (stage == StageFirst) {
	  // Create and register the input pin
    cObjectPtr<IMediaDescriptionManager> description_manager;
    RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER,
      IID_ADTF_MEDIA_DESCRIPTION_MANAGER,(tVoid**)&description_manager,__exception_ptr));
    
    // Create the output pin description
    tChar const * package_description = description_manager->GetMediaDescription("SensorPackage");
    RETURN_IF_POINTER_NULL(package_description);        
    cObjectPtr<IMediaType> package_type = new cMediaType(0, 0, 0, "SensorPackage", package_description, IMediaDescription::MDF_DDL_DEFAULT_VERSION);	
    RETURN_IF_FAILED(package_type->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&sensor_package_description_));
    
    // Create the input pin
    RETURN_IF_FAILED(sensor_package_input_.Create("sensorPackage", package_type, static_cast<IPinEventSink*>(this)));
    RETURN_IF_FAILED(RegisterPin(&sensor_package_input_));
    
    // Create the suppression input description
    tChar const * suppression_description = description_manager->GetMediaDescription("tBoolSignalValue");
    RETURN_IF_POINTER_NULL(suppression_description);        
    cObjectPtr<IMediaType> suppression_type = new cMediaType(0, 0, 0, "tBoolSignalValue", suppression_description, IMediaDescription::MDF_DDL_DEFAULT_VERSION);	
		RETURN_IF_FAILED(suppression_type->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&suppression_data_description_));
		
		// Create the input pin
    RETURN_IF_FAILED(suppress_input_.Create("suppress_warnings", suppression_type, static_cast<IPinEventSink*>(this)));
    RETURN_IF_FAILED(RegisterPin(&suppress_input_));
    
    // Create the bool output description
    tChar const * bool_description = description_manager->GetMediaDescription("tBoolSignalValue");
    RETURN_IF_POINTER_NULL(bool_description);        
    cObjectPtr<IMediaType> bool_type = new cMediaType(0, 0, 0, "tBoolSignalValue", bool_description, IMediaDescription::MDF_DDL_DEFAULT_VERSION);	
		RETURN_IF_FAILED(bool_type->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&bool_data_description_));
    
    // Create the output pins
    RETURN_IF_FAILED(wheel_active_output_.Create("wheelActive", bool_type, NULL));
    RETURN_IF_FAILED(RegisterPin(&wheel_active_output_));
    
    RETURN_IF_FAILED(hazard_light_output_.Create("hazardLightsEnabled", bool_type, NULL));
    RETURN_IF_FAILED(RegisterPin(&hazard_light_output_));
	}
	
	else if (stage == StageGraphReady) {
	  debug_ = GetPropertyBool("debug");
	  
	  suppressed_ = false;
	}
	
	RETURN_NOERROR;
}
예제 #4
0
tResult cDriverModule::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cBaseQtFilter::Init(eStage, __exception_ptr));

    // pins need to be created at StageFirst
    if (eStage == StageFirst)    {

        cObjectPtr<IMediaDescriptionManager> pDescManager;
        RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER,
            IID_ADTF_MEDIA_DESCRIPTION_MANAGER,
            (tVoid**)&pDescManager,
            __exception_ptr));

        // input jury struct
        tChar const * strDesc1 = pDescManager->GetMediaDescription("tJuryStruct");
        RETURN_IF_POINTER_NULL(strDesc1);
        cObjectPtr<IMediaType> pType1 = new cMediaType(0, 0, 0, "tJuryStruct", strDesc1, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_JuryStructInputPin.Create("Jury_Struct", pType1, this));
        RETURN_IF_FAILED(RegisterPin(&m_JuryStructInputPin));
        RETURN_IF_FAILED(pType1->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescJuryStruct));

        // input maneuver list
        tChar const * strDesc3 = pDescManager->GetMediaDescription("tManeuverList");
        RETURN_IF_POINTER_NULL(strDesc3);
        cObjectPtr<IMediaType> pType3 = new cMediaType(0, 0, 0, "tManeuverList", strDesc3, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_ManeuverListInputPin.Create("Maneuver_List", pType3, this));
        RETURN_IF_FAILED(RegisterPin(&m_ManeuverListInputPin));
        RETURN_IF_FAILED(pType3->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescManeuverList));

        // output driver struct
        tChar const * strDesc2 = pDescManager->GetMediaDescription("tDriverStruct");
        RETURN_IF_POINTER_NULL(strDesc2);
        cObjectPtr<IMediaType> pType2 = new cMediaType(0, 0, 0, "tDriverStruct", strDesc2, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        RETURN_IF_FAILED(m_DriverStructOutputPin.Create("Driver_Struct", pType2, this));
        RETURN_IF_FAILED(RegisterPin(&m_DriverStructOutputPin));
        RETURN_IF_FAILED(pType2->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescDriverStruct));

        m_bDebugModeEnabled = GetPropertyBool("Debug Output to Console");
    }
    else if(eStage == StageGraphReady)
    {
        // disable maneuver group box until receiving maneuver list
        m_pWidget->EnableManeuverGroupBox(false);
        // no ids were set so far
        m_bIDsJuryStructSet = tFalse;
        m_bIDsDriverStructSet = tFalse;
    }
    RETURN_NOERROR;
}
예제 #5
0
// -------------------------------------------------------------------------------------------------
float LaneFilter::calculateImageLuminosity(Mat const & image) {
// -------------------------------------------------------------------------------------------------
  int scan_rate = GetPropertyInt("scan_rate");
  float sum = 0;
  int counter = 0;
  for (int row = 0; row < image.rows; row += scan_rate) {
    for (int col = 0; col < image.cols; col += scan_rate) {
      Vec3b cur = image.at<Vec3b>(row, col);
      sum += (1.0f / 3.0f) * (cur[0] + cur[1] + cur[2]);
      counter++;
    }
  }
  
  if (GetPropertyBool("debug")) LOG_INFO(cString::Format("Current luminosity: %f", sum / counter));
  return sum / counter;
}
예제 #6
0
tResult cQrPlayer::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr));
    if (eStage == StageFirst)
	{
		//this is a VideoPin
        RETURN_IF_FAILED(m_oPinInputVideo.Create("Video_RGB_input",IPin::PD_Input, static_cast<IPinEventSink*>(this))); 
		RETURN_IF_FAILED(RegisterPin(&m_oPinInputVideo));
		
		
		cObjectPtr<IMediaDescriptionManager> pDescManager;
        RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER,IID_ADTF_MEDIA_DESCRIPTION_MANAGER,(tVoid**)&pDescManager,__exception_ptr));

        tChar const * strDescSignalValueOutput = pDescManager->GetMediaDescription("tSignalValue");
        RETURN_IF_POINTER_NULL(strDescSignalValueOutput);        
        cObjectPtr<IMediaType> pTypeSignalValueOutput = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalValueOutput,IMediaDescription::MDF_DDL_DEFAULT_VERSION);	
        RETURN_IF_FAILED(pTypeSignalValueOutput->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pCoderDescSignalOutput)); 
		
        //accelerate output
        RETURN_IF_FAILED(m_oPinAccelerateSignal.Create("accelerate", pTypeSignalValueOutput, static_cast<IPinEventSink*> (this)));
        RETURN_IF_FAILED(RegisterPin(&m_oPinAccelerateSignal));

        // Steer Angle Output
        RETURN_IF_FAILED(m_oPinSteeringSignal.Create("steerAngle", pTypeSignalValueOutput, static_cast<IPinEventSink*> (this)));
        RETURN_IF_FAILED(RegisterPin(&m_oPinSteeringSignal));
     
	}
    else if (eStage == StageNormal)
    {
       	m_bConsoleOutputEnabled = GetPropertyBool("Output to Console");
    }
    else if (eStage == StageGraphReady)
    {
        cObjectPtr<IMediaType> pType;
        RETURN_IF_FAILED(m_oPinInputVideo.GetMediaType(&pType));

        cObjectPtr<IMediaTypeVideo> pTypeVideo;
        RETURN_IF_FAILED(pType->GetInterface(IID_ADTF_MEDIA_TYPE_VIDEO, (tVoid**)&pTypeVideo));

        UpdateImageFormat(pTypeVideo->GetFormat());      
		
    }
    RETURN_NOERROR;
}
예제 #7
0
// -------------------------------------------------------------------------------------------------
tResult LaneFilter::processImage(IMediaSample* image_sample) {
// -------------------------------------------------------------------------------------------------
  const tVoid* source_buffer;
  
  bool enable_lights = false;
  
  if (IS_OK(image_sample->Lock(&source_buffer))) {
    int source_width = input_format_.nWidth;
    int source_height = input_format_.nHeight;
    
    Mat current_image(source_height, source_width, CV_8UC3, (uchar*)source_buffer);
    
    enable_lights = calculateImageLuminosity(current_image) < GetPropertyFloat("lum_threshold");
    
    // Detect the edges of the image by using a Canny Algo
    Mat preprocessed;
    lane_preprocessor_.set_gaussian_blur(Size(15,15), 2);
    lane_preprocessor_.preprocess_image(current_image, preprocessed);
    
    std::vector<Vector2> mapped_points;
    Mat mapping_image;
    lane_detector_.detect_lanes(preprocessed, mapping_image, mapped_points);
    image_sample->Unlock(source_buffer);
    
    transmitLanePoints(mapped_points);
  }
  
  if (GetPropertyBool("headlights_enabled")) {
    if(enable_lights != headlights_on_) {
      transmitHeadLight(enable_lights);
      headlights_on_ = enable_lights;
    }
  }
  
  RETURN_NOERROR;
}
예제 #8
0
void CLoginSession::CmdSignIn (void)

//	CmdSignIn
//
//	Sign in the user

	{
	CUIHelper Helper(m_HI);

	//	Get the fields

	CString sUsername = GetPropertyString(ID_CTRL_USERNAME, PROP_TEXT);
	CString sPassword = GetPropertyString(ID_CTRL_PASSWORD, PROP_TEXT);
	bool bAutoSignIn = GetPropertyBool(ID_CTRL_AUTO_SIGN_IN, PROP_CHECKED);

	//	Get the text for the username. If blank, then we have an error.

	if (sUsername.IsBlank())
		{
		Helper.CreateInputErrorMessage(this, m_rcInputError, CONSTLIT("Username Missing"), CONSTLIT("You must have a username to sign in."));
		return;
		}

	//	Register the name

	m_HI.AddBackgroundTask(new CSignInUserTask(m_HI, m_Service, sUsername, sPassword, bAutoSignIn), this, CMD_SIGN_IN_COMPLETE);

	//	Disable controls

	SetPropertyBool(ID_CTRL_USERNAME, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_PASSWORD, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_MAIN_ACTION, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_AUTO_SIGN_IN, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_REGISTER, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_PASSWORD_RESET, PROP_ENABLED, false);
	}
tResult ROI::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr));

    if (eStage == StageFirst)
    {
        RETURN_IF_FAILED(InitDescriptions(__exception_ptr));
        RETURN_IF_FAILED(CreateInputPins(__exception_ptr));
        RETURN_IF_FAILED(CreateOutputPins(__exception_ptr));
    }
    else if (eStage == StageNormal)
    {
        hoodScanLineNumber = GetPropertyInt(HOOD_SCANLINE_NUMBER_PROPERTY);
        roomScanLineNumber = GetPropertyInt(ROOM_SCANLINE_NUMBER_PROPERTY);
        maxHoodDetectionCount = GetPropertyInt(MAX_HOOD_DETECTION_COUNT_PROPERTY);
        rgbVideoManipulation = GetPropertyInt(RGB_VIDEO_MANIPULATION_PROPERTY);
        depthVideoManipulation = GetPropertyInt(DEPTH_VIDEO_MANIPULATION_PROPERTY);
        isHoodDetectionEnabled = GetPropertyBool(DETECT_HOOD_PROPERTY);
        isRoomDetectionEnabled = GetPropertyBool(DETECT_ROOM_PROPERTY);
        roomHeightManipulation = GetPropertyFloat(ROOM_HEIGHT_MANIPULATION_PROPERTY);

        logger.Log(cString::Format("roomHeightManipulation: %d", roomHeightManipulation).GetPtr(), false);
        logger.Log(cString::Format("hoodScanLineNumber: %d", hoodScanLineNumber).GetPtr(), false);
        logger.Log(cString::Format("roomScanLineNumber: %d", roomScanLineNumber).GetPtr(), false);
        logger.Log(cString::Format("processingWidthPercentage: %d", processingWidthPercentage).GetPtr(), false);
        logger.Log(cString::Format("maxHoodDetectionCount: %d", maxHoodDetectionCount).GetPtr(), false);
        logger.Log(cString::Format("rgbVideoManipulation: %d", rgbVideoManipulation).GetPtr(), false);
        logger.Log(cString::Format("depthVideoManipulation: %d", depthVideoManipulation).GetPtr(), false);
        logger.Log(cString::Format("isHoodDetectionEnabled: %d", isHoodDetectionEnabled).GetPtr(), false);
        logger.Log(cString::Format("isRoomDetectionEnabled: %d", isRoomDetectionEnabled).GetPtr(), false);
    }
    else if (eStage == StageGraphReady)
    {
        // init RGB Video
        cObjectPtr<IMediaType> rgbMediaType;
        RETURN_IF_FAILED(rgbVideoInputPin.GetMediaType(&rgbMediaType));

        cObjectPtr<IMediaTypeVideo> rgbVideoType;
        RETURN_IF_FAILED(rgbMediaType->GetInterface(IID_ADTF_MEDIA_TYPE_VIDEO, (tVoid **) &rgbVideoType));

        rgbVideoInputFormat = *(rgbVideoType->GetFormat());
        rgbVideoOutputFormat = *(rgbVideoType->GetFormat());
        rgbVideoOutputPin.SetFormat(&rgbVideoOutputFormat, NULL);

        // init Depth Video
        cObjectPtr<IMediaType> depthMediaType;
        RETURN_IF_FAILED(depthVideoInputPin.GetMediaType(&depthMediaType));

        cObjectPtr<IMediaTypeVideo> depthVideoType;
        RETURN_IF_FAILED(depthMediaType->GetInterface(IID_ADTF_MEDIA_TYPE_VIDEO, (tVoid **) &depthVideoType));

        depthVideoInputFormat = *(depthVideoType->GetFormat());
        depthVideoOutputFormat = *(depthVideoType->GetFormat());
        depthVideoOutputPin.SetFormat(&depthVideoOutputFormat, NULL);

        logger.Log(cString::Format("RGB Input format: %d x %d @ %d Bit", rgbVideoInputFormat.nWidth, rgbVideoInputFormat.nHeight,
                                   rgbVideoInputFormat.nBitsPerPixel).GetPtr(), false);
        logger.Log(cString::Format("RGB Output format: %d x %d @ %d Bit", rgbVideoOutputFormat.nWidth, rgbVideoOutputFormat.nHeight,
                                   rgbVideoOutputFormat.nBitsPerPixel).GetPtr(), false);

        logger.Log(cString::Format("Depth Input format: %d x %d @ %d Bit", depthVideoInputFormat.nWidth, depthVideoInputFormat.nHeight,
                                   depthVideoInputFormat.nBitsPerPixel).GetPtr(), false);
        logger.Log(cString::Format("Depth Output format: %d x %d @ %d Bit", depthVideoOutputFormat.nWidth, depthVideoOutputFormat.nHeight,
                                   depthVideoOutputFormat.nBitsPerPixel).GetPtr(), false);

        if (depthVideoOutputFormat.nBitsPerPixel != 8)
        {
            THROW_ERROR_DESC(depthVideoOutputFormat.nBitsPerPixel, "Wrong depth video format. Use HTWK_Grayscale in front of this filter.");
        }

        // init processing parameters
        processingData.processingWidth = depthVideoInputFormat.nWidth * (processingWidthPercentage / 100.0);
        processingData.startOffset = (depthVideoInputFormat.nWidth - processingData.processingWidth) / 2;
        processingData.hoodScanLineStepWidth = processingData.processingWidth / (hoodScanLineNumber - 1);
        processingData.roomScanLineStepWidth = processingData.processingWidth / (roomScanLineNumber - 1);

        logger.Log(cString::Format("hoodScanLineNumber: %d", hoodScanLineNumber).GetPtr(), false);
        logger.Log(cString::Format("processingWidthPercentage: %d", processingWidthPercentage).GetPtr(), false);
        logger.Log(cString::Format("processingWidth: %d", processingData.processingWidth).GetPtr(), false);
        logger.Log(cString::Format("startOffset: %d", processingData.startOffset).GetPtr(), false);
        logger.Log(cString::Format("hoodScanLineStepWidth: %d", processingData.hoodScanLineStepWidth).GetPtr(), false);
        logger.Log(cString::Format("roomScanLineStepWidth: %d", processingData.roomScanLineStepWidth).GetPtr(), false);
    }

    RETURN_NOERROR;
}
tResult StateControlManagementSlim::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cAsyncDataTriggeredFilter::Init(eStage, __exception_ptr));

    // pins need to be created at StageFirst
    if (eStage == StageFirst)    
    {
    	//LOG_WARNING("StateControlManagement: StageFirst;");

    	/* get Information regarding input and output pins for specific types */
    	RETURN_IF_FAILED(TActionStruct_object.StageFirst(__exception_ptr));
        RETURN_IF_FAILED(TFeedbackStruct_object.StageFirst(__exception_ptr));

    	// create and register the input pin
    	RETURN_IF_FAILED(CreateInputPins(__exception_ptr));
    	RETURN_IF_FAILED(CreateOutputPins(__exception_ptr));

        m_bDebugModeEnabled = GetPropertyBool("Debug Output to Console");
		#ifdef WRITE_DEBUG_OUTPUT_TO_FILE
		// creating logfile log file for SCM
        //LOG_WARNING("SCM: debug mode: 'logging' for scm-data enabled, writing to /opt/scm_log-'date-and-time'.log");
        time_t rawtime;
        struct tm * timeinfo;
        time(&rawtime);
        timeinfo = localtime(&rawtime);
//        cString fileDate = cString(asctime(timeinfo));
//        fileDate.Replace(" ", "_");
//        fileDate.Replace(":", "_");
//        cString logFilename = "/opt/scm_log_" + fileDate + ".log";
//        logFilename.Replace("\n", "");
//		  scm_logfile.open(logFilename, ios::out | ios::trunc);
//		  scm_logfile << "# SCM data log, recorded at: " << asctime(timeinfo) << std::endl;
		//scm_logfile.close();
        size_t N = 80;
        char dateAndTime[N];
        strftime(dateAndTime, N, "%Y_%m_%d-%H_%M_%S", timeinfo);

        cString dateAndTime_str = cString(dateAndTime);
        cString logFilename = "/opt/scm_log_" + cString(dateAndTime) + ".log";
        logFilename.Replace("\n", "");
        LOG_WARNING("SCM: debug mode: 'logging' for scm-data enabled, writing to '" + logFilename + "'.");
		scm_logfile.open(logFilename, ios::out | ios::trunc);
		scm_logfile << "# SCM data log, recorded at: " << asctime(timeinfo) << std::endl;
		#endif

        /* StateController Management*/
        i16CurrentScmManeuverID = -1;
        i16CurrentScmStepID = -1;
        i8CurrentActLvlMode = NOT_INITIALIZED;


    }
    else if (eStage == StageNormal)
    {
    	//LOG_WARNING("StateControlManagement: StageNormal;");
    	m_bPrintStrucModeEnabled = GetPropertyBool("Print Structure to Console");
        // load xml files for defining the structure of the StateController
        tResult scmLoadstate = LoadSCMStructureData();
        if(scmLoadstate < 0) {
        	LOG_ERROR(adtf_util::cString::Format("SCM: Structure could not be loaded!"));
        }
        THROW_IF_FAILED(scmLoadstate);
        if(m_bDebugModeEnabled && scmLoadstate == 0){
        	LOG_WARNING(adtf_util::cString::Format("SCM: Structure loaded successfully!"));
        }

        /* Initialization of SCM after successfully loading structure*/
        i16CurrentScmManeuverID = 0;
        i16CurrentScmStepID = 0;

        /* START StateControl Management in startup-state, wait for first PASSIVE request to start,
         *  e.g. verification of loaded maneuver list from JuryCommunication */
        i8CurrentActLvlMode = PASSIVE;

        if(m_bDebugModeEnabled) LOG_WARNING(adtf_util::cString::Format("SCM: initialized maneuverID, stepID and actLvlmode:Passive"));

    }
    else if(eStage == StageGraphReady)
    {
    	//LOG_WARNING("StateControlManagement: StageGraphReady;");

        // IDs for ActionStruct and FeedbackStruct are set
        RETURN_IF_FAILED(TActionStruct_object.StageGraphReady());
        RETURN_IF_FAILED(TFeedbackStruct_object.StageGraphReady());


        /* START StateControl Management in startup-state (maneuver 0, step 0) in passive mode, wait for response from JCom
         *  that maneuver list was successfully loaded */
        if(m_bDebugModeEnabled) LOG_WARNING(adtf_util::cString::Format("SCM: waiting for feedback from JCom regarding loaded maneuverlist."));
    }
    RETURN_NOERROR;
}
tResult cMarkerDetectFilter::Init(tInitStage eStage, __exception)
{
    RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr));
    if (eStage == StageFirst)
        {
        //create the video rgb input pin
        RETURN_IF_FAILED(m_oPinInputVideo.Create("Video_RGB_input",IPin::PD_Input, static_cast<IPinEventSink*>(this))); 
        RETURN_IF_FAILED(RegisterPin(&m_oPinInputVideo));

        //create the video rgb output pin
        RETURN_IF_FAILED(m_oPinOutputVideo.Create("Video_RGB_output", IPin::PD_Output, static_cast<IPinEventSink*>(this)));
        RETURN_IF_FAILED(RegisterPin(&m_oPinOutputVideo));

        // create the description manager
        cObjectPtr<IMediaDescriptionManager> pDescManager;
        RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER,IID_ADTF_MEDIA_DESCRIPTION_MANAGER, (tVoid**)&pDescManager,__exception_ptr));

		tChar const * strDescSignalLanacc_man = pDescManager->GetMediaDescription("tSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalLanacc_man);
		cObjectPtr<IMediaType> pTypeSignalmaneuver_lanacc = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalLanacc_man, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalmaneuver_lanacc->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&mediatype_Lan_Acc_Man));
		RETURN_IF_FAILED(Lan_Acc_Man.Create("Lan_Acc_Man", pTypeSignalmaneuver_lanacc, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&Lan_Acc_Man));

		tChar const * strDescSignalmaneuver_accspeed = pDescManager->GetMediaDescription("tSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalmaneuver_accspeed);
		cObjectPtr<IMediaType> pTypeSignalmaneuver_accspeed = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalmaneuver_accspeed, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalmaneuver_accspeed->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&mediatype_Lan_Acc_Speed));
		RETURN_IF_FAILED(Lan_Acc_Speed.Create("Lane_Speed", pTypeSignalmaneuver_accspeed, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&Lan_Acc_Speed));

		tChar const * strDescSignalmaneuver_idJury = pDescManager->GetMediaDescription("tSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalmaneuver_idJury);
		cObjectPtr<IMediaType> pTypeSignalmaneuver_idjury = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalmaneuver_idJury, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalmaneuver_idjury->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&mediatype_maneuverid_Jury));
		RETURN_IF_FAILED(maneuverid_Jury.Create("maneuverid_Jury", pTypeSignalmaneuver_idjury, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&maneuverid_Jury));

		tChar const * strDescSignalmaneuver_id = pDescManager->GetMediaDescription("tSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalmaneuver_id);
		cObjectPtr<IMediaType> pTypeSignalmaneuver_id = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalmaneuver_id, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalmaneuver_id->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&mediatype_maneuver_id));
		RETURN_IF_FAILED(maneuver_id.Create("Maneuver_ID", pTypeSignalmaneuver_id, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&maneuver_id));

		tChar const * strDescSignalmaneuver_finish = pDescManager->GetMediaDescription("tBoolSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalmaneuver_finish);
		cObjectPtr<IMediaType> pTypeSignalmaneuver_finish = new cMediaType(0, 0, 0, "tBoolSignalValue", strDescSignalmaneuver_finish, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalmaneuver_finish->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&mediatype_maneuver_finish));
		RETURN_IF_FAILED(maneuver_finish.Create("Maneuver_int_Finish", pTypeSignalmaneuver_finish, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&maneuver_finish));

        // create the description for the road sign pin
        tChar const * strDesc = pDescManager->GetMediaDescription("tRoadSign");   
        RETURN_IF_POINTER_NULL(strDesc);    
        cObjectPtr<IMediaType> pType = new cMediaType(0, 0, 0, "tRoadSign", strDesc, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        
        // create the road sign OutputPin
        RETURN_IF_FAILED(m_oPinRoadSign.Create("RoadSign", pType, this));
        RETURN_IF_FAILED(RegisterPin(&m_oPinRoadSign));
        // set the description for the road sign pin
        RETURN_IF_FAILED(pType->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescriptionRoadSign));
                
        // create the description for the road sign pin
        tChar const * strDescExt = pDescManager->GetMediaDescription("tRoadSignExt");   
        RETURN_IF_POINTER_NULL(strDescExt);    
        cObjectPtr<IMediaType> pTypeExt = new cMediaType(0, 0, 0, "tRoadSignExt", strDescExt, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
        
        // create the extended road sign OutputPin
        RETURN_IF_FAILED(m_oPinRoadSignExt.Create("RoadSign_ext", pTypeExt, this));
        RETURN_IF_FAILED(RegisterPin(&m_oPinRoadSignExt));
        // set the description for the extended road sign pin
        RETURN_IF_FAILED(pTypeExt->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pDescriptionRoadSignExt));
        }
    else if (eStage == StageNormal)
        {
            // get the propeerties
    		ReadProperties(NULL);
            m_iOutputMode = GetPropertyInt("Video Output Pin");
            m_f32MarkerSize = static_cast<tFloat32>(GetPropertyFloat("Size of Markers"));
            m_bDebugModeEnabled = GetPropertyBool("Debug Output to Console");
            imshowflag = GetPropertyBool(MD_ENABLE_IMSHOW);
            imshowflag_ver = GetPropertyBool(MD_ENABLE_IMSHOW_VER);
            m_bCamaraParamsLoaded = tFalse;
            //Get path of marker configuration file
            cFilename fileConfig = GetPropertyStr("Dictionary File For Markers");
            //create absolute path for marker configuration file
            ADTF_GET_CONFIG_FILENAME(fileConfig);
            fileConfig = fileConfig.CreateAbsolutePath(".");
            
            //check if marker configuration file exits
            if (fileConfig.IsEmpty() || !(cFileSystem::Exists(fileConfig)))
                {
                LOG_ERROR("Dictionary File for Markers not found");
                RETURN_ERROR(ERR_INVALID_FILE);
                }   
            else
                {
                //try to read the marker configuration file
                if(m_Dictionary.fromFile(string(fileConfig))==false)
                    {
                    RETURN_ERROR(ERR_INVALID_FILE);
                    LOG_ERROR("Dictionary File for Markers could not be read");
                    }
                if(m_Dictionary.size()==0)
                    {
                    RETURN_ERROR(ERR_INVALID_FILE);
                    LOG_ERROR("Dictionary File does not contain valid markers or could not be read sucessfully");
                    }
                //set marker configuration file to highlyreliable markers class
                if (!(HighlyReliableMarkers::loadDictionary(m_Dictionary)==tTrue))
                    {
                    //LOG_ERROR("Dictionary File could not be read for highly reliable markers"); 
                    }
                } 
    
            //Get path of calibration file with camera paramters
            cFilename fileCalibration = GetPropertyStr("Calibration File for used Camera"); ;
        
            //Get path of calibration file with camera paramters
            ADTF_GET_CONFIG_FILENAME(fileCalibration);
            fileCalibration = fileCalibration.CreateAbsolutePath(".");
            //check if calibration file with camera paramters exits
            if (fileCalibration.IsEmpty() || !(cFileSystem::Exists(fileCalibration)))
                {
                LOG_ERROR("Calibration File for camera not found");
                }   
            else
                {
                // read the calibration file with camera paramters exits and save to member variable
                m_TheCameraParameters.readFromXMLFile(fileCalibration.GetPtr());
                cv::FileStorage camera_data (fileCalibration.GetPtr(),cv::FileStorage::READ);
                camera_data ["camera_matrix"] >> m_Intrinsics; 
                camera_data ["distortion_coefficients"] >> m_Distorsion;    
                m_bCamaraParamsLoaded = tTrue;
                }   
        }
// -------------------------------------------------------------------------------------------------
tResult SensorPackageFilter::OnPinEvent(IPin* source, tInt event_code, tInt param1, tInt param2,
    IMediaSample* media_sample) {
// -------------------------------------------------------------------------------------------------
	RETURN_IF_POINTER_NULL(source);
	RETURN_IF_POINTER_NULL(media_sample);
	
	// Create a synchronizer, that enters the critical section whenever possible. If a previous
	// thread is still inside the critical section, all proceeding threads have to wait for the
	// first to leave.
	__synchronized_obj(critical_section_);
	
	if (event_code == IPinEventSink::PE_MediaSampleReceived) {
	  tFloat32 sensor_value = 0;
	  tUInt32 time_stamp = 0;

    {
      __adtf_sample_read_lock_mediadescription(sensor_data_description_, media_sample, coder);

      coder->Get("f32Value", (tVoid*) &sensor_value);
      coder->Get("ui32ArduinoTimestamp", (tVoid*) &time_stamp);              
    }
    
	  if (source == &ir_long_front_center_input_pin_) {
      ir_l_fc_.add(sensor_value);
      x_ &= 0b1111111111110;
	  }
	
	  else if (source == &ir_long_front_left_input_pin_) {
	    ir_l_fl_.add(sensor_value);
	    x_ &= 0b1111111111101;
	  }
	
	  else if (source == &ir_long_front_right_input_pin_) {
	    ir_l_fr_.add(sensor_value);
	    x_ &= 0b1111111111011;
	  }
	  
	  // IR Short sensors
	  else if (source == &ir_short_front_center_input_pin_) {
	    ir_s_fc_.add(sensor_value);
	    x_ &= 0b1111111110111;
	  }
	  
	  else if (source == &ir_short_front_left_input_pin_) {
	    ir_s_fl_.add(sensor_value);
	    x_ &= 0b1111111101111;
	  }
	  
	  else if (source == &ir_short_front_right_input_pin_) {
	    ir_s_fr_.add(sensor_value);
	    x_ &= 0b1111111011111;
	  }
	  
	  else if (source == &ir_short_left_input_pin_) {
	    ir_s_l_.add(sensor_value);
	    x_ &= 0b1111110111111;
	  }
	  
	  else if (source == &ir_short_right_input_pin_) {
	    ir_s_r_.add(sensor_value);
	    x_ &= 0b1111101111111;
	  }
	  
	  else if (source == &ir_short_rear_center_input_pin_) {
	    ir_s_rc_.add(sensor_value);
	    x_ &= 0b1111011111111;
	  }
	  
	  else if (source == &us_front_left_input_pin_) {
	    us_f_l_.add(sensor_value);
	    x_ &= 0b1110111111111;
	  }
	  
	  else if (source == &us_front_right_input_pin_) {
	    us_f_r_.add(sensor_value);
	    x_ &= 0b1101111111111;
	  }
	  
	  else if (source == &us_rear_left_input_pin_) {
	    us_r_l_.add(sensor_value);
	    x_ &= 0b1011111111111;
	  }
	  
	  else if (source == &us_rear_right_input_pin_) {
	    us_r_r_.add(sensor_value);
	    x_ &= 0b0111111111111;
	  }
	  
	  if (!x_) {
	    if (GetPropertyBool("debug")) LOG_INFO("Transmit sensor package");
	    transmitSensorPackage(time_stamp);
	    x_ = 0b1111111111111;
	  } else {
	  
	  }
	}
	
	RETURN_NOERROR;
}
예제 #13
0
void CLoginSession::CmdRegister (void)

//	CmdRegister
//
//	Handle register command

	{
	CUIHelper Helper(m_HI);

	//	Get the fields

	CString sUsername = GetPropertyString(ID_CTRL_USERNAME, PROP_TEXT);
	CString sPassword = GetPropertyString(ID_CTRL_PASSWORD, PROP_TEXT);
	CString sPasswordConfirm = GetPropertyString(ID_CTRL_PASSWORD_CONFIRM, PROP_TEXT);
	CString sEmail = GetPropertyString(ID_CTRL_EMAIL, PROP_TEXT);
	bool bAutoSignIn = GetPropertyBool(ID_CTRL_AUTO_SIGN_IN, PROP_CHECKED);

	//	Get the text for the username. If blank, then we have an error.

	if (sUsername.IsBlank())
		{
		Helper.CreateInputErrorMessage(this, m_rcInputError, CONSTLIT("Username Missing"), CONSTLIT("You must have a username to register."));
		return;
		}

	//	Make sure the passwords match

	else if (!strEquals(sPassword, sPasswordConfirm))
		{
		Helper.CreateInputErrorMessage(this, m_rcInputError, CONSTLIT("Password Does Not Match"), CONSTLIT("The password you entered does not match the confirmation password."));
		return;
		}

	//	Validate password complexity

	CString sError;
	if (!CHexarc::ValidatePasswordComplexity(sPassword, &sError))
		{
		Helper.CreateInputErrorMessage(this, m_rcInputError, CONSTLIT("Password Is Too Easy"), sError);
		return;
		}

	//	If email is blank, explain why we need it

	if (!m_bBlankEmailWarning && sEmail.IsBlank())
		{
		Helper.CreateInputErrorMessage(this, m_rcInputError, CONSTLIT("Email Address Is Optional, but..."), CONSTLIT("If you provide your email address we will be able to reset your password if you request it."));
		m_bBlankEmailWarning = true;
		return;
		}

	//	Register the name

	m_HI.AddBackgroundTask(new CRegisterUserTask(m_HI, m_Service, sUsername, sPassword, sEmail, bAutoSignIn), this, CMD_REGISTER_COMPLETE);

	//	Disable controls

	SetPropertyBool(ID_CTRL_USERNAME, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_PASSWORD, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_PASSWORD_CONFIRM, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_MAIN_ACTION, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_EMAIL, PROP_ENABLED, false);
	SetPropertyBool(ID_CTRL_AUTO_SIGN_IN, PROP_ENABLED, false);
	SetPropertyBool(CMD_SWITCH_TO_LOGIN, PROP_ENABLED, false);
	SetPropertyBool(CMD_TOS, PROP_ENABLED, false);
	}
예제 #14
0
tResult PIDController::ReadProperties(const tChar* strPropertyName)
{

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_KP))
    {
        m_f64PIDKp = GetPropertyFloat(WSC_PROP_PID_KP);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_KD))
    {
        m_f64PIDKd = GetPropertyFloat(WSC_PROP_PID_KD);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_KI))
    {
        m_f64PIDKi = GetPropertyFloat(WSC_PROP_PID_KI);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_SAMPLE_TIME))
    {
        m_f64PIDSampleTime = GetPropertyFloat(WSC_PROP_PID_SAMPLE_TIME);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PT1_OUTPUT_FACTOR))
    {
        m_f64PT1OutputFactor = GetPropertyFloat(WSC_PROP_PT1_OUTPUT_FACTOR);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PT1_GAIN))
    {
        m_f64PT1Gain = GetPropertyFloat(WSC_PROP_PT1_GAIN);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PT1_TIMECONSTANT))
    {
        m_f64PT1TimeConstant = GetPropertyFloat(WSC_PROP_PT1_TIMECONSTANT);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, "Controller Typ"))
    {
        m_i32ControllerMode = GetPropertyInt("Controller Typ");
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_DEBUG_MODE))
    {
        m_bShowDebug = static_cast<tBool>(GetPropertyBool(WSC_PROP_DEBUG_MODE));
        if(m_bShowDebug) {
        	LOG_INFO("PIDController: Debug mode is enabled");
        }
    }
    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PT1_CORRECTION_FACTOR))
    {
        m_f64PT1CorrectionFactor = GetPropertyFloat(WSC_PROP_PT1_CORRECTION_FACTOR);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_MINOUTPUT))
    {
        m_f64PIDMinimumOutput = GetPropertyFloat(WSC_PROP_PID_MINOUTPUT);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_MAXOUTPUT))
    {
        m_f64PIDMaximumOutput = GetPropertyFloat(WSC_PROP_PID_MAXOUTPUT);
    }

    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_WINDUP))
    {
        m_i32AntiWindupMethod = GetPropertyInt(WSC_PROP_PID_WINDUP);
    }
    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_SETZERO))
    {
    	m_bPID_Zero_Beh = GetPropertyBool(WSC_PROP_PID_SETZERO);
    }
    if (NULL == strPropertyName || cString::IsEqual(strPropertyName, WSC_PROP_PID_USEDIRINPUT))
    {
    	m_bUseSetSpeedDirInfo = GetPropertyBool(WSC_PROP_PID_USEDIRINPUT);
    }

    RETURN_NOERROR;
}