This page details the Angular services that are part of the application.
classDiagram
class CarbonEstimationService{
<<service>>
-carbonIntensityService: CarbonIntensityService
-loggingService: LoggingService
+calculateCarbonEstimation(formValue: EstimatorValues) CarbonEstimation
+estimateServerCount(formValue: EstimatorValues) number
-estimateDeviceUsage(formValue: EstimatorValues) DeviceUsage[]
}
class CarbonIntensityService{
<<service>>
+getCarbonIntensity(location: WorldLocation) gCo2ePerKwh
}
class LoggingService{
<<service>>
+log(...output: any[])
}
CarbonEstimationService --> "-carbonIntensityService" CarbonIntensityService
CarbonEstimationService --> "-loggingService" LoggingService
The main service responsible for producing a carbon estimate.
Takes input form values and uses them to calculate a carbon estimation.
Uses LoggingService to output intermediate parts of the calculation.
Uses CarbonIntensityService to get the carbon intensity of input locations.
Returns estimation as percentages.
Uses functions in other modules to perform the calculation.
classDiagram
direction LR
class CarbonEstimationService{
<<service>>
-loggingService: LoggingService
+calculateCarbonEstimation(formValue: EstimatorValues) CarbonEstimation
+estimateServerCount(formValue: EstimatorValues) number
-estimateDeviceUsage(formValue: EstimatorValues) DeviceUsage[]
}
namespace estimation-directory {
class estimate-upstream-emissions{
<<module>>
+estimateUpstreamEmissions(deviceUsage: DeviceUsage[]) UpstreamEstimation
}
class estimate-direct-emissions{
<<module>>
+estimateDirectEmissions(deviceUsage: DeviceUsage[]) DirectEstimation
}
class estimate-indirect-emissions{
<<module>>
+estimateIndirectEmissions(input: Cloud, intensity: gCo2ePerKwh) IndirectEstimation
}
class estimate-downstream-emissions{
<<module>>
+Record~PurposeOfSite, SiteInformation~ siteTypeInfo
+estimateDownstreamEmissions(Downstream downstream, intensity: gCo2ePerKwh) DownstreamEstimation
}
}
CarbonEstimationService ..> estimate-upstream-emissions
CarbonEstimationService ..> estimate-direct-emissions
CarbonEstimationService ..> estimate-indirect-emissions
CarbonEstimationService ..> estimate-downstream-emissions
formValue:
EstimatorValues
- The user form input.
CarbonEstimation
- Contains the components of the estimation as percentages.
Method is used as part of calculateCarbonEstimation()
and exposed publicly so that the CarbonEstimatorFormComponent can update the preview server count as input values are changed.
formValue:
EstimatorValues
- The user form input.
number
- The estimated server count given the current input.
Currently a simple service to wrap the usage of the CO2.js library to reduce dependencies and allow a switch to a different provider in future.
Gets a carbon intensity figure given a region.
location:
WorldLocation
- The location to get the carbon intensity for.
gCo2ePerKwh
- The carbon intensity of the location in grams of CO2 equivalent per Kilowatt hour of energy consumed.
Currently a simple service to wrap console logging.
Checks whether isDevMode()
returns true before calling console.log()
. The method takes the same arguments as console.log()
(a rest parameter array of any
), so that it can be called in the same way and pass on the arguments directly.
...output: any[]
- Any data that should be logged.
void