From eeff7499b4409470930d4ed0286d0880492d9475 Mon Sep 17 00:00:00 2001 From: "luke.cowan" Date: Fri, 13 Nov 2020 10:40:21 +0000 Subject: [PATCH 1/5] Created Beam class for ElectromagneticEmissionPdu dis7 --- pom.xml | 2 +- src/main/java/edu/nps/moves/dis7/Beam.java | 339 ++++++++++ .../moves/dis7/ElectronicEmissionsPdu.java | 578 ++++++++++-------- .../java/edu/nps/moves/dis7/PduFactory.java | 317 ++++++++++ .../java/edu/nps/moves/dis7/TrackJamData.java | 246 ++++---- 5 files changed, 1105 insertions(+), 377 deletions(-) create mode 100644 src/main/java/edu/nps/moves/dis7/Beam.java create mode 100644 src/main/java/edu/nps/moves/dis7/PduFactory.java diff --git a/pom.xml b/pom.xml index 508172cf..26910465 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ open-dis jar Open-DIS - 5.1-SNAPSHOT + 5.1.1-SNAPSHOT An open source implementation of the Distributed Interactive Simulation (DIS) IEEE-1278 protocol http://www.open-dis.org diff --git a/src/main/java/edu/nps/moves/dis7/Beam.java b/src/main/java/edu/nps/moves/dis7/Beam.java new file mode 100644 index 00000000..3d2628c9 --- /dev/null +++ b/src/main/java/edu/nps/moves/dis7/Beam.java @@ -0,0 +1,339 @@ +package edu.nps.moves.dis7; + + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.Serializable; +import java.util.Objects; + + +/** + * This field shall specify information about a particular active beam. Section 7.6.2. + * + * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. This work is licensed under the BSD open source + * license, available at https://www.movesinstitute.org/licenses/bsd.html + * @author DMcG + */ +public class Beam extends Object implements Serializable +{ + /** Specifies the length of this beam's data, 8 bit unsigned int */ + protected short beamDataLength; + + /** unique beam number, 8 bit unsigned int */ + protected short beamNumber; + + /** + * Used in conjunction with the Emitter Name field as a database primary key, this field shall specify a number by which receiving + * entities reference stored database parameters required to regenerate the beam., 16 bit unsigned int + */ + protected int beamParameterIndex; + + /** + * specify dynamic parameters of the emitter and shall be represented by an EE Fundamental Parameter Data record (see 6.2.22). + */ + protected EEFundamentalParameterData fundamentalParameterData = new EEFundamentalParameterData(); + + /** + * specify parameters of the beam and shall be represented by a Beam Data record (see 6.2.11) + */ + protected BeamData beamData = new BeamData(); + + /** + * specify the intended use of a particular beam. Typical functions include search, acquisition, tracking, illumination, jamming, and so + * on. This field is intended to help receiving entities determine the emission mode represented by the beam. This field shall be + * represented by an 8-bit enumeration + */ + protected short beamFunction; + + /** + * This field, in conjunction with the High-Density Track/Jam field, shall identify, for the current PDU and emitter beam, the number of + * entities tracked or under illumination (as appropriate for an emitter beam’s function) or the number of targeted emitter beams (for + * jammers). This field shall be represented by an 8-bit unsigned integer. + */ + protected short numberOfTargets; + + /** + * This field shall be used to indicate that receiving simulation applications can assume that all viable targets in the field of regard + * specified by the beam data are being tracked or jammed. This field shall be represented by an 8-bit enumeration + */ + protected short highDensityTrackJam; + + /** + * This field shall indicate the status of the beam (e.g., the beam is active or deactivated) and shall be represented by the Beam + * Status record (see 6.2.12) + */ + protected BeamStatus beamStatus = new BeamStatus(); + + /** + * Jamming Technique. This field shall be used to identify the jamming method or methods and shall be represented by a Jamming Technique + * record (see 6.2.49). + */ + protected JammingTechnique jammingTechnique = new JammingTechnique(); + + /** + * This field is optional for any given beam. Rules for inclusion and use are provided in 5.7.3.3, 5.7.3.7, and 5.7.3.8. When included, + * this field shall be represented by a series of Track/Jam Data records (see 6.2.90). + */ + protected TrackJamData trackJamData = new TrackJamData(); + + /** Constructor */ + public Beam() + { + } + + public int getMarshalledSize() + { + int marshalSize = 0; + + marshalSize = marshalSize + 1; // beamDataLength + marshalSize = marshalSize + 1; // beamNumber + marshalSize = marshalSize + 2; // beamParameterIndex + marshalSize = marshalSize + fundamentalParameterData.getMarshalledSize(); // fundamentalParameterData + marshalSize = marshalSize + beamData.getMarshalledSize(); // beamData + marshalSize = marshalSize + 1; // beamFunction + marshalSize = marshalSize + 1; // numberOfTargets + marshalSize = marshalSize + 1; // highDensityTrackJam + marshalSize = marshalSize + beamStatus.getMarshalledSize(); // beamStatus + marshalSize = marshalSize + jammingTechnique.getMarshalledSize(); // jammingTechnique + if (numberOfTargets != 0) { + marshalSize = marshalSize + trackJamData.getMarshalledSize(); // trackJamData + } + + return marshalSize; + } + + public EEFundamentalParameterData getFundamentalParameterData() + { + return fundamentalParameterData; + } + + public void setFundamentalParameterData(EEFundamentalParameterData fundamentalParameterData) + { + this.fundamentalParameterData = fundamentalParameterData; + } + + public BeamData getBeamData() + { + return beamData; + } + + public void setBeamData(BeamData beamData) + { + this.beamData = beamData; + } + + public short getBeamFunction() + { + return beamFunction; + } + + public void setBeamFunction(short beamFunction) + { + this.beamFunction = beamFunction; + } + + public short getNumberOfTargets() + { + return numberOfTargets; + } + + public void setNumberOfTargets(short numberOfTargets) + { + this.numberOfTargets = numberOfTargets; + } + + public short getHighDensityTrackJam() + { + return highDensityTrackJam; + } + + public void setHighDensityTrackJam(short highDensityTrackJam) + { + this.highDensityTrackJam = highDensityTrackJam; + } + + public BeamStatus getBeamStatus() + { + return beamStatus; + } + + public void setBeamStatus(BeamStatus beamStatus) + { + this.beamStatus = beamStatus; + } + + public JammingTechnique getJammingTechnique() + { + return jammingTechnique; + } + + public void setJammingTechnique(JammingTechnique jammingTechnique) + { + this.jammingTechnique = jammingTechnique; + } + + public TrackJamData getTrackJamData() + { + return trackJamData; + } + + public void setTrackJamData(TrackJamData trackJamData) + { + this.trackJamData = trackJamData; + } + + public int getBeamDataLength() + { + return beamDataLength; + } + + public void setBeamDataLength(short beamDataLength) + { + this.beamDataLength = beamDataLength; + } + + public short getBeamNumber() + { + return beamNumber; + } + + public void setBeamNumber(short pEmitterFunction) + { + beamNumber = pEmitterFunction; + } + + public int getBeamParameterIndex() + { + return beamParameterIndex; + } + + public void setBeamParameterIndex(short pEmitterIDNumber) + { + beamParameterIndex = pEmitterIDNumber; + } + + public void marshal(DataOutputStream dos) + { + try { + dos.writeByte((byte) beamDataLength); + dos.writeByte((byte) beamNumber); + dos.writeShort(beamParameterIndex); + fundamentalParameterData.marshal(dos); + beamData.marshal(dos); + dos.writeByte((byte) beamFunction); + dos.writeByte((byte) numberOfTargets); + dos.writeByte((byte) highDensityTrackJam); + beamStatus.marshal(dos); + jammingTechnique.marshal(dos); + if (numberOfTargets != 0) { //When the Number of Targets value is zero, this field shall be omitted + trackJamData.marshal(dos); + } + } // end try + catch (Exception e) { + System.out.println(e); + } + } // end of marshal method + + /** + * Packs a Pdu into the ByteBuffer. + * @param buff The ByteBuffer at the position to begin writing + * @throws java.nio.BufferOverflowException if buff is too small + * @throws java.nio.ReadOnlyBufferException if buff is read only + * @see java.nio.ByteBuffer + * @since ?? + */ + public void marshal(java.nio.ByteBuffer buff) + { + buff.put((byte) beamDataLength); + buff.put((byte) beamNumber); + buff.putShort((short) beamParameterIndex); + fundamentalParameterData.marshal(buff); + beamData.marshal(buff); + buff.put((byte) beamFunction); + buff.put((byte) numberOfTargets); + buff.put((byte) highDensityTrackJam); + beamStatus.marshal(buff); + jammingTechnique.marshal(buff); + if (numberOfTargets != 0) { //When the Number of Targets value is zero, this field shall be omitted + trackJamData.marshal(buff); + } + } // end of marshal method + + public void unmarshal(DataInputStream dis) + { + try { + beamDataLength = (short) dis.readUnsignedByte(); + beamNumber = (short) dis.readUnsignedByte(); + beamParameterIndex = dis.readUnsignedShort(); + fundamentalParameterData.unmarshal(dis); + beamData.unmarshal(dis); + beamFunction = (short) dis.readUnsignedShort(); + numberOfTargets = (short) dis.readUnsignedShort(); + highDensityTrackJam = (short) dis.readUnsignedShort(); + beamStatus.unmarshal(dis); + jammingTechnique.unmarshal(dis); + if (numberOfTargets != 0) { //When the Number of Targets value is zero, this field shall be omitted + trackJamData.unmarshal(dis); + } + + } // end try + catch (Exception e) { + System.out.println(e); + } + } // end of unmarshal method + + /** + * Unpacks a Pdu from the underlying data. + * @param buff The ByteBuffer at the position to begin reading + * @throws java.nio.BufferUnderflowException if buff is too small + * @see java.nio.ByteBuffer + * @since ?? + */ + public void unmarshal(java.nio.ByteBuffer buff) + { + beamDataLength = (short) ( buff.get() & 0xFF ); + beamNumber = (short) ( buff.get() & 0xFF ); + beamParameterIndex = ( buff.getShort() & 0xFFFF ); + fundamentalParameterData.unmarshal(buff); + beamData.unmarshal(buff); + beamFunction = (short) ( buff.get() & 0xFF ); + numberOfTargets = (short) ( buff.get() & 0xFF ); + highDensityTrackJam = (short) ( buff.get() & 0xFF ); + beamStatus.unmarshal(buff); + jammingTechnique.unmarshal(buff); + if (numberOfTargets != 0) { //When the Number of Targets value is zero, this field shall be omitted + trackJamData.unmarshal(buff); + } + } // end of unmarshal method + + @Override + public boolean equals(Object o) + { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Beam beam = (Beam) o; + return beamDataLength == beam.beamDataLength && + beamNumber == beam.beamNumber && + beamParameterIndex == beam.beamParameterIndex && + beamFunction == beam.beamFunction && + numberOfTargets == beam.numberOfTargets && + highDensityTrackJam == beam.highDensityTrackJam && + Objects.equals(fundamentalParameterData, beam.fundamentalParameterData) && + Objects.equals(beamData, beam.beamData) && + Objects.equals(beamStatus, beam.beamStatus) && + Objects.equals(jammingTechnique, beam.jammingTechnique) && + Objects.equals(trackJamData, beam.trackJamData); + } + + @Override + public int hashCode() + { + return Objects + .hash(beamDataLength, beamNumber, beamParameterIndex, fundamentalParameterData, beamData, beamFunction, numberOfTargets, highDensityTrackJam, beamStatus, jammingTechnique, trackJamData); + } + +} // end of class diff --git a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java index 2f75b69c..db89ef98 100644 --- a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java +++ b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java @@ -1,327 +1,365 @@ package edu.nps.moves.dis7; -import java.util.*; -import java.io.*; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** - * Section 5.3.7.1. Information about active electronic warfare (EW) emissions and active EW countermeasures shall be communicated using an Electromagnetic Emission PDU. NOT COMPLETE - * - * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. - * This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html + * Section 5.3.7.1. Information about active electronic warfare (EW) emissions and active EW countermeasures shall be communicated using an + * Electromagnetic Emission PDU. NOT COMPLETE * + * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. This work is licensed under the BSD open source + * license, available at https://www.movesinstitute.org/licenses/bsd.html * @author DMcG */ public class ElectronicEmissionsPdu extends DistributedEmissionsFamilyPdu implements Serializable { - /** ID of the entity emitting */ - protected EntityID emittingEntityID = new EntityID(); + /** ID of the entity emitting */ + protected EntityID emittingEntityID = new EntityID(); - /** ID of event */ - protected EventIdentifier eventID = new EventIdentifier(); + /** ID of event */ + protected EventIdentifier eventID = new EventIdentifier(); - /** This field shall be used to indicate if the data in the PDU represents a state update or just data that has changed since issuance of the last Electromagnetic Emission PDU [relative to the identified entity and emission system(s)]. */ - protected short stateUpdateIndicator; + /** + * This field shall be used to indicate if the data in the PDU represents a state update or just data that has changed since issuance of + * the last Electromagnetic Emission PDU [relative to the identified entity and emission system(s)]. + */ + protected short stateUpdateIndicator; - /** This field shall specify the number of emission systems being described in the current PDU. */ - protected short numberOfSystems; + /** This field shall specify the number of emission systems being described in the current PDU. */ + protected short numberOfSystems; - /** padding */ - protected int paddingForEmissionsPdu; + /** padding */ + protected int paddingForEmissionsPdu; - /** this field shall specify the length of this emitter system's data in 32-bit words. */ - protected short systemDataLength; + /** this field shall specify the length of this emitter system's data in 32-bit words. */ + protected short systemDataLength; - /** the number of beams being described in the current PDU for the emitter system being described. */ - protected short numberOfBeams; + /** the number of beams being described in the current PDU for the emitter system being described. */ + protected short numberOfBeams; - /** information about a particular emitter system and shall be represented by an Emitter System record (see 6.2.23). */ - protected EmitterSystem emitterSystem = new EmitterSystem(); + /** information about a particular emitter system and shall be represented by an Emitter System record (see 6.2.23). */ + protected EmitterSystem emitterSystem = new EmitterSystem(); - /** the location of the antenna beam source with respect to the emitting entity's coordinate system. This location shall be the origin of the emitter coordinate system that shall have the same orientation as the entity coordinate system. This field shall be represented by an Entity Coordinate Vector record see 6.2.95 */ - protected Vector3Float location = new Vector3Float(); + /** + * the location of the antenna beam source with respect to the emitting entity's coordinate system. This location shall be the origin of + * the emitter coordinate system that shall have the same orientation as the entity coordinate system. This field shall be represented + * by an Entity Coordinate Vector record see 6.2.95 + */ + protected Vector3Float location = new Vector3Float(); - /** Electronic emmissions systems THIS IS WRONG. It has the WRONG class type and will cause problems in any marshalling. */ - protected List< Vector3Float > systems = new ArrayList< Vector3Float >(); + /** Electronic emmissions systems THIS IS WRONG. It has the WRONG class type and will cause problems in any marshalling. */ + protected List systems = new ArrayList<>(); + protected Beam beam = new Beam(); -/** Constructor */ - public ElectronicEmissionsPdu() - { - setPduType( (short)23 ); - setPaddingForEmissionsPdu( (int)0 ); - } + /** Constructor */ + public ElectronicEmissionsPdu() + { + setPduType((short) 23); + setPaddingForEmissionsPdu((int) 0); + } -public int getMarshalledSize() -{ - int marshalSize = 0; - - marshalSize = super.getMarshalledSize(); - marshalSize = marshalSize + emittingEntityID.getMarshalledSize(); // emittingEntityID - marshalSize = marshalSize + eventID.getMarshalledSize(); // eventID - marshalSize = marshalSize + 1; // stateUpdateIndicator - marshalSize = marshalSize + 1; // numberOfSystems - marshalSize = marshalSize + 2; // paddingForEmissionsPdu - marshalSize = marshalSize + 1; // systemDataLength - marshalSize = marshalSize + 1; // numberOfBeams - marshalSize = marshalSize + emitterSystem.getMarshalledSize(); // emitterSystem - marshalSize = marshalSize + location.getMarshalledSize(); // location - for(int idx=0; idx < systems.size(); idx++) - { - Vector3Float listElement = systems.get(idx); - marshalSize = marshalSize + listElement.getMarshalledSize(); - } - - return marshalSize; -} - - -public void setEmittingEntityID(EntityID pEmittingEntityID) -{ emittingEntityID = pEmittingEntityID; -} - -public EntityID getEmittingEntityID() -{ return emittingEntityID; -} - -public void setEventID(EventIdentifier pEventID) -{ eventID = pEventID; -} - -public EventIdentifier getEventID() -{ return eventID; -} - -public void setStateUpdateIndicator(short pStateUpdateIndicator) -{ stateUpdateIndicator = pStateUpdateIndicator; -} - -public short getStateUpdateIndicator() -{ return stateUpdateIndicator; -} - -public short getNumberOfSystems() -{ return (short)systems.size(); -} - -/** Note that setting this value will not change the marshalled value. The list whose length this describes is used for that purpose. - * The getnumberOfSystems method will also be based on the actual list length rather than this value. - * The method is simply here for java bean completeness. - */ -public void setNumberOfSystems(short pNumberOfSystems) -{ numberOfSystems = pNumberOfSystems; -} + public int getMarshalledSize() + { + int marshalSize = 0; + + marshalSize = super.getMarshalledSize(); + marshalSize = marshalSize + emittingEntityID.getMarshalledSize(); // emittingEntityID + marshalSize = marshalSize + eventID.getMarshalledSize(); // eventID + marshalSize = marshalSize + 1; // stateUpdateIndicator + marshalSize = marshalSize + 1; // numberOfSystems + marshalSize = marshalSize + 2; // paddingForEmissionsPdu + marshalSize = marshalSize + 1; // systemDataLength + marshalSize = marshalSize + 1; // numberOfBeams + marshalSize = marshalSize + 2; // paddingForEmissionsPdu + marshalSize = marshalSize + emitterSystem.getMarshalledSize(); // emitterSystem + marshalSize = marshalSize + location.getMarshalledSize(); // location + marshalSize = marshalSize + beam.getMarshalledSize(); // beam + + return marshalSize; + } -public void setPaddingForEmissionsPdu(int pPaddingForEmissionsPdu) -{ paddingForEmissionsPdu = pPaddingForEmissionsPdu; -} + public EntityID getEmittingEntityID() + { + return emittingEntityID; + } + + public void setEmittingEntityID(EntityID pEmittingEntityID) + { + emittingEntityID = pEmittingEntityID; + } -public int getPaddingForEmissionsPdu() -{ return paddingForEmissionsPdu; -} + public EventIdentifier getEventID() + { + return eventID; + } -public void setSystemDataLength(short pSystemDataLength) -{ systemDataLength = pSystemDataLength; -} + public void setEventID(EventIdentifier pEventID) + { + eventID = pEventID; + } -public short getSystemDataLength() -{ return systemDataLength; -} + public short getStateUpdateIndicator() + { + return stateUpdateIndicator; + } -public void setNumberOfBeams(short pNumberOfBeams) -{ numberOfBeams = pNumberOfBeams; -} + public void setStateUpdateIndicator(short pStateUpdateIndicator) + { + stateUpdateIndicator = pStateUpdateIndicator; + } -public short getNumberOfBeams() -{ return numberOfBeams; -} + public short getNumberOfSystems() + { + return (short) systems.size(); + } -public void setEmitterSystem(EmitterSystem pEmitterSystem) -{ emitterSystem = pEmitterSystem; -} + public Beam getBeam() + { + return beam; + } -public EmitterSystem getEmitterSystem() -{ return emitterSystem; -} + public void setBeam(Beam beam) + { + this.beam = beam; + } -public void setLocation(Vector3Float pLocation) -{ location = pLocation; -} + /** + * Note that setting this value will not change the marshalled value. The list whose length this describes is used for that purpose. The + * getnumberOfSystems method will also be based on the actual list length rather than this value. The method is simply here for java + * bean completeness. + */ + public void setNumberOfSystems(short pNumberOfSystems) + { + numberOfSystems = pNumberOfSystems; + } -public Vector3Float getLocation() -{ return location; -} + public int getPaddingForEmissionsPdu() + { + return paddingForEmissionsPdu; + } -public void setSystems(List pSystems) -{ systems = pSystems; -} + public void setPaddingForEmissionsPdu(int pPaddingForEmissionsPdu) + { + paddingForEmissionsPdu = pPaddingForEmissionsPdu; + } -public List getSystems() -{ return systems; } + public short getSystemDataLength() + { + return systemDataLength; + } + public void setSystemDataLength(short pSystemDataLength) + { + systemDataLength = pSystemDataLength; + } -public void marshal(DataOutputStream dos) -{ - super.marshal(dos); - try + public short getNumberOfBeams() { - emittingEntityID.marshal(dos); - eventID.marshal(dos); - dos.writeByte( (byte)stateUpdateIndicator); - dos.writeByte( (byte)systems.size()); - dos.writeShort( (short)paddingForEmissionsPdu); - dos.writeByte( (byte)systemDataLength); - dos.writeByte( (byte)numberOfBeams); - emitterSystem.marshal(dos); - location.marshal(dos); - - for(int idx = 0; idx < systems.size(); idx++) - { - Vector3Float aVector3Float = systems.get(idx); - aVector3Float.marshal(dos); - } // end of list marshalling - - } // end try - catch(Exception e) - { - System.out.println(e);} - } // end of marshal method + return numberOfBeams; + } -public void unmarshal(DataInputStream dis) -{ - super.unmarshal(dis); + public void setNumberOfBeams(short pNumberOfBeams) + { + numberOfBeams = pNumberOfBeams; + } - try + public EmitterSystem getEmitterSystem() { - emittingEntityID.unmarshal(dis); - eventID.unmarshal(dis); - stateUpdateIndicator = (short)dis.readUnsignedByte(); - numberOfSystems = (short)dis.readUnsignedByte(); - paddingForEmissionsPdu = (int)dis.readUnsignedShort(); - systemDataLength = (short)dis.readUnsignedByte(); - numberOfBeams = (short)dis.readUnsignedByte(); - emitterSystem.unmarshal(dis); - location.unmarshal(dis); - for(int idx = 0; idx < numberOfSystems; idx++) - { - Vector3Float anX = new Vector3Float(); - anX.unmarshal(dis); - systems.add(anX); - } - - } // end try - catch(Exception e) - { - System.out.println(e); + return emitterSystem; } - } // end of unmarshal method + public void setEmitterSystem(EmitterSystem pEmitterSystem) + { + emitterSystem = pEmitterSystem; + } -/** - * Packs a Pdu into the ByteBuffer. - * @throws java.nio.BufferOverflowException if buff is too small - * @throws java.nio.ReadOnlyBufferException if buff is read only - * @see java.nio.ByteBuffer - * @param buff The ByteBuffer at the position to begin writing - * @since ?? - */ -public void marshal(java.nio.ByteBuffer buff) -{ - super.marshal(buff); - emittingEntityID.marshal(buff); - eventID.marshal(buff); - buff.put( (byte)stateUpdateIndicator); - buff.put( (byte)systems.size()); - buff.putShort( (short)paddingForEmissionsPdu); - buff.put( (byte)systemDataLength); - buff.put( (byte)numberOfBeams); - emitterSystem.marshal(buff); - location.marshal(buff); - - for(int idx = 0; idx < systems.size(); idx++) - { - Vector3Float aVector3Float = (Vector3Float)systems.get(idx); - aVector3Float.marshal(buff); - } // end of list marshalling + public Vector3Float getLocation() + { + return location; + } - } // end of marshal method + public void setLocation(Vector3Float pLocation) + { + location = pLocation; + } -/** - * Unpacks a Pdu from the underlying data. - * @throws java.nio.BufferUnderflowException if buff is too small - * @see java.nio.ByteBuffer - * @param buff The ByteBuffer at the position to begin reading - * @since ?? - */ -public void unmarshal(java.nio.ByteBuffer buff) -{ - super.unmarshal(buff); - - emittingEntityID.unmarshal(buff); - eventID.unmarshal(buff); - stateUpdateIndicator = (short)(buff.get() & 0xFF); - numberOfSystems = (short)(buff.get() & 0xFF); - paddingForEmissionsPdu = (int)(buff.getShort() & 0xFFFF); - systemDataLength = (short)(buff.get() & 0xFF); - numberOfBeams = (short)(buff.get() & 0xFF); - emitterSystem.unmarshal(buff); - location.unmarshal(buff); - for(int idx = 0; idx < numberOfSystems; idx++) - { - Vector3Float anX = new Vector3Float(); - anX.unmarshal(buff); - systems.add(anX); - } - - } // end of unmarshal method - - - /* - * The equals method doesn't always work--mostly it works only on classes that consist only of primitives. Be careful. - */ -@Override - public boolean equals(Object obj) - { - - if(this == obj){ - return true; + public List getSystems() + { + return systems; } - if(obj == null){ - return false; + public void setSystems(List pSystems) + { + systems = pSystems; } - if(getClass() != obj.getClass()) - return false; + public void marshal(DataOutputStream dos) + { + super.marshal(dos); + try { + emittingEntityID.marshal(dos); + eventID.marshal(dos); + dos.writeByte((byte) stateUpdateIndicator); + dos.writeByte((byte) systems.size()); + dos.writeShort((short) paddingForEmissionsPdu); + dos.writeByte((byte) systemDataLength); + dos.writeByte((byte) numberOfBeams); + emitterSystem.marshal(dos); + location.marshal(dos); + beam.marshal(dos); + + } // end try + catch (Exception e) { + System.out.println(e); + } + } // end of marshal method - return equalsImpl(obj); - } + public void unmarshal(DataInputStream dis) + { + super.unmarshal(dis); + + try { + emittingEntityID.unmarshal(dis); + eventID.unmarshal(dis); + stateUpdateIndicator = (short) dis.readUnsignedByte(); + numberOfSystems = (short) dis.readUnsignedByte(); + paddingForEmissionsPdu = (int) dis.readUnsignedShort(); + systemDataLength = (short) dis.readUnsignedByte(); + numberOfBeams = (short) dis.readUnsignedByte(); + emitterSystem.unmarshal(dis); + location.unmarshal(dis); + beam.unmarshal(dis); + + } // end try + catch (Exception e) { + System.out.println(e); + } + } // end of unmarshal method + + + /** + * Packs a Pdu into the ByteBuffer. + * @param buff The ByteBuffer at the position to begin writing + * @throws java.nio.BufferOverflowException if buff is too small + * @throws java.nio.ReadOnlyBufferException if buff is read only + * @see java.nio.ByteBuffer + * @since ?? + */ + public void marshal(java.nio.ByteBuffer buff) + { + super.marshal(buff); + emittingEntityID.marshal(buff); + eventID.marshal(buff); + buff.put((byte) stateUpdateIndicator); + buff.put((byte) systems.size()); + buff.putShort((short) paddingForEmissionsPdu); + buff.put((byte) systemDataLength); + buff.put((byte) numberOfBeams); + emitterSystem.marshal(buff); + location.marshal(buff); + beam.marshal(buff); -@Override - public boolean equalsImpl(Object obj) - { - boolean ivarsEqual = true; + } // end of marshal method - if(!(obj instanceof ElectronicEmissionsPdu)) - return false; + /** + * Unpacks a Pdu from the underlying data. + * @param buff The ByteBuffer at the position to begin reading + * @throws java.nio.BufferUnderflowException if buff is too small + * @see java.nio.ByteBuffer + * @since ?? + */ + public void unmarshal(java.nio.ByteBuffer buff) + { + super.unmarshal(buff); + + emittingEntityID.unmarshal(buff); + eventID.unmarshal(buff); + stateUpdateIndicator = (short) ( buff.get() & 0xFF ); + numberOfSystems = (short) ( buff.get() & 0xFF ); + paddingForEmissionsPdu = (int) ( buff.getShort() & 0xFFFF ); + systemDataLength = (short) ( buff.get() & 0xFF ); + numberOfBeams = (short) ( buff.get() & 0xFF ); + buff.getShort(); // remove padding + emitterSystem.unmarshal(buff); + location.unmarshal(buff); + beam.unmarshal(buff); + + } // end of unmarshal method + + + /* + * The equals method doesn't always work--mostly it works only on classes that consist only of primitives. Be careful. + */ + @Override + public boolean equals(Object obj) + { - final ElectronicEmissionsPdu rhs = (ElectronicEmissionsPdu)obj; + if (this == obj) { + return true; + } - if( ! (emittingEntityID.equals( rhs.emittingEntityID) )) ivarsEqual = false; - if( ! (eventID.equals( rhs.eventID) )) ivarsEqual = false; - if( ! (stateUpdateIndicator == rhs.stateUpdateIndicator)) ivarsEqual = false; - if( ! (numberOfSystems == rhs.numberOfSystems)) ivarsEqual = false; - if( ! (paddingForEmissionsPdu == rhs.paddingForEmissionsPdu)) ivarsEqual = false; - if( ! (systemDataLength == rhs.systemDataLength)) ivarsEqual = false; - if( ! (numberOfBeams == rhs.numberOfBeams)) ivarsEqual = false; - if( ! (emitterSystem.equals( rhs.emitterSystem) )) ivarsEqual = false; - if( ! (location.equals( rhs.location) )) ivarsEqual = false; + if (obj == null) { + return false; + } - for(int idx = 0; idx < systems.size(); idx++) - { - if( ! ( systems.get(idx).equals(rhs.systems.get(idx)))) ivarsEqual = false; - } + if (getClass() != obj.getClass()) { + return false; + } + return equalsImpl(obj); + } - return ivarsEqual && super.equalsImpl(rhs); - } + @Override + public boolean equalsImpl(Object obj) + { + boolean ivarsEqual = true; + + if (!( obj instanceof ElectronicEmissionsPdu )) { + return false; + } + + final ElectronicEmissionsPdu rhs = (ElectronicEmissionsPdu) obj; + + if (!( emittingEntityID.equals(rhs.emittingEntityID) )) { + ivarsEqual = false; + } + if (!( eventID.equals(rhs.eventID) )) { + ivarsEqual = false; + } + if (!( stateUpdateIndicator == rhs.stateUpdateIndicator )) { + ivarsEqual = false; + } + if (!( numberOfSystems == rhs.numberOfSystems )) { + ivarsEqual = false; + } + if (!( paddingForEmissionsPdu == rhs.paddingForEmissionsPdu )) { + ivarsEqual = false; + } + if (!( systemDataLength == rhs.systemDataLength )) { + ivarsEqual = false; + } + if (!( numberOfBeams == rhs.numberOfBeams )) { + ivarsEqual = false; + } + if (!( emitterSystem.equals(rhs.emitterSystem) )) { + ivarsEqual = false; + } + if (!( location.equals(rhs.location) )) { + ivarsEqual = false; + } + + for (int idx = 0; idx < systems.size(); idx++) { + if (!( systems.get(idx).equals(rhs.systems.get(idx)) )) { + ivarsEqual = false; + } + } + + + return ivarsEqual && super.equalsImpl(rhs); + } } // end of class diff --git a/src/main/java/edu/nps/moves/dis7/PduFactory.java b/src/main/java/edu/nps/moves/dis7/PduFactory.java new file mode 100644 index 00000000..2ea5a7f4 --- /dev/null +++ b/src/main/java/edu/nps/moves/dis7/PduFactory.java @@ -0,0 +1,317 @@ +package edu.nps.moves.dis7; + + +import edu.nps.moves.dis7.AcknowledgePdu; +import edu.nps.moves.dis7.AcknowledgeReliablePdu; +import edu.nps.moves.dis7.ActionRequestPdu; +import edu.nps.moves.dis7.ActionRequestReliablePdu; +import edu.nps.moves.dis7.ActionResponsePdu; +import edu.nps.moves.dis7.ActionResponseReliablePdu; +import edu.nps.moves.dis7.ArealObjectStatePdu; +import edu.nps.moves.dis7.CollisionElasticPdu; +import edu.nps.moves.dis7.CollisionPdu; +import edu.nps.moves.dis7.CommentPdu; +import edu.nps.moves.dis7.CommentReliablePdu; +import edu.nps.moves.dis7.CreateEntityPdu; +import edu.nps.moves.dis7.CreateEntityReliablePdu; +import edu.nps.moves.dis7.DataPdu; +import edu.nps.moves.dis7.DataQueryPdu; +import edu.nps.moves.dis7.DataQueryReliablePdu; +import edu.nps.moves.dis7.DataReliablePdu; +import edu.nps.moves.dis7.DesignatorPdu; +import edu.nps.moves.dis7.DetonationPdu; +import edu.nps.moves.dis7.ElectronicEmissionsPdu; +import edu.nps.moves.dis7.EntityStatePdu; +import edu.nps.moves.dis7.EntityStateUpdatePdu; +import edu.nps.moves.dis7.EventReportPdu; +import edu.nps.moves.dis7.EventReportReliablePdu; +import edu.nps.moves.dis7.FastEntityStatePdu; +import edu.nps.moves.dis7.FirePdu; +import edu.nps.moves.dis7.IntercomControlPdu; +import edu.nps.moves.dis7.IntercomSignalPdu; +import edu.nps.moves.dis7.IsPartOfPdu; +import edu.nps.moves.dis7.LinearObjectStatePdu; +import edu.nps.moves.dis7.MinefieldResponseNackPdu; +import edu.nps.moves.dis7.MinefieldStatePdu; +import edu.nps.moves.dis7.Pdu; +import edu.nps.moves.dis7.PointObjectStatePdu; +import edu.nps.moves.dis7.ReceiverPdu; +import edu.nps.moves.dis7.RecordQueryReliablePdu; +import edu.nps.moves.dis7.RemoveEntityPdu; +import edu.nps.moves.dis7.RemoveEntityReliablePdu; +import edu.nps.moves.dis7.RepairCompletePdu; +import edu.nps.moves.dis7.RepairResponsePdu; +import edu.nps.moves.dis7.ResupplyOfferPdu; +import edu.nps.moves.dis7.ResupplyReceivedPdu; +import edu.nps.moves.dis7.SeesPdu; +import edu.nps.moves.dis7.ServiceRequestPdu; +import edu.nps.moves.dis7.SetDataPdu; +import edu.nps.moves.dis7.SetDataReliablePdu; +import edu.nps.moves.dis7.SignalPdu; +import edu.nps.moves.dis7.StartResumePdu; +import edu.nps.moves.dis7.StartResumeReliablePdu; +import edu.nps.moves.dis7.StopFreezePdu; +import edu.nps.moves.dis7.StopFreezeReliablePdu; +import edu.nps.moves.dis7.TransmitterPdu; +import edu.nps.moves.dis7.UaPdu; +import edu.nps.moves.disenum.PduType; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + + +public class PduFactory +{ + private boolean useFastPdu; + private Logger logger; + + public PduFactory() + { + this(false); + } + + public PduFactory(boolean useFastPdu) + { + this.useFastPdu = false; + this.useFastPdu = useFastPdu; + this.logger = Logger.getLogger(edu.nps.moves.disutil.PduFactory.class.getName()); + this.logger.setLevel(Level.OFF); + } + + public boolean getUseFastPdu() + { + return this.useFastPdu; + } + + public void setUseFastPdu(boolean use) + { + this.useFastPdu = use; + } + + public void setLoggingLevel(Level loggingLevel) + { + this.logger.setLevel(loggingLevel); + } + + public Pdu createPdu(byte[] data) + { + return this.createPdu(ByteBuffer.wrap(data)); + } + + public Pdu createPdu(ByteBuffer buff) + { + int pos = buff.position(); + if (pos + 2 > buff.limit()) { + return null; + } else { + buff.position(pos + 2); + int pduType = buff.get() & 255; + buff.position(pos); + PduType pduTypeEnum = PduType.lookup[pduType]; + Pdu aPdu = null; + switch (pduTypeEnum) { + case ENTITY_STATE: + if (this.useFastPdu) { + aPdu = new FastEntityStatePdu(); + } else { + aPdu = new EntityStatePdu(); + } + break; + case FIRE: + aPdu = new FirePdu(); + break; + case DETONATION: + aPdu = new DetonationPdu(); + break; + case COLLISION: + aPdu = new CollisionPdu(); + break; + case SERVICE_REQUEST: + aPdu = new ServiceRequestPdu(); + break; + case RESUPPLY_OFFER: + aPdu = new ResupplyOfferPdu(); + break; + case RESUPPLY_RECEIVED: + aPdu = new ResupplyReceivedPdu(); + break; + case REPAIR_COMPLETE: + aPdu = new RepairCompletePdu(); + break; + case REPAIR_RESPONSE: + aPdu = new RepairResponsePdu(); + break; + case CREATE_ENTITY: + aPdu = new CreateEntityPdu(); + break; + case REMOVE_ENTITY: + aPdu = new RemoveEntityPdu(); + break; + case START_RESUME: + aPdu = new StartResumePdu(); + break; + case STOP_FREEZE: + aPdu = new StopFreezePdu(); + break; + case ACKNOWLEDGE: + aPdu = new AcknowledgePdu(); + break; + case ACTION_REQUEST: + aPdu = new ActionRequestPdu(); + break; + case ACTION_RESPONSE: + aPdu = new ActionResponsePdu(); + break; + case DATA_QUERY: + aPdu = new DataQueryPdu(); + break; + case SET_DATA: + aPdu = new SetDataPdu(); + break; + case DATA: + aPdu = new DataPdu(); + break; + case EVENT_REPORT: + aPdu = new EventReportPdu(); + break; + case COMMENT: + aPdu = new CommentPdu(); + break; + case ELECTROMAGNETIC_EMISSION: + aPdu = new ElectronicEmissionsPdu(); + break; + case DESIGNATOR: + aPdu = new DesignatorPdu(); + break; + case TRANSMITTER: + aPdu = new TransmitterPdu(); + break; + case SIGNAL: + aPdu = new SignalPdu(); + break; + case RECEIVER: + aPdu = new ReceiverPdu(); + break; + case UNDERWATER_ACOUSTIC: + aPdu = new UaPdu(); + break; + case SUPPLEMENTAL_EMISSION_ENTITY_STATE: + aPdu = new SeesPdu(); + break; + case INTERCOM_SIGNAL: + aPdu = new IntercomSignalPdu(); + break; + case INTERCOM_CONTROL: + aPdu = new IntercomControlPdu(); + break; + case ISPARTOF: + aPdu = new IsPartOfPdu(); + break; + case MINEFIELD_STATE: + aPdu = new MinefieldStatePdu(); + break; + case MINEFIELD_RESPONSE_NAK: + aPdu = new MinefieldResponseNackPdu(); + break; + case POINT_OBJECT_STATE: + aPdu = new PointObjectStatePdu(); + break; + case LINEAR_OBJECT_STATE: + aPdu = new LinearObjectStatePdu(); + break; + case AREAL_OBJECT_STATE: + aPdu = new ArealObjectStatePdu(); + break; + case CREATE_ENTITY_R: + aPdu = new CreateEntityReliablePdu(); + break; + case REMOVE_ENTITY_R: + aPdu = new RemoveEntityReliablePdu(); + break; + case START_RESUME_R: + aPdu = new StartResumeReliablePdu(); + break; + case STOP_FREEZE_R: + aPdu = new StopFreezeReliablePdu(); + break; + case ACKNOWLEDGE_R: + aPdu = new AcknowledgeReliablePdu(); + break; + case ACTION_REQUEST_R: + aPdu = new ActionRequestReliablePdu(); + break; + case ACTION_RESPONSE_R: + aPdu = new ActionResponseReliablePdu(); + break; + case DATA_QUERY_R: + aPdu = new DataQueryReliablePdu(); + break; + case SET_DATA_R: + aPdu = new SetDataReliablePdu(); + break; + case DATA_R: + aPdu = new DataReliablePdu(); + break; + case EVENT_REPORT_R: + aPdu = new EventReportReliablePdu(); + break; + case COMMENT_R: + aPdu = new CommentReliablePdu(); + break; + case RECORD_QUERY_R: + aPdu = new RecordQueryReliablePdu(); + break; + case COLLISION_ELASTIC: + aPdu = new CollisionElasticPdu(); + break; + case ENTITY_STATE_UPDATE: + aPdu = new EntityStateUpdatePdu(); + break; + default: + this.logger.log(Level.INFO, "PDU not implemented. Type = " + pduType + "\n"); + if (pduTypeEnum != null) { + this.logger.log(Level.INFO, " PDU name is: " + pduTypeEnum.getDescription()); + } + } + + if (aPdu != null) { + ( (Pdu) aPdu ).unmarshal(buff); + } + + return (Pdu) aPdu; + } + } + + public List getPdusFromBundle(byte[] data) + { + ArrayList pdus = new ArrayList(); + int pduStartPointInData = 0; + + while (true) { + byte[] remaining = Arrays.copyOfRange(data, pduStartPointInData, data.length); + + try { + Pdu pdu = this.createPdu(remaining); + if (pdu == null) { + break; + } + + pdus.add(pdu); + int pduLength = pdu.getLength(); + pduStartPointInData += pduLength; + if (pduStartPointInData >= data.length) { + break; + } + } catch (Exception var7) { + System.out.println("Problems decoding multiple PDUs in datagram; decoded as may as possible"); + break; + } + } + + return pdus; + } +} diff --git a/src/main/java/edu/nps/moves/dis7/TrackJamData.java b/src/main/java/edu/nps/moves/dis7/TrackJamData.java index d95ba9ba..1db62aa9 100644 --- a/src/main/java/edu/nps/moves/dis7/TrackJamData.java +++ b/src/main/java/edu/nps/moves/dis7/TrackJamData.java @@ -1,140 +1,174 @@ package edu.nps.moves.dis7; -import java.io.*; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.Serializable; +import java.nio.ByteBuffer; /** - * Track-Jam data Section 6.2.89 - * - * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. - * This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html + * Track-Jam data Section 6.2.89 * + * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. This work is licensed under the BSD open source + * license, available at https://www.movesinstitute.org/licenses/bsd.html * @author DMcG */ public class TrackJamData extends Object implements Serializable { - /** the entity tracked or illumated, or an emitter beam targeted with jamming */ - protected EntityID entityID = new EntityID(); - - /** Emitter system associated with the entity */ - protected short emitterNumber; - - /** Beam associated with the entity */ - protected short beamNumber; - - -/** Constructor */ - public TrackJamData() - { - } - -public int getMarshalledSize() -{ - int marshalSize = 0; - - marshalSize = marshalSize + entityID.getMarshalledSize(); // entityID - marshalSize = marshalSize + 1; // emitterNumber - marshalSize = marshalSize + 1; // beamNumber + /** the entity tracked or illumated, or an emitter beam targeted with jamming */ + protected EntityID entityID = new EntityID(); - return marshalSize; -} + /** Emitter system associated with the entity */ + protected short emitterNumber; + /** Beam associated with the entity */ + protected short beamNumber; -public void setEntityID(EntityID pEntityID) -{ entityID = pEntityID; -} -public EntityID getEntityID() -{ return entityID; -} - -public void setEmitterNumber(short pEmitterNumber) -{ emitterNumber = pEmitterNumber; -} + /** Constructor */ + public TrackJamData() + { + } -public short getEmitterNumber() -{ return emitterNumber; -} + public int getMarshalledSize() + { + int marshalSize = 0; -public void setBeamNumber(short pBeamNumber) -{ beamNumber = pBeamNumber; -} + marshalSize = marshalSize + entityID.getMarshalledSize(); // entityID + marshalSize = marshalSize + 1; // emitterNumber + marshalSize = marshalSize + 1; // beamNumber -public short getBeamNumber() -{ return beamNumber; -} + return marshalSize; + } + public EntityID getEntityID() + { + return entityID; + } -/** - * Packs a Pdu into the ByteBuffer. - * @throws java.nio.BufferOverflowException if buff is too small - * @throws java.nio.ReadOnlyBufferException if buff is read only - * @see java.nio.ByteBuffer - * @param buff The ByteBuffer at the position to begin writing - * @since ?? - */ -public void marshal(java.nio.ByteBuffer buff) -{ - entityID.marshal(buff); - buff.put( (byte)emitterNumber); - buff.put( (byte)beamNumber); - } // end of marshal method + public void setEntityID(EntityID pEntityID) + { + entityID = pEntityID; + } -/** - * Unpacks a Pdu from the underlying data. - * @throws java.nio.BufferUnderflowException if buff is too small - * @see java.nio.ByteBuffer - * @param buff The ByteBuffer at the position to begin reading - * @since ?? - */ -public void unmarshal(java.nio.ByteBuffer buff) -{ - entityID.unmarshal(buff); - emitterNumber = (short)(buff.get() & 0xFF); - beamNumber = (short)(buff.get() & 0xFF); - } // end of unmarshal method + public short getEmitterNumber() + { + return emitterNumber; + } + public void setEmitterNumber(short pEmitterNumber) + { + emitterNumber = pEmitterNumber; + } - /* - * The equals method doesn't always work--mostly it works only on classes that consist only of primitives. Be careful. - */ -@Override - public boolean equals(Object obj) - { + public short getBeamNumber() + { + return beamNumber; + } - if(this == obj){ - return true; + public void setBeamNumber(short pBeamNumber) + { + beamNumber = pBeamNumber; } - if(obj == null){ - return false; + /** + * Packs a Pdu into the DataOutputStream. + */ + public void marshal(DataOutputStream dos) + { + entityID.marshal(dos); + try { + dos.writeByte((byte) emitterNumber); + dos.writeByte((byte) beamNumber); + } catch (IOException e) { + System.out.println(e); + } + } // end of marshal method + /** + * Packs a Pdu into the ByteBuffer. + * @throws java.nio.BufferOverflowException if buff is too small + * @throws java.nio.ReadOnlyBufferException if buff is read only + * @see java.nio.ByteBuffer + * @param buff The ByteBuffer at the position to begin writing + * @since ?? + */ + public void marshal(java.nio.ByteBuffer buff) + { + entityID.marshal(buff); + buff.put( (byte)emitterNumber); + buff.put( (byte)beamNumber); + } // end of marshal method + /** + * Unpacks a Pdu from the underlying data. + */ + public void unmarshal(DataInputStream dis) + { + try { + entityID.unmarshal(dis); + emitterNumber = (short) dis.readUnsignedShort(); + beamNumber = (short) dis.readUnsignedShort(); + } catch (IOException e) { + e.printStackTrace(); + } + } // end of unmarshal method + + public void unmarshal(ByteBuffer buff) + { + entityID.unmarshal(buff); + emitterNumber = (short)(buff.get() & 0xFF); + beamNumber = (short)(buff.get() & 0xFF); } - if(getClass() != obj.getClass()) - return false; + /* + * The equals method doesn't always work--mostly it works only on classes that consist only of primitives. Be careful. + */ + @Override + public boolean equals(Object obj) + { - return equalsImpl(obj); - } + if (this == obj) { + return true; + } - /** - * Compare all fields that contribute to the state, ignoring - transient and static fields, for this and the supplied object - * @param obj the object to compare to - * @return true if the objects are equal, false otherwise. - */ - public boolean equalsImpl(Object obj) - { - boolean ivarsEqual = true; + if (obj == null) { + return false; + } - if(!(obj instanceof TrackJamData)) - return false; + if (getClass() != obj.getClass()) { + return false; + } - final TrackJamData rhs = (TrackJamData)obj; + return equalsImpl(obj); + } - if( ! (entityID.equals( rhs.entityID) )) ivarsEqual = false; - if( ! (emitterNumber == rhs.emitterNumber)) ivarsEqual = false; - if( ! (beamNumber == rhs.beamNumber)) ivarsEqual = false; + /** + * Compare all fields that contribute to the state, ignoring transient and static fields, for this and the supplied object + * @param obj the object to compare to + * @return true if the objects are equal, false otherwise. + */ + public boolean equalsImpl(Object obj) + { + boolean ivarsEqual = true; + + if (!( obj instanceof TrackJamData )) { + return false; + } + + final TrackJamData rhs = (TrackJamData) obj; + + if (!( entityID.equals(rhs.entityID) )) { + ivarsEqual = false; + } + if (!( emitterNumber == rhs.emitterNumber )) { + ivarsEqual = false; + } + if (!( beamNumber == rhs.beamNumber )) { + ivarsEqual = false; + } + + return ivarsEqual; + } - return ivarsEqual; - } } // end of class From db20ab179ad4a5533dfe3afac151fecb64656964 Mon Sep 17 00:00:00 2001 From: "luke.cowan" Date: Fri, 13 Nov 2020 10:40:42 +0000 Subject: [PATCH 2/5] Unit Test for ElectromagneticEmissionPdu --- .../dis7/ElectronicEmissionsPduTest.java | 123 +++++++++++++++++ .../nps/moves/dis7/EntityStatePduTest.java | 125 ++++++++++++++++++ .../moves/dis/ElectromagneticEmissionPdu.raw | Bin 0 -> 100 bytes 3 files changed, 248 insertions(+) create mode 100644 src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java create mode 100644 src/test/java/edu/nps/moves/dis7/EntityStatePduTest.java create mode 100644 src/test/resources/edu/nps/moves/dis/ElectromagneticEmissionPdu.raw diff --git a/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java b/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java new file mode 100644 index 00000000..6713496d --- /dev/null +++ b/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java @@ -0,0 +1,123 @@ +package edu.nps.moves.dis7; + + +import edu.nps.moves.dis.PduFileLoader; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + + +/** + * @author lcowan + */ +public class ElectronicEmissionsPduTest +{ + + public ElectronicEmissionsPduTest() + { + } + + @BeforeClass + public static void setUpClass() + { + } + + @AfterClass + public static void tearDownClass() + { + } + + @Before + public void setUp() + { + } + + @After + public void tearDown() + { + } + + + @Test + public void unmarshal() + throws IOException + { + PduFactory factory = new PduFactory(); + Pdu pdu = factory.createPdu(PduFileLoader.load("ElectromagneticEmissionPdu.raw")); + + // Expected field values were determined from Wireshark: Decode As -> DIS. + + // Header + assertEquals(7, pdu.getProtocolVersion()); + assertEquals(51, pdu.getExerciseID()); + assertEquals(23, pdu.getPduType()); + assertEquals(6, pdu.getProtocolFamily()); + assertEquals(100, pdu.getMarshalledSize()); + assertEquals(0, pdu.getPadding()); + + ElectronicEmissionsPdu espdu = (ElectronicEmissionsPdu) pdu; + + // Entity ID + assertEquals(162, espdu.getEmittingEntityID().getSiteID()); + assertEquals(2, espdu.getEmittingEntityID().getApplicationID()); + assertEquals(0, espdu.getEmittingEntityID().getEntityID()); + + // Event ID + assertEquals(0, espdu.getEventID().getEventNumber()); + + // Emission System + assertEquals(18, espdu.getSystemDataLength()); + assertEquals(1, espdu.getNumberOfBeams()); + + // Emitter System + assertEquals(15660, espdu.getEmitterSystem().getEmitterName()); + assertEquals(7, espdu.getEmitterSystem().getEmitterFunction()); + assertEquals(1, espdu.getEmitterSystem().getEmitterIDNumber()); + + // Location + assertEquals(0.0, espdu.getLocation().getX(), 0.0001); + assertEquals(0.0, espdu.getLocation().getY(), 0.0001); + assertEquals(0.0, espdu.getLocation().getZ(), 0.0001); + + // Beam + assertEquals(13, espdu.getBeam().getBeamDataLength()); + assertEquals(1, espdu.getBeam().getBeamNumber()); + assertEquals(1, espdu.getBeam().getBeamParameterIndex()); + assertEquals(14000000000.0, espdu.getBeam().getFundamentalParameterData().getFrequency(), 0.000001); + assertEquals(6000000000.0, espdu.getBeam().getFundamentalParameterData().getFrequencyRange(), 0.000001); + assertEquals(55.0, espdu.getBeam().getFundamentalParameterData().getEffectiveRadiatedPower(), 0.000001); + assertEquals(600.0, espdu.getBeam().getFundamentalParameterData().getPulseRepetitionFrequency(), 0.000001); + assertEquals(3.0, espdu.getBeam().getFundamentalParameterData().getPulseWidth(), 0.000001); + assertEquals(0, espdu.getBeam().getBeamData().getBeamAzimuthCenter(), 0.000001); + assertEquals(0.698132, espdu.getBeam().getBeamData().getBeamAzimuthSweep(), 0.000001); + assertEquals(0.436332, espdu.getBeam().getBeamData().getBeamElevationCenter(), 0.000001); + assertEquals(0.436332, espdu.getBeam().getBeamData().getBeamElevationSweep(), 0.000001); + assertEquals(90.4001, espdu.getBeam().getBeamData().getBeamSweepSync(), 0.000001); + assertEquals(7, espdu.getBeam().getBeamFunction()); + assertEquals(0, espdu.getBeam().getNumberOfTargets()); + assertEquals(0, espdu.getBeam().getHighDensityTrackJam()); + assertEquals(0, espdu.getBeam().getBeamStatus().getBeamState()); + assertEquals(0, espdu.getBeam().getJammingTechnique().getCategory()); + assertEquals(0, espdu.getBeam().getJammingTechnique().getKind()); + assertEquals(0, espdu.getBeam().getJammingTechnique().getSpecific()); + assertEquals(0, espdu.getBeam().getJammingTechnique().getCategory()); + + + } + + @Test + public void marshal() + { + EntityStatePdu espdu = new EntityStatePdu(); + + byte[] buffer = espdu.marshal(); + + assertEquals(buffer.length, espdu.getMarshalledSize()); + } +} diff --git a/src/test/java/edu/nps/moves/dis7/EntityStatePduTest.java b/src/test/java/edu/nps/moves/dis7/EntityStatePduTest.java new file mode 100644 index 00000000..6d0c1805 --- /dev/null +++ b/src/test/java/edu/nps/moves/dis7/EntityStatePduTest.java @@ -0,0 +1,125 @@ +package edu.nps.moves.dis7; + + +import edu.nps.moves.dis.PduFileLoader; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + + +/** + * @author mcgredo + */ +public class EntityStatePduTest +{ + + public EntityStatePduTest() + { + } + + @BeforeClass + public static void setUpClass() + { + } + + @AfterClass + public static void tearDownClass() + { + } + + @Before + public void setUp() + { + } + + @After + public void tearDown() + { + } + + + @Test + public void unmarshal() + throws IOException + { + PduFactory factory = new PduFactory(); + Pdu pdu = factory.createPdu(PduFileLoader.load("EntityStatePdu-26.raw")); + + // Expected field values were determined from Wireshark: Decode As -> DIS. + + // Header + assertEquals(6, pdu.getProtocolVersion()); + assertEquals(7, pdu.getExerciseID()); + assertEquals(1, pdu.getPduType()); + assertEquals(1, pdu.getProtocolFamily()); + assertEquals(144, pdu.getLength()); + assertEquals(0, pdu.getPadding()); + + EntityStatePdu espdu = (EntityStatePdu) pdu; + + // Entity ID + assertEquals(42, espdu.getEntityID().getSiteID()); + assertEquals(4, espdu.getEntityID().getApplicationID()); + assertEquals(26, espdu.getEntityID().getEntityID()); + + // Force ID + assertEquals(1, espdu.getForceId()); + + // Entity Type (aka DIS Enumeration) + assertEquals(1, espdu.getEntityType().getEntityKind()); + assertEquals(1, espdu.getEntityType().getDomain()); + assertEquals(39, espdu.getEntityType().getCountry()); + assertEquals(7, espdu.getEntityType().getCategory()); + assertEquals(2, espdu.getEntityType().getSubcategory()); + assertEquals(1, espdu.getEntityType().getSpecific()); + assertEquals(0, espdu.getEntityType().getExtra()); + + // Alternative Entity Type + assertEquals(1, espdu.getAlternativeEntityType().getEntityKind()); + assertEquals(1, espdu.getAlternativeEntityType().getDomain()); + assertEquals(39, espdu.getAlternativeEntityType().getCountry()); + assertEquals(7, espdu.getAlternativeEntityType().getCategory()); + assertEquals(2, espdu.getAlternativeEntityType().getSubcategory()); + assertEquals(1, espdu.getAlternativeEntityType().getSpecific()); + assertEquals(0, espdu.getAlternativeEntityType().getExtra()); + + // Entity Linear Velocity + assertEquals(0, espdu.getEntityLinearVelocity().getX(), 0); + assertEquals(0, espdu.getEntityLinearVelocity().getY(), 0); + assertEquals(0, espdu.getEntityLinearVelocity().getZ(), 0); + + // Entity Location + assertEquals(4374082.80485589, espdu.getEntityLocation().getX(), 0.001); + assertEquals(1667679.95730107, espdu.getEntityLocation().getY(), 0.001); + assertEquals(4318284.36890269, espdu.getEntityLocation().getZ(), 0.001); + + // Entity Orientation + assertEquals(1.93505, espdu.getEntityOrientation().getPsi(), 0.001); + assertEquals(0, espdu.getEntityOrientation().getTheta(), 0.001); + assertEquals(-2.31924, espdu.getEntityOrientation().getPhi(), 0.001); + + // Dead Reckoning Parameters + // TODO assertEquals(???, espdu.getDeadReckoningParameters()); + // Entity Marking + assertEquals("26", new String(espdu.getMarking().getCharacters()).trim()); + + // Capabilities + assertEquals(0, espdu.getCapabilities()); + } + + @Test + public void marshal() + { + EntityStatePdu espdu = new EntityStatePdu(); + + byte[] buffer = espdu.marshal(); + + assertEquals(buffer.length, espdu.getLength()); + } +} diff --git a/src/test/resources/edu/nps/moves/dis/ElectromagneticEmissionPdu.raw b/src/test/resources/edu/nps/moves/dis/ElectromagneticEmissionPdu.raw new file mode 100644 index 0000000000000000000000000000000000000000..5b7dc66cf0d5527eef8a1c091ce7fb540416fd83 GIT binary patch literal 100 zcmZQK7H3mm+I@&2g@J)#5d#yPWMp6v0%BVob|8rWyo?Nt0ReLl`)|4s=M=-h;3CGr a;NSp}w>R2x$nJjHXApMUa^@C0R2u*u=M&NZ literal 0 HcmV?d00001 From d6566321d66483ba55a7cb67893c81af0e3d2353 Mon Sep 17 00:00:00 2001 From: "luke.cowan" Date: Fri, 20 Nov 2020 08:41:15 +0000 Subject: [PATCH 3/5] Revert pom to 5.1-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 26910465..508172cf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ open-dis jar Open-DIS - 5.1.1-SNAPSHOT + 5.1-SNAPSHOT An open source implementation of the Distributed Interactive Simulation (DIS) IEEE-1278 protocol http://www.open-dis.org From 5cbbbbdb9c2d243a90fb21344863b1812259d513 Mon Sep 17 00:00:00 2001 From: "luke.cowan" Date: Fri, 20 Nov 2020 08:44:17 +0000 Subject: [PATCH 4/5] Removed redundant systems. Replaced with BeamData --- .../moves/dis7/ElectronicEmissionsPdu.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java index db89ef98..b58902d7 100644 --- a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java +++ b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java @@ -53,7 +53,6 @@ public class ElectronicEmissionsPdu extends DistributedEmissionsFamilyPdu implem protected Vector3Float location = new Vector3Float(); /** Electronic emmissions systems THIS IS WRONG. It has the WRONG class type and will cause problems in any marshalling. */ - protected List systems = new ArrayList<>(); protected Beam beam = new Beam(); /** Constructor */ @@ -115,7 +114,7 @@ public void setStateUpdateIndicator(short pStateUpdateIndicator) public short getNumberOfSystems() { - return (short) systems.size(); + return numberOfSystems; } public Beam getBeam() @@ -188,15 +187,6 @@ public void setLocation(Vector3Float pLocation) location = pLocation; } - public List getSystems() - { - return systems; - } - - public void setSystems(List pSystems) - { - systems = pSystems; - } public void marshal(DataOutputStream dos) { @@ -205,7 +195,7 @@ public void marshal(DataOutputStream dos) emittingEntityID.marshal(dos); eventID.marshal(dos); dos.writeByte((byte) stateUpdateIndicator); - dos.writeByte((byte) systems.size()); + dos.writeByte((byte) numberOfSystems); dos.writeShort((short) paddingForEmissionsPdu); dos.writeByte((byte) systemDataLength); dos.writeByte((byte) numberOfBeams); @@ -256,7 +246,7 @@ public void marshal(java.nio.ByteBuffer buff) emittingEntityID.marshal(buff); eventID.marshal(buff); buff.put((byte) stateUpdateIndicator); - buff.put((byte) systems.size()); + buff.put((byte) numberOfSystems); buff.putShort((short) paddingForEmissionsPdu); buff.put((byte) systemDataLength); buff.put((byte) numberOfBeams); @@ -352,14 +342,12 @@ public boolean equalsImpl(Object obj) if (!( location.equals(rhs.location) )) { ivarsEqual = false; } - - for (int idx = 0; idx < systems.size(); idx++) { - if (!( systems.get(idx).equals(rhs.systems.get(idx)) )) { - ivarsEqual = false; - } + if (!( beam.equals(rhs.beam) )) { + ivarsEqual = false; } + return ivarsEqual && super.equalsImpl(rhs); } } // end of class From 815d53ffdd372b269949521ba865509d79a680c7 Mon Sep 17 00:00:00 2001 From: "luke.cowan" Date: Fri, 20 Nov 2020 09:09:44 +0000 Subject: [PATCH 5/5] Renamed Beam to ElectronicEmissionBeamData --- .../moves/dis7/ElectronicEmissionsPdu.java | 26 +++++----- ...java => ElectronicEmissisionBeamData.java} | 52 +++++++++---------- .../dis7/ElectronicEmissionsPduTest.java | 42 +++++++-------- 3 files changed, 59 insertions(+), 61 deletions(-) rename src/main/java/edu/nps/moves/dis7/{Beam.java => ElectronicEmissisionBeamData.java} (78%) diff --git a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java index b58902d7..6a0f4c2f 100644 --- a/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java +++ b/src/main/java/edu/nps/moves/dis7/ElectronicEmissionsPdu.java @@ -4,8 +4,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; /** @@ -52,8 +50,8 @@ public class ElectronicEmissionsPdu extends DistributedEmissionsFamilyPdu implem */ protected Vector3Float location = new Vector3Float(); - /** Electronic emmissions systems THIS IS WRONG. It has the WRONG class type and will cause problems in any marshalling. */ - protected Beam beam = new Beam(); + /** Electronic emmissions systems */ + protected ElectronicEmissisionBeamData electronicEmissisionBeamData = new ElectronicEmissisionBeamData(); /** Constructor */ public ElectronicEmissionsPdu() @@ -77,7 +75,7 @@ public int getMarshalledSize() marshalSize = marshalSize + 2; // paddingForEmissionsPdu marshalSize = marshalSize + emitterSystem.getMarshalledSize(); // emitterSystem marshalSize = marshalSize + location.getMarshalledSize(); // location - marshalSize = marshalSize + beam.getMarshalledSize(); // beam + marshalSize = marshalSize + electronicEmissisionBeamData.getMarshalledSize(); // electronicEmissisionBeamData return marshalSize; } @@ -117,14 +115,14 @@ public short getNumberOfSystems() return numberOfSystems; } - public Beam getBeam() + public ElectronicEmissisionBeamData getElectronicEmissionBeamData() { - return beam; + return electronicEmissisionBeamData; } - public void setBeam(Beam beam) + public void setElectronicEmissionBeamData(ElectronicEmissisionBeamData electronicEmissisionBeamData) { - this.beam = beam; + this.electronicEmissisionBeamData = electronicEmissisionBeamData; } /** @@ -201,7 +199,7 @@ public void marshal(DataOutputStream dos) dos.writeByte((byte) numberOfBeams); emitterSystem.marshal(dos); location.marshal(dos); - beam.marshal(dos); + electronicEmissisionBeamData.marshal(dos); } // end try catch (Exception e) { @@ -223,7 +221,7 @@ public void unmarshal(DataInputStream dis) numberOfBeams = (short) dis.readUnsignedByte(); emitterSystem.unmarshal(dis); location.unmarshal(dis); - beam.unmarshal(dis); + electronicEmissisionBeamData.unmarshal(dis); } // end try catch (Exception e) { @@ -252,7 +250,7 @@ public void marshal(java.nio.ByteBuffer buff) buff.put((byte) numberOfBeams); emitterSystem.marshal(buff); location.marshal(buff); - beam.marshal(buff); + electronicEmissisionBeamData.marshal(buff); } // end of marshal method @@ -277,7 +275,7 @@ public void unmarshal(java.nio.ByteBuffer buff) buff.getShort(); // remove padding emitterSystem.unmarshal(buff); location.unmarshal(buff); - beam.unmarshal(buff); + electronicEmissisionBeamData.unmarshal(buff); } // end of unmarshal method @@ -342,7 +340,7 @@ public boolean equalsImpl(Object obj) if (!( location.equals(rhs.location) )) { ivarsEqual = false; } - if (!( beam.equals(rhs.beam) )) { + if (!( electronicEmissisionBeamData.equals(rhs.electronicEmissisionBeamData) )) { ivarsEqual = false; } diff --git a/src/main/java/edu/nps/moves/dis7/Beam.java b/src/main/java/edu/nps/moves/dis7/ElectronicEmissisionBeamData.java similarity index 78% rename from src/main/java/edu/nps/moves/dis7/Beam.java rename to src/main/java/edu/nps/moves/dis7/ElectronicEmissisionBeamData.java index 3d2628c9..3da2e0aa 100644 --- a/src/main/java/edu/nps/moves/dis7/Beam.java +++ b/src/main/java/edu/nps/moves/dis7/ElectronicEmissisionBeamData.java @@ -8,23 +8,23 @@ /** - * This field shall specify information about a particular active beam. Section 7.6.2. + * This field shall specify information about a particular active electronicEmissisionBeamData. Section 7.6.2. * * Copyright (c) 2008-2016, MOVES Institute, Naval Postgraduate School. All rights reserved. This work is licensed under the BSD open source * license, available at https://www.movesinstitute.org/licenses/bsd.html * @author DMcG */ -public class Beam extends Object implements Serializable +public class ElectronicEmissisionBeamData extends Object implements Serializable { - /** Specifies the length of this beam's data, 8 bit unsigned int */ + /** Specifies the length of this electronicEmissisionBeamData's data, 8 bit unsigned int */ protected short beamDataLength; - /** unique beam number, 8 bit unsigned int */ + /** unique electronicEmissisionBeamData number, 8 bit unsigned int */ protected short beamNumber; /** * Used in conjunction with the Emitter Name field as a database primary key, this field shall specify a number by which receiving - * entities reference stored database parameters required to regenerate the beam., 16 bit unsigned int + * entities reference stored database parameters required to regenerate the electronicEmissisionBeamData., 16 bit unsigned int */ protected int beamParameterIndex; @@ -34,32 +34,32 @@ public class Beam extends Object implements Serializable protected EEFundamentalParameterData fundamentalParameterData = new EEFundamentalParameterData(); /** - * specify parameters of the beam and shall be represented by a Beam Data record (see 6.2.11) + * specify parameters of the electronicEmissisionBeamData and shall be represented by a ElectronicEmissisionBeamData Data record (see 6.2.11) */ protected BeamData beamData = new BeamData(); /** - * specify the intended use of a particular beam. Typical functions include search, acquisition, tracking, illumination, jamming, and so - * on. This field is intended to help receiving entities determine the emission mode represented by the beam. This field shall be + * specify the intended use of a particular electronicEmissisionBeamData. Typical functions include search, acquisition, tracking, illumination, jamming, and so + * on. This field is intended to help receiving entities determine the emission mode represented by the electronicEmissisionBeamData. This field shall be * represented by an 8-bit enumeration */ protected short beamFunction; /** - * This field, in conjunction with the High-Density Track/Jam field, shall identify, for the current PDU and emitter beam, the number of - * entities tracked or under illumination (as appropriate for an emitter beam’s function) or the number of targeted emitter beams (for + * This field, in conjunction with the High-Density Track/Jam field, shall identify, for the current PDU and emitter electronicEmissisionBeamData, the number of + * entities tracked or under illumination (as appropriate for an emitter electronicEmissisionBeamData’s function) or the number of targeted emitter beams (for * jammers). This field shall be represented by an 8-bit unsigned integer. */ protected short numberOfTargets; /** * This field shall be used to indicate that receiving simulation applications can assume that all viable targets in the field of regard - * specified by the beam data are being tracked or jammed. This field shall be represented by an 8-bit enumeration + * specified by the electronicEmissisionBeamData data are being tracked or jammed. This field shall be represented by an 8-bit enumeration */ protected short highDensityTrackJam; /** - * This field shall indicate the status of the beam (e.g., the beam is active or deactivated) and shall be represented by the Beam + * This field shall indicate the status of the electronicEmissisionBeamData (e.g., the electronicEmissisionBeamData is active or deactivated) and shall be represented by the ElectronicEmissisionBeamData * Status record (see 6.2.12) */ protected BeamStatus beamStatus = new BeamStatus(); @@ -71,13 +71,13 @@ public class Beam extends Object implements Serializable protected JammingTechnique jammingTechnique = new JammingTechnique(); /** - * This field is optional for any given beam. Rules for inclusion and use are provided in 5.7.3.3, 5.7.3.7, and 5.7.3.8. When included, + * This field is optional for any given electronicEmissisionBeamData. Rules for inclusion and use are provided in 5.7.3.3, 5.7.3.7, and 5.7.3.8. When included, * this field shall be represented by a series of Track/Jam Data records (see 6.2.90). */ protected TrackJamData trackJamData = new TrackJamData(); /** Constructor */ - public Beam() + public ElectronicEmissisionBeamData() { } @@ -315,18 +315,18 @@ public boolean equals(Object o) if (o == null || getClass() != o.getClass()) { return false; } - Beam beam = (Beam) o; - return beamDataLength == beam.beamDataLength && - beamNumber == beam.beamNumber && - beamParameterIndex == beam.beamParameterIndex && - beamFunction == beam.beamFunction && - numberOfTargets == beam.numberOfTargets && - highDensityTrackJam == beam.highDensityTrackJam && - Objects.equals(fundamentalParameterData, beam.fundamentalParameterData) && - Objects.equals(beamData, beam.beamData) && - Objects.equals(beamStatus, beam.beamStatus) && - Objects.equals(jammingTechnique, beam.jammingTechnique) && - Objects.equals(trackJamData, beam.trackJamData); + ElectronicEmissisionBeamData electronicEmissisionBeamData = (ElectronicEmissisionBeamData) o; + return beamDataLength == electronicEmissisionBeamData.beamDataLength && + beamNumber == electronicEmissisionBeamData.beamNumber && + beamParameterIndex == electronicEmissisionBeamData.beamParameterIndex && + beamFunction == electronicEmissisionBeamData.beamFunction && + numberOfTargets == electronicEmissisionBeamData.numberOfTargets && + highDensityTrackJam == electronicEmissisionBeamData.highDensityTrackJam && + Objects.equals(fundamentalParameterData, electronicEmissisionBeamData.fundamentalParameterData) && + Objects.equals(beamData, electronicEmissisionBeamData.beamData) && + Objects.equals(beamStatus, electronicEmissisionBeamData.beamStatus) && + Objects.equals(jammingTechnique, electronicEmissisionBeamData.jammingTechnique) && + Objects.equals(trackJamData, electronicEmissisionBeamData.trackJamData); } @Override diff --git a/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java b/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java index 6713496d..0031cdbc 100644 --- a/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java +++ b/src/test/java/edu/nps/moves/dis7/ElectronicEmissionsPduTest.java @@ -86,27 +86,27 @@ public void unmarshal() assertEquals(0.0, espdu.getLocation().getZ(), 0.0001); // Beam - assertEquals(13, espdu.getBeam().getBeamDataLength()); - assertEquals(1, espdu.getBeam().getBeamNumber()); - assertEquals(1, espdu.getBeam().getBeamParameterIndex()); - assertEquals(14000000000.0, espdu.getBeam().getFundamentalParameterData().getFrequency(), 0.000001); - assertEquals(6000000000.0, espdu.getBeam().getFundamentalParameterData().getFrequencyRange(), 0.000001); - assertEquals(55.0, espdu.getBeam().getFundamentalParameterData().getEffectiveRadiatedPower(), 0.000001); - assertEquals(600.0, espdu.getBeam().getFundamentalParameterData().getPulseRepetitionFrequency(), 0.000001); - assertEquals(3.0, espdu.getBeam().getFundamentalParameterData().getPulseWidth(), 0.000001); - assertEquals(0, espdu.getBeam().getBeamData().getBeamAzimuthCenter(), 0.000001); - assertEquals(0.698132, espdu.getBeam().getBeamData().getBeamAzimuthSweep(), 0.000001); - assertEquals(0.436332, espdu.getBeam().getBeamData().getBeamElevationCenter(), 0.000001); - assertEquals(0.436332, espdu.getBeam().getBeamData().getBeamElevationSweep(), 0.000001); - assertEquals(90.4001, espdu.getBeam().getBeamData().getBeamSweepSync(), 0.000001); - assertEquals(7, espdu.getBeam().getBeamFunction()); - assertEquals(0, espdu.getBeam().getNumberOfTargets()); - assertEquals(0, espdu.getBeam().getHighDensityTrackJam()); - assertEquals(0, espdu.getBeam().getBeamStatus().getBeamState()); - assertEquals(0, espdu.getBeam().getJammingTechnique().getCategory()); - assertEquals(0, espdu.getBeam().getJammingTechnique().getKind()); - assertEquals(0, espdu.getBeam().getJammingTechnique().getSpecific()); - assertEquals(0, espdu.getBeam().getJammingTechnique().getCategory()); + assertEquals(13, espdu.getElectronicEmissionBeamData().getBeamDataLength()); + assertEquals(1, espdu.getElectronicEmissionBeamData().getBeamNumber()); + assertEquals(1, espdu.getElectronicEmissionBeamData().getBeamParameterIndex()); + assertEquals(14000000000.0, espdu.getElectronicEmissionBeamData().getFundamentalParameterData().getFrequency(), 0.000001); + assertEquals(6000000000.0, espdu.getElectronicEmissionBeamData().getFundamentalParameterData().getFrequencyRange(), 0.000001); + assertEquals(55.0, espdu.getElectronicEmissionBeamData().getFundamentalParameterData().getEffectiveRadiatedPower(), 0.000001); + assertEquals(600.0, espdu.getElectronicEmissionBeamData().getFundamentalParameterData().getPulseRepetitionFrequency(), 0.000001); + assertEquals(3.0, espdu.getElectronicEmissionBeamData().getFundamentalParameterData().getPulseWidth(), 0.000001); + assertEquals(0, espdu.getElectronicEmissionBeamData().getBeamData().getBeamAzimuthCenter(), 0.000001); + assertEquals(0.698132, espdu.getElectronicEmissionBeamData().getBeamData().getBeamAzimuthSweep(), 0.000001); + assertEquals(0.436332, espdu.getElectronicEmissionBeamData().getBeamData().getBeamElevationCenter(), 0.000001); + assertEquals(0.436332, espdu.getElectronicEmissionBeamData().getBeamData().getBeamElevationSweep(), 0.000001); + assertEquals(90.4001, espdu.getElectronicEmissionBeamData().getBeamData().getBeamSweepSync(), 0.000001); + assertEquals(7, espdu.getElectronicEmissionBeamData().getBeamFunction()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getNumberOfTargets()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getHighDensityTrackJam()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getBeamStatus().getBeamState()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getJammingTechnique().getCategory()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getJammingTechnique().getKind()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getJammingTechnique().getSpecific()); + assertEquals(0, espdu.getElectronicEmissionBeamData().getJammingTechnique().getCategory()); }