
com.highmobility.autoapi.VehicleLocation Maven / Gradle / Ivy
/*
* The MIT License
*
* Copyright (c) 2014- High-Mobility GmbH (https://high-mobility.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.highmobility.autoapi;
import com.highmobility.autoapi.property.Property;
import com.highmobility.autoapi.value.Coordinates;
import com.highmobility.autoapi.value.measurement.Angle;
import com.highmobility.autoapi.value.measurement.Length;
import com.highmobility.value.Bytes;
/**
* The Vehicle Location capability
*/
public class VehicleLocation {
public static final int IDENTIFIER = Identifier.VEHICLE_LOCATION;
public static final byte PROPERTY_COORDINATES = 0x04;
public static final byte PROPERTY_HEADING = 0x05;
public static final byte PROPERTY_ALTITUDE = 0x06;
public static final byte PROPERTY_PRECISION = 0x07;
/**
* Get Vehicle Location property availability information.
*/
public static class GetVehicleLocationAvailability extends GetAvailabilityCommand {
/**
* Get every Vehicle Location property availability
*/
public GetVehicleLocationAvailability() {
super(IDENTIFIER);
}
/**
* Get specific Vehicle Location property availabilities
*
* @param propertyIdentifiers The property identifierBytes
*/
public GetVehicleLocationAvailability(Bytes propertyIdentifiers) {
super(IDENTIFIER, propertyIdentifiers);
}
/**
* Get specific Vehicle Location property availabilities
*
* @param propertyIdentifiers The property identifierBytes
*/
public GetVehicleLocationAvailability(byte... propertyIdentifiers) {
super(IDENTIFIER, new Bytes(propertyIdentifiers));
}
GetVehicleLocationAvailability(byte[] bytes, @SuppressWarnings("unused") boolean fromRaw) throws CommandParseException {
super(bytes);
}
}
/**
* Get vehicle location
*/
public static class GetVehicleLocation extends GetCommand {
/**
* Get all Vehicle Location properties
*/
public GetVehicleLocation() {
super(State.class, IDENTIFIER);
}
/**
* Get specific Vehicle Location properties
*
* @param propertyIdentifiers The property identifiers
*/
public GetVehicleLocation(Bytes propertyIdentifiers) {
super(State.class, IDENTIFIER, propertyIdentifiers);
}
/**
* Get specific Vehicle Location properties
*
* @param propertyIdentifiers The property identifiers
*/
public GetVehicleLocation(byte... propertyIdentifiers) {
super(State.class, IDENTIFIER, new Bytes(propertyIdentifiers));
}
GetVehicleLocation(byte[] bytes, @SuppressWarnings("unused") boolean fromRaw) throws CommandParseException {
super(State.class, bytes);
}
}
/**
* Get specific Vehicle Location properties
*
* @deprecated use {@link GetVehicleLocation#GetVehicleLocation(byte...)} instead
*/
@Deprecated
public static class GetVehicleLocationProperties extends GetCommand {
/**
* @param propertyIdentifiers The property identifiers
*/
public GetVehicleLocationProperties(Bytes propertyIdentifiers) {
super(State.class, IDENTIFIER, propertyIdentifiers);
}
/**
* @param propertyIdentifiers The property identifiers
*/
public GetVehicleLocationProperties(byte... propertyIdentifiers) {
super(State.class, IDENTIFIER, new Bytes(propertyIdentifiers));
}
GetVehicleLocationProperties(byte[] bytes, @SuppressWarnings("unused") boolean fromRaw) throws CommandParseException {
super(State.class, bytes);
}
}
/**
* The vehicle location state
*/
public static class State extends SetCommand {
Property coordinates = new Property<>(Coordinates.class, PROPERTY_COORDINATES);
Property heading = new Property<>(Angle.class, PROPERTY_HEADING);
Property altitude = new Property<>(Length.class, PROPERTY_ALTITUDE);
Property precision = new Property<>(Length.class, PROPERTY_PRECISION);
/**
* @return The coordinates
*/
public Property getCoordinates() {
return coordinates;
}
/**
* @return Heading angle
*/
public Property getHeading() {
return heading;
}
/**
* @return Altitude above the WGS 84 reference ellipsoid
*/
public Property getAltitude() {
return altitude;
}
/**
* @return The precision
*/
public Property getPrecision() {
return precision;
}
State(byte[] bytes) throws CommandParseException {
super(bytes);
while (propertyIterator.hasNext()) {
propertyIterator.parseNext(p -> {
switch (p.getPropertyIdentifier()) {
case PROPERTY_COORDINATES: return coordinates.update(p);
case PROPERTY_HEADING: return heading.update(p);
case PROPERTY_ALTITUDE: return altitude.update(p);
case PROPERTY_PRECISION: return precision.update(p);
}
return null;
});
}
}
private State(Builder builder) {
super(builder);
coordinates = builder.coordinates;
heading = builder.heading;
altitude = builder.altitude;
precision = builder.precision;
}
public static final class Builder extends SetCommand.Builder {
private Property coordinates;
private Property heading;
private Property altitude;
private Property precision;
public Builder() {
super(IDENTIFIER);
}
public State build() {
return new State(this);
}
/**
* @param coordinates The coordinates
* @return The builder
*/
public Builder setCoordinates(Property coordinates) {
this.coordinates = coordinates.setIdentifier(PROPERTY_COORDINATES);
addProperty(this.coordinates);
return this;
}
/**
* @param heading Heading angle
* @return The builder
*/
public Builder setHeading(Property heading) {
this.heading = heading.setIdentifier(PROPERTY_HEADING);
addProperty(this.heading);
return this;
}
/**
* @param altitude Altitude above the WGS 84 reference ellipsoid
* @return The builder
*/
public Builder setAltitude(Property altitude) {
this.altitude = altitude.setIdentifier(PROPERTY_ALTITUDE);
addProperty(this.altitude);
return this;
}
/**
* @param precision The precision
* @return The builder
*/
public Builder setPrecision(Property precision) {
this.precision = precision.setIdentifier(PROPERTY_PRECISION);
addProperty(this.precision);
return this;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy