use of org.omg.DynamicAny.DynAnyPackage.InvalidValue in project ACS by ACS-Community.
the class DynAnyParser method parseEventAny.
private void parseEventAny(DynAny dynAny2, String path) {
if (monitor != null && monitor.isCanceled()) {
cancelFlag = true;
// Check for cancellation each time through
return;
}
DynAny da = dynAny2;
int tcKind = da.type().kind().value();
ParsedAnyData entry = new ParsedAnyData(path, "", "");
try {
switch(tcKind) {
case TCKind._tk_short:
entry.setType("short");
entry.setValue(String.valueOf(da.get_short()));
pdlist.add(entry);
break;
case TCKind._tk_long:
entry.setType("long");
entry.setValue(String.valueOf(da.get_long()));
pdlist.add(entry);
break;
case TCKind._tk_longlong:
entry.setType("longlong");
if (path.contains("timestamp")) {
entry.setValue(String.valueOf(UTCUtility.getUTCDate(UTCUtility.utcOmgToJava(da.get_longlong()))));
} else
entry.setValue(String.valueOf(da.get_longlong()));
pdlist.add(entry);
break;
case TCKind._tk_ulonglong:
entry.setType("ulonglong");
entry.setValue(String.valueOf(da.get_ulonglong()));
pdlist.add(entry);
break;
case TCKind._tk_string:
entry.setType("string");
entry.setValue(da.get_string());
pdlist.add(entry);
break;
case TCKind._tk_boolean:
entry.setType("boolean");
entry.setValue("" + da.get_boolean());
pdlist.add(entry);
break;
case TCKind._tk_float:
entry.setType("float");
entry.setValue("" + da.get_float());
pdlist.add(entry);
break;
case TCKind._tk_double:
entry.setType("double");
entry.setValue("" + da.get_double());
pdlist.add(entry);
break;
case TCKind._tk_enum:
entry.setType("enum");
entry.setValue(((DynEnum) da).get_as_string());
pdlist.add(entry);
break;
case TCKind._tk_array:
entry.setType("array");
entry.setValue("size: " + da.component_count());
pdlist.add(entry);
int numDisplayElements = Math.min(da.component_count(), 5);
int elementType = da.type().content_type().kind().value();
switch(elementType) {
case TCKind._tk_double:
for (int j = 0; j < numDisplayElements; j++) {
String dname = path + "[" + j + "]";
double value = da.current_component().get_double();
pdlist.add(new ParsedAnyData(dname, "double", ("" + value)));
da.next();
}
break;
default:
pdlist.add(new ParsedAnyData(path, "Unimplemented type for array: " + elementType, "Unknown"));
}
break;
case TCKind._tk_struct:
case TCKind._tk_except:
DynStruct ds = (DynStruct) da;
String structName = ds.type().name();
if (DEBUG)
System.out.println("Struct name: " + structName);
entry.setType("struct");
if (path.equals("")) {
entry.setName(structName);
} else
// TODO: still not
entry.setName(path + " / " + structName);
// working --
// this doesn't
// display
// Actuator
// Space at all!
StringBuilder members = new StringBuilder("Members: ");
for (int i = 0; i < ds.component_count(); i++) {
members.append(ds.current_member_name() + ((i == ds.component_count() - 1) ? " " : ", "));
ds.next();
}
entry.setValue(members.toString());
pdlist.add(entry);
ds.rewind();
for (int i = 0; i < ds.component_count(); i++) {
String dname = ds.current_member_name();
if (DEBUG)
System.out.println("\tMember name: " + dname + " type: " + ds.current_component().type().kind().value());
parseEventAny(ds.current_component(), dname);
ds.next();
}
if (DEBUG) {
NameValuePair[] nvp = ds.get_members();
for (int i = 0; i < nvp.length; i++) {
System.out.println(nvp[i].id + " " + nvp[i].value);
}
}
break;
case TCKind._tk_sequence:
DynSequence dsq = (DynSequence) da;
String seqName = path + dsq.type().name();
// TODO: Straighten this
entry.setType("sequence" + seqName);
// out
entry.setValue("IDL sequences not implemented yet");
default:
entry.setType(da.type().kind().toString());
entry.setValue("Unimplemented type");
pdlist.add(entry);
break;
}
} catch (TypeMismatch e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidValue e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BadKind e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
Aggregations