Skip to content

Commit ec1df2c

Browse files
# Conflicts: # .gitignore # pom.xml
2 parents 0fc5ec9 + 5e9d3c9 commit ec1df2c

File tree

9 files changed

+87
-17
lines changed

9 files changed

+87
-17
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ null
66
*.iml
77
.gitignore
88
.vscode/.gitignore
9-
/jSensors.iml
9+
/jSensors.iml

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ Monitorize all the hardware sensors of your PC using Java
3939

4040
## Installation ##
4141

42-
To install jSensors you can add the dependecy to your software project management tool: http://mvnrepository.com/artifact/com.profesorfalken/jSensors/1.0.2
42+
To install jSensors you can add the dependecy to your software project management tool: http://mvnrepository.com/artifact/com.profesorfalken/jSensors/2.0.2
4343

4444
For example, for Maven you have just to add to your pom.xml:
4545

4646
<dependency>
4747
<groupId>com.profesorfalken</groupId>
4848
<artifactId>jSensors</artifactId>
49-
<version>1.0.2</version>
49+
<version>2.0.2</version>
5050
</dependency>
5151

5252

@@ -90,6 +90,27 @@ It will retrieve a list of hardware components: CPUs, GPUs, Disks...
9090

9191
Same for other hardware components as GPU or Disks.
9292

93+
### Use as a standalone application ###
94+
95+
Execute jSensors and get all sensors data:
96+
97+
```
98+
java -jar jsensors-2.0.2.jar
99+
```
100+
101+
This will generate a console output.
102+
103+
104+
It is also possible to show a simple gui with all the sensors data:
105+
106+
```
107+
java -jar jsensors-2.0.2.jar --gui
108+
```
109+
110+
Result:
111+
112+
![jSensorsGUI](https://raw.githubusercontent.com/profesorfalken/profesorfalken.github.io/master/files/jsensors-gui.png)
113+
93114
## Configuring jSensors ##
94115

95116
In order to change jSensors configuration you can either:
@@ -98,16 +119,19 @@ In order to change jSensors configuration you can either:
98119

99120
You only have to create in your classpaht a file with the name _jsensors.properties_.
100121

101-
For the moment (v1.0-PreAlfa) the only modificable parameters (and its default values) are:
102-
103-
# Used for unit testing
122+
For the moment the only modificable parameters (and its default values) are:
123+
124+
# Test mode
125+
# REAL: test on real hardware
126+
# STUB: use simulated/hardcoded results to test
104127
testMode=REAL
105-
stubFile=stubFileName
106-
128+
# Stub Content
129+
# string value of the simulated results
130+
stubContent=""
107131
# Debug mode
108132
# If activated it logs in console all retrieved details
109133
debugMode=false
110-
134+
111135
#### Override config element for one request ####
112136

113137
When performing a request we can easily override config elements:

src/main/java/com/profesorfalken/jsensors/manager/SensorsManager.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
import java.util.List;
2222
import java.util.Locale;
2323

24-
import com.profesorfalken.jsensors.model.components.Components;
25-
import com.profesorfalken.jsensors.model.components.Cpu;
26-
import com.profesorfalken.jsensors.model.components.Disk;
27-
import com.profesorfalken.jsensors.model.components.Gpu;
24+
import com.profesorfalken.jsensors.model.components.*;
2825
import com.profesorfalken.jsensors.model.sensors.Fan;
2926
import com.profesorfalken.jsensors.model.sensors.Load;
3027
import com.profesorfalken.jsensors.model.sensors.Sensors;
@@ -49,6 +46,7 @@ public Components getComponents() {
4946
List<Cpu> cpus = new ArrayList<Cpu>();
5047
List<Gpu> gpus = new ArrayList<Gpu>();
5148
List<Disk> disks = new ArrayList<Disk>();
49+
List<Mobo> mobos = new ArrayList<Mobo>();
5250

5351
String normalizedSensorsData = getSensorsData();
5452

@@ -61,10 +59,12 @@ public Components getComponents() {
6159
gpus.add(getGpu(componentData));
6260
} else if (componentData.startsWith("DISK")) {
6361
disks.add(getDisk(componentData));
62+
} else if (componentData.startsWith("MOBO")) {
63+
mobos.add(getMobo(componentData));
6464
}
6565
}
6666

67-
return new Components(cpus, gpus, disks);
67+
return new Components(cpus, gpus, disks, mobos);
6868
}
6969

7070
private Cpu getCpu(String cpuData) {
@@ -79,6 +79,10 @@ private Disk getDisk(String diskData) {
7979
return new Disk(getName(diskData), getSensors(diskData));
8080
}
8181

82+
private Mobo getMobo(String moboData) {
83+
return new Mobo(getName(moboData), getSensors(moboData));
84+
}
85+
8286
private static String getName(String componentData) {
8387
String name = null;
8488

src/main/java/com/profesorfalken/jsensors/manager/windows/WindowsSensorsManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ private static String normalizeSensorsData(String rawSensorsData) {
7171
normalizedSensorsData.append(COMPONENT_SEPARATOR).append(LINE_BREAK);
7272
normalizedSensorsData.append("DISK").append(LINE_BREAK);
7373
readingHardLabel = true;
74+
} else if ("Mainboard".equals(hardwareType)) {
75+
normalizedSensorsData.append(COMPONENT_SEPARATOR).append(LINE_BREAK);
76+
normalizedSensorsData.append("MOBO").append(LINE_BREAK);
77+
readingHardLabel = false;
7478
}
7579
continue;
7680
}

src/main/java/com/profesorfalken/jsensors/manager/windows/powershell/PowerShellScriptHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ private static String sensorsQueryLoop() {
7676
code.append("ForEach ($subhw in $hw.SubHardware)").append(LINE_BREAK);
7777
code.append("{").append(LINE_BREAK);
7878
code.append("$subhw.Update()").append(LINE_BREAK);
79+
code.append("ForEach ($sensor in $subhw.Sensors)").append(LINE_BREAK);
80+
code.append("{").append(LINE_BREAK);
81+
code.append("$sensor").append(LINE_BREAK);
82+
code.append("Write-Host \"\"").append(LINE_BREAK);
83+
code.append("}").append(LINE_BREAK);
7984
code.append("}").append(LINE_BREAK);
8085
code.append("ForEach ($sensor in $hw.Sensors)").append(LINE_BREAK);
8186
code.append("{").append(LINE_BREAK);

src/main/java/com/profesorfalken/jsensors/model/components/Components.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ public class Components {
2525
public final List<Cpu> cpus;
2626
public final List<Gpu> gpus;
2727
public final List<Disk> disks;
28+
public final List<Mobo> mobos;
2829

29-
public Components(List<Cpu> cpus, List<Gpu> gpus, List<Disk> disks) {
30+
public Components(List<Cpu> cpus, List<Gpu> gpus, List<Disk> disks, List<Mobo> mobos) {
3031
this.cpus = cpus;
3132
this.gpus = gpus;
3233
this.disks = disks;
34+
this.mobos = mobos;
3335
}
3436
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2016-2017 Javier Garcia Alonso.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.profesorfalken.jsensors.model.components;
17+
18+
import com.profesorfalken.jsensors.model.sensors.Sensors;
19+
20+
/**
21+
*
22+
* @author Roel Goossens
23+
*/
24+
public class Mobo extends Component {
25+
26+
public Mobo(String name, Sensors sensors) {
27+
super(name, sensors);
28+
}
29+
30+
}

src/main/resources/jsensors.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# REAL: test on real hardware
33
# STUB: use simulated/hardcoded results to test
44
testMode=REAL
5-
stubFile=stubFileName
6-
5+
# Stub Content
6+
# string value of the simulated results
7+
stubContent=""
78
# Debug mode
89
# If activated it logs in console all retrieved details
910
debugMode=false
Binary file not shown.

0 commit comments

Comments
 (0)