Search in sources :

Example 1 with CSubFeature

use of com.profesorfalken.jsensors.manager.unix.jna.CSubFeature 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++;
            }
        }
    }
}
Also used : DoubleByReference(com.sun.jna.ptr.DoubleByReference) IntByReference(com.sun.jna.ptr.IntByReference) CSubFeature(com.profesorfalken.jsensors.manager.unix.jna.CSubFeature) CSensors(com.profesorfalken.jsensors.manager.unix.jna.CSensors) CFeature(com.profesorfalken.jsensors.manager.unix.jna.CFeature) CChip(com.profesorfalken.jsensors.manager.unix.jna.CChip)

Example 2 with CSubFeature

use of com.profesorfalken.jsensors.manager.unix.jna.CSubFeature in project jSensors by profesorfalken.

the class UnixSensorsManager method subFeatures.

private static List<CSubFeature> subFeatures(CSensors cSensors, CChip chip, CFeature feature) {
    List<CSubFeature> subFeatures = new ArrayList<CSubFeature>();
    CSubFeature foundSubFeature;
    int numSubFeature = 0;
    while ((foundSubFeature = cSensors.sensors_get_all_subfeatures(chip, feature, new IntByReference(numSubFeature))) != null) {
        subFeatures.add(foundSubFeature);
        numSubFeature++;
    }
    return subFeatures;
}
Also used : IntByReference(com.sun.jna.ptr.IntByReference) CSubFeature(com.profesorfalken.jsensors.manager.unix.jna.CSubFeature) ArrayList(java.util.ArrayList)

Example 3 with CSubFeature

use of com.profesorfalken.jsensors.manager.unix.jna.CSubFeature in project jSensors by profesorfalken.

the class UnixSensorsManager method addSubFeatures.

private void addSubFeatures(CSensors cSensors, CChip chip, List<CSubFeature> subFeatures) {
    for (final CSubFeature subFeature : subFeatures) {
        addDebugData(String.format("SubFeature type: %d", subFeature.type));
        addDebugData(String.format("SubFeature name: %s", subFeature.name));
        double value = 0.0;
        DoubleByReference pValue = new DoubleByReference(value);
        if (cSensors.sensors_get_value(chip, subFeature.number, pValue) == 0) {
            addDebugData(String.format("SubFeature value: %s", pValue.getValue()));
            if (subFeature.name.endsWith("_input")) {
                addData(String.format("%s", pValue.getValue()));
                break;
            }
        } else {
            addData("Could not retrieve value");
        }
    }
}
Also used : DoubleByReference(com.sun.jna.ptr.DoubleByReference) CSubFeature(com.profesorfalken.jsensors.manager.unix.jna.CSubFeature)

Example 4 with CSubFeature

use of com.profesorfalken.jsensors.manager.unix.jna.CSubFeature 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);
    }
}
Also used : CSubFeature(com.profesorfalken.jsensors.manager.unix.jna.CSubFeature) CFeature(com.profesorfalken.jsensors.manager.unix.jna.CFeature)

Aggregations

CSubFeature (com.profesorfalken.jsensors.manager.unix.jna.CSubFeature)4 CFeature (com.profesorfalken.jsensors.manager.unix.jna.CFeature)2 DoubleByReference (com.sun.jna.ptr.DoubleByReference)2 IntByReference (com.sun.jna.ptr.IntByReference)2 CChip (com.profesorfalken.jsensors.manager.unix.jna.CChip)1 CSensors (com.profesorfalken.jsensors.manager.unix.jna.CSensors)1 ArrayList (java.util.ArrayList)1