/*
File: TransmitterPdu.java
CVS Info: $Id: TransmitterPdu.java,v 1.0 2000/06/07 18:00:00 laflam Exp $
Compiler: jdk 1.3
*/
// This is the one to work on
package mil.navy.nps.dis; // package for Naval Postgraduate School DIS Libaray
import mil.navy.nps.util.*; // General-purpose utilities
import mil.navy.nps.disEnumerations.*; // Enumerations for DIS
import java.lang.*;
import java.util.*; // utility stuff we need
import java.io.*; // input/output for serialization
/**
* Transmitter PDU for DIS .
*
*@version 1.0
*@author David W. Laflam (http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/)
*
*@author Don Brutzman (http://web.nps.navy.mil/~brutzman)
*
*
* * As with other PDUs, it knows how to serialize and deserialize itself * from the wire. It also knows how to clone itself, and knows how to * calculate its size when sent to the wire. *
* *
sizeOf = 832 bytes
*/
public final static int sizeOf = 832; // is this the PDU Size Total DWL // size of object as written to wire
public TransmitterPdu()
{
super.setPduType(PduTypeField.TRANSMITTER);
entityID = new EntityID(); // (site,host,entity) 16 bit unsigned integer
radioID = new UnsignedShort(0); // 16 bit unsigned integer
radioEntityType = new RadioEntityType(); //
transmitState = new UnsignedByte(0) ; // 8-bit enumeration
inputSource = new UnsignedByte(0) ; // 8-bit enumeration
padding1 = new UnsignedShort(0); // 16-bits unused
antennaLocation = new WorldCoordinate(); // XYZ (64-bit floating point)
relativeAntennaLocation = new EntityCoordinate() ; // XYZ (32-bit floating point)
antennaPatternType = new UnsignedShort(0); // 16-bits enumeration
antennaPatternLength = new UnsignedShort(0); // 16-unsigned integer
frequency = new UnsignedLong(0); // 64-bit unsigned integer
transmitFrequencyBandwidth = new UnsignedInt(0); // 32-bit floating point
power = new UnsignedInt(0); // 32-bit floating point
modulationType = new ModulationType(); // spread spectrum 16 bit boolean
// (major,detailed,system)
// 16 bit enumeration
cryptoSytem = new UnsignedShort(0); // 16-bit enumeration
cryptoKeyId = new UnsignedShort(0); // 16-bit unsigned integer
lengthOfModulationParameters = new UnsignedByte(0) ; // 8-bit unsigned integer
padding2 = new UnsignedShort(0); // 16-bits unused
padding3 = new UnsignedByte(0); // 16-bits unused
return;
}// end public TransmitterPdu()
/**
* Make a copy of the object. This requires a deep copy, so we don't have two
* objects sharing pointers to the same data.
* @return a new Fire PDU entity
*/
public Object clone()
{
TransmitterPdu newTransmitterPdu = (TransmitterPdu)super.clone(); // this will inherit from the super class //dwl
newTransmitterPdu.setEntityID(this.getEntityID());
newTransmitterPdu.setRadioID(this.getRadioID());
newTransmitterPdu.setRadioEntityType(this.getRadioEntityType());
newTransmitterPdu.setTransmitState(this.getTransmitState());
newTransmitterPdu.setInputSource(this.getInputSource());
newTransmitterPdu.setAntennaLocation(this.getAntennaLocation());
newTransmitterPdu.setRelativeAntennaLocation(this.getRelativeAntennaLocation());
newTransmitterPdu.setAntennaPatternType(this.getAntennaPatternType());
newTransmitterPdu.setAntennaPatternLength(this.getAntennaPatternLength());
newTransmitterPdu.setFrequency(this.getFrequency());
newTransmitterPdu.setTransmitFrequencyBandwidth(this.getTransmitFrequencyBandwidth());
newTransmitterPdu.setPower(this.getPower());
newTransmitterPdu.setModulationType(this.getModulationType());
newTransmitterPdu.setCryptoSytem(this.getCryptoSytem());
newTransmitterPdu.setCryptoKeyId(this.getCryptoKeyId());
newTransmitterPdu.setLengthOfModulationParameters(this.getLengthOfModulationParameters());
return newTransmitterPdu;
}// end public Object clone()
/**
* Serialize and write out the output stream, order is important here since
* it needs to conform to the DIS standard
* @exception RuntimeException when IO error occurs.
*/
public void serialize(DataOutputStream outputStream)
{
super.serialize(outputStream); // write out header info
try
{
entityID.serialize(outputStream);
radioID.serialize(outputStream);
radioEntityType.serialize(outputStream);
transmitState.serialize(outputStream);
inputSource.serialize(outputStream);
padding1.serialize(outputStream);
antennaLocation.serialize(outputStream);
relativeAntennaLocation.serialize(outputStream);
antennaPatternType.serialize(outputStream);
antennaPatternLength.serialize(outputStream);
frequency.serialize(outputStream);
transmitFrequencyBandwidth.serialize(outputStream);
power.serialize(outputStream);
modulationType.serialize(outputStream);
cryptoSytem.serialize(outputStream);
cryptoKeyId.serialize(outputStream);
lengthOfModulationParameters.serialize(outputStream);
padding2.serialize(outputStream);
padding3.serialize(outputStream);
}
catch (Exception someError)
{
throw new
RuntimeException("Exception in TransmitterPdu.serialize, error writing to wire.\n" + someError);
}
return;
} // end public void serialize()
/**
* Deserialize the input stream, and order is important here, since we need to
* read in the same order as specified by the DIS standard
* @exception RuntimeException when IO error occurs.
*/
public void deSerialize(DataInputStream inputStream)
{
super.deSerialize(inputStream); // read in all the header info
try
{
entityID.deSerialize(inputStream);
radioID.deSerialize(inputStream);
radioEntityType.deSerialize(inputStream);
transmitState.deSerialize(inputStream);
inputSource.deSerialize(inputStream);
padding1.deSerialize(inputStream);
antennaLocation.deSerialize(inputStream);
relativeAntennaLocation.deSerialize(inputStream);
antennaPatternType.deSerialize(inputStream);
antennaPatternLength.deSerialize(inputStream);
frequency.deSerialize(inputStream);
transmitFrequencyBandwidth.deSerialize(inputStream);
power.deSerialize(inputStream);
modulationType.deSerialize(inputStream);
cryptoSytem.deSerialize(inputStream);
cryptoKeyId.deSerialize(inputStream);
lengthOfModulationParameters.deSerialize(inputStream);
padding2.deSerialize(inputStream);
padding3.deSerialize(inputStream);
}
catch (Exception someError)
{
throw new
RuntimeException("Exception in TransmitterPdu.deSerialize, error reading from wire.\n" + someError);
}
}// end public void deSerialize()
/**
* Returns the length of the entity
* @return an integer length of the entity
*/
public int length()
{
return sizeOf; // EntityTypes are this long, always. This is the 288
}// end public int length()
/**
* Returns the PDU name - Transmitter PDU
* @return a string "Transmitter PDU"
*/
public String pduName()
{
return new String("Transmitter PDU");
} //end public String pduName()
/**
* Print the values of the following object out, with correct level of
* indentation on the page.
* firingEntityID, targetEntityID, munitionID, fireMissionIndex, locationInWorldCoordinate,
* burstDescriptor, velocity, and range.
*/
public void printValues(int indentLevel, PrintStream printStream)
{
StringBuffer indent = ProtocolDataUnit.getPaddingOfLength(indentLevel);
int idx, superclassIndent = indentLevel;
printStream.println();
printStream.println("Transmitter PDU-");
// ugly wart: get the superclass over to the left a couple pixels, if we have any to spare,
// so the header info will be indented a bit less.
if(superclassIndent > 0)
superclassIndent -= 1;
super.printValues(superclassIndent, printStream);
entityID.printValues(indentLevel, printStream);
printStream.println(indent + "radioID: " + radioID); // print the primitive type
printStream.println(indent + "radioEntityType: " + radioEntityType);
printStream.println(indent + "transmitState: " + transmitState);
printStream.println(indent + "inputSource: " + inputSource);
printStream.println(indent + "padding1: " + padding1);
printStream.println(indent + "antennaLocation: " + antennaLocation);
printStream.println(indent + "relativeAntennaLocation : " + relativeAntennaLocation );
printStream.println(indent + "antennaPatternType: " + antennaPatternType);
printStream.println(indent + "antennaPatternLength: " + antennaPatternLength);
printStream.println(indent + "frequency: " + frequency);
printStream.println(indent + "transmitFrequencyBandwidth: " + transmitFrequencyBandwidth);
printStream.println(indent + "power: " + power);
printStream.println(indent + "modulationType: " + modulationType);
printStream.println(indent + "cryptoSytem: " + cryptoSytem);
printStream.println(indent + "cryptoKeyId: " + cryptoKeyId);
printStream.println(indent + "lengthOfModulationParameters: " + lengthOfModulationParameters);
printStream.println(indent + "padding2: " + padding2);
printStream.println(indent + "padding3: " + padding3);
// printStream.println(indent + "transmitterRadioID: " + transmitterRadioID); // print the primitive type
// transmitterRadioID.printValues(indentLevel, printStream);
return;
}// end public void printValues(
//Accessor methods (Set and Get)
/**
* Gets entity ID.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the firing entity ID
*/
public EntityID getEntityID()
{
return (EntityID)entityID.clone();
}
/**
* Sets entity ID
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pFiringEntityID the firing entity ID
*/
public void setEntityID(EntityID pEntityID)
{
entityID = pEntityID;
}
/**
*Sets setEntityID(short pSiteID, short pApplicationID, short pEntityID),accessor method.
*will create an new EntityID = entityID
*This field shall identify the entity issuing the PDU,
* and shall be represented by the PDU Header Record (see 5.2.24)
*/
public void setEntityID(short pSiteID, short pApplicationID, short pEntityID)
{ entityID = new EntityID(pSiteID, pApplicationID, pEntityID);
}
/**
* Gets RadioID.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the radioID
*/
public UnsignedShort getRadioID()
{
return (UnsignedShort)radioID.clone();
}
/**
* Sets RadioID.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pRadioID of radioID
*/
public void setRadioID(UnsignedShort pRadioID)
{
radioID = pRadioID;
}
/**
* Gets RadioID.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the radioID
*/
public RadioEntityType getRadioEntityType()
{
return (RadioEntityType)radioEntityType.clone();
}
/**
* Sets RadioEntityType
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pRadioEntityType of RadioEntityType.
*/
public void setRadioEntityType(RadioEntityType pRadioEntityType)
{
radioEntityType = pRadioEntityType;
System.out.println("set a new radio entity type of " + radioEntityType);
}
/**
* Gets TransmitState.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the transmitState
*/
public UnsignedByte getTransmitState()
{
return (UnsignedByte)transmitState.clone();
}
/**
* Sets TransmitState
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pTransmitState of TransmitState.
*/
public void setTransmitState(UnsignedByte pTransmitState)
{
transmitState = pTransmitState;
}
/**
* Gets InputSource.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the inputSource
*/
public UnsignedByte getInputSource()
{
return (UnsignedByte)inputSource.clone();
}
/**
* Sets InputSource
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pInputSource of InputSource.
*/
public void setInputSource(UnsignedByte pInputSource)
{
inputSource = pInputSource;
}
// no need for a get and set for the padding //DWL
// protected UnsignedShort padding // 16-bits unused
/**
* Gets AntennaLocation.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the antennaLocation
*/
public WorldCoordinate getAntennaLocation()
{
return (WorldCoordinate)antennaLocation.clone();
}
/**
* Sets AntennaLocation
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pAntennaLocation of AntennaLocation.
*/
public void setAntennaLocation(WorldCoordinate pAntennaLocation)
{
antennaLocation = pAntennaLocation;
}
/**
* Sets AntennaLocation
*/
public void setAntennaLocation(double pX, double pY, double pZ)
{
antennaLocation = new WorldCoordinate (pX, pY, pZ);
}
/**
* Gets RelativeAntennaLocation.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the relativeAntennaLocation
*/
public EntityCoordinate getRelativeAntennaLocation()
{
return (EntityCoordinate)relativeAntennaLocation.clone();
}
/**
* Sets RelativeAntennaLocation
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pRelativeAntennaLocation of RelativeAntennaLocation.
*/
public void setRelativeAntennaLocation(EntityCoordinate pRelativeAntennaLocation)
{
relativeAntennaLocation = pRelativeAntennaLocation;
}
/**
* Gets AntennaPatternType.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the antennaPatternType.
*/
public UnsignedShort getAntennaPatternType()
{
return (UnsignedShort)antennaPatternType.clone();
}
/**
* Sets AntennaPatternType
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pAntennaPatternType of AntennaPatternType.
*/
public void setAntennaPatternType(UnsignedShort pAntennaPatternType)
{
antennaPatternType = pAntennaPatternType;
}
/**
* Gets AntennaPatternLength.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the antennaPatternLength
*/
public UnsignedShort getAntennaPatternLength()
{
return (UnsignedShort)antennaPatternLength.clone();
}
/**
* Sets AntennaPatternLength
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pAntennaPatternLength of AntennaPatternLength.
*/
public void setAntennaPatternLength(UnsignedShort pAntennaPatternLength)
{
antennaPatternLength = pAntennaPatternLength;
}
/**
* Gets Frequency.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the frequency
*/
public UnsignedLong getFrequency()
{
return (UnsignedLong)frequency.clone();
}
/**
* Sets Frequency
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pFrequency of Frequency.
*/
public void setFrequency(UnsignedLong pFrequency)
{
frequency = pFrequency;
}
/**
* Gets TransmitFrequencyBandwidth.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the transmitFrequencyBandwidth
*/
public UnsignedInt getTransmitFrequencyBandwidth()
{
return (UnsignedInt)transmitFrequencyBandwidth.clone();
}
/**
* Sets TransmitFrequencyBandwidth
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pTransmitFrequencyBandwidth of TransmitFrequencyBandwidth.
*/
public void setTransmitFrequencyBandwidth(UnsignedInt pTransmitFrequencyBandwidth)
{
transmitFrequencyBandwidth = pTransmitFrequencyBandwidth;
}
/**
* Gets Power.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the power
*/
public UnsignedInt getPower()
{
return (UnsignedInt)power.clone();
//return power;
}
/**
* Sets Power
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pPower of Power.
*/
public void setPower(UnsignedInt pPower)
{
power = pPower;
}
/**
* Gets ModulationType.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the modulationType
*/
public ModulationType getModulationType()
{
return (ModulationType)modulationType.clone();
}
/**
* Sets ModulationType
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pModulationType of ModulationType.
*/
public void setModulationType(ModulationType pModulationType)
{
modulationType = pModulationType;
}
/**
* Gets CryptoSytem.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the cryptoSytem
*/
public UnsignedShort getCryptoSytem()
{
return (UnsignedShort)cryptoSytem.clone();
}
/**
* Sets CryptoSytem
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pCryptoSytem of CryptoSytem.
*/
public void setCryptoSytem(UnsignedShort pCryptoSytem)
{
cryptoSytem = pCryptoSytem;
}
/**
* Gets CryptoKeyId.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the cryptoKeyId
*/
public UnsignedShort getCryptoKeyId()
{
return (UnsignedShort)cryptoKeyId.clone();
}
/**
* Sets CryptoKeyId
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pCryptoKeyId of CryptoKeyId.
*/
public void setCryptoKeyId(UnsignedShort pCryptoKeyId)
{
cryptoKeyId = pCryptoKeyId;
}
/**
* Gets LengthOfModulationParameters.
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @return a clone of the lengthOfModulationParameters
*/
public UnsignedByte getLengthOfModulationParameters()
{
return (UnsignedByte)lengthOfModulationParameters.clone();
}
/**
* Sets LengthOfModulationParameters
* Each Entity in a given exercise executing on a DIS application shall be assigned an Entity Identifier Record
* Unique to the exercise.
* @param pLengthOfModulationParameters of LengthOfModulationParameters.
*/
public void setLengthOfModulationParameters(UnsignedByte pLengthOfModulationParameters)
{
lengthOfModulationParameters = pLengthOfModulationParameters;
}
// no need for a get and set for the padding2 padding3 //DWL
// protected padding
// 24 bit unsued (write 3 bytes ?)
/**
* String toString
* Used for debuging
* System.out.println("Transmitter Object. = " + transmitter);
* This print out all values for the fields for the NEW Transmitter object
*/
public String toString ()
{
String result;
result = "\nEntityID = " + entityID + " \nRadioID = " + radioID + " \nRadioEntityType = " + radioEntityType +
" \nTransmitState = " + transmitState + "\nInputSource = " + inputSource + "\nPadding1 = " + padding1 +
" \nAntennaLocaction = " + antennaLocation + "\nRelativeAntennaLocation = " + relativeAntennaLocation +
" \nAntennaPatternType = " + antennaPatternType + "\nAntennaPatternLength = " + antennaPatternLength +
" \nFrequency = " + frequency +
" \nTransmitFrequencyBandwidth = " + transmitFrequencyBandwidth + "\nPower = " + power ;
return result ;
}
} // end of class TransmitterPdu.java