Skip to content

ParticipantCarbonReportingService

farhanrahman edited this page Jun 22, 2012 · 3 revisions

This is a Participant service that allows Participants to access the shared states of Reports that every Agents own.

ParticipantCarbonReportingService

Participants can choose to use this class in order to get read access to the shared state of the Environment containing the reports held by all the Agents. In order to use this, a Participant must declare a local variable of this type (ParticipantCarbonReportingService) and use that to fully utilise the service.

public static ParticipantSharedState createSharedState(Map,?> data, UUID participantID): Static utility function that allows Agents to create a ParticipantSharedState of a Map,?> of report. The function is as follows

	public static ParticipantSharedState createSharedState(Map<?,?> data, UUID participantID){
		return new ParticipantSharedState("Report", (Serializable) data, participantID);	
	}

public Map<Integer,Double> getReportFor(UUID participantId): Getter function that allows a Participant to fetch the report for an Agent having an id of participantId.

	@SuppressWarnings("unchecked")
	public Map<Integer,Double> getReportFor(UUID participantId){
		Map<Integer,Double> report = new HashMap<Integer,Double>();
		Serializable data = this.sharedState.get("Report", participantId);
		if(data instanceof Map<?,?>){
			report = (Map<Integer,Double>) data;
			return report;
		}else{
			return null;
		}
	}
Clone this wiki locally