zaber.motion.Measurement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of motion-library Show documentation
Show all versions of motion-library Show documentation
A library that aims to provide easy-to-use API for communication with Zaber devices using Zaber ASCII Protocol.
// ===== 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();
}
}