All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zaber.motion.Measurement Maven / Gradle / Ivy

Go to download

A library that aims to provide easy-to-use API for communication with Zaber devices using Zaber ASCII Protocol.

There is a newer version: 6.7.0
Show newest version
// ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== //
// ============== DO NOT EDIT DIRECTLY ============== //

package zaber.motion;

import zaber.motion.protobufs.Main;

/**
 * Represents a numerical value with optional units specified.
 */
public final class Measurement {

    private double value;

    /**
     * Value of the measurement.
     */
    public void setValue(double value) {
        this.value = value;
    }

    /**
     * @return Value of the measurement.
     */
    public double getValue() {
        return this.value;
    }

    private Units unit;

    /**
     * Optional units of the measurement.
     */
    public void setUnit(Units unit) {
        this.unit = unit;
    }

    /**
     * @return Optional units of the measurement.
     */
    public Units getUnit() {
        return this.unit;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Measurement { ");
        sb.append("value: ");
        sb.append(this.value);
        sb.append(", ");
        sb.append("unit: ");
        sb.append(this.unit);
        sb.append(" }");
        return sb.toString();
    }

    public Measurement() {
    }

    public Measurement(
        double value) {
        this.value = value;
    }

    public Measurement(
        double value,
        Units unit) {
        this.value = value;
        this.unit = unit;
    }

    public static Main.Measurement toProtobuf(Measurement source) {

        Main.Measurement.Builder builder = Main.Measurement.newBuilder();

        builder = builder.setValue(source.getValue());
        builder = builder.setUnit((source.getUnit() == null ? Units.NATIVE : source.getUnit()).getName());
        return builder.build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy