1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

Some cosmetic changes, also initialize the Metadata properly

This commit is contained in:
James Cotton 2011-03-06 13:36:49 -06:00
parent 6dd509ded3
commit 1f202089d1
3 changed files with 14 additions and 7 deletions

View File

@ -3,12 +3,15 @@ package org.openpilot.uavtalk;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
public class UAVMetaObject extends UAVObject {
public UAVMetaObject(int objID, String name, UAVDataObject parent) throws Exception {
super(objID, true, name);
this.parent = parent;
ownMetadata = new Metadata();
ownMetadata.flightAccess = UAVObject.AccessMode.ACCESS_READWRITE;
ownMetadata.gcsAccess = UAVObject.AccessMode.ACCESS_READWRITE;
@ -48,9 +51,17 @@ public class UAVMetaObject extends UAVObject {
fields.add( new UAVObjectField("Logging Update Mode", "", UAVObjectField.FieldType.ENUM, 1, updateModeEnum) );
fields.add( new UAVObjectField("Logging Update Period", "", UAVObjectField.FieldType.UINT32, 1, null ) );
int numBytes = 0;
ListIterator<UAVObjectField> li = fields.listIterator();
while(li.hasNext()) {
numBytes += li.next().getNumBytes();
}
// Initialize object
// Initialize parent
super.initialize(0);
super.initializeFields(fields, ByteBuffer.allocate(10), 10);
initializeFields(fields, ByteBuffer.allocate(numBytes), numBytes);
// Setup metadata of parent
parentMetadata = parent.getDefaultMetadata();

View File

@ -461,7 +461,7 @@ public abstract class UAVObject {
* Return a string with the object information (only the header)
*/
public String toStringBrief() {
return getName() + " ( " + Integer.toHexString(getObjID()) + " " + Integer.toHexString(getInstID()) + " " + getNumBytes() + ")\n";
return getName() + " (" + Integer.toHexString(getObjID()) + " " + Integer.toHexString(getInstID()) + " " + getNumBytes() + ")\n";
}
/**

View File

@ -440,11 +440,7 @@ public class UAVObjectField {
public String toString() {
String sout = new String();
sout += name + ": [ ";
for (int n = 0; n < numElements; ++n)
sout += String.valueOf(n) + "(" + getValue(n) + ") ";
sout += "] " + units + "\n";
sout += name + ": " + ((List) data).toString() + " (" + units + ")\n";
return sout;
}