public class

ParticipantLocationService

extends LocationService
java.lang.Object
   ↳ uk.ac.imperial.presage2.core.environment.EnvironmentService
     ↳ uk.ac.imperial.presage2.util.location.LocationService
       ↳ uk.ac.imperial.presage2.util.location.ParticipantLocationService

Class Overview

This is an extension of the LocationService to provide tools specifically for Participants. This class can also handle the ParticipantSharedState of Location for the agent using it.

Some functions depend on the environment having an EnvironmentMembersService available

Usage

Agents who have Location to share (implementing HasLocation) can create shared state which registering with the environment with #createSharedState(UUID, HasLocation):

 ParticipantSharedState<Location> ss = ParticipantLocationService
 		.createSharedState(myID, myLoc);
 

The environment should provide this service in the EnvironmentRegistrationResponse:

 ParticipantLocationService p = new ParticipantLocationService(participant,
 		sharedState, serviceProvider);
 

Summary

Fields
protected final EnvironmentMembersService membersService
protected final UUID myID
protected final HasPerceptionRange rangeProvider
[Expand]
Inherited Fields
From class uk.ac.imperial.presage2.core.environment.EnvironmentService
Public Constructors
ParticipantLocationService(UUID id, Location loc, HasPerceptionRange hasRange, EnvironmentSharedStateAccess sharedState, EnvironmentServiceProvider serviceProvider)

Create a ParticipantLocationService for Participant p which has a location provided by hasLoc, perception range provided by hasRange.

ParticipantLocationService(Participant p, EnvironmentSharedStateAccess sharedState, EnvironmentServiceProvider serviceProvider)
Public Methods
static ParticipantSharedState createSharedState(UUID pid, Location loc)
Create the ParticipantSharedState required for this service.
Location getAgentLocation(UUID participantID)
Get the location of a given agent specified by it's participant UUID.
Map<UUIDLocation> getNearbyAgents()
Get the agents who are visible to me at this time and their Locations.
void setAgentLocation(UUID participantID, Location l)
Not available for Participant use!
[Expand]
Inherited Methods
From class uk.ac.imperial.presage2.util.location.LocationService
From class uk.ac.imperial.presage2.core.environment.EnvironmentService
From class java.lang.Object

Fields

protected final EnvironmentMembersService membersService

protected final UUID myID

protected final HasPerceptionRange rangeProvider

Public Constructors

public ParticipantLocationService (UUID id, Location loc, HasPerceptionRange hasRange, EnvironmentSharedStateAccess sharedState, EnvironmentServiceProvider serviceProvider)

Create a ParticipantLocationService for Participant p which has a location provided by hasLoc, perception range provided by hasRange. The EnvironmentSharedStateAccess is provided by sharedState. This constructor will create a new ParticipantSharedState for Location from the given HasLocation

Parameters
hasRange HasPerceptionRange which provides the range at which this agent can perceive other agents.
sharedState EnvironmentSharedStateAccess which this EnvironmentService should use.
serviceProvider EnvironmentServiceProvider for fetching dependencies

public ParticipantLocationService (Participant p, EnvironmentSharedStateAccess sharedState, EnvironmentServiceProvider serviceProvider)

Public Methods

public static ParticipantSharedState createSharedState (UUID pid, Location loc)

Create the ParticipantSharedState required for this service.

Parameters
pid UUID of the participant to create sharedstate object for.
loc Location initial location for this participant.
Returns

public Location getAgentLocation (UUID participantID)

Get the location of a given agent specified by it's participant UUID.

Parameters
participantID UUID of participant to look up
Returns

public Map<UUIDLocation> getNearbyAgents ()

Get the agents who are visible to me at this time and their Locations. If we are using Cells we do a cell lookup, otherwise we go through the full agent list.

Returns

public void setAgentLocation (UUID participantID, Location l)

Not available for Participant use!