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
042766bf
Commit
042766bf
authored
May 18, 2018
by
Tobias Meuser
Browse files
Merge changes of Björn Büschke
parent
1053046d
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/pubsub/SubscriptionListener.java
0 → 100755
View file @
042766bf
/*
* 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
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayContact
;
public
interface
SubscriptionListener
{
void
onSubscribeAtBroker
(
OverlayContact
pSubscriber
,
Subscription
[]
subscriptions
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/BumpProperty.java
0 → 100644
View file @
042766bf
/*
* 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.data
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 26.03.2018
*
*/
public
class
BumpProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
final
boolean
_bump
;
private
long
_detectionDate
;
public
BumpProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
boolean
pBump
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_bump
=
pBump
;
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
boolean
hasBump
()
{
return
_bump
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
BumpProperty
(
_location
,
_edge
,
false
);
}
@Override
public
int
hashCode
()
{
return
getEdge
().
getEdgeID
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
BumpProperty
)
{
BumpProperty
bumpProperty
=
(
BumpProperty
)
obj
;
return
bumpProperty
.
getEdge
().
equals
(
getEdge
())
&&
(
bumpProperty
.
hasBump
()
==
hasBump
());
}
return
super
.
equals
(
obj
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/FogProperty.java
0 → 100644
View file @
042766bf
/*
* 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.data
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 27.03.2018
*
*/
public
class
FogProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
final
boolean
_fog
;
private
long
_detectionDate
;
public
FogProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
boolean
pFog
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_fog
=
pFog
;
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
boolean
hasFog
()
{
return
_fog
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
FogProperty
(
_location
,
_edge
,
false
);
}
@Override
public
int
hashCode
()
{
return
getEdge
().
getEdgeID
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
FogProperty
)
{
FogProperty
fogProperty
=
(
FogProperty
)
obj
;
return
fogProperty
.
getEdge
().
equals
(
getEdge
())
&&
(
fogProperty
.
hasFog
()
==
hasFog
());
}
return
super
.
equals
(
obj
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/HazardProperty.java
0 → 100644
View file @
042766bf
/*
* 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.data
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 26.03.2018
*
*/
public
class
HazardProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
final
boolean
_hazard
;
private
long
_detectionDate
;
public
HazardProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
boolean
pHazard
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_hazard
=
pHazard
;
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
boolean
hasHazard
()
{
return
_hazard
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
HazardProperty
(
_location
,
_edge
,
false
);
}
@Override
public
int
hashCode
()
{
return
getEdge
().
getEdgeID
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
HazardProperty
)
{
HazardProperty
hazardProperty
=
(
HazardProperty
)
obj
;
return
hazardProperty
.
getEdge
().
equals
(
getEdge
())
&&
(
hazardProperty
.
hasHazard
()
==
hasHazard
());
}
return
super
.
equals
(
obj
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/RainProperty.java
0 → 100644
View file @
042766bf
/*
* 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
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 27.03.2018
*
*/
public
class
RainProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
final
boolean
_rain
;
private
long
_detectionDate
;
public
RainProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
boolean
pRain
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_rain
=
pRain
;
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
boolean
hasRain
()
{
return
_rain
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
RainProperty
(
_location
,
_edge
,
false
);
}
@Override
public
int
hashCode
()
{
return
getEdge
().
getEdgeID
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
RainProperty
)
{
RainProperty
rainProperty
=
(
RainProperty
)
obj
;
return
rainProperty
.
getEdge
().
equals
(
getEdge
())
&&
(
rainProperty
.
hasRain
()
==
hasRain
());
}
return
super
.
equals
(
obj
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/TrafficSignProperty.java
0 → 100644
View file @
042766bf
/*
* 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.data
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
/**
* @author Bjoern Bueschke
* @version 1.0 at 26.03.2018
*
*/
public
class
TrafficSignProperty
implements
RoadProperty
{
private
final
Location
_location
;
private
final
RoadNetworkEdge
_edge
;
private
final
boolean
_sign
;
private
long
_detectionDate
;
public
TrafficSignProperty
(
Location
pLocation
,
RoadNetworkEdge
pEdge
,
boolean
pSign
)
{
_location
=
pLocation
;
_edge
=
pEdge
;
_sign
=
pSign
;
_detectionDate
=
Time
.
getCurrentTime
();
}
@Override
public
long
getDetectionDate
()
{
return
_detectionDate
;
}
@Override
public
Location
getLocation
()
{
return
_location
;
}
@Override
public
RoadNetworkEdge
getEdge
()
{
return
_edge
;
}
public
boolean
hasSign
()
{
return
_sign
;
}
@Override
public
EnvironmentProperty
getDefaultProperty
()
{
return
new
TrafficSignProperty
(
_location
,
_edge
,
false
);
}
@Override
public
int
hashCode
()
{
return
getEdge
().
getEdgeID
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
TrafficSignProperty
)
{
TrafficSignProperty
signProperty
=
(
TrafficSignProperty
)
obj
;
return
signProperty
.
getEdge
().
equals
(
getEdge
())
&&
(
signProperty
.
hasSign
()
==
hasSign
());
}
return
super
.
equals
(
obj
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/BumpEnvironmentSensorPlugin.java
0 → 100644
View file @
042766bf
/*
* 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.BumpProperty
;
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.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
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/FogEnvironmentSensorPlugin.java
0 → 100644
View file @
042766bf
/*
* 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.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.FogProperty
;
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.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
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 @
042766bf
/*
* 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.HazardProperty
;
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.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
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/RainEnvironmentSensorPlugin.java
0 → 100644
View file @
042766bf
/*
* 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.RainProperty
;
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.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
RainEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
RainEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
public
RainEnvironmentSensorPlugin
(
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
rain
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
RainProperty
)
{
if
(((
RainProperty
)
roadProperty
).
hasRain
())
{
rain
=
true
;
}
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
rain
=
!
rain
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
RainProperty
(
location
,
edge
,
rain
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
RainEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
RainEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/plugin/TrafficSignEnvironmentSensorPlugin.java
0 → 100644
View file @
042766bf
/*
* 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.EnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.TrafficSignProperty
;
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
TrafficSignEnvironmentSensorPlugin
implements
EnvironmentSensorPlugin
{
private
Host
_host
;
private
SiSComponent
_sis
;
private
double
_accuracy
;
private
static
Random
_random
=
Randoms
.
getRandom
(
TrafficSignEnvironmentSensorPlugin
.
class
);
@XMLConfigurableConstructor
({
"accuracy"
})
public
TrafficSignEnvironmentSensorPlugin
(
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
sign
=
false
;
for
(
RoadProperty
roadProperty
:
edge
.
getActiveProperties
())
{
if
(
roadProperty
instanceof
TrafficSignProperty
)
{
if
(((
TrafficSignProperty
)
roadProperty
).
hasSign
())
{
sign
=
true
;
}
}
}
if
(
_random
.
nextDouble
()
>=
_accuracy
)
{
sign
=
!
sign
;
}
List
<
EnvironmentProperty
>
properties
=
new
ArrayList
<>();
EnvironmentProperty
property
=
new
TrafficSignProperty
(
location
,
edge
,
sign
);
properties
.
add
(
property
);
return
properties
;
}
catch
(
InformationNotAvailableException
e
)
{
throw
new
AssertionError
(
SiSTypes
.
ROAD_EDGE
+
" and "
+
SiSTypes
.
PHY_LOCATION
+
" are required!"
);
}
}
@Override
public
TrafficSignEnvironmentSensorPlugin
clone
()
throws
CloneNotSupportedException
{
return
new
TrafficSignEnvironmentSensorPlugin
(
_accuracy
);
}
public
void
setAccuracy
(
double
pAccuracy
)
{
_accuracy
=
pAccuracy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/information/RoadInformation.java
View file @
042766bf
...
@@ -55,4 +55,12 @@ public class RoadInformation extends EnvironmentInformation<RoadProperty>
...
@@ -55,4 +55,12 @@ public class RoadInformation extends EnvironmentInformation<RoadProperty>
}
}
}
}
@Override
public
<
T
>
boolean
hasAttribute
(
AvailableInformationAttributes
pKey
)
{
if
(
pKey
.
equals
(
AvailableInformationAttributes
.
EDGE
))
{
return
true
;
}
return
super
.
hasAttribute
(
pKey
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/util/Geohash.java
View file @
042766bf
package
de.tudarmstadt.maki.simonstrator.api.util
;
package
de.tudarmstadt.maki.simonstrator.api.util
;
/*
/*
* Copyright (c) 2005-2010 KOM
–
Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM
�
Multimedia Communications Lab
*
*
* This file is part of Simonstrator.KOM.
* This file is part of Simonstrator.KOM.
*
*
...
@@ -22,6 +22,9 @@ package de.tudarmstadt.maki.simonstrator.api.util;
...
@@ -22,6 +22,9 @@ package de.tudarmstadt.maki.simonstrator.api.util;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/**
/**
...
@@ -88,6 +91,10 @@ public class Geohash {
...
@@ -88,6 +91,10 @@ public class Geohash {
* @return
* @return
*/
*/
public
static
String
getAdjacentGeohash
(
String
pGeohash
,
int
pX
,
int
pY
)
{
public
static
String
getAdjacentGeohash
(
String
pGeohash
,
int
pX
,
int
pY
)
{
/*
* (1,0) right/eastern GeoHash (-1,0) left/western GeoHash (0,1)
* lower/southernGeoHash (0,-1) upper/northern GeoHash
*/
byte
[]
decode
=
decode
(
pGeohash
);
byte
[]
decode
=
decode
(
pGeohash
);
if
(
pX
!=
0
)
{
if
(
pX
!=
0
)
{
...
@@ -137,6 +144,53 @@ public class Geohash {
...
@@ -137,6 +144,53 @@ public class Geohash {
return
encode
(
decode
);
return
encode
(
decode
);
}
}
/**
* Get the adjacent regions depending if vehicle drives in N, E, S, W direction
*
* @param geohash
* center geohash
* @param heading
* angle of driving direction
* @return adjacent geohash regions depending on driving direction
*/
public
static
List
<
String
>
getSubscriptionHorizon
(
String
geohash
,
double
heading
)
{
List
<
String
>
adjacentAreas
=
new
ArrayList
<>();
int
direction
=
(
int
)
heading
;
if
(
0
<=
direction
&&
direction
<
45
||
315
<=
direction
&&
direction
<=
360
)
{
// N
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
-
1
));
// top
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
1
,
0
));
// right
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
-
1
,
0
));
// left
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
0
,
-
1
),
1
,
0
));
// top,right
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
0
,
-
1
),
-
1
,
0
));
// top,left
}
if
(
45
<=
direction
&&
direction
<
135
)
{
// E
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
1
,
0
));
// right
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
-
1
));
// top
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
1
));
// bottom
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
1
,
0
),
0
,
-
1
));
// right, top
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
1
,
0
),
0
,
1
));
// right, bottom
}
if
(
135
<=
direction
&&
direction
<
225
)
{
// S
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
1
));
// bottom
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
1
,
0
));
// right
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
-
1
,
0
));
// left
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
0
,
1
),
1
,
0
));
// bottom, right
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
0
,
1
),
-
1
,
0
));
// bottom, left
}
if
(
225
<=
direction
&&
direction
<
315
)
{
// W
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
-
1
,
0
));
// left
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
1
));
// bottom
adjacentAreas
.
add
(
getAdjacentGeohash
(
geohash
,
0
,
-
1
));
// top
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
-
1
,
0
),
0
,
-
1
));
// left, top
adjacentAreas
.
add
(
getAdjacentGeohash
(
getAdjacentGeohash
(
geohash
,
-
1
,
0
),
0
,
1
));
// left, bottom
}
return
adjacentAreas
;
}
private
static
boolean
isBitSet
(
byte
b
,
int
offset
)
{
private
static
boolean
isBitSet
(
byte
b
,
int
offset
)
{
return
getBit
(
b
,
offset
)
==
1
;
return
getBit
(
b
,
offset
)
==
1
;
}
}
...
...
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