Skip to content

Commit

Permalink
feature: implement the PowerSPY module
Browse files Browse the repository at this point in the history
  • Loading branch information
mcolmant committed Dec 1, 2014
1 parent fd0fc76 commit 569f0ef
Show file tree
Hide file tree
Showing 25 changed files with 1,431 additions and 30 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# PowerAPI
PowerAPI is a middleware toolkit for building software-defined power meters. Software-defined power meters are configurable software libraries that can estimate the power consumption of software in real-time. PowerAPI supports the acquisition of raw metrics from a wide diversity of sensors (*eg.*, physical meters, processor interfaces, hardware counters, OS counters) and the delivery of power consumptions via different channels (including file system, network, web, graphical). As a middleware toolkit, PowerAPI offers the capability of assembling power meters *«à la carte»* to accommodate user requirements.
PowerAPI is a middleware toolkit for building software-defined power meters.
Software-defined power meters are configurable software libraries that can estimate the power consumption of software in real-time.
PowerAPI supports the acquisition of raw metrics from a wide diversity of sensors (*eg.*, physical meters, processor interfaces, hardware counters, OS counters) and the delivery of power consumptions via different channels (including file system, network, web, graphical).
As a middleware toolkit, PowerAPI offers the capability of assembling power meters *«à la carte»* to accommodate user requirements.

# About
PowerAPI is an open-source project developed by the [Spirals research group](https://team.inria.fr/spirals) (University of Lille 1 and Inria).
PowerAPI is an open-source project developed by the [Spirals research group](https://team.inria.fr/spirals) (University of Lille 1 and Inria) and fully managed with [sbt](http://www.scala-sbt.org/).

## Mailing list
You can follow the latest news and asks questions by subscribing to our [mailing list](https://sympa.inria.fr/sympa/info/powerapi).
Expand All @@ -17,6 +20,8 @@ We all stand on the shoulders of giants and get by with a little help from our f
* [Akka](http://akka.io) (version 2.3.6 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for asynchronous processing
* [Typesage Config](https://github.com/typesafehub/config) (version 1.2.1 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for reading configuration files.
* [Apache log4j2](http://logging.apache.org/log4j/2.x/) (version 2.1 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for logging outside actors.
* [Bluecove](http://bluecove.org/) (version 2.1.0 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for interfacing the Bluetooth stack in Java (PowerSpy).
* [Bluecove-gpl](http://bluecove.org/bluecove-gpl/) (version 2.1.0 under [GPL licence](http://www.gnu.org/licenses/gpl.html)), for supporting Bluecove on Linux (PowerSpy).

# Licence
This software is licensed under the *GNU Affero General Public License*, quoted below.
Expand Down
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.2.1",
"org.apache.logging.log4j" % "log4j-api" % "2.1",
"org.apache.logging.log4j" % "log4j-core" % "2.1",
"net.sf.bluecove" % "bluecove" % "2.1.0",
"net.sf.bluecove" % "bluecove-gpl" % "2.1.0",
"com.typesafe.akka" %% "akka-testkit" % "2.3.6" % "test",
"org.scalatest" %% "scalatest" % "2.2.2" % "test"
)
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/BluetoothDevice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

import java.io.Closeable;

public interface BluetoothDevice extends Closeable {
public void send(String message);
public String recv(long timeout, boolean errorOnTimeout);
}
46 changes: 46 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/IEEE754Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

import java.nio.ByteOrder;

public class IEEE754Utils {
public static Float fromString(String bits) throws NumberFormatException {
if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
char[] bitsCharArray = bits.toCharArray();

for (int i = 0; i < bitsCharArray.length / 2; i += 2) {
char first = bitsCharArray[i];
char second = bitsCharArray[i + 1];
bitsCharArray[i] = bitsCharArray[bitsCharArray.length - i - 2];
bitsCharArray[i + 1] = bitsCharArray[bitsCharArray.length - i - 1];
bitsCharArray[bitsCharArray.length - i - 2] = first;
bitsCharArray[bitsCharArray.length - i - 1] = second;
}

bits = String.valueOf(bitsCharArray);
}

return Float.intBitsToFloat(Integer.valueOf(bits, 16));
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/PowerSpy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

public interface PowerSpy extends BluetoothDevice, PowerSpyListenable {
static final long DEFAULT_TIMEOUT = 3000;

void startPowerMonitoring();
void stopPowerMonitoring();
}
47 changes: 47 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/PowerSpyEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

public class PowerSpyEvent {
private final Double currentRMS;
private final Float uScale;
private final Float iScale;

public PowerSpyEvent(Double currentRMS, Float uScale, Float iScale) {
this.currentRMS = currentRMS;
this.uScale = uScale;
this.iScale = iScale;
}

public Double getCurrentRMS() {
return currentRMS;
}

public Float getUScale() {
return uScale;
}

public Float getIScale() {
return iScale;
}
}
28 changes: 28 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/PowerSpyListenable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

public interface PowerSpyListenable {
void addPowerSpyListener(PowerSpyListener listener);
void removePowerSpyListener(PowerSpyListener listener);
}
27 changes: 27 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/PowerSpyListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

public interface PowerSpyListener {
void dataUpdated(PowerSpyEvent event);
}
28 changes: 28 additions & 0 deletions src/main/java/org/powerapi/module/powerspy/PowerSpyVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This software is licensed under the GNU Affero General Public License, quoted below.
*
* This file is a part of PowerAPI.
*
* Copyright (C) 2011-2014 Inria, University of Lille 1.
*
* PowerAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PowerAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PowerAPI.
*
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html.
*/
package org.powerapi.module.powerspy;

public enum PowerSpyVersion {
POWERSPY_V1,
POWERSPY_V2
}
Loading

0 comments on commit 569f0ef

Please sign in to comment.