use of com.profesorfalken.jsensors.manager.unix.jna.CFeature in project jSensors by profesorfalken.
the class TestSensorsLinux method main.
public static void main(String[] args) {
CSensors INSTANCE = (CSensors) Native.loadLibrary("sensors", CSensors.class);
System.err.println("Return method: " + INSTANCE.sensors_init(null));
CChip result;
int numSensor = 0;
while ((result = INSTANCE.sensors_get_detected_chips(null, new IntByReference(numSensor))) != null) {
// System.out.println("Found " + result);
numSensor++;
System.out.println("Adapter " + INSTANCE.sensors_get_adapter_name(result.bus));
CFeature feature;
int numFeature = 0;
while ((feature = INSTANCE.sensors_get_features(result, new IntByReference(numFeature))) != null) {
// System.out.println("Found " + feature);
numFeature++;
String label = INSTANCE.sensors_get_label(result, feature);
CSubFeature subFeature;
int numSubFeature = 0;
while ((subFeature = INSTANCE.sensors_get_all_subfeatures(result, feature, new IntByReference(numSubFeature))) != null) {
double value = 0.0;
DoubleByReference pValue = new DoubleByReference(value);
int returnValue = INSTANCE.sensors_get_value(result, subFeature.number, pValue);
System.out.println(label + " feature " + subFeature.name + ": " + pValue.getValue());
System.out.println(label + "returnValue: " + returnValue);
System.out.println("");
numSubFeature++;
}
}
}
}
use of com.profesorfalken.jsensors.manager.unix.jna.CFeature in project jSensors by profesorfalken.
the class UnixSensorsManager method features.
private static List<CFeature> features(CSensors cSensors, CChip chip) {
List<CFeature> features = new ArrayList<CFeature>();
CFeature foundFeature;
int numFeature = 0;
while ((foundFeature = cSensors.sensors_get_features(chip, new IntByReference(numFeature))) != null) {
features.add(foundFeature);
numFeature++;
}
return features;
}
use of com.profesorfalken.jsensors.manager.unix.jna.CFeature in project jSensors by profesorfalken.
the class UnixSensorsManager method normalizeSensorsData.
private String normalizeSensorsData(CSensors cSensors) {
List<CChip> chips = detectedChips(cSensors);
for (final CChip chip : chips) {
addData("[COMPONENT]");
addDebugData(String.format("Type: %d", chip.bus.type));
addDebugData(String.format("Address: %d", chip.addr));
addDebugData(String.format("Path: %s", chip.path));
addDebugData(String.format("Prefix: %s", chip.prefix));
if (chip.bus != null) {
switch(chip.bus.type) {
case 1:
addData("CPU");
break;
case 2:
addData("GPU");
break;
case 4:
case 5:
addData("DISK");
break;
default:
addData("UNKNOWN");
}
}
addData(String.format("Label: %s", cSensors.sensors_get_adapter_name(chip.bus)));
List<CFeature> features = features(cSensors, chip);
addFeatures(cSensors, chip, features);
}
if (debugMode) {
LOGGER.info(sensorsDebugData.toString());
}
return sensorsData.toString();
}
use of com.profesorfalken.jsensors.manager.unix.jna.CFeature in project jSensors by profesorfalken.
the class UnixSensorsManager method addFeatures.
private void addFeatures(CSensors cSensors, CChip chip, List<CFeature> features) {
for (final CFeature feature : features) {
addDebugData(String.format("Feature type: %d", feature.type));
addDebugData(String.format("Feature name: %s", feature.name));
addDebugData(String.format("Feature label: %s", cSensors.sensors_get_label(chip, feature)));
if (feature.name.startsWith("temp")) {
addData(String.format("Temp %s:", cSensors.sensors_get_label(chip, feature)), false);
} else if (feature.name.startsWith("fan")) {
addData(String.format("Fan %s:", cSensors.sensors_get_label(chip, feature)), false);
}
List<CSubFeature> subFeatures = subFeatures(cSensors, chip, feature);
addSubFeatures(cSensors, chip, subFeatures);
}
}
Aggregations