Skip to content
This repository was archived by the owner on Nov 15, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@ public List<IMeasurement> calculateMeasurement() throws Exception {
}

private Float doCompute(String topic, Long started, Long stopped) {
Float value = 0.0f;
Float f_a = null;
Long a = null;
List<IMeasurement> measurements = this.getMeasureInputByRole("inputs");
List<IMeasurement> inputs = this.doFilter(topic, started, stopped, measurements);
for (IMeasurement input : inputs) {
if (f_a == null) {
f_a = (Float) input.getValues().get("value");
a = (Long) input.getValues().get("issued");
} else {
Float f_b = (Float) input.getValues().get("value");
Long b = (Long) input.getValues().get("issued");
value += (b - a) * ((f_a + f_b) / 2);
Float value = 0.0f; Float f_a = null; Long a = null;
List<IMeasurement> inputs = this.getMeasureInputByRole("inputs");
for (IMeasurement input : inputs) {
if (f_a == null) {
f_a = (Float) input.getValues().get("value");
a = (Long) input.getValues().get("issued");
} else {
Float f_b = (Float) input.getValues().get("value");
Long b = (Long) input.getValues().get("issued");
value += (b - a) * ((f_a + f_b) / 2);
}
}
}
return value;
}

Expand Down
30 changes: 8 additions & 22 deletions EmitPowerMeasure/metadata/MeasureMetadata.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Measure name="EmitPowerMeasure" type="DIRECT" category="Emit" provider="Measure.org">
<description>Power in watt provided by EMIT powermeters.</description>
<scopeProperties name="hostname" type="STRING" defaultValue="app.icam.fr">
<description>Hostname</description>
</scopeProperties>
<scopeProperties name="port" type="INTEGER" defaultValue="80">
<description>Port</description>
</scopeProperties>
<scopeProperties name="protocol" type="STRING" defaultValue="http">
<description>Protocol</description>
</scopeProperties>
<scopeProperties name="toolname" type="STRING" defaultValue="emit">
<description>Toolname</description>
</scopeProperties>
<scopeProperties name="username" type="STRING" defaultValue="measure@emit.icam.fr">
<description>Username</description>
</scopeProperties>
<scopeProperties name="password" type="STRING" defaultValue="m3@suR">
<description>Password</description>
</scopeProperties>
<scopeProperties name="topic" type="STRING" defaultValue="peaktech/power">
<description>Topic</description>
</scopeProperties>
<scopeProperties name="hostname" type="STRING" defaultValue="app.icam.fr"></scopeProperties>
<scopeProperties name="port" type="INTEGER" defaultValue="80"></scopeProperties>
<scopeProperties name="protocol" type="STRING" defaultValue="http"></scopeProperties>
<scopeProperties name="toolname" type="STRING" defaultValue="emit"></scopeProperties>
<scopeProperties name="username" type="STRING" defaultValue="measure@emit.icam.fr"></scopeProperties>
<scopeProperties name="password" type="STRING" defaultValue="**********"></scopeProperties>
<scopeProperties name="topic" type="STRING" defaultValue="peaktech/power"></scopeProperties>
<unit name="EmitPowerMeasurement">
<fields fieldName="topic" fieldType="u_text"/>
<fields fieldName="issued" fieldType="u_long"/>
<fields fieldName="value" fieldType="u_float"/>
</unit>
</Measure>
</Measure>