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
3c79589c
Commit
3c79589c
authored
Nov 02, 2018
by
Tobias Meuser
Browse files
Added cost-based communication
parent
0f3113f7
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/pubsub/CostBasedPubSubComponent.java
0 → 100755
View file @
3c79589c
/*
* 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.pubsub
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Attribute
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic
;
public
interface
CostBasedPubSubComponent
extends
PubSubComponent
{
public
Subscription
createSubscription
(
Topic
topic
,
Filter
filter
,
double
costs
);
public
Notification
createNotification
(
Topic
topic
,
List
<
Attribute
<?>>
attributes
,
double
costs
,
byte
[]
payload
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/AbstractRelevanceCalculationComponent.java
0 → 100755
View file @
3c79589c
/*
* 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.relevance
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.vehicular.RelevanceCalculationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInformationConsumer.SiSConsumerHandle
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSType
;
public
abstract
class
AbstractRelevanceCalculationComponent
implements
RelevanceCalculationComponent
{
private
SiSComponent
_sis
;
private
Host
_host
;
private
List
<
SiSConsumerHandle
>
sisHandles
=
new
ArrayList
<>();
public
AbstractRelevanceCalculationComponent
(
Host
pHost
)
{
_host
=
pHost
;
}
public
abstract
Map
<
SiSType
<?>,
SiSRequest
>
getRequiredInformation
();
@Override
public
Host
getHost
()
{
return
_host
;
}
protected
SiSComponent
getSiS
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
getHost
().
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
e
);
}
}
return
_sis
;
}
@Override
public
void
initialize
()
{
Map
<
SiSType
<?>,
SiSRequest
>
metrics
=
getRequiredInformation
();
for
(
Map
.
Entry
<
SiSType
<?>,
SiSRequest
>
metric
:
metrics
.
entrySet
())
{
SiSConsumerHandle
handle
=
getSiS
().
get
().
rawObservations
(
metric
.
getKey
(),
metric
.
getValue
(),
null
);
sisHandles
.
add
(
handle
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance
/ImpactFunction.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular
/ImpactFunction.java
View file @
3c79589c
...
...
@@ -18,7 +18,7 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/vehicular/RelevanceCalculationComponent.java
0 → 100755
View file @
3c79589c
/*
* 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.relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
public
interface
RelevanceCalculationComponent
extends
HostComponent
{
public
double
calculateRelevance
(
INodeID
receivingNode
,
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance/Event
RelevanceCalculationComponent.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular/Vehicular
RelevanceCalculationComponent.java
View file @
3c79589c
...
...
@@ -18,7 +18,7 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.VehicularPointInformation
;
...
...
@@ -32,7 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0.0
*
*/
public
interface
Event
RelevanceCalculationComponent
extends
HostComponent
{
public
interface
Vehicular
RelevanceCalculationComponent
extends
HostComponent
{
/**
* This method calculates the relevance of an event for a vehicle, combining
* the temporal and the geographical relevance.
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance
/impl/AbstractQoIBasedImpactFunction.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular
/impl/AbstractQoIBasedImpactFunction.java
View file @
3c79589c
...
...
@@ -18,18 +18,18 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
.impl
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
.impl
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.vehicular.ImpactFunction
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AggregatedInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.relevance.ImpactFunction
;
public
abstract
class
AbstractQoIBasedImpactFunction
<
T
extends
PointInformation
>
implements
ImpactFunction
<
T
>
{
protected
static
final
long
SCALING
=
Time
.
SECOND
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance
/impl/SimpleQoIBasedImpactFunction.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular
/impl/SimpleQoIBasedImpactFunction.java
View file @
3c79589c
...
...
@@ -18,7 +18,7 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
.impl
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
.impl
;
import
java.util.List
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance
/impl/VectoralQoIBasedImpactFunction.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular
/impl/VectoralQoIBasedImpactFunction.java
View file @
3c79589c
...
...
@@ -18,7 +18,7 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
.impl
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
.impl
;
import
java.util.List
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/DefaultPropertyCostEstimator.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/Default
Vehicular
PropertyCostEstimator.java
View file @
3c79589c
...
...
@@ -20,12 +20,16 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.LocationBasedEnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.bump.BumpProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.hazard.HazardProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
public
class
DefaultPropertyCostEstimator
implements
PropertyCostEstimator
{
public
class
Default
Vehicular
PropertyCostEstimator
implements
Vehicular
PropertyCostEstimator
{
@Override
public
double
calculateCosts
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
...
...
@@ -39,4 +43,16 @@ public class DefaultPropertyCostEstimator implements PropertyCostEstimator {
return
1
;
}
@Override
public
double
calculateCosts
(
Notification
pNotification
)
{
EnvironmentInformation
<?
extends
LocationBasedEnvironmentProperty
>
environmentInformation
=
EnvironmentInformation
.
createFromNotification
(
pNotification
);
if
(
environmentInformation
instanceof
RoadInformation
)
{
return
calculateCosts
(((
RoadInformation
)
environmentInformation
).
getValue
());
}
throw
new
AssertionError
(
"Cost calculation only valid for road information!"
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/PropertyCostEstimator.java
View file @
3c79589c
...
...
@@ -20,12 +20,8 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.
sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.
pubsub.Notification
;
public
interface
PropertyCostEstimator
{
default
double
calculateCosts
(
RoadProperty
pProperty
)
{
return
calculateCosts
(
pProperty
.
getClass
());
}
double
calculateCosts
(
Class
<?
extends
RoadProperty
>
pProperty
);
double
calculateCosts
(
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/PropertyCostEstimatorFactory.java
View file @
3c79589c
...
...
@@ -21,7 +21,7 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
public
class
PropertyCostEstimatorFactory
{
private
static
DefaultPropertyCostEstimator
_costEstimator
=
new
DefaultPropertyCostEstimator
();
private
static
Default
Vehicular
PropertyCostEstimator
_costEstimator
=
new
Default
Vehicular
PropertyCostEstimator
();
public
static
PropertyCostEstimator
getPropertyCostEstimator
()
{
return
_costEstimator
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/VehicularPropertyCostEstimator.java
0 → 100755
View file @
3c79589c
/*
* 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.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
public
interface
VehicularPropertyCostEstimator
extends
PropertyCostEstimator
{
default
double
calculateCosts
(
RoadProperty
pProperty
)
{
return
calculateCosts
(
pProperty
.
getClass
());
}
double
calculateCosts
(
Class
<?
extends
RoadProperty
>
pProperty
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/subscriptions/topic/CostBasedTopic.java
View file @
3c79589c
...
...
@@ -7,6 +7,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyCostEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyCostEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.VehicularPropertyCostEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType
;
...
...
@@ -45,7 +46,8 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic
if
(
pInformation
instanceof
RoadInformation
)
{
RoadInformation
roadInfo
=
(
RoadInformation
)
pInformation
;
PropertyCostEstimator
costEstimator
=
PropertyCostEstimatorFactory
.
getPropertyCostEstimator
();
double
costsForMissingInformation
=
costEstimator
.
calculateCosts
(
roadInfo
.
getValue
());
double
costsForMissingInformation
=
((
VehicularPropertyCostEstimator
)
costEstimator
)
.
calculateCosts
(
roadInfo
.
getValue
());
if
(
costsForMissingInformation
>=
_costs
)
{
return
true
;
...
...
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