:battery: USING R AND JAVA to Get and Analyzed your laptop battery health report. Compare the current with design capacity
USING R AND JAVA to Get and Analyzed your laptop battery health report. Compare the current with design capacity
The battery capacity will decrease over time. This application will help you to track the current capacity compared to the design capacity
click Scan
After scan successful you will received the information of your computer. Now you have to option, you can either choose the short result
to get the percentage of design capacity or a details one which will thoroughly analyze the battery health since you bought the laptop.
Choose the Short Result Option:
Choose the Detail Result Option:
two windows of a point plot and a csv file will pop up give the the data how your battery capacity decrease over time
I will use cmd commnad to generate a battery-report.html and using Jsoup.jar to parsing this file and read it into a csv file.
I will then use Renjin to intergrate R into JVM to clean and analyze this batter data base on each week since the laptop was bought.
The html file will give us the data as
I will then use BufferedReader to read this .html file
After the data has been read. CSVWriter from the OpenCSV can be used to write these data into a .csv file
.csv file can then be used by R language to clean and analyze.
I use Renjin instead of JRI because Renjin will run on JVM and not require and JRI
require installed R on the computer to implement. Renjin can be set up in Java IDE as
engine.eval command just simply pass the command into normal R Terminal to execute the data.frame
The data after been clean and analyze in BatteryReport.csv, I use JFreeChart to draw a scatter point plot analyze how the capacity of laptop
battery decrease in terms of weeks since it was first used.
Most of the API is build based on javaFX
<dependencies>
<!-- https://mvnrepository.com/artifact/org.jfree/jcommon -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jfree/jfreechart -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.nuiton.thirdparty/JRI -->
<dependency>
<groupId>org.nuiton.thirdparty</groupId>
<artifactId>JRI</artifactId>
<version>0.9-6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.renjin/renjin-script-engine -->
<dependency>
<groupId>org.renjin</groupId>
<artifactId>renjin-script-engine</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
For more concise, the full build set up and the above repositories and dependencies can be access pom.xml
jsoup: for the purpose of parsing and reading the html file.
opencsv: can be used to write and read csv file
Renjin: using JVM to intergrate Java and R for better data analysize (note: user does not need to have R installed on computer when using Renjin)
JRI: user can used JRI for the familiar if Renjin is still new
JCommon and
JFreeChart: for the purpose of drawing the plot