@Override public void receiveInteraction( InteractionClassHandle interactionClass, ParameterHandleValueMap theParameters, byte[] tag, OrderType sentOrdering, TransportationTypeHandle theTransport, LogicalTime time, OrderType receivedOrdering, SupplementalReceiveInfo receiveInfo) throws FederateInternalError { StringBuilder builder = new StringBuilder("Interaction Received:"); HLAASCIIstring strParam = this._encoderFactory.createHLAASCIIstring(); // print the handle builder.append(" handle=" + interactionClass); if (interactionClass.equals(AddVehicle.handle)) { builder.append(" (VehicleHandle)"); } else if (interactionClass.equals(CreateObject.handle)) { builder.append(" (CreateObject)"); } else if (interactionClass.equals(DeleteObject.handle)) { builder.append(" (DeleteObject)"); } // print the tag builder.append(", tag=" + new String(tag)); // print the time (if we have it) we'll get null if we are just receiving // a forwarded call from the other reflect callback above if (time != null) { builder.append(", time=" + ((HLAfloat64Time) time).getValue()); } // print the parameter information builder.append(", parameterCount=" + theParameters.size()); builder.append("\n"); for (ParameterHandle parameter : theParameters.keySet()) { // print the parameter handle builder.append("\tparamHandle="); builder.append(parameter); try { if (parameter.equals(CreateObject.pos)) { builder.append(", paramValue="); builder.append(_positionRecordCoder.decode(theParameters.get(parameter))); } else { strParam.decode(theParameters.get(parameter)); // print the parameter value builder.append(", paramValue="); builder.append(strParam.getValue()); } } catch (DecoderException e) { builder.append("Couldn't read!"); } builder.append("\n"); } log(builder.toString()); }
@Override public void reflectAttributeValues( ObjectInstanceHandle theObject, AttributeHandleValueMap theAttributes, byte[] tag, OrderType sentOrdering, TransportationTypeHandle theTransport, LogicalTime time, OrderType receivedOrdering, SupplementalReflectInfo reflectInfo) throws FederateInternalError { StringBuilder builder = new StringBuilder("Reflection for object:"); // print the handle builder.append(" handle=" + theObject); // print the tag builder.append(", tag=" + new String(tag)); // print the time (if we have it) we'll get null if we are just receiving // a forwarded call from the other reflect callback above builder.append(", time=" + ((HLAfloat64Time) time).getValue()); // print the attribute information builder.append(", attributeCount=" + theAttributes.size()); builder.append("\n"); for (AttributeHandle attributeHandle : theAttributes.keySet()) { // print the attibute handle builder.append("\tattributeHandle="); // if we're dealing with Flavor, decode into the appropriate enum value if (attributeHandle.equals(Vehicle.position)) { builder.append(attributeHandle); builder.append(" (Position)"); builder.append(", attributeValue="); Position rec; try { rec = _positionRecordCoder.decode(theAttributes.get(attributeHandle)); builder.append(rec.toString()); } catch (DecoderException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { builder.append(attributeHandle); builder.append(" (Unknown) "); } builder.append("\n"); } log(builder.toString()); }