forked from farhanrahman/kyoto
-
Notifications
You must be signed in to change notification settings - Fork 1
CarbonReportingService
farhanrahman edited this page Jun 22, 2012
·
3 revisions
Global Service used by ActionHandlers to update the shared state of all the historic Reports held by all the Participants. Currently the only ActionHandler that depends on this global service is the SubmitCarbonEmissionReportHandler.
ActionHandlers can use this service by first initialising a local field which implements the CarbonReportingService. The handler can then use the updateReport() method of the CarbonReportingService to change the shared data currently held by the Participant who invoked the Action - SubmitCarbonEmissionReport.
updateReport(final UUID id, final Double carbonEmission, final Time simTime): updates the shared data of Reports of Participant with a UUID id
public void updateReport(final UUID id, final Double carbonEmission, final Time simTime){
this.sharedState.change("Report", id, new StateTransformer(){
@Override
public Serializable transform(Serializable state) {
@SuppressWarnings("unchecked")
Map<Integer,Double> s = (Map<Integer,Double>) state;
s.put(simTime.intValue(), carbonEmission);
return (Serializable) s;
}
});
}