main.com.divpundir.mavlink.definitions.icarous.IcarousHeartbeat.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of definitions Show documentation
Show all versions of definitions Show documentation
A modern MAVLink library for the JVM written in Kotlin.
package com.divpundir.mavlink.definitions.icarous
import com.divpundir.mavlink.api.GeneratedMavField
import com.divpundir.mavlink.api.GeneratedMavMessage
import com.divpundir.mavlink.api.MavDeserializer
import com.divpundir.mavlink.api.MavEnumValue
import com.divpundir.mavlink.api.MavMessage
import com.divpundir.mavlink.serialization.decodeEnumValue
import com.divpundir.mavlink.serialization.encodeEnumValue
import com.divpundir.mavlink.serialization.truncateZeros
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.Byte
import kotlin.ByteArray
import kotlin.Int
import kotlin.UInt
import kotlin.Unit
/**
* ICAROUS heartbeat
*/
@GeneratedMavMessage(
id = 42_000u,
crcExtra = -29,
)
public data class IcarousHeartbeat(
/**
* See the FMS_STATE enum.
*/
@GeneratedMavField(type = "uint8_t")
public val status: MavEnumValue = MavEnumValue.fromValue(0u),
) : MavMessage {
public override val instanceMetadata: MavMessage.Metadata = METADATA
public override fun serializeV1(): ByteArray {
val outputBuffer = ByteBuffer.allocate(SIZE_V1).order(ByteOrder.LITTLE_ENDIAN)
outputBuffer.encodeEnumValue(status.value, 1)
return outputBuffer.array()
}
public override fun serializeV2(): ByteArray {
val outputBuffer = ByteBuffer.allocate(SIZE_V2).order(ByteOrder.LITTLE_ENDIAN)
outputBuffer.encodeEnumValue(status.value, 1)
return outputBuffer.array().truncateZeros()
}
public companion object {
private const val ID: UInt = 42_000u
private const val CRC_EXTRA: Byte = -29
private const val SIZE_V1: Int = 1
private const val SIZE_V2: Int = 1
private val DESERIALIZER: MavDeserializer = MavDeserializer { bytes ->
val inputBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN)
val status = inputBuffer.decodeEnumValue(1).let { value ->
val entry = IcarousFmsState.getEntryFromValueOrNull(value)
if (entry != null) MavEnumValue.of(entry) else MavEnumValue.fromValue(value)
}
IcarousHeartbeat(
status = status,
)
}
private val METADATA: MavMessage.Metadata = MavMessage.Metadata(ID, CRC_EXTRA,
DESERIALIZER)
public val classMetadata: MavMessage.Metadata = METADATA
public fun builder(builderAction: Builder.() -> Unit): IcarousHeartbeat =
Builder().apply(builderAction).build()
}
public class Builder {
public var status: MavEnumValue = MavEnumValue.fromValue(0u)
public fun build(): IcarousHeartbeat = IcarousHeartbeat(
status = status,
)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy