Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
e157b605
Commit
e157b605
authored
Sep 22, 2020
by
Tobias Meuser
Browse files
Merged tm/vehicular-services into master-integration
parents
8b80fdfa
0fbcbc65
Changes
140
Expand all
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/JamPropertyGenerator.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyImpactEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
JamPropertyGenerator
implements
RoadPropertyGenerator
{
@Override
public
RoadProperty
generateProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
double
travelTime
=
(
pEdge
.
getLength
()
/
pEdge
.
getMaxSpeed
());
double
newTravelTime
=
((
VehicularPropertyImpactEstimator
)
PropertyImpactEstimatorFactory
.
getPropertyBenefitEstimator
()).
calculateImpactIfKnown
(
JamProperty
.
class
)
+
travelTime
;
double
newSpeed
=
pEdge
.
getLength
()
/
newTravelTime
;
return
new
JamProperty
(
pLocation
,
pEdge
,
true
,
newSpeed
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getGenerateClass
()
{
return
JamProperty
.
class
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/RainPropertyGenerator.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RainProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
RainPropertyGenerator
implements
RoadPropertyGenerator
{
@Override
public
RoadProperty
generateProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
return
new
RainProperty
(
pLocation
,
pEdge
,
true
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getGenerateClass
()
{
return
RainProperty
.
class
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/RoadPropertyGenerator.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
interface
RoadPropertyGenerator
{
RoadProperty
generateProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
);
Class
<?
extends
RoadProperty
>
getGenerateClass
();
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/TrafficSignPropertyGenerator.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.TrafficSignProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
TrafficSignPropertyGenerator
implements
RoadPropertyGenerator
{
@Override
public
RoadProperty
generateProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
return
new
TrafficSignProperty
(
pLocation
,
pEdge
,
true
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getGenerateClass
()
{
return
TrafficSignProperty
.
class
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/DeterministicExponentialLifetimeDistribution.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator.lifetime
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
DeterministicExponentialLifetimeDistribution
implements
LifetimeDistribution
{
private
long
_averageEventDuration
;
private
double
_existProbability
;
private
double
_percentile
;
@XMLConfigurableConstructor
({
"duration"
,
"percentile"
})
public
DeterministicExponentialLifetimeDistribution
(
long
pEventDuration
,
double
pPercentile
)
{
_averageEventDuration
=
pEventDuration
;
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
Time
.
SECOND
);
_percentile
=
pPercentile
;
}
@XMLConfigurableConstructor
({
"duration"
})
public
DeterministicExponentialLifetimeDistribution
(
long
pEventDuration
)
{
_averageEventDuration
=
pEventDuration
;
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
Time
.
SECOND
);
_percentile
=
0.5
;
}
@Override
public
long
getLifetime
()
{
return
(
long
)
Math
.
ceil
(
Math
.
log
(
_percentile
)
/
Math
.
log
(
_existProbability
))
*
Time
.
SECOND
;
}
@Override
public
long
getAverageLifetime
()
{
return
_averageEventDuration
;
}
@Override
public
double
getProbabilityForLifetime
(
long
pLifetime
)
{
return
Math
.
pow
(
_existProbability
,
pLifetime
/
Time
.
SECOND
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/ExponentialLifetimeDistribution.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator.lifetime
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
ExponentialLifetimeDistribution
implements
LifetimeDistribution
{
private
Random
eventDurationRandom
=
Randoms
.
getRandom
(
getClass
());
private
long
_averageEventDuration
;
private
double
_existProbability
;
private
long
_granularity
=
10
*
Time
.
SECOND
;
@XMLConfigurableConstructor
({
"duration"
})
public
ExponentialLifetimeDistribution
(
long
pEventDuration
)
{
_averageEventDuration
=
pEventDuration
;
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
_granularity
);
}
@Override
public
long
getLifetime
()
{
double
random
=
eventDurationRandom
.
nextDouble
();
long
theoreticLifetime
=
(
long
)
Math
.
ceil
(
Math
.
log
(
random
)
/
Math
.
log
(
_existProbability
));
long
lifetime
=
Math
.
max
(
theoreticLifetime
*
_granularity
,
_granularity
*
2
);
System
.
out
.
println
(
"Random lifetime: "
+
random
+
" with duration: "
+
theoreticLifetime
*
_granularity
+
" (final: "
+
lifetime
+
")"
);
return
lifetime
;
}
@Override
public
long
getAverageLifetime
()
{
return
_averageEventDuration
;
}
@Override
public
double
getProbabilityForLifetime
(
long
pLifetime
)
{
return
Math
.
pow
(
_existProbability
,
pLifetime
/
_granularity
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/GaussianLifetimeDistribution.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator.lifetime
;
import
java.util.Random
;
import
org.apache.commons.math3.special.Erf
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
GaussianLifetimeDistribution
implements
LifetimeDistribution
{
private
Random
eventDurationRandom
=
Randoms
.
getRandom
(
getClass
());
private
static
long
_averageEventDuration
;
private
static
long
_standardDeviationEventDuration
;
@XMLConfigurableConstructor
({
"duration"
,
"duration_variance"
})
public
GaussianLifetimeDistribution
(
long
pEventDuration
,
long
pDeviation
)
{
_averageEventDuration
=
pEventDuration
;
_standardDeviationEventDuration
=
pDeviation
;
}
@Override
public
long
getLifetime
()
{
long
delay
=
(
long
)
((
eventDurationRandom
.
nextGaussian
()
*
_standardDeviationEventDuration
+
_averageEventDuration
)
/
Time
.
SECOND
)
*
Time
.
SECOND
;
return
delay
;
}
@Override
public
long
getAverageLifetime
()
{
return
_averageEventDuration
;
}
@Override
public
double
getProbabilityForLifetime
(
long
pLifetime
)
{
double
average
=
_averageEventDuration
/
(
double
)
Time
.
SECOND
;
double
standardDeviation
=
_standardDeviationEventDuration
/
(
double
)
Time
.
SECOND
;
double
age
=
pLifetime
/
(
double
)
Time
.
SECOND
;
double
parameter
=
(
average
-
age
)
/
(
Math
.
sqrt
(
2
)
*
standardDeviation
);
return
1
-
0.5
*
Erf
.
erfc
(
parameter
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/LifetimeDistribution.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator.lifetime
;
public
interface
LifetimeDistribution
{
long
getLifetime
();
long
getAverageLifetime
();
double
getProbabilityForLifetime
(
long
pLifetime
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/BumpEnvironmentSensorPlugin.java
0 → 100644
View file @
e157b605
/*
* Copyright (c) 2005-2018 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.BumpProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 26.03.2018
*
*/
public
class
BumpEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
BumpEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
public
BumpEnvironmentSensorPlugin
(
double
pAccuracy
)
{
setAccuracy
(
pAccuracy
);
}
@Override
public
void
setHost
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
_host
.
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
"SiS requried!"
,
e
);
}
}
try
{
RoadNetworkEdge
edge
=
_sis
.
get
().
localState
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
Location
location
=
_sis
.
get
().
localState
(
SiSTypes
.
PHY_LOCATION
,
SiSRequest
.
NONE
);
boolean
bump
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
BumpProperty
)
{
if
(((
BumpProperty
)
roadProperty
).
hasBump
())
{
bump
=
true
;
}
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
bump
=
!
bump
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
BumpProperty
(
location
,
edge
,
bump
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
BumpProperty
.
class
;
}
@Override
public
BumpEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
BumpEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/EnvironmentSensorPlugin.java
View file @
e157b605
...
...
@@ -24,7 +24,8 @@ package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
...
...
@@ -36,5 +37,7 @@ public interface EnvironmentSensorPlugin extends Cloneable {
EnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
;
Class
<?
extends
RoadProperty
>
getSupportedClass
();
void
setHost
(
Host
pHost
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/FogEnvironmentSensorPlugin.java
0 → 100644
View file @
e157b605
/*
* Copyright (c) 2005-2018 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.FogProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 27.03.2018
*
*/
public
class
FogEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
FogEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
public
FogEnvironmentSensorPlugin
(
double
pAccuracy
)
{
setAccuracy
(
pAccuracy
);
}
@Override
public
void
setHost
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
_host
.
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
"SiS requried!"
,
e
);
}
}
try
{
RoadNetworkEdge
edge
=
_sis
.
get
().
localState
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
Location
location
=
_sis
.
get
().
localState
(
SiSTypes
.
PHY_LOCATION
,
SiSRequest
.
NONE
);
boolean
fog
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
FogProperty
)
{
if
(((
FogProperty
)
roadProperty
).
hasFog
())
{
fog
=
true
;
}
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
fog
=
!
fog
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
FogProperty
(
location
,
edge
,
fog
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
FogProperty
.
class
;
}
@Override
public
FogEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
FogEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/HazardEnvironmentSensorPlugin.java
0 → 100644
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.HazardProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 27.03.2018
*
*/
public
class
HazardEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
HazardEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
public
HazardEnvironmentSensorPlugin
(
double
pAccuracy
)
{
setAccuracy
(
pAccuracy
);
}
@Override
public
void
setHost
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
_host
.
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
"SiS requried!"
,
e
);
}
}
try
{
RoadNetworkEdge
edge
=
_sis
.
get
().
localState
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
Location
location
=
_sis
.
get
().
localState
(
SiSTypes
.
PHY_LOCATION
,
SiSRequest
.
NONE
);
boolean
hazard
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
HazardProperty
)
{
if
(((
HazardProperty
)
roadProperty
).
hasHazard
())
{
hazard
=
true
;
}
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
hazard
=
!
hazard
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
HazardProperty
(
location
,
edge
,
hazard
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
HazardProperty
.
class
;
}
@Override
public
HazardEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
HazardEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/JamEnvironmentSensorPlugin.java
View file @
e157b605
...
...
@@ -22,15 +22,17 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
Road
Property
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
jam.Jam
Property
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
properties.
EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
properties.Jam
Property
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
properties.Road
Property
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
...
...
@@ -51,6 +53,8 @@ public class JamEnvironmentSensorPlugin implements EnvironmentSensorPlugin {
private
double
_accuracy
;
private
double
_range
=
200
;
private
static
Random
_random
=
Randoms
.
getRandom
(
JamEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
...
...
@@ -63,6 +67,10 @@ public class JamEnvironmentSensorPlugin implements EnvironmentSensorPlugin {
_host
=
pHost
;
}
public
void
setRange
(
double
pRange
)
{
_range
=
pRange
;
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_sis
==
null
)
{
...
...
@@ -74,31 +82,61 @@ public class JamEnvironmentSensorPlugin implements EnvironmentSensorPlugin {
}
try
{
List
<
RoadNetworkEdge
>
investigated
=
new
ArrayList
<>();
RoadNetworkEdge
edge
=
_sis
.
get
().
localState
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
investigated
.
add
(
edge
);
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Set
<
RoadNetworkEdge
>
toBeAdded
=
new
HashSet
<>();
for
(
RoadNetworkEdge
roadNetworkEdge
:
investigated
)
{
toBeAdded
.
add
(
roadNetworkEdge
);
toBeAdded
.
addAll
(
roadNetworkEdge
.
getAccessibleEdges
());
toBeAdded
.
addAll
(
roadNetworkEdge
.
getAccessibleEdges
());
}
investigated
=
new
ArrayList
<>(
toBeAdded
);
}
Location
location
=
_sis
.
get
().
localState
(
SiSTypes
.
PHY_LOCATION
,
SiSRequest
.
NONE
);
boolean
jammed
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
JamProperty
)
{
if
(((
JamProperty
)
roadProperty
).
isJammed
())
{
jammed
=
true
;
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
for
(
RoadNetworkEdge
roadNetworkEdge
:
investigated
)
{
boolean
jammed
=
false
;
Location
eventLocation
=
null
;
RoadNetworkEdge
eventEdge
=
null
;
for
(
RoadProperty
roadProperty
:
roadNetworkEdge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
JamProperty
)
{
if
(((
JamProperty
)
roadProperty
).
isJammed
())
{
jammed
=
true
;
}
eventLocation
=
roadProperty
.
getLocation
();
eventEdge
=
roadProperty
.
getEdge
();
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
jammed
=
!
jammed
;
}
if
(
eventLocation
!=
null
&&
location
.
distanceTo
(
eventLocation
)
<=
_range
)
{
EnvironmentProperty
property
=
new
JamProperty
(
eventLocation
,
eventEdge
,
jammed
);
properties
.
add
(
property
);
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
jammed
=
!
jammed
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
JamProperty
(
location
,
edge
,
jammed
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
JamProperty
.
class
;
}
@Override
public
JamEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
JamEnvironmentSensorPlugin
(
_accuracy
);
JamEnvironmentSensorPlugin
jamEnvironmentSensorPlugin
=
new
JamEnvironmentSensorPlugin
(
_accuracy
);
jamEnvironmentSensorPlugin
.
setRange
(
_range
);
return
jamEnvironmentSensorPlugin
;
}
public
void
setAccuracy
(
double
pAccuracy
)
{
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/MaliciousEnvironmentSensorPlugin.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
public
class
MaliciousEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
static
final
Random
RANDOM
=
Randoms
.
getRandom
(
MaliciousEnvironmentSensorPlugin
.
class
);
private
EnvironmentSensorPlugin
_goodPlugin
;
private
EnvironmentSensorPlugin
_badPlugin
;
private
boolean
_isMalicious
=
false
;
private
double
_probability
;
public
void
setMaliciousProbability
(
double
pProbability
)
{
_probability
=
pProbability
;
if
(
RANDOM
.
nextDouble
()
<
_probability
)
{
_isMalicious
=
true
;
}
else
{
_isMalicious
=
false
;
}
}
public
void
setGoodPlugin
(
EnvironmentSensorPlugin
pGoodPlugin
)
{
_goodPlugin
=
pGoodPlugin
;
if
(
_badPlugin
!=
null
&&
!
_badPlugin
.
getSupportedClass
().
equals
(
_goodPlugin
.
getSupportedClass
()))
{
throw
new
AssertionError
(
"Both plugins need to provide the same data entry."
);
}
}
public
void
setBadPlugin
(
EnvironmentSensorPlugin
pBadPlugin
)
{
_badPlugin
=
pBadPlugin
;
if
(
_goodPlugin
!=
null
&&
!
_badPlugin
.
getSupportedClass
().
equals
(
_goodPlugin
.
getSupportedClass
()))
{
throw
new
AssertionError
(
"Both plugins need to provide the same data entry."
);
}
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_isMalicious
)
{
return
_badPlugin
.
getEnvironmentProperties
();
}
else
{
return
_goodPlugin
.
getEnvironmentProperties
();
}
}
@Override
public
EnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
MaliciousEnvironmentSensorPlugin
maliciousEnvironmentSensorPlugin
=
new
MaliciousEnvironmentSensorPlugin
();
maliciousEnvironmentSensorPlugin
.
setGoodPlugin
(
_goodPlugin
.
clone
());
maliciousEnvironmentSensorPlugin
.
setBadPlugin
(
_badPlugin
.
clone
());
maliciousEnvironmentSensorPlugin
.
setMaliciousProbability
(
_probability
);
return
maliciousEnvironmentSensorPlugin
;
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
_goodPlugin
.
getSupportedClass
();
}
@Override
public
void
setHost
(
Host
pHost
)
{
_goodPlugin
.
setHost
(
pHost
);
_badPlugin
.
setHost
(
pHost
);
}
public
boolean
isMalicious
()
{
return
_isMalicious
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/MaliciousVectoralJamEnvironmentSensorPlugin.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.plugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ProbabilityDistribution
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.measurement.MeasurementDistributionTypeContainer
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.vectoral.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 27.02.2018
*
*/
public
class
MaliciousVectoralJamEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
final
double
_originalAccuracy
;
private
final
double
_maxDeviation
;
private
double
_valueOffset
;
private
double
_communicatedAccuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
MaliciousVectoralJamEnvironmentSensorPlugin
.
class
);
private
static
Random
_accuracyRandom
=
Randoms
.
getRandom
(
MaliciousVectoralJamEnvironmentSensorPlugin
.
class
+
"Accuracy"
);
@XMLConfigurableConstructor
({
"accuracy"
,
"dist_type"
,
"max_deviation"
,
"value_offset"
,
"communicated_accuracy"
})
public
MaliciousVectoralJamEnvironmentSensorPlugin
(
double
pAccuracy
,
String
pDist
,
double
pMaxDeviation
,
double
pValueOffset
,
double
pCommunicatedAccuracy
)
{
_originalAccuracy
=
pAccuracy
;
_maxDeviation
=
pMaxDeviation
;
double
deviation
=
pMaxDeviation
*
pAccuracy
;
int
upperBound
=
1
;
double
lowerBound
=
0.4
;
if
(
deviation
+
pAccuracy
>
upperBound
)
{
deviation
=
upperBound
-
pAccuracy
;
}
if
(
pAccuracy
-
deviation
<
lowerBound
)
{
deviation
=
pAccuracy
-
lowerBound
;
}
double
accuracy
=
pAccuracy
+
_accuracyRandom
.
nextGaussian
()
*
deviation
;
if
(
accuracy
<
pAccuracy
-
deviation
)
{
accuracy
=
pAccuracy
-
deviation
;
}
if
(
accuracy
>
pAccuracy
+
deviation
)
{
accuracy
=
pAccuracy
+
deviation
;
}
setAccuracy
(
accuracy
);
_valueOffset
=
pValueOffset
;
_communicatedAccuracy
=
pCommunicatedAccuracy
;
MeasurementDistributionTypeContainer
.
setDistribution
(
VectoralJamProperty
.
class
,
ProbabilityDistribution
.
valueOf
(
pDist
));
}
@Override
public
void
setHost
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
List
<
EnvironmentProperty
>
getEnvironmentProperties
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
_host
.
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
"SiS requried!"
,
e
);
}
}
try
{
RoadNetworkEdge
edge
=
_sis
.
get
().
localState
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
Location
location
=
_sis
.
get
().
localState
(
SiSTypes
.
PHY_LOCATION
,
SiSRequest
.
NONE
);
double
speed
=
-
1
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
JamProperty
)
{
speed
=
((
JamProperty
)
roadProperty
).
getAverageSpeed
();
}
}
if
(
speed
==
-
1
)
{
speed
=
edge
.
getOriginalMaxSpeed
();
}
double
measuredSpeed
=
measureValue
(
speed
);
if
(
_valueOffset
!=
0
)
{
measuredSpeed
+=
_valueOffset
;
}
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
location
,
edge
);
if
(
_communicatedAccuracy
==
0
)
{
vectoralJamProperty
.
setSpeed
(
measuredSpeed
,
_accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
));
}
else
{
vectoralJamProperty
.
setSpeed
(
measuredSpeed
,
_communicatedAccuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
));
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
vectoralJamProperty
;
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
public
double
measureValue
(
double
pRealSpeed
)
{
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
null
,
null
);
vectoralJamProperty
.
setSpeed
(
pRealSpeed
,
_accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
));
double
nextDouble
=
_random
.
nextDouble
();
double
currentAggregate
=
0
;
for
(
int
i
=
0
;
i
<
vectoralJamProperty
.
getValueProbabilities
().
length
;
i
++)
{
currentAggregate
+=
vectoralJamProperty
.
getValueProbabilities
()[
i
];
if
(
currentAggregate
>
nextDouble
)
{
return
vectoralJamProperty
.
getValueAtIndex
(
i
);
}
}
throw
new
AssertionError
(
"Unexpected!"
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
JamProperty
.
class
;
}
@Override
public
MaliciousVectoralJamEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
MaliciousVectoralJamEnvironmentSensorPlugin
(
_originalAccuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
).
toString
(),
_maxDeviation
,
_valueOffset
,
_communicatedAccuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/RainEnvironmentSensorPlugin.java
0 → 100644
View file @
e157b605
This diff is collapsed.
Click to expand it.
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/TrafficSignEnvironmentSensorPlugin.java
0 → 100644
View file @
e157b605
This diff is collapsed.
Click to expand it.
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/VectoralJamEnvironmentSensorPlugin.java
View file @
e157b605
...
...
@@ -28,12 +28,12 @@ import java.util.Random;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ProbabilityDistribution
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.measurement.MeasurementDistributionTypeContainer
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.vectoral.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
...
...
@@ -112,9 +112,7 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
double
speed
=
-
1
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
JamProperty
)
{
if
(((
JamProperty
)
roadProperty
).
isJammed
())
{
speed
=
((
JamProperty
)
roadProperty
).
getAverageSpeed
();
}
speed
=
((
JamProperty
)
roadProperty
).
getAverageSpeed
();
}
}
...
...
@@ -129,13 +127,15 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
vectoralJamProperty
.
setSpeed
(
measuredSpeed
,
_accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
));
if
(
edge
.
getEdgeID
().
equals
(
"A5.9"
))
{
for
(
int
i
=
0
;
i
<
vectoralJamProperty
.
getValueProbabilities
().
length
;
i
++)
{
if
(
vectoralJamProperty
.
getValueProbabilities
()[
i
]
>
0.99
)
{
System
.
out
.
println
(
speed
+
" --> "
+
vectoralJamProperty
.
getMostProbableValue
());
}
}
}
// if (edge.getEdgeID().equals("A5.9")) {
// for (int i = 0; i < vectoralJamProperty.getValueProbabilities().length; i++)
// {
// if (vectoralJamProperty.getValueProbabilities()[i] > 0.99) {
// System.out.println(speed + " --> " +
// vectoralJamProperty.getMostProbableValue());
// }
// }
// }
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
vectoralJamProperty
;
...
...
@@ -164,6 +164,11 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
throw
new
AssertionError
(
"Unexpected!"
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
JamProperty
.
class
;
}
@Override
public
VectoralJamEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
VectoralJamEnvironmentSensorPlugin
(
_originalAccuracy
,
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/VectoralRoadConditionEnvironmentSensorPlugin.java
View file @
e157b605
...
...
@@ -28,11 +28,12 @@ import java.util.Random;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ProbabilityDistribution
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.vectoral.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.roadcondition.RoadConditionProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
...
...
@@ -141,6 +142,11 @@ public class VectoralRoadConditionEnvironmentSensorPlugin implements Environment
throw
new
AssertionError
(
"Unexpected!"
);
}
@Override
public
Class
<?
extends
RoadProperty
>
getSupportedClass
()
{
return
RoadConditionProperty
.
class
;
}
@Override
public
VectoralRoadConditionEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
VectoralRoadConditionEnvironmentSensorPlugin
(
_accuracy
);
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sis/type/SiSTypes.java
View file @
e157b605
...
...
@@ -70,6 +70,11 @@ public final class SiSTypes {
*/
public
static
final
SiSType
<
Double
>
HEADING
=
create
(
"HEADING"
,
Double
.
class
,
null
);
/**
* [m] Length of the vehicle
*/
public
static
final
SiSType
<
Double
>
VEHICLE_LENGTH
=
create
(
"VEHICLE_LENGTH"
,
Double
.
class
,
null
);
/**
* PHY-Location - x (deprecated)
*/
...
...
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment