mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Removed various debugging outputs and exceptions for now (will add back in a
more principled manner later). Also updated the auto generated code.
This commit is contained in:
parent
22e00c780f
commit
f338625092
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="tests"/>
|
||||
<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"/>
|
||||
|
@ -9,7 +9,7 @@ public abstract class UAVDataObject extends UAVObject {
|
||||
* @param isSet
|
||||
* @param name
|
||||
*/
|
||||
public UAVDataObject(int objID, Boolean isSingleInst, Boolean isSet, String name) throws Exception {
|
||||
public UAVDataObject(int objID, Boolean isSingleInst, Boolean isSet, String name) {
|
||||
super(objID, isSingleInst, name);
|
||||
mobj = null;
|
||||
this.isSet = isSet;
|
||||
|
@ -105,10 +105,9 @@ public abstract class UAVObject {
|
||||
* When unable to unpack a field
|
||||
*/
|
||||
public void initializeFields(List<UAVObjectField> fields, ByteBuffer data,
|
||||
int numBytes) throws Exception {
|
||||
int numBytes) {
|
||||
// TODO: QMutexLocker locker(mutex);
|
||||
this.numBytes = numBytes;
|
||||
// this.data = data;
|
||||
this.fields = fields;
|
||||
// Initialize fields
|
||||
for (int n = 0; n < fields.size(); ++n) {
|
||||
@ -288,7 +287,7 @@ public abstract class UAVObject {
|
||||
* @throws Exception
|
||||
* @returns The number of bytes copied
|
||||
*/
|
||||
public int unpack(ByteBuffer dataIn) throws Exception {
|
||||
public int unpack(ByteBuffer dataIn) {
|
||||
if( dataIn == null )
|
||||
return 0;
|
||||
|
||||
|
@ -90,8 +90,8 @@ public class UAVObjectField {
|
||||
* to the arm/uavtalk standard (little endian)
|
||||
* @param dataOut
|
||||
* @return the number of bytes added
|
||||
* @throws Exception */
|
||||
public int pack(ByteBuffer dataOut) throws Exception {
|
||||
**/
|
||||
public int pack(ByteBuffer dataOut) {
|
||||
//QMutexLocker locker(obj->getMutex());
|
||||
// Pack each element in output buffer
|
||||
dataOut.order(ByteOrder.LITTLE_ENDIAN);
|
||||
@ -147,7 +147,7 @@ public class UAVObjectField {
|
||||
break;
|
||||
case STRING:
|
||||
// TODO: Implement strings
|
||||
throw new Exception("Strings not yet implemented");
|
||||
throw new Error("Strings not yet implemented");
|
||||
}
|
||||
// Done
|
||||
return getNumBytes();
|
||||
@ -358,13 +358,13 @@ public class UAVObjectField {
|
||||
}
|
||||
}
|
||||
|
||||
public double getDouble() throws Exception { return getDouble(0); };
|
||||
public double getDouble(int index) throws Exception {
|
||||
public double getDouble() { return getDouble(0); };
|
||||
public double getDouble(int index) {
|
||||
return Double.valueOf((Double) getValue(index));
|
||||
}
|
||||
|
||||
public void setDouble(double value) throws Exception { setDouble(value, 0); };
|
||||
public void setDouble(double value, int index) throws Exception {
|
||||
public void setDouble(double value) { setDouble(value, 0); };
|
||||
public void setDouble(double value, int index) {
|
||||
setValue(value, index);
|
||||
}
|
||||
|
||||
@ -436,9 +436,7 @@ public class UAVObjectField {
|
||||
String sout = new String();
|
||||
sout += name + ": [ ";
|
||||
for (int n = 0; n < numElements; ++n)
|
||||
{
|
||||
sout += String.valueOf(n) + "(" + getValue(n) + ") ";
|
||||
}
|
||||
|
||||
sout += "] " + units + "\n";
|
||||
return sout;
|
||||
@ -488,6 +486,18 @@ public class UAVObjectField {
|
||||
((ArrayList<Long>) data).add((long) 0);
|
||||
}
|
||||
break;
|
||||
case FLOAT32:
|
||||
((ArrayList<Float>) data).clear();
|
||||
for(int index = 0; index < numElements; ++index) {
|
||||
((ArrayList<Float>) data).add((float) 0);
|
||||
}
|
||||
break;
|
||||
case ENUM:
|
||||
((ArrayList<Byte>) data).clear();
|
||||
for(int index = 0; index < numElements; ++index) {
|
||||
((ArrayList<Byte>) data).add((byte) 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,8 +556,6 @@ public class UAVObjectField {
|
||||
numBytesPerElement = 0;
|
||||
}
|
||||
clear();
|
||||
|
||||
System.out.println(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,50 +26,18 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.openpilot.uavtalk;
|
||||
package org.openpilot.uavtalk.uavobjects;
|
||||
|
||||
import org.openpilot.uavtalk.uavobjects.*;
|
||||
import org.openpilot.uavtalk.UAVObject;
|
||||
import java.util.HashMap;
|
||||
import org.openpilot.uavtalk.UAVObjectManager;
|
||||
|
||||
public class UAVObjects {
|
||||
|
||||
private static UAVObject[] uavobjects=null;
|
||||
private static HashMap id2obj;
|
||||
|
||||
public static void init() {
|
||||
if (uavobjects==null) {
|
||||
uavobjects=new UAVObject[] {
|
||||
$(OBJINIT)
|
||||
};
|
||||
id2obj=new HashMap();
|
||||
for (int i=0;i< uavobjects.length;i++)
|
||||
id2obj.put(uavobjects[i].getObjID(),i);
|
||||
public class UAVObjectsInitialize {
|
||||
|
||||
public static void register(UAVObjectManager objMngr) {
|
||||
try {
|
||||
$(OBJINIT)
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static UAVObject[] getUAVObjectArray() {
|
||||
return uavobjects;
|
||||
}
|
||||
|
||||
public static boolean hasObjectWithID(int id) {
|
||||
return id2obj.containsKey(id);
|
||||
}
|
||||
|
||||
public static UAVObject getObjectByID(int id) {
|
||||
if (!hasObjectWithID(id))
|
||||
return null;
|
||||
return uavobjects[(Integer)id2obj.get(id)];
|
||||
}
|
||||
|
||||
public static UAVObject getObjectByName(String name) {
|
||||
return uavobjects[0];
|
||||
}
|
||||
|
||||
public static void printAll() {
|
||||
for (UAVObject obj : uavobjects)
|
||||
System.out.println(obj.getObjName());
|
||||
}
|
||||
|
||||
$(OBJGETTER)
|
||||
}
|
@ -36,7 +36,6 @@ import java.util.ListIterator;
|
||||
import org.openpilot.uavtalk.UAVObjectManager;
|
||||
import org.openpilot.uavtalk.UAVObject;
|
||||
import org.openpilot.uavtalk.UAVDataObject;
|
||||
import org.openpilot.uavtalk.UAVMetaObject;
|
||||
import org.openpilot.uavtalk.UAVObjectField;
|
||||
|
||||
/**
|
||||
@ -46,7 +45,7 @@ generated from $(XMLFILE)
|
||||
**/
|
||||
public class $(NAME) extends UAVDataObject {
|
||||
|
||||
public $(NAME)() throws Exception {
|
||||
public $(NAME)() {
|
||||
super(OBJID, ISSINGLEINST, ISSETTINGS, NAME);
|
||||
|
||||
List<UAVObjectField> fields = new ArrayList<UAVObjectField>();
|
||||
@ -57,10 +56,9 @@ $(FIELDSINIT)
|
||||
int numBytes = 0;
|
||||
ListIterator<UAVObjectField> li = fields.listIterator();
|
||||
while(li.hasNext()) {
|
||||
numBytes += li.next().getNumBytesElement();
|
||||
numBytes += li.next().getNumBytes();
|
||||
}
|
||||
NUMBYTES = numBytes;
|
||||
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, ByteBuffer.allocate(NUMBYTES), NUMBYTES);
|
||||
|
@ -54,14 +54,14 @@ bool UAVObjectGeneratorJava::generate(UAVObjectParser* parser,QString templatepa
|
||||
ObjectInfo* info=parser->getObjectByIndex(objidx);
|
||||
process_object(info);
|
||||
|
||||
javaObjInit.append(" objMngr->registerObject( new " + info->name + "() );\n");
|
||||
javaObjInit.append("\t\t\tobjMngr.registerObject( new " + info->name + "() );\n");
|
||||
objInc.append("#include \"" + info->namelc + ".h\"\n");
|
||||
}
|
||||
|
||||
// Write the gcs object inialization files
|
||||
javaInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||
javaInitTemplate.replace( QString("$(OBJINIT)"), javaObjInit);
|
||||
bool res = writeFileIfDiffrent( javaOutputPath.absolutePath() + "/uavobjectsinit.java", javaInitTemplate );
|
||||
bool res = writeFileIfDiffrent( javaOutputPath.absolutePath() + "/UAVObjectsInitialize.java", javaInitTemplate );
|
||||
if (!res) {
|
||||
cout << "Error: Could not write output files" << endl;
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user