1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Continuing to work on the java code to be more consistent with GCS code

This commit is contained in:
James Cotton 2011-03-02 20:23:27 -06:00
parent 1810fb61a0
commit f0e4c10cfa
5 changed files with 117 additions and 31 deletions

View File

@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -2,17 +2,20 @@ package org.openpilot.uavtalk;
public abstract class UAVDataObject extends UAVObject {
/**
* @brief Constructor for UAVDataObject
* @param objID the object id to be created
* @param isSingleInst
* @param isSet
* @param name
*/
public UAVDataObject(int objID, Boolean isSingleInst, Boolean isSet, String name) {
super(objID, isSingleInst, name);
}
public void initialize(int instID, UAVMetaObject mobj) {
}
public abstract void initialize(int instID, UAVMetaObject mobj);
public void initialize(UAVMetaObject mobj) {
}
public abstract void initialize(UAVMetaObject mobj);
Boolean isSettings() {
return null;
@ -22,6 +25,23 @@ public abstract class UAVDataObject extends UAVObject {
return null;
}
public abstract UAVDataObject clone(int instID);
public UAVDataObject clone(int instID) {
try {
return (UAVDataObject) super.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public:
static int OBJID = $(OBJIDHEX);
static String NAME;
static String DESCRIPTION;
static boolean ISSINGLEINST = $(ISSINGLEINST);
static boolean ISSETTINGS = $(ISSETTINGS);
static int NUMBYTES = sizeof(DataFields);
}

View File

@ -2,23 +2,41 @@ package org.openpilot.uavtalk;
public class UAVMetaObject extends UAVObject {
private UAVDataObject parent;
public UAVMetaObject(int objID, String mname, UAVDataObject parent) {
super(objID, true, mname);
public UAVMetaObject(int objID, String name, UAVDataObject parent) {
super(objID, true, name);
this.parent = parent;
ownMetadata.flightAccess = UAVObject.AccessMode.ACCESS_READWRITE;
ownMetadata.gcsAccess = UAVObject.AccessMode.ACCESS_READWRITE;
ownMetadata.flightTelemetryAcked = UAVObject.Acked.TRUE;
ownMetadata.flightTelemetryUpdateMode = UAVObject.UpdateMode.UPDATEMODE_ONCHANGE;
ownMetadata.flightTelemetryUpdatePeriod = 0;
ownMetadata.gcsTelemetryAcked = UAVObject.Acked.TRUE;
ownMetadata.gcsTelemetryUpdateMode = UAVObject.UpdateMode.UPDATEMODE_ONCHANGE;
ownMetadata.gcsTelemetryUpdatePeriod = 0;
ownMetadata.loggingUpdateMode = UAVObject.UpdateMode.UPDATEMODE_ONCHANGE;
ownMetadata.loggingUpdatePeriod = 0;
}
UAVObject getParentObject() {
return parent;
}
@Override
public void deserialize(byte[] arr, int offset) {
// TODO Auto-generated method stub
}
@Override
public UAVMetaObject getDefaultMetadata() {
// TODO Auto-generated method stub
return null;
public Metadata getMetadata() {
return ownMetadata;
}
@Override
public Metadata getDefaultMetadata() {
return ownMetadata;
}
@Override
@ -45,4 +63,17 @@ public class UAVMetaObject extends UAVObject {
return null;
}
public UAVMetaObject(quint32 objID, const QString& name, UAVObject* parent);
UAVObject* getParentObject();
void setMetadata(const Metadata& mdata);
void setData(const Metadata& mdata);
Metadata getData();
private UAVObject parent;
private Metadata ownMetadata;
private Metadata parentMetadata;
}

View File

@ -20,11 +20,27 @@ public abstract class UAVObject {
ACCESS_READWRITE,
ACCESS_READONLY
} ;
private Boolean isSingleInst;
private int instID;
private UAVMetaObject meta;
/**
* Access mode
*/
public enum Acked{
FALSE,
TRUE
} ;
final class Metadata {
public AccessMode flightAccess; /** Defines the access level for the local flight transactions (readonly and readwrite) */
public AccessMode gcsAccess; /** Defines the access level for the local GCS transactions (readonly and readwrite) */
public Acked flightTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */
public UpdateMode flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */
public int flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */
public Acked gcsTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */
public UpdateMode gcsTelemetryUpdateMode; /** Update mode used by the GCS (UpdateMode) */
public int gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */
public UpdateMode loggingUpdateMode; /** Update mode used by the logging module (UpdateMode) */
public int loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */
} ;
public UAVObject(int objID, Boolean isSingleInst, String name) {
assert(objID == getObjID()); // ID is in implementation code, make sure it matches object
@ -62,9 +78,13 @@ public abstract class UAVObject {
return true;
}
public void setMetadata(UAVMetaObject obj) { meta = obj; }
public UAVMetaObject getMetadata() { return meta; }
public abstract UAVMetaObject getDefaultMetadata();
public abstract void setMetadata(Metadata obj);
public abstract Metadata getMetadata();
public abstract Metadata getDefaultMetadata();
private Boolean isSingleInst;
private int instID;
private UAVMetaObject meta;
/*
// Unported code from QT

View File

@ -31,29 +31,34 @@ package org.openpilot.uavtalk.uavobjects;
import org.openpilot.uavtalk.UAVObject;
import org.openpilot.uavtalk.UAVDataObject;
import org.openpilot.uavtalk.UAVMetaObject;
import org.openpilot.uavtalk.UAVObjectField;
/**
$(DESCRIPTION)
generated from $(XMLFILE)
**/
public class $(NAME) extends UAVDataObject{
public class $(NAME) extends UAVDataObject {
$(FIELDSINIT)
public $(NAME) (int objID, Boolean isSingleInst, Boolean isSet, String name) {
super(OBJID, ISSINGLEINST, ISSETTINGS, NAME);
}
public void setGeneratedMetaData() {
getMetaData().gcsAccess = UAVMetaObject.$(GCSACCESS);
getMetaData().gcsTelemetryAcked = UAVMetaObject.$(GCSTELEM_ACKEDTF);
getMetaData().gcsTelemetryUpdateMode = UAVMetaObject.$(GCSTELEM_UPDATEMODE);
getMetaData().gcsAccess = UAVObject.AccessMode.$(GCSACCESS);
getMetaData().gcsTelemetryAcked = UAVObject.Acked.$(GCSTELEM_ACKEDTF);
getMetaData().gcsTelemetryUpdateMode = UAVObject.UpdateMode.$(GCSTELEM_UPDATEMODE);
getMetaData().gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
getMetaData().flightAccess = UAVMetaObject.$(FLIGHTACCESS);
getMetaData().flightTelemetryAcked = UAVMetaObject.$(FLIGHTTELEM_ACKEDTF);
getMetaData().flightTelemetryUpdateMode = UAVMetaObject.$(FLIGHTTELEM_UPDATEMODE);
getMetaData().flightAccess = UAVObject.AccessMode.$(FLIGHTACCESS);
getMetaData().flightTelemetryAcked = UAVObject.Acked.$(FLIGHTTELEM_ACKEDTF);
getMetaData().flightTelemetryUpdateMode = UAVObject.UpdateMode.$(FLIGHTTELEM_UPDATEMODE);
getMetaData().flightTelemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD);
getMetaData().loggingUpdateMode = UAVMetaObject.$(LOGGING_UPDATEMODE);
getMetaData().loggingUpdateMode = UAVObject.UpdateMode.$(LOGGING_UPDATEMODE);
getMetaData().loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD);
}
@ -69,6 +74,15 @@ $(FIELDSINIT)
public String getDescription() {
return "$(DESCRIPTION)";
}
protected:
// Constants
static final int OBJID = $(OBJIDHEX);
static final String NAME;
static final String DESCRIPTION;
static final boolean ISSINGLEINST = $(ISSINGLEINST);
static final boolean ISSETTINGS = $(ISSETTINGS);
static final int NUMBYTES = sizeof(DataFields);
$(GETTERSETTER)
}