cn.wsyjlly.mavlink.common.v1.messages.MissionRequestList Maven / Gradle / Ivy
package cn.wsyjlly.mavlink.common.v1.messages;
import cn.wsyjlly.mavlink.annotation.MavlinkMessage;
import cn.wsyjlly.mavlink.annotation.MavlinkMessageParam;
import cn.wsyjlly.mavlink.common.Message;
import cn.wsyjlly.mavlink.protocol.ByteArray;
import cn.wsyjlly.mavlink.protocol.util.ByteModel;
import java.util.Objects;
/**********************************
* Author YSW
* Description
* Date 2020.11.26 - 02:45
**********************************/
@MavlinkMessage(
id = 43,
messagePayloadLength = 2,
description = "Request the overall list of mission items from the system/component."
)
public class MissionRequestList implements Message {
@MavlinkMessageParam(mavlinkType = "uint8_t", position = 1, typeSize = 1, streamLength = 1, description = "System ID")
private short targetSystem;
@MavlinkMessageParam(mavlinkType = "uint8_t", position = 2, typeSize = 1, streamLength = 1, description = "Component ID")
private short targetComponent;
private final int messagePayloadLength = 2;
private byte[] messagePayload = new byte[messagePayloadLength];
public MissionRequestList(short targetSystem, short targetComponent) {
this.targetSystem = targetSystem;
this.targetComponent = targetComponent;
}
public MissionRequestList(byte[] messagePayload) {
if (messagePayload.length != messagePayloadLength){
throw new IllegalArgumentException("Byte array length is not equal to 2!");
}
messagePayload(messagePayload);
}
public MissionRequestList(){ }
@Override
public void messagePayload(byte[] messagePayload) {
this.messagePayload = messagePayload;
ByteArray byteArray = new ByteArray(messagePayload);
targetSystem = byteArray.getUnsignedInt8(0);
targetComponent = byteArray.getUnsignedInt8(1);
}
@Override
public byte[] messagePayload() {
ByteArray byteArray = new ByteArray(messagePayload);
byteArray.putUnsignedInt8(targetSystem,0);
byteArray.putUnsignedInt8(targetComponent,1);
return messagePayload;
}
@Override
public String hexStringPayload() {
return ByteModel.bytes2HexString(messagePayload);
}
public final MissionRequestList setTargetSystem(short targetSystem) {
this.targetSystem = targetSystem;
return this;
}
public final short getTargetSystem() {
return targetSystem;
}
public final MissionRequestList setTargetComponent(short targetComponent) {
this.targetComponent = targetComponent;
return this;
}
public final short getTargetComponent() {
return targetComponent;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o != null && this.getClass().equals(o.getClass())) {
MissionRequestList other = (MissionRequestList)o;
if (!Objects.deepEquals(this.targetSystem, other.targetSystem)) {
return false;
} else {
return Objects.deepEquals(this.targetComponent, other.targetComponent);
}
} else {
return false;
}
}
@Override
public int hashCode() {
int result = 0;
result = 31 * result + Objects.hashCode(this.targetSystem);
result = 31 * result + Objects.hashCode(this.targetComponent);
return result;
}
@Override
public String toString() {
return "MissionRequestList{" +
"targetSystem=" + targetSystem +
", targetComponent=" + targetComponent +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy