Search in sources :

Example 1 with VitalsSensor

use of il.ac.technion.cs.smarthouse.sensors.vitals.VitalsSensor in project Smartcity-Smarthouse by TechnionYP5777.

the class Controller method initialize.

@Override
public void initialize(final URL location, final ResourceBundle __) {
    sensor = new VitalsSensor(Random.sensorId(), 40001);
    for (boolean res = false; !res; ) res = sensor.register();
    pulseLabelSensor.setDisable(false);
    bpLabelSensor.setDisable(false);
    bpRSlider = new RangeSlider(0, 200, 80, 120);
    mainVBox.getChildren().add(4, bpRSlider);
    pulseSlider.valueProperty().addListener((ov, oldVal, newVal) -> {
        if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
            return;
        final int pulse = (int) Math.round(newVal.doubleValue());
        pulseLabelSensor.setText("Pulse: " + pulse);
        sensor.updateSystem(pulse, (int) Math.round(bpRSlider.getHighValue()), (int) Math.round(bpRSlider.getLowValue()));
        printUpdateMessage();
    });
    bpRSlider.lowValueProperty().addListener((ov, oldVal, newVal) -> {
        if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
            return;
        final int diastolicBP = (int) Math.round(newVal.doubleValue());
        bpLabelSensor.setText("Blood Pressure: " + (int) Math.round(bpRSlider.getHighValue()) + "/" + diastolicBP);
        sensor.updateSystem((int) Math.round(pulseSlider.getValue()), (int) Math.round(bpRSlider.getHighValue()), diastolicBP);
        printUpdateMessage();
    });
    bpRSlider.highValueProperty().addListener((ov, oldVal, newVal) -> {
        if (Math.round(oldVal.doubleValue()) == Math.round(newVal.doubleValue()))
            return;
        final int systolicBP = (int) Math.round(newVal.doubleValue());
        bpLabelSensor.setText("Blood Pressure: " + systolicBP + "/" + (int) Math.round(bpRSlider.getLowValue()));
        sensor.updateSystem((int) Math.round(pulseSlider.getValue()), systolicBP, (int) Math.round(bpRSlider.getLowValue()));
        printUpdateMessage();
    });
}
Also used : VitalsSensor(il.ac.technion.cs.smarthouse.sensors.vitals.VitalsSensor) RangeSlider(org.controlsfx.control.RangeSlider)

Aggregations

VitalsSensor (il.ac.technion.cs.smarthouse.sensors.vitals.VitalsSensor)1 RangeSlider (org.controlsfx.control.RangeSlider)1