[477] | 1 | package example.energy; |
---|
| 2 | |
---|
| 3 | import schedframe.Parameters; |
---|
| 4 | import schedframe.PluginConfiguration; |
---|
[1415] | 5 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
[477] | 6 | import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; |
---|
[1415] | 7 | import schedframe.resources.computing.profiles.energy.power.plugin.EnergyPluginConfiguration; |
---|
[1207] | 8 | import schedframe.resources.devices.PhysicalResource; |
---|
[477] | 9 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
[1415] | 10 | import schemas.StringValueWithUnit; |
---|
[477] | 11 | |
---|
| 12 | public abstract class BaseEnergyEstimationPlugin implements EnergyEstimationPlugin { |
---|
| 13 | |
---|
[1415] | 14 | EnergyPluginConfiguration plugConf; |
---|
| 15 | |
---|
[477] | 16 | @Override |
---|
| 17 | public PluginConfiguration getConfiguration() { |
---|
[1415] | 18 | return plugConf; |
---|
[477] | 19 | } |
---|
| 20 | |
---|
| 21 | @Override |
---|
[1415] | 22 | public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
[477] | 23 | throw new RuntimeException("Not implemented."); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | @Override |
---|
[1415] | 27 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
[477] | 28 | throw new RuntimeException("Not implemented."); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | public void init(Parameters parameters) { |
---|
[1415] | 32 | plugConf = new EnergyPluginConfiguration(); |
---|
| 33 | try{ |
---|
| 34 | StringValueWithUnit powerCapLevel = parameters.get("powerCapLevel").get(0); |
---|
| 35 | plugConf.setPowerCapLevel(Double.valueOf(powerCapLevel.getContent()).doubleValue()); |
---|
| 36 | } catch(Exception e){ |
---|
| 37 | plugConf.setPowerCapLevel(-1); |
---|
| 38 | } |
---|
| 39 | try{ |
---|
| 40 | StringValueWithUnit powerFloorLevel = parameters.get("powerFloorLevel").get(0); |
---|
| 41 | plugConf.setPowerFloorLevel(Double.valueOf(powerFloorLevel.getContent()).doubleValue()); |
---|
| 42 | } catch(Exception e){ |
---|
| 43 | plugConf.setPowerFloorLevel(-1); |
---|
| 44 | } |
---|
[477] | 45 | } |
---|
| 46 | |
---|
| 47 | public String getName() { |
---|
| 48 | return getClass().getName(); |
---|
| 49 | } |
---|
| 50 | } |
---|