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
b473db0c
Commit
b473db0c
authored
Jul 24, 2019
by
Tobias Meuser
Browse files
First working version of privacy-sensitive communication
parent
0a1cfdb4
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyComponent.java
View file @
b473db0c
...
...
@@ -61,4 +61,8 @@ public class PrivacyComponent implements HostComponent {
public
PrivacyLevel
getPrivacyLevel
()
{
return
_privacy
;
}
public
void
setPrivacyLevel
(
PrivacyLevel
pPrivacy
)
{
_privacy
=
pPrivacy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyComponentFactory.java
View file @
b473db0c
...
...
@@ -35,6 +35,8 @@ public class PrivacyComponentFactory implements HostComponentFactory {
private
double
_sum
=
0
;
private
Random
_random
=
Randoms
.
getRandom
(
getClass
());
private
double
[]
_ratio
;
@Override
public
HostComponent
createComponent
(
Host
pHost
)
{
PrivacyLevel
level
=
PrivacyLevel
.
NO_PRIVACY
;
...
...
@@ -53,11 +55,19 @@ public class PrivacyComponentFactory implements HostComponentFactory {
return
privacyComponent
;
}
public
void
setPrivacyFrequency
(
PrivacyLevelFrequency
pPrivacyLevel
)
{
_levels
.
add
(
pPrivacyLevel
);
_sum
+=
pPrivacyLevel
.
getProbability
();
public
void
setRatio
(
String
pRatio
)
{
String
[]
split
=
pRatio
.
split
(
"-"
);
_ratio
=
new
double
[
split
.
length
];
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
_ratio
[
i
]
=
Double
.
valueOf
(
split
[
i
]);
_sum
+=
_ratio
[
i
];
}
}
public
void
setPrivacy
(
PrivacyLevel
pPrivacyLevel
)
{
_levels
.
add
(
new
PrivacyLevelFrequency
(
pPrivacyLevel
,
_ratio
[
_levels
.
size
()]));
PrivacyLevel
.
PRIVACY_LEVELS
.
add
(
pPrivacyLevel
.
getLevel
()
);
PrivacyLevel
.
PRIVACY_LEVELS
.
add
(
pPrivacyLevel
);
}
public
static
class
PrivacyLevelFrequency
{
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyLevel.java
View file @
b473db0c
...
...
@@ -30,8 +30,8 @@ public class PrivacyLevel implements Comparable<PrivacyLevel> {
}
imprecisionAreaRadius
=
pImprecisionAreaRadius
;
String
[]
responsibilityLevels
;
if
(
responsibility
.
contains
(
";"
)
)
{
responsibilityLevels
=
responsibility
.
split
(
";"
);
if
(
responsibility
.
trim
().
length
()
>
0
)
{
responsibilityLevels
=
responsibility
.
trim
().
split
(
";"
);
}
else
{
responsibilityLevels
=
new
String
[
0
];
}
...
...
@@ -41,6 +41,17 @@ public class PrivacyLevel implements Comparable<PrivacyLevel> {
}
}
public
String
getResponsibility
()
{
StringBuffer
result
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
responsibility
.
length
;
i
++)
{
if
(
i
!=
0
)
{
result
.
append
(
";"
);
}
result
.
append
(
responsibility
[
i
]);
}
return
result
.
toString
();
}
public
int
getId
()
{
return
id
;
}
...
...
@@ -77,6 +88,10 @@ public class PrivacyLevel implements Comparable<PrivacyLevel> {
@Override
public
int
compareTo
(
PrivacyLevel
pArg0
)
{
return
Double
.
compare
(
imprecisionAreaRadius
,
pArg0
.
getImprecisionAreaRadius
());
int
compare
=
Double
.
compare
(
imprecisionAreaRadius
,
pArg0
.
getImprecisionAreaRadius
());
if
(
compare
==
0
)
{
compare
=
Double
.
compare
(
id
,
pArg0
.
getId
());
}
return
compare
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/DeterministicExponentialLifetimeDistribution.java
View file @
b473db0c
...
...
@@ -38,6 +38,15 @@ public class DeterministicExponentialLifetimeDistribution implements LifetimeDis
_percentile
=
pPercentile
;
}
@XMLConfigurableConstructor
({
"duration"
})
public
DeterministicExponentialLifetimeDistribution
(
long
pEventDuration
)
{
_averageEventDuration
=
pEventDuration
;
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
Time
.
SECOND
);
_percentile
=
0.5
;
}
@Override
public
long
getLifetime
()
{
return
(
long
)
Math
.
ceil
(
Math
.
log
(
_percentile
)
/
Math
.
log
(
_existProbability
))
*
Time
.
SECOND
;
...
...
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