AttractionPoint.java 3.71 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
 *
 * This file is part of PeerfactSim.KOM.
 * 
 * PeerfactSim.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.tud.kom.p2psim.impl.topology.movement.modular.attraction;

import java.util.Random;

import de.tud.kom.p2psim.api.topology.movement.MovementListener;
26
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
27
import de.tud.kom.p2psim.impl.topology.PositionVector;
28
import de.tudarmstadt.maki.simonstrator.api.Host;
29
import de.tudarmstadt.maki.simonstrator.api.Randoms;
30
31
32
33
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationActuator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationListener;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationRequest;
34
35
36

/**
 * This is the implementation of a AttractionPoint, which implements the
37
 * {@link LocationActuator} interface. So a {@link AttractionPoint} has the
38
39
40
41
42
 * ability to be moved.
 * 
 * @author Christoph Muenker
 * @version 1.0, 02.07.2013
 */
43
public class AttractionPoint implements SimLocationActuator {
44
45
46
47
48
49
50
51
	protected static Random rnd = Randoms.getRandom(AttractionPoint.class);

	private PositionVector posVec;

	private double minSpeed;

	private double maxSpeed;

52
53
	private double currentSpeed = -1;

54
55
56
57
58
59
60
61
62
	public AttractionPoint(PositionVector posVec, double minSpeed,
			double maxSpeed) {
		this.posVec = posVec;

		this.minSpeed = minSpeed;
		this.maxSpeed = maxSpeed;
	}

	@Override
63
64
	public double getMinMovementSpeed() {
		return minSpeed;
65
66
67
	}

	@Override
68
69
	public double getMaxMovementSpeed() {
		return maxSpeed;
70
71
72
	}

	@Override
73
74
	public void setMovementSpeed(double speed) {
		this.currentSpeed = speed;
75
76
77
	}

	@Override
78
79
80
81
82
83
84
85
86
	public double getMovementSpeed() {
		if (currentSpeed == -1) {
			double min_speed = getMinMovementSpeed();
			double max_speed = getMaxMovementSpeed();

			double value = rnd.nextDouble();
			this.currentSpeed = (value * (max_speed - min_speed)) + min_speed;
		}
		return currentSpeed;
87
88
89
	}

	@Override
90
91
	public Location getLastLocation() {
		return posVec;
92
93
94
	}

	@Override
95
96
97
	public void requestLocationUpdates(LocationRequest request,
			LocationListener listener) {
		throw new UnsupportedOperationException();
98
99
100
	}

	@Override
101
102
	public void removeLocationUpdates(LocationListener listener) {
		throw new UnsupportedOperationException();
103
104
105
	}

	@Override
106
107
	public LocationRequest getLocationRequest() {
		throw new UnsupportedOperationException();
108
109
110
	}

	@Override
111
112
	public void initialize() {
		throw new UnsupportedOperationException();
113
114
115
	}

	@Override
116
117
	public void shutdown() {
		throw new UnsupportedOperationException();
118
	}
119

120
	@Override
121
122
123
	public Host getHost() {
		throw new UnsupportedOperationException();
	}
124

125
126
127
	@Override
	public void updateCurrentLocation(double longitude, double latitude) {
		posVec.setEntries(longitude, latitude);
128
129
	}

130
131
132
133
134
135
	@Override
	public void setNewTargetLocation(double longitude, double latitude)
			throws UnsupportedOperationException {
		throw new UnsupportedOperationException();
	}

136
137
138
139
	@Override
	public PositionVector getRealPosition() {
		return posVec;
	}
140

141
}