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
a1226c51
Commit
a1226c51
authored
Apr 30, 2018
by
Tobias Meuser
Browse files
First really working version for adhoc
parent
323dda39
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/
vector/
TemporalDependencyMatrix.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/TemporalDependencyMatrix.java
View file @
a1226c51
...
...
@@ -19,7 +19,7 @@
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
.vector
;
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
;
import
java.util.Arrays
;
import
java.util.HashMap
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/VectoralProperty.java
View file @
a1226c51
...
...
@@ -22,9 +22,10 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.vector.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
...
...
@@ -36,6 +37,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
public
abstract
class
VectoralProperty
implements
RoadProperty
,
Cloneable
{
private
static
final
boolean
TRIM_PROBABILITIES
=
false
;
private
static
final
double
MINIMAL_PROBABILITY
=
0.0001
;
private
static
Map
<
DeviationIdentifier
,
Double
>
_requiredStandardDeviation
=
new
HashMap
<>();
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
...
...
@@ -77,7 +79,17 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
}
}
else
{
Arrays
.
fill
(
_valueProbabilities
,
0
);
_valueProbabilities
[(
int
)
pMean
]
=
1
;
_valueProbabilities
[(
int
)
Math
.
round
(
pMean
)]
=
1
;
// int lowerMean = (int) Math.floor(pMean);
// int higherMean = (int) Math.ceil(pMean);
// double difference = pMean - lowerMean;
//
// _valueProbabilities[lowerMean] = 1 - difference;
//
// if (lowerMean != higherMean) {
// _valueProbabilities[higherMean] = difference;
// }
}
}
...
...
@@ -131,6 +143,8 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
return
getValueAtIndex
(
getMostProbableIndex
());
}
public
abstract
int
getIndexForValue
(
Object
pValue
);
public
abstract
TemporalDependencyMatrix
getDependencyMatrix
();
@Override
...
...
@@ -201,4 +215,124 @@ public abstract class VectoralProperty implements RoadProperty, Cloneable {
return
result
;
}
public
void
set
(
int
pIndex
,
double
pAccuracy
,
ProbabilityDistribution
pDist
)
{
switch
(
pDist
)
{
case
SIMPLE:
setSimple
(
pIndex
,
pAccuracy
);
break
;
case
GAUSSIAN:
setGaussianWithAccuracy
(
pIndex
,
pAccuracy
);
break
;
default
:
throw
new
AssertionError
(
"Unknown ProbablilityDistribution "
+
pDist
);
}
}
public
void
setSimple
(
int
pIndex
,
double
pAccuracy
)
{
double
[]
valueProbabilities
=
getValueProbabilities
();
Arrays
.
fill
(
valueProbabilities
,
0
);
int
index
=
(
int
)
(
pIndex
);
valueProbabilities
[
index
]
+=
pAccuracy
;
int
distance
=
1
;
if
(
index
+
distance
<
valueProbabilities
.
length
)
{
valueProbabilities
[
index
+
distance
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
else
{
valueProbabilities
[
index
-
distance
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
if
(
index
-
1
>=
1
)
{
valueProbabilities
[
index
-
distance
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
else
{
valueProbabilities
[
index
+
distance
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
}
public
void
setGaussianWithAccuracy
(
double
pValue
,
double
pAccuracy
)
{
double
deviation
=
determineCorrectDeviation
((
int
)
pValue
,
pAccuracy
);
setGaussianProbabilities
(
pValue
,
deviation
);
}
public
void
setGaussian
(
double
pIndex
,
double
pDeviation
)
{
setGaussianProbabilities
(
pIndex
,
pDeviation
);
}
public
double
determineCorrectDeviation
(
int
pIndex
,
double
pAccuracy
)
{
DeviationIdentifier
identifier
=
new
DeviationIdentifier
(
getClass
(),
pIndex
,
pAccuracy
);
if
(!
_requiredStandardDeviation
.
containsKey
(
identifier
))
{
if
(
pAccuracy
<
1
)
{
VectoralProperty
vectoralProperty
=
clone
();
double
deviation
=
10
;
boolean
reduceChange
=
false
;
double
currentChange
=
deviation
/
2
;
do
{
vectoralProperty
.
setGaussian
(
pIndex
,
deviation
);
if
(
vectoralProperty
.
getProbabilityForIndex
((
int
)
pIndex
)
>
pAccuracy
)
{
deviation
+=
currentChange
;
}
else
{
deviation
-=
currentChange
;
reduceChange
=
true
;
}
if
(
reduceChange
)
{
currentChange
/=
2.0
;
}
}
while
(
Math
.
round
(
vectoralProperty
.
getProbabilityForIndex
(
pIndex
)
*
10000
)
!=
Math
.
round
(
pAccuracy
*
10000
));
_requiredStandardDeviation
.
put
(
identifier
,
deviation
);
}
else
{
_requiredStandardDeviation
.
put
(
identifier
,
0
d
);
}
}
return
_requiredStandardDeviation
.
get
(
identifier
);
}
public
abstract
int
getDefaultIndex
();
private
class
DeviationIdentifier
{
private
Class
<?
extends
VectoralProperty
>
_propertyClass
;
private
int
_index
;
private
double
_accuracy
;
public
DeviationIdentifier
(
Class
<?
extends
VectoralProperty
>
pPropertyClass
,
int
pIndex
,
double
pAccuracy
)
{
_propertyClass
=
pPropertyClass
;
_index
=
pIndex
;
_accuracy
=
pAccuracy
;
}
public
Class
<?
extends
VectoralProperty
>
getPropertyClass
()
{
return
_propertyClass
;
}
public
int
getIndex
()
{
return
_index
;
}
public
double
getAccuracy
()
{
return
_accuracy
;
}
@Override
public
int
hashCode
()
{
return
_index
*
Double
.
hashCode
(
_accuracy
);
}
@Override
public
boolean
equals
(
Object
pObj
)
{
if
(
pObj
instanceof
DeviationIdentifier
)
{
DeviationIdentifier
identifier
=
(
DeviationIdentifier
)
pObj
;
return
_propertyClass
.
equals
(
identifier
.
getPropertyClass
())
&&
_index
==
identifier
.
getIndex
()
&&
_accuracy
==
identifier
.
getAccuracy
();
}
return
super
.
equals
(
pObj
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/JamInformationContainer.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/
jam/
JamInformationContainer.java
View file @
a1226c51
...
...
@@ -19,7 +19,7 @@
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
;
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
.jam
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/JamProperty.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/
jam/
JamProperty.java
View file @
a1226c51
...
...
@@ -19,9 +19,11 @@
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
;
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
.jam
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
...
...
@@ -57,6 +59,10 @@ public class JamProperty implements RoadProperty {
_averageSpeed
=
pAverageSpeed
;
}
public
void
resetDetectionDate
()
{
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/VectoralJamProperty.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/
jam/
VectoralJamProperty.java
View file @
a1226c51
...
...
@@ -19,14 +19,15 @@
*/
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
;
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data
.jam
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.vector.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.NumericVectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ProbabilityDistribution
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
...
...
@@ -37,9 +38,10 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
*/
public
class
VectoralJamProperty
extends
NumericVectoralProperty
{
public
static
final
double
SCALING
=
6
;
private
static
final
int
DIMENSIONS
=
1
0
;
private
static
final
int
DIMENSIONS
=
1
5
;
private
static
Map
<
Double
,
Double
>
_requiredStandardDeviation
=
new
HashMap
<>();
// private static Map<Double, Double> _requiredStandardDeviation = new
// HashMap<>();
private
static
TemporalDependencyMatrix
_temporalDependencyMatrix
;
public
VectoralJamProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
...
...
@@ -62,43 +64,46 @@ public class VectoralJamProperty extends NumericVectoralProperty {
public
void
setSpeed
(
double
pSpeed
,
double
pAccuracy
,
ProbabilityDistribution
pDist
)
{
switch
(
pDist
)
{
case
SIMPLE:
setSimpleSpeed
(
pSpeed
,
pAccuracy
);
break
;
throw
new
AssertionError
(
"Currently not to be used!"
);
// setSimple((int) (pSpeed / VectoralJamProperty.SCALING),
// pAccuracy);
// break;
case
GAUSSIAN:
setGaussian
Speed
WithAccuracy
(
pSpeed
,
pAccuracy
);
setGaussianWithAccuracy
(
pSpeed
/
VectoralJamProperty
.
SCALING
,
pAccuracy
);
break
;
default
:
throw
new
AssertionError
(
"Unknown ProbablilityDistribution "
+
pDist
);
}
}
private
void
setSimpleSpeed
(
double
pSpeed
,
double
pAccuracy
)
{
double
[]
valueProbabilities
=
getValueProbabilities
();
Arrays
.
fill
(
valueProbabilities
,
0
);
int
index
=
(
int
)
(
pSpeed
/
SCALING
);
valueProbabilities
[
index
]
+=
pAccuracy
;
if
(
index
+
1
<
valueProbabilities
.
length
)
{
valueProbabilities
[
index
+
1
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
else
{
valueProbabilities
[
index
-
1
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
if
(
index
-
1
>=
1
)
{
valueProbabilities
[
index
-
1
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
else
{
valueProbabilities
[
index
+
1
]
+=
(
1
-
pAccuracy
)
/
2.0
;
}
}
public
void
setGaussianSpeedWithAccuracy
(
double
pSpeed
,
double
pAccuracy
)
{
double
deviation
=
determineCorrectDeviation
(
pSpeed
,
pAccuracy
);
setGaussianProbabilities
(
pSpeed
/
SCALING
,
deviation
/
SCALING
);
}
public
void
setGaussianSpeed
(
double
pSpeed
,
double
pDeviation
)
{
setGaussianProbabilities
(
pSpeed
/
SCALING
,
pDeviation
/
SCALING
);
}
// private void setSimpleSpeed(double pSpeed, double pAccuracy) {
// double[] valueProbabilities = getValueProbabilities();
// Arrays.fill(valueProbabilities, 0);
// int index = (int) (pSpeed / SCALING);
// valueProbabilities[index] += pAccuracy;
//
// if (index + 1 < valueProbabilities.length) {
// valueProbabilities[index + 1] += (1 - pAccuracy) / 2.0;
// } else {
// valueProbabilities[index - 1] += (1 - pAccuracy) / 2.0;
// }
//
// if (index - 1 >= 1) {
// valueProbabilities[index - 1] += (1 - pAccuracy) / 2.0;
// } else {
// valueProbabilities[index + 1] += (1 - pAccuracy) / 2.0;
// }
// }
//
// public void setGaussianSpeedWithAccuracy(double pSpeed, double pAccuracy)
// {
// double deviation = determineCorrectDeviation(pSpeed, pAccuracy);
// setGaussianProbabilities(pSpeed / SCALING, deviation / SCALING);
// }
//
// public void setGaussianSpeed(double pSpeed, double pDeviation) {
// setGaussianProbabilities(pSpeed / SCALING, pDeviation / SCALING);
// }
@Override
public
VectoralJamProperty
clone
()
{
...
...
@@ -123,6 +128,14 @@ public class VectoralJamProperty extends NumericVectoralProperty {
return
pIndex
*
SCALING
;
}
@Override
public
int
getIndexForValue
(
Object
pValue
)
{
if
(
pValue
instanceof
Number
)
{
return
(
int
)
(((
Number
)
pValue
).
doubleValue
()
*
SCALING
);
}
throw
new
AssertionError
(
"Unknown value!"
);
}
@Override
public
TemporalDependencyMatrix
getDependencyMatrix
()
{
if
(
_temporalDependencyMatrix
==
null
)
{
...
...
@@ -168,8 +181,8 @@ public class VectoralJamProperty extends NumericVectoralProperty {
double
speed
=
getExpectation
();
if
(
speed
<
(((
int
)
(
originalMaxSpeed
/
VectoralJamProperty
.
SCALING
))
*
VectoralJamProperty
.
SCALING
)
*
0.375
)
{
if
(
speed
<
(((
int
)
(
originalMaxSpeed
*
0.375
/
VectoralJamProperty
.
SCALING
)
)
*
VectoralJamProperty
.
SCALING
)
)
{
return
true
;
}
}
...
...
@@ -195,37 +208,44 @@ public class VectoralJamProperty extends NumericVectoralProperty {
return
super
.
equals
(
pObj
);
}
public
double
determineCorrectDeviation
(
double
speed
,
double
pAccuracy
)
{
if
(!
_requiredStandardDeviation
.
containsKey
(
speed
))
{
if
(
pAccuracy
<
1
)
{
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
null
,
null
);
double
deviation
=
10
;
boolean
reduceChange
=
false
;
double
currentChange
=
deviation
/
2
;
do
{
vectoralJamProperty
.
setGaussianSpeed
(
speed
,
deviation
);
if
(
vectoralJamProperty
.
getProbabilityForValue
(
speed
)
>
pAccuracy
)
{
deviation
+=
currentChange
;
}
else
{
deviation
-=
currentChange
;
reduceChange
=
true
;
}
if
(
reduceChange
)
{
currentChange
/=
2.0
;
}
}
while
(
Math
.
round
(
vectoralJamProperty
.
getProbabilityForValue
(
speed
)
*
10000
)
!=
Math
.
round
(
pAccuracy
*
10000
));
_requiredStandardDeviation
.
put
(
speed
,
deviation
);
}
else
{
_requiredStandardDeviation
.
put
(
speed
,
0
d
);
}
}
return
_requiredStandardDeviation
.
get
(
speed
);
}
@Override
public
int
getDefaultIndex
()
{
return
(
int
)
(
RoadNetworkEdge
.
getCorrespondingState
(
getEdge
().
getOriginalMaxSpeed
())
/
SCALING
);
}
// public double determineCorrectDeviation(double speed, double pAccuracy) {
// if (!_requiredStandardDeviation.containsKey(speed)) {
// if (pAccuracy < 1) {
// VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(null,
// null);
//
// double deviation = 10;
//
// boolean reduceChange = false;
// double currentChange = deviation / 2;
//
// do {
// vectoralJamProperty.setGaussianSpeed(speed, deviation);
// if (vectoralJamProperty.getProbabilityForValue(speed) > pAccuracy) {
// deviation += currentChange;
// } else {
// deviation -= currentChange;
// reduceChange = true;
// }
//
// if (reduceChange) {
// currentChange /= 2.0;
// }
// } while (Math.round(vectoralJamProperty.getProbabilityForValue(speed) *
// 10000) != Math
// .round(pAccuracy * 10000));
//
// _requiredStandardDeviation.put(speed, deviation);
// } else {
// _requiredStandardDeviation.put(speed, 0d);
// }
// }
//
// return _requiredStandardDeviation.get(speed);
// }
}
\ No newline at end of file
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/measurement/MeasurementDistributionTypeContainer.java
0 → 100755
View file @
a1226c51
/*
* 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.data.measurement
;
import
java.util.HashMap
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ProbabilityDistribution
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 26.04.2018
*
*/
public
class
MeasurementDistributionTypeContainer
{
private
static
Map
<
Class
<?>,
ProbabilityDistribution
>
_knownDistributions
=
new
HashMap
<>();
public
static
void
setDistribution
(
Class
<?>
pClass
,
ProbabilityDistribution
pDistribution
)
{
_knownDistributions
.
put
(
pClass
,
pDistribution
);
}
public
static
ProbabilityDistribution
getDistribution
(
Class
<?>
pClass
)
{
return
_knownDistributions
.
get
(
pClass
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/roadcondition/RoadCondition.java
0 → 100755
View file @
a1226c51
/*
* 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.data.roadcondition
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 26.04.2018
*
*/
public
enum
RoadCondition
{
VERY_DRY
,
DRY
,
MEDIUM
,
WET
,
VERY_WET
,
FROZEN
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/roadcondition/RoadConditionProperty.java
0 → 100755
View file @
a1226c51
/*
* 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.data.roadcondition
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 27.02.2018
*
*/
public
class
RoadConditionProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
long
_detectionDate
;
private
RoadCondition
_roadCondition
;
public
RoadConditionProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
this
(
pLocation
,
pEdge
,
RoadCondition
.
DRY
);
}
public
RoadConditionProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
RoadCondition
pRoadCondition
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_detectionDate
=
Time
.
getCurrentTime
();
_roadCondition
=
pRoadCondition
;
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
RoadCondition
getRoadCondition
()
{
return
_roadCondition
;
}
public
void
setRoadCondition
(
RoadCondition
pRoadCondition
)
{
_roadCondition
=
pRoadCondition
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
RoadConditionProperty
(
_location
,
_edge
,
RoadCondition
.
DRY
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/roadcondition/VectoralRoadConditionProperty.java
0 → 100755
View file @
a1226c51
/*
* 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.data.roadcondition
;
import
java.util.Arrays
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
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.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.JamInformationContainer
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 12.04.2018
*
*/
public
class
VectoralRoadConditionProperty
extends
VectoralProperty
{
private
static
final
int
DIMENSIONS
=
6
;
private
static
TemporalDependencyMatrix
_temporalDependencyMatrix
;
public
VectoralRoadConditionProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
)
{
super
(
pLocation
,
pEdge
,
DIMENSIONS
);
}
/**
*
*/
public
VectoralRoadConditionProperty
()
{
this
(
null
,
null
);
}
public
void
setConditon
(
RoadCondition
pCondition
,
double
pAccuracy
,
ProbabilityDistribution
pDist
)
{
switch
(
pDist
)
{
case
SIMPLE:
setSimple
(
pCondition
.
ordinal
(),
pAccuracy
);
break
;
case
GAUSSIAN:
setGaussianWithAccuracy
(
pCondition
.
ordinal
(),
pAccuracy
);
break
;
default
:
throw
new
AssertionError
(
"Unknown ProbablilityDistribution "
+
pDist
);
}
}
@Override
public
VectoralRoadConditionProperty
clone
()
{
VectoralRoadConditionProperty
vectoralJamProperty
=
new
VectoralRoadConditionProperty
(
getLocation
(),
getEdge
());
vectoralJamProperty
.
setProbabilities
(
Arrays
.
copyOf
(
getValueProbabilities
(),
getValueProbabilities
().
length
));
vectoralJamProperty
.
setDetectionDate
(
getDetectionDate
());
return
vectoralJamProperty
;
}
@Override
public
VectoralRoadConditionProperty
age
(
long
pAge
)
{
return
(
VectoralRoadConditionProperty
)
super
.
age
(
pAge
);
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
VectoralRoadConditionProperty
(
getLocation
(),
getEdge
());
}
@Override
public
RoadCondition
getValueAtIndex
(
int
pIndex
)
{
return
RoadCondition
.
values
()[
pIndex
];
}
@Override
public
int
getIndexForValue
(
Object
pValue
)
{
return
RoadCondition
.
valueOf
(
pValue
.
toString
()).
ordinal
();
}
@Override
public
TemporalDependencyMatrix
getDependencyMatrix
()
{
if
(
_temporalDependencyMatrix
==
null
)
{
TemporalDependencyMatrix
temporalDependencyMatrix
=
new
TemporalDependencyMatrix
(
DIMENSIONS
);
double
TEMPORAL_CHANGE
=
1
/
((
double
)
JamInformationContainer
.
EVENT_DURATION
/
Time
.
SECOND
)
/
2.0
;
{
double
[]
probabilities
=
new
double
[
DIMENSIONS
];
probabilities
[
0
]
+=
(
1
-
(
DIMENSIONS
-
1
)
*
TEMPORAL_CHANGE
);
for
(
int
x
=
1
;
x
<
DIMENSIONS
-
1
;
x
++)
{
probabilities
[
x
]
+=
TEMPORAL_CHANGE
;
}
temporalDependencyMatrix
.
setTransitionProbability
(
0
,
probabilities
);
}
for
(
int
x
=
1
;
x
<
DIMENSIONS
;
x
++)
{
double
[]
probabilities
=
new
double
[
DIMENSIONS
];
if
(
x
>
1
)
{
probabilities
[
x
-
1
]
+=
TEMPORAL_CHANGE
;
}
else
{
probabilities
[
x
+
1
]
+=
TEMPORAL_CHANGE
;
}
if
(
x
<
DIMENSIONS
-
1
)
{
probabilities
[
x
+
1
]
+=
TEMPORAL_CHANGE
;
}
else
{
probabilities
[
x
-
1
]
+=
TEMPORAL_CHANGE
;
}
probabilities
[
x
]
+=
(
1
-
2
*
TEMPORAL_CHANGE
);
temporalDependencyMatrix
.
setTransitionProbability
(
x
,
probabilities
);
}
_temporalDependencyMatrix
=
temporalDependencyMatrix
;
}
return
_temporalDependencyMatrix
;
}
public
double
getProbabilityForValue
(
Object
pValue
)
{
if
(
pValue
instanceof
RoadCondition
)
{
RoadCondition
value
=
(
RoadCondition
)
pValue
;
int
index
=
value
.
ordinal
();
return
getValueProbabilities
()[
index
];
}
return
0
;
}
@Override
public
int
hashCode
()
{
return
getMostProbableValue
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
pObj
)
{
if
(
pObj
instanceof
VectoralRoadConditionProperty
)
{
VectoralRoadConditionProperty
property
=
(
VectoralRoadConditionProperty
)
pObj
;
if
(
property
.
getMostProbableValue
().
equals
(
getMostProbableValue
()))
{
return
true
;
}
return
false
;
}
return
super
.
equals
(
pObj
);
}
@Override
public
int
getDefaultIndex
()
{
return
0
;
}
}
\ No newline at end of file
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/JamEnvironmentSensorPlugin.java
View file @
a1226c51
...
...
@@ -29,8 +29,8 @@ 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.JamProperty
;
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.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/VectoralJamEnvironmentSensorPlugin.java
View file @
a1226c51
...
...
@@ -29,10 +29,11 @@ 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.JamProperty
;
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.VectoralJamProperty
;
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.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
...
...
@@ -53,20 +54,28 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
private
double
_accuracy
;
private
final
double
_originalAccuracy
;
private
final
double
_maxDeviation
;
private
static
Random
_random
=
Randoms
.
getRandom
(
VectoralJamEnvironmentSensorPlugin
.
class
);
private
static
Random
_accuracyRandom
=
Randoms
.
getRandom
(
VectoralJamEnvironmentSensorPlugin
.
class
+
"Accuracy"
);
private
ProbabilityDistribution
_probabilityDistribution
=
ProbabilityDistribution
.
SIMPLE
;
@XMLConfigurableConstructor
({
"accuracy"
,
"dist_type"
,
"max_deviation"
})
public
VectoralJamEnvironmentSensorPlugin
(
double
pAccuracy
,
String
pDist
,
double
pMaxDeviation
)
{
_originalAccuracy
=
pAccuracy
;
_maxDeviation
=
pMaxDeviation
;
double
deviation
=
pMaxDeviation
*
pAccuracy
;
int
upperBound
=
1
;
double
lowerBound
=
0.4
;
@XMLConfigurableConstructor
({
"accuracy"
})
public
VectoralJamEnvironmentSensorPlugin
(
double
pAccuracy
)
{
double
deviation
=
0.2
*
pAccuracy
;
if
(
deviation
+
pAccuracy
>
1
)
{
deviation
=
1
-
pAccuracy
;
if
(
deviation
+
pAccuracy
>
upperBound
)
{
deviation
=
upperBound
-
pAccuracy
;
}
if
(
pAccuracy
-
deviation
<
0.6
)
{
deviation
=
pAccuracy
-
0.6
;
if
(
pAccuracy
-
deviation
<
lowerBound
)
{
deviation
=
pAccuracy
-
lowerBound
;
}
double
accuracy
=
pAccuracy
+
_accuracyRandom
.
nextGaussian
()
*
deviation
;
if
(
accuracy
<
pAccuracy
-
deviation
)
{
...
...
@@ -76,6 +85,9 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
accuracy
=
pAccuracy
+
deviation
;
}
setAccuracy
(
accuracy
);
MeasurementDistributionTypeContainer
.
setDistribution
(
VectoralJamProperty
.
class
,
ProbabilityDistribution
.
valueOf
(
pDist
));
}
@Override
...
...
@@ -107,13 +119,23 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
}
if
(
speed
==
-
1
)
{
speed
=
(
int
)
(
edge
.
getOriginalMaxSpeed
()
/
VectoralJamProperty
.
SCALING
)
*
VectoralJamProperty
.
SCALING
;
speed
=
edge
.
getOriginalMaxSpeed
();
}
double
measuredSpeed
=
measureValue
(
speed
);
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
location
,
edge
);
vectoralJamProperty
.
setSpeed
(
measuredSpeed
,
_accuracy
,
_probabilityDistribution
);
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
());
}
}
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
vectoralJamProperty
;
...
...
@@ -126,7 +148,8 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
public
double
measureValue
(
double
pRealSpeed
)
{
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
null
,
null
);
vectoralJamProperty
.
setSpeed
(
pRealSpeed
,
_accuracy
,
_probabilityDistribution
);
vectoralJamProperty
.
setSpeed
(
pRealSpeed
,
_accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
));
double
nextDouble
=
_random
.
nextDouble
();
double
currentAggregate
=
0
;
...
...
@@ -143,7 +166,9 @@ public class VectoralJamEnvironmentSensorPlugin implements EnvironmentSensorPlug
@Override
public
VectoralJamEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
VectoralJamEnvironmentSensorPlugin
(
_accuracy
);
return
new
VectoralJamEnvironmentSensorPlugin
(
_originalAccuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
VectoralJamProperty
.
class
).
toString
(),
_maxDeviation
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/VectoralRoadConditionEnvironmentSensorPlugin.java
0 → 100755
View file @
a1226c51
/*
* 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.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.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
VectoralRoadConditionEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
VectoralRoadConditionEnvironmentSensorPlugin
.
class
);
private
static
Random
_accuracyRandom
=
Randoms
.
getRandom
(
VectoralRoadConditionEnvironmentSensorPlugin
.
class
+
"Accuracy"
);
private
ProbabilityDistribution
_probabilityDistribution
=
ProbabilityDistribution
.
SIMPLE
;
@XMLConfigurableConstructor
({
"accuracy"
})
public
VectoralRoadConditionEnvironmentSensorPlugin
(
double
pAccuracy
)
{
double
deviation
=
0.2
*
pAccuracy
;
if
(
deviation
+
pAccuracy
>
1
)
{
deviation
=
1
-
pAccuracy
;
}
if
(
pAccuracy
-
deviation
<
0.6
)
{
deviation
=
pAccuracy
-
0.6
;
}
double
accuracy
=
pAccuracy
+
_accuracyRandom
.
nextGaussian
()
*
deviation
;
if
(
accuracy
<
pAccuracy
-
deviation
)
{
accuracy
=
pAccuracy
-
deviation
;
}
if
(
accuracy
>
pAccuracy
+
deviation
)
{
accuracy
=
pAccuracy
+
deviation
;
}
setAccuracy
(
accuracy
);
}
@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
)
{
if
(((
JamProperty
)
roadProperty
).
isJammed
())
{
speed
=
((
JamProperty
)
roadProperty
).
getAverageSpeed
();
}
}
}
if
(
speed
==
-
1
)
{
speed
=
(
int
)
(
edge
.
getOriginalMaxSpeed
()
/
VectoralJamProperty
.
SCALING
)
*
VectoralJamProperty
.
SCALING
;
}
double
measuredSpeed
=
measureValue
(
speed
);
VectoralJamProperty
vectoralJamProperty
=
new
VectoralJamProperty
(
location
,
edge
);
vectoralJamProperty
.
setSpeed
(
measuredSpeed
,
_accuracy
,
_probabilityDistribution
);
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
,
_probabilityDistribution
);
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
VectoralRoadConditionEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
VectoralRoadConditionEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/information/EnvironmentInformation.java
View file @
a1226c51
...
...
@@ -32,6 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Attribute
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.LocationBasedEnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
...
...
@@ -121,6 +122,11 @@ public class EnvironmentInformation<T extends LocationBasedEnvironmentProperty>
T
value
=
pInformation
.
getAttribute
(
attribute
);
attributes
.
add
(
pPubSub
.
createAttribute
(
expectedClass
,
attribute
.
getAttributeID
(),
value
));
}
attributes
.
add
(
pPubSub
.
createAttribute
(
RoadNetworkEdge
.
class
,
AvailableInformationAttributes
.
EDGE
.
getAttributeID
(),
pInformation
.
getAttribute
(
AvailableInformationAttributes
.
EDGE
)));
Attribute
<
EnvironmentInformation
>
ATTR_VALUE
=
pPubSub
.
createAttribute
(
EnvironmentInformation
.
class
,
AvailableInformationAttributes
.
VALUE
.
getAttributeID
(),
null
);
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/information/RoadInformation.java
View file @
a1226c51
...
...
@@ -49,4 +49,10 @@ public class RoadInformation extends EnvironmentInformation<RoadProperty>
return
super
.
getAttribute
(
pKey
);
}
public
void
copyAttributes
(
RoadInformation
pSrc
)
{
for
(
AvailableInformationAttributes
attribute
:
pSrc
.
getAvailableAttributes
())
{
setAttribute
(
attribute
,
pSrc
.
getAttribute
(
attribute
));
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkEdge.java
View file @
a1226c51
...
...
@@ -24,9 +24,9 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralJamProperty
;
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.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeController
;
...
...
@@ -81,7 +81,10 @@ public class RoadNetworkEdge {
}
}
public
double
getCurrentSpeedState
()
{
/**
* @return
*/
public
double
getCurrentSpeed
()
{
double
actualSpeed
=
-
1
;
JamProperty
jamProperty
=
getJamProperty
();
if
(
jamProperty
!=
null
)
{
...
...
@@ -89,10 +92,13 @@ public class RoadNetworkEdge {
}
else
{
actualSpeed
=
getCorrespondingState
(
getOriginalMaxSpeed
());
}
return
actualSpeed
;
}
public
double
getCurrentSpeedState
()
{
return
getCorrespondingState
(
getCurrentSpeed
());
}
public
JamProperty
getJamProperty
()
{
List
<
RoadProperty
>
activeProperties
=
getActiveProperties
();
for
(
RoadProperty
roadProperty
:
activeProperties
)
{
...
...
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