Commit f9b2f9e9 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Adapt audibility filter classes to new config style

parent cff341a6
......@@ -46,18 +46,6 @@ namespace ITA
///
struct ITA_SIMULATION_SCHEDULER_API AudibilityFilterConfig : public VistaPropertyList
{
///
/// \brief Available properties of the IAudibilityFilter.
///
/// This struct primarily maps a variable to the string that is the key to the property.
/// \remark The format of the properties is the following: {property function}_{type of property}
///
struct ITA_SIMULATION_SCHEDULER_API Properties
{
static const std::string getConditionFilterKey_Section ( ); ///< Section containing all condition filter configs.
static const std::string getConditionFilterOrderKey_Section ( ); ///< Section containing the order of the condition filters.
};
///
/// \brief Set the condition filter config of the AudibilityFilterConfig.
///
......
......@@ -35,12 +35,9 @@ namespace ITA
///
struct ITA_SIMULATION_SCHEDULER_API RateFilterConfig : public IAudibilityFilter::AudibilityFilterConfig
{
static const std::string getRateFilterConfigName ( ); ///< Section name of the RateFilterConfig.
void setRate ( double dRate );
struct ITA_SIMULATION_SCHEDULER_API Properties
{
static const std::string getRateKey_double ( ); ///< Desired rate for the filter in Hertz.
};
double getRate ( ) const;
///
/// \brief Returns the default Configuration for a CRateFilter.
......
......@@ -36,8 +36,6 @@ namespace ITA
///
struct ITA_SIMULATION_SCHEDULER_API ZoneConditionConfig : FilterConditionConfig
{
static const std::string getZoneFilterConfigName ( ); ///< Section name of the ZoneFilterConfig.
///
/// \brief Set the zones for the config.
///
......
......@@ -2,6 +2,7 @@
// simulation scheduler includes
#include <ITA/simulation_scheduler/update_scene.h>
#include "../configuration_keys.h"
#include "ITAException.h"
......@@ -17,17 +18,6 @@ namespace ITA
{
};
const std::string IAudibilityFilter::AudibilityFilterConfig::Properties::getConditionFilterKey_Section ( )
{
return "ConditionFilter";
}
const std::string IAudibilityFilter::AudibilityFilterConfig::Properties::
getConditionFilterOrderKey_Section ( )
{
return "ConditionFilterOrder";
}
void IAudibilityFilter::AudibilityFilterConfig::setConditionFilterConfig (
const std::vector<IFilterCondition::FilterConditionConfig>& vFilterConfig )
{
......@@ -49,7 +39,7 @@ namespace ITA
if ( filterConfig.size ( ) == 1 &&
filterConfig.begin ( )->second.GetPropertyType ( ) == VistaProperty::ePropType::PROPT_PROPERTYLIST )
{
audibilityFilterConfig.SetValueInSubList ( std::to_string ( counter ), Properties::getConditionFilterOrderKey_Section ( ), filterConfig.begin ( )->first );
audibilityFilterConfig.SetValueInSubList ( std::to_string ( counter ), conditionFilterOrderSectionName, filterConfig.begin ( )->first );
config.MergeWith ( filterConfig );
}
else
......@@ -58,7 +48,7 @@ namespace ITA
counter++;
}
audibilityFilterConfig.SetPropertyListValue ( Properties::getConditionFilterKey_Section ( ), config );
audibilityFilterConfig.SetPropertyListValue ( conditionFilterSectionName, config );
}
else
ITA_EXCEPT_INVALID_PARAMETER ( "Config is not a compatible audibility filter config." );
......@@ -71,11 +61,11 @@ namespace ITA
{
const auto audibilityFilterConfig = GetSubListConstRef ( begin ( )->first );
if ( audibilityFilterConfig.HasSubList ( Properties::getConditionFilterKey_Section ( ) ) && audibilityFilterConfig.HasSubList ( Properties::getConditionFilterOrderKey_Section ( ) ) )
if ( audibilityFilterConfig.HasSubList ( conditionFilterSectionName ) && audibilityFilterConfig.HasSubList ( conditionFilterOrderSectionName ) )
{
const auto filterConfigs = audibilityFilterConfig.GetSubListConstRef ( Properties::getConditionFilterKey_Section ( ) );
const auto filterConfigs = audibilityFilterConfig.GetSubListConstRef ( conditionFilterSectionName );
const auto filterOrder = audibilityFilterConfig.GetSubListConstRef ( Properties::getConditionFilterOrderKey_Section ( ) );
const auto filterOrder = audibilityFilterConfig.GetSubListConstRef ( conditionFilterOrderSectionName );
std::vector<IFilterCondition::FilterConditionConfig> configs;
......
......@@ -2,6 +2,7 @@
// simulation scheduler includes
#include <ITA/simulation_scheduler/update_scene.h>
#include "../configuration_keys.h"
// ITA includes
#include <ITAException.h>
......@@ -12,29 +13,29 @@ namespace ITA
{
namespace audibility_filter
{
const std::string CRateFilter::RateFilterConfig::getRateFilterConfigName ( )
void CRateFilter::RateFilterConfig::setRate(double dRate)
{
return "RateFilter";
SetValueInSubList ( rateFilterRateKey, rateFilterConfigSectionName, dRate );
}
CRateFilter::RateFilterConfig CRateFilter::RateFilterConfig::getDefaultRateFilterConfig ( )
double CRateFilter::RateFilterConfig::getRate() const
{
auto oConfig = RateFilterConfig ( );
oConfig.SetValueInSubList ( Properties::getRateKey_double ( ), getRateFilterConfigName ( ), 1.0 );
return oConfig;
return GetValueInSubList <double> ( rateFilterRateKey, rateFilterConfigSectionName );
}
const std::string CRateFilter::RateFilterConfig::Properties::getRateKey_double ( )
CRateFilter::RateFilterConfig CRateFilter::RateFilterConfig::getDefaultRateFilterConfig ( )
{
return "@Rate";
auto oConfig = RateFilterConfig ( );
oConfig.SetValueInSubList ( rateFilterRateKey, rateFilterConfigSectionName, 1.0 );
return oConfig;
}
CRateFilter::CRateFilter ( const RateFilterConfig& oConfig ) : IAudibilityFilter(oConfig)
{
if ( !oConfig.HasSubList ( RateFilterConfig::getRateFilterConfigName ( ) ) )
if ( !oConfig.HasSubList ( rateFilterConfigSectionName ) )
ITA_EXCEPT_INVALID_PARAMETER ( "Config is not a valid rate filter config." );
m_dRate = oConfig.GetValueInSubListOrDefault ( RateFilterConfig::Properties::getRateKey_double ( ), RateFilterConfig::getRateFilterConfigName ( ), 1.0 );
m_dRate = oConfig.GetValueInSubListOrDefault ( rateFilterRateKey, rateFilterConfigSectionName, 1.0 );
}
bool CRateFilter::changeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate )
......
......@@ -2,6 +2,7 @@
// simulation scheduler includes
#include <ITA/simulation_scheduler/update_scene.h>
#include "../configuration_keys.h"
// ITA includes
#include <ITAException.h>
......@@ -12,28 +13,24 @@ namespace ITA
{
namespace audibility_filter
{
const std::string CZoneCondition::ZoneConditionConfig::getZoneFilterConfigName ( )
{
return "ZoneFilter";
}
void CZoneCondition::ZoneConditionConfig::setZones ( const std::vector<std::pair<VistaVector3D, VistaVector3D>>& vpZones )
{
auto counter = 0;
for ( const auto& zone : vpZones )
{
SetValueInSubList ( "Zone" + std::to_string ( counter ) + "first", getZoneFilterConfigName ( ), zone.first );
SetValueInSubList ( "Zone" + std::to_string ( counter ) + "second", getZoneFilterConfigName ( ), zone.second );
SetValueInSubList ( "Zone" + std::to_string ( counter ) + "first", zoneConditionConfigSectionName, zone.first );
SetValueInSubList ( "Zone" + std::to_string ( counter ) + "second", zoneConditionConfigSectionName, zone.second );
counter++;
}
}
std::vector<std::pair<VistaVector3D, VistaVector3D>> CZoneCondition::ZoneConditionConfig::getZones ( ) const
{
if ( HasSubList ( getZoneFilterConfigName ( ) ) )
if ( HasSubList ( zoneConditionConfigSectionName ) )
{
std::vector<std::pair<VistaVector3D, VistaVector3D>> vpZones;
const auto zones = GetSubListConstRef ( getZoneFilterConfigName ( ) );
const auto zones = GetSubListConstRef ( zoneConditionConfigSectionName );
for ( auto i = 0; i < zones.size ( ) / 2; ++i )
{
std::pair<VistaVector3D, VistaVector3D> zone;
......
......@@ -35,6 +35,19 @@ namespace ITA
const std::string workerFieldOfDuty = "@FieldOfDuty";
}
namespace audibility_filter
{
const std::string zoneConditionConfigSectionName = "ZoneFilter";
const std::string conditionFilterSectionName = "ConditionFilter";
const std::string conditionFilterOrderSectionName = "ConditionFilterOrder";
const std::string rateFilterConfigSectionName = "RateFilter";
const std::string rateFilterRateKey = "@Rate";
}
} // namespace simulation_scheduler
} // namespace ITA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment