Package gov.nih.mipav.model.dicomcomm
Class DICOM_PDUService
- java.lang.Object
-
- gov.nih.mipav.model.dicomcomm.DICOM_Comms
-
- gov.nih.mipav.model.dicomcomm.DICOM_PDUService
-
- Direct Known Subclasses:
DICOM_Receiver
public class DICOM_PDUService extends DICOM_Comms
The Protocol Data Units (PDU) - PDU_Service class is a wrapper of all the lower level DICOM messaging classes. This class is the true implementor of the DICOM networking protocol.
This DICOM communication package was originally based on the Java Dicom Package, whose license is below:Java Dicom Package (com.zmed.dicom) Copyright (c) 1996-1997 Z Medical Imaging Systems, Inc. This software is provided, as is, for non-commercial educational purposes only. Use or incorporation of this software or derivative works in commercial applications requires written consent from Z Medical Imaging Systems, Inc. Z MEDICAL IMAGING SYSTEMS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR CONFORMANCE TO ANY SPECIFICATION OR STANDARD. Z MEDICAL IMAGING SYSTEMS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING OR MODIFYING THIS SOFTWARE OR ITS DERIVATIVES. ============================================================================= This software package is implemented similarly to the UC Davis public domain C++ DICOM implementation which contains the following copyright notice: Copyright (C) 1995, University of California, Davis THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND THE UNIVERSITY OF CALIFORNIA DOES NOT MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH THE USER. Copyright of the software and supporting documentation is owned by the University of California, and free access is hereby granted as a license to use this software, copy this software and prepare derivative works based upon this software. However, any distribution of this software source code or supporting documentation or derivative works (source code and supporting documentation) must include this copyright notice. The UC Davis C++ source code is publicly available from the following anonymous ftp site: ftp://imrad.ucdmc.ucdavis.edu/pub/dicom/UCDMC/
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gov.nih.mipav.model.dicomcomm.DICOM_Comms
DICOM_Comms.ByteBuffer
-
-
Field Summary
Fields Modifier and Type Field Description DICOM_AAbortRQabortRQAbort connection request.DICOM_AAssociateACassociateACAssociate accept object.DICOM_AAssociateRJassociateRJAssociate reject object.DICOM_AAssociateRQassociateRQAssociate request object.protected DICOM_Comms.ByteBuffercompDataBuffer used to hold image data.DICOMDisplayerdicomMessageDisplayerReference to the DICOM GUI for displaying message information.DICOM_ObjectListfindResultsList of the results of a DICOM query.(package private) DICOM_FileIOioBufferBuffer used in sending DICOM image.DICOM_ObjectListmoveResultslist of the results of a DICOM move.DICOM_PDataTFpDataTFData transfer object.(package private) java.util.Vector<DICOM_PresentationContextAccept>PresentationContextsA list of Presentation contexts.(package private) java.util.Hashtable<java.lang.String,DICOM_PDUItemType>proposedAbstractSyntaxsA hash table of proposed abstract syntaxes where: value = AbstractSyntaxes; key = UID.DICOM_AReleaseRQreleaseRQRelease request.DICOM_AReleaseRSPreleaseRSPRelease response.DICOM_Socketsocketsocket used to connect to server.-
Fields inherited from class gov.nih.mipav.model.dicomcomm.DICOM_Comms
BIG_ENDIAN, breakSize, inBuffersLength, incomingBuffers, LITTLE_ENDIAN, MAX_READ_LENGTH, outBuffersLength, outgoingBuffers
-
-
Constructor Summary
Constructors Constructor Description DICOM_PDUService()PDU_Service constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidabort()Aborts an association and closes the socket.voidaddAbstractSyntax(java.lang.String SOP_UID)Adds proposed abstract syntax to hash table.voidaddAllSupportedAbstractSyntaxes()Adds all proposed abstract syntaxes to hash table.voidaddFindResultToList(DICOM_Object dco, DICOM_Object ddo)Utility function to collect the results of a DICOM query.voidaddJustVerificationAbstractSyntax()Adds just the verification syntax for DICOM verification process.private voidbuildRawBuffer(DICOM_Comms vrBuffer)Fills the compData buffer from the vrBuffer.incomming buffers.private booleancanWeHandleTransferSyntax(DICOM_PDUItemType trnSyntax)Determines wheather or not this transfer syntax is support by MIPAV.voidclose()Disconnect socket and free up memory.voidconnectClientToServer(java.lang.String remoteAppTitle, boolean verification, java.lang.String transferSyntax, java.lang.String classUID)This is a simple interface to establish an association over a socket from the client (i.e.private DICOM_UserInformationconstructUserInformation()Fills the with MIPAV information.protected voidfinalize()Used to make sure socket has properly been closed.DICOM_AAssociateRQgetAAssociateRQ()Returns the association request.java.lang.StringgetImplementationClassUID()Implementation class uid.java.lang.StringgetImplementationVersion()Implementation version uid.java.lang.StringgetLocalAppTitle()Returns the AETitle we use to identify ourself (our local AppTitle name).protected java.lang.StringgetTransferSyntaxID()Gets the transfer syntax ID of the data.voidhandleConnectionFromServer(java.net.Socket sock)Establishes an association over a socket from the server (SCP) side.private booleaninterrogateAAssociateAC()Decompose association ack.private booleaninterrogateAAssociateRQ()Decompose association request and send proper response.voidparseDICOMintoBuffer(DICOM_Object ddo, DICOM_Comms vrBuffer, DICOM_FileIO ioBuffer)voidparseDICOMIntoRawVR(DICOM_Object dobj, DICOM_Comms vrBuffer)Converts a DICOMObject into an outgoing DICOM data stream.static voidparseRawVRIntoDICOM(DICOM_Comms vrBuffer, DICOM_Object dobj)Convert an incoming DICOM network data stream into a DICOMObject.static java.lang.String[]parseServerInfo(java.lang.String info)Parses the server info string and returns a tokenized array of strings that where deliniated by ";" (See MIPAV preference file).intreadBinary(byte[] data, int count)Actual binary data from the port.DICOM_ObjectreadDICOMDataObjectFromFile(java.lang.String filename)Loads a DICOM image from a file.booleanreadInObject(DICOM_Object DICOMobj)The main method for reading incoming DICOM messages. true: complete PData unit received, socket still open false: release request received, then close the socketvoidsaveImageToFile(DICOM_Comms.ByteBuffer dataObj, java.lang.String fileName)Saves the DDO to the file name supplied as a method parameter.voidsendBinary(byte[] data, int offset, int count)Actual binary data to be sent.private voidsetApplicationContext(java.lang.String applicationUID)Sets the application context UID.voidsetDICOMMessageDisplayer(DICOMDisplayer displayer)Sets the display viewer.private voidsetLocalAddress(java.lang.String localAddress)Sets the local address of the calling application entity.private booleanshouldWeAcceptAbstractSyntax(DICOM_PDUItemType abstractSyntax)Should MIPAV accept the abstract syntax.private booleanshouldWeAcceptApplicationContext(DICOM_PDUItemType applicationContext)As it turn out we accept all application contexts.booleanshouldWeAcceptLocalAppTitle(java.lang.String AEtitle)Accept all.booleanshouldWeAcceptRemoteAppTitle(java.lang.String remoteAETitle)Accept only AETitles listed in the server host table (remote) *** We accept all AETitles at this time!voidshowMessage(java.lang.String str)Shows a message in the GUI message panel.voidwrite(DICOM_Object DICOMObj, java.lang.String sopClassUID, byte messageHeader)Writes the DICOMObj out through the socket.voidwrite(java.lang.String transferSyntax, DICOM_Object ddo, java.lang.String sopClassUID, byte messageHeader)Writes the image (loaded into ioBuffer from file) out the port.-
Methods inherited from class gov.nih.mipav.model.dicomcomm.DICOM_Comms
bufferToInt16, bufferToInt32, flush, flush, getIncomingEndian, getIncomingSize, getOutgoingEndian, getOutgoingSize, int16ToBuffer, int32ToBuffer, peekFirstByte, peekForEndOfSequence, read, read, readByte, readBytes, readFill, readInt32, readShort16, seekToEndOfGroupTwoTags, setIncomingEndianess, setOutgoingEndianess, write, write, writeByte, writeByteIn, writeIn, writeInt32, writeInt32In, writeShort16, writeShort16In
-
-
-
-
Field Detail
-
abortRQ
public DICOM_AAbortRQ abortRQ
Abort connection request.
-
associateAC
public DICOM_AAssociateAC associateAC
Associate accept object.
-
associateRJ
public DICOM_AAssociateRJ associateRJ
Associate reject object.
-
associateRQ
public DICOM_AAssociateRQ associateRQ
Associate request object.
-
dicomMessageDisplayer
public DICOMDisplayer dicomMessageDisplayer
Reference to the DICOM GUI for displaying message information.
-
findResults
public DICOM_ObjectList findResults
List of the results of a DICOM query.
-
moveResults
public DICOM_ObjectList moveResults
list of the results of a DICOM move.
-
pDataTF
public DICOM_PDataTF pDataTF
Data transfer object.
-
releaseRQ
public DICOM_AReleaseRQ releaseRQ
Release request.
-
releaseRSP
public DICOM_AReleaseRSP releaseRSP
Release response.
-
socket
public DICOM_Socket socket
socket used to connect to server.
-
compData
protected DICOM_Comms.ByteBuffer compData
Buffer used to hold image data.
-
PresentationContexts
java.util.Vector<DICOM_PresentationContextAccept> PresentationContexts
A list of Presentation contexts.
-
proposedAbstractSyntaxs
java.util.Hashtable<java.lang.String,DICOM_PDUItemType> proposedAbstractSyntaxs
A hash table of proposed abstract syntaxes where: value = AbstractSyntaxes; key = UID.
-
ioBuffer
DICOM_FileIO ioBuffer
Buffer used in sending DICOM image.
-
-
Method Detail
-
parseRawVRIntoDICOM
public static void parseRawVRIntoDICOM(DICOM_Comms vrBuffer, DICOM_Object dobj)
Convert an incoming DICOM network data stream into a DICOMObject.- Parameters:
vrBuffer- the I/O DICOM_CommsLink.java from which to read the data streamdobj- the DICOM_Object.java to fill
-
parseServerInfo
public static java.lang.String[] parseServerInfo(java.lang.String info)
Parses the server info string and returns a tokenized array of strings that where deliniated by ";" (See MIPAV preference file).- Parameters:
info- A string deliniated by ";" that contains (AETitle, Alias, IP, PORT).- Returns:
- server info parsed into an array of strings (AETitle, Alias, IP, PORT).
-
addAbstractSyntax
public void addAbstractSyntax(java.lang.String SOP_UID)
Adds proposed abstract syntax to hash table.- Parameters:
SOP_UID- The abstract syntax to be added the list of proposed Abstract Syntaxs
-
addAllSupportedAbstractSyntaxes
public void addAllSupportedAbstractSyntaxes()
Adds all proposed abstract syntaxes to hash table.
-
addFindResultToList
public void addFindResultToList(DICOM_Object dco, DICOM_Object ddo)
Utility function to collect the results of a DICOM query. Fills the findResults list.- Parameters:
dco- the received command objectddo- the received data object
-
addJustVerificationAbstractSyntax
public void addJustVerificationAbstractSyntax()
Adds just the verification syntax for DICOM verification process.
-
close
public void close()
Disconnect socket and free up memory.
-
connectClientToServer
public void connectClientToServer(java.lang.String remoteAppTitle, boolean verification, java.lang.String transferSyntax, java.lang.String classUID) throws DICOM_ExceptionThis is a simple interface to establish an association over a socket from the client (i.e. MIPAV) (SCU) side.- Parameters:
remoteAppTitle- the application entity title to attempt to connect toverification- if true only add Verification UID syntax.transferSyntax- if this is passed in, only add this transfer syntax to the the available pres contextsclassUID- used in conjunction with transfer syntax to specify ONE type of abstract syntax to use- Throws:
DICOM_Exception- Throws an error if there was a problem connecting to the server.
-
getAAssociateRQ
public DICOM_AAssociateRQ getAAssociateRQ()
Returns the association request.- Returns:
- the association request
-
getImplementationClassUID
public java.lang.String getImplementationClassUID()
Implementation class uid.- Returns:
- the UID
-
getImplementationVersion
public java.lang.String getImplementationVersion()
Implementation version uid.- Returns:
- The version.
-
getLocalAppTitle
public java.lang.String getLocalAppTitle() throws DICOM_ExceptionReturns the AETitle we use to identify ourself (our local AppTitle name).- Returns:
- Returns the AETitle we use to identify ourself (our local AppTitle name).
- Throws:
DICOM_Exception- Throws an error if there was a problem getting the default AETitle.
-
handleConnectionFromServer
public void handleConnectionFromServer(java.net.Socket sock) throws DICOM_ExceptionEstablishes an association over a socket from the server (SCP) side.- Parameters:
sock- the socket (connected) to work with- Throws:
DICOM_Exception- Throws an error if there was a problem connecting to the server.
-
parseDICOMIntoRawVR
public void parseDICOMIntoRawVR(DICOM_Object dobj, DICOM_Comms vrBuffer)
Converts a DICOMObject into an outgoing DICOM data stream.- Parameters:
dobj- the DICOMObject to sendvrBuffer- the I/O Buffer to write to
-
readBinary
public int readBinary(byte[] data, int count) throws DICOM_ExceptionActual binary data from the port.- Overrides:
readBinaryin classDICOM_Comms- Parameters:
data- buffer to store the datacount- number of bytes to be read- Returns:
- number of bytes actually read
- Throws:
DICOM_Exception- Throws an error if there was a problem reading the socket.
-
readDICOMDataObjectFromFile
public DICOM_Object readDICOMDataObjectFromFile(java.lang.String filename) throws DICOM_Exception
Loads a DICOM image from a file.- Parameters:
filename- The name of the file to load.- Returns:
- Returns the DICOM data object (image).
- Throws:
DICOM_Exception- Throws an error if there was a problem reading in the image.
-
readInObject
public boolean readInObject(DICOM_Object DICOMobj) throws DICOM_Exception
The main method for reading incoming DICOM messages. true: complete PData unit received, socket still open false: release request received, then close the socket- Parameters:
DICOMobj- The DICOM object. Null if pDataTF.getVRLinkedBuffer holds data.- Returns:
- true complete PData unit received, socket still open false release request received, then close the socket
- Throws:
DICOM_Exception- Throws an error if a problem reading in the object or data is encountered.
-
saveImageToFile
public void saveImageToFile(DICOM_Comms.ByteBuffer dataObj, java.lang.String fileName) throws DICOM_Exception
Saves the DDO to the file name supplied as a method parameter.- Parameters:
fileName- name of the file where the ddo is to be stored- Throws:
DICOM_Exception- Throws error if a problem writing the image to file is encountered.
-
sendBinary
public void sendBinary(byte[] data, int offset, int count) throws DICOM_ExceptionActual binary data to be sent.- Overrides:
sendBinaryin classDICOM_Comms- Parameters:
data- buffer of data send out the port (socket)offset- starting offsetcount- number of bytes to be sent- Throws:
Throws- an error when a problem is encoutered writing.DICOM_Exception- DOCUMENT ME!
-
setDICOMMessageDisplayer
public void setDICOMMessageDisplayer(DICOMDisplayer displayer)
Sets the display viewer.- Parameters:
displayer- The GUI used to display
-
shouldWeAcceptLocalAppTitle
public boolean shouldWeAcceptLocalAppTitle(java.lang.String AEtitle) throws DICOM_ExceptionAccept all.- Parameters:
AEtitle- the calling (remote AE Title)- Returns:
- always returns true
- Throws:
DICOM_Exception- Not used at this time!
-
shouldWeAcceptRemoteAppTitle
public boolean shouldWeAcceptRemoteAppTitle(java.lang.String remoteAETitle) throws DICOM_ExceptionAccept only AETitles listed in the server host table (remote) *** We accept all AETitles at this time!- Parameters:
remoteAETitle- - calling (remote AE Title)- Returns:
- true if the remoteAETitle has been found in the server host table (host table in the user preference file
- Throws:
DICOM_Exception- Not used at this time.
-
showMessage
public void showMessage(java.lang.String str)
Shows a message in the GUI message panel.- Parameters:
str- the message to be shown.
-
write
public void write(java.lang.String transferSyntax, DICOM_Object ddo, java.lang.String sopClassUID, byte messageHeader) throws DICOM_ExceptionWrites the image (loaded into ioBuffer from file) out the port.- Parameters:
transferSyntax- Transfer syntaxddo-sopClassUID- SOP class UIDmessageHeader- 1 = indicates command, 0 = data.- Throws:
DICOM_Exception- Throws error if an error is encountered writing the image out the port.
-
write
public void write(DICOM_Object DICOMObj, java.lang.String sopClassUID, byte messageHeader) throws DICOM_Exception
Writes the DICOMObj out through the socket.- Parameters:
DICOMObj- the DICOM object to be sent.sopClassUID- SOP class UIDmessageHeader- Value of 0 indicates data message. Value of 1 indicates command message.- Throws:
DICOM_Exception- Indicates erroring writing DICOM objects.
-
finalize
protected void finalize()
Used to make sure socket has properly been closed.- Overrides:
finalizein classDICOM_Comms
-
getTransferSyntaxID
protected java.lang.String getTransferSyntaxID()
Gets the transfer syntax ID of the data.- Returns:
- String the transfer syntax UID.
-
abort
private void abort()
Aborts an association and closes the socket.
-
buildRawBuffer
private void buildRawBuffer(DICOM_Comms vrBuffer)
Fills the compData buffer from the vrBuffer.incomming buffers.- Parameters:
vrBuffer- DICOM_Comms
-
canWeHandleTransferSyntax
private boolean canWeHandleTransferSyntax(DICOM_PDUItemType trnSyntax)
Determines wheather or not this transfer syntax is support by MIPAV.- Parameters:
trnSyntax- transfer syntax we need to check to see if we support it- Returns:
- true if we support the transfer syntax - false if not
-
constructUserInformation
private DICOM_UserInformation constructUserInformation()
Fills the with MIPAV information.- Returns:
- the user information object
-
interrogateAAssociateAC
private boolean interrogateAAssociateAC()
Decompose association ack.- Returns:
- if at least one is an acceptable syntax return true else return false.
-
interrogateAAssociateRQ
private boolean interrogateAAssociateRQ() throws DICOM_ExceptionDecompose association request and send proper response.- Returns:
- Returns false if it fails.
- Throws:
DICOM_Exception- Throws error if an error is encountered writing response to association.
-
setApplicationContext
private void setApplicationContext(java.lang.String applicationUID)
Sets the application context UID.- Parameters:
applicationUID- The application context UID.
-
setLocalAddress
private void setLocalAddress(java.lang.String localAddress)
Sets the local address of the calling application entity.- Parameters:
localAddress- The IP address of the calling application entity.
-
shouldWeAcceptAbstractSyntax
private boolean shouldWeAcceptAbstractSyntax(DICOM_PDUItemType abstractSyntax)
Should MIPAV accept the abstract syntax.- Parameters:
abstractSyntax- The abstract syntax that will be compared to the list of abstract syntaxes that is supported.- Returns:
- True if we support the abstract syntax, otherwise false.
-
shouldWeAcceptApplicationContext
private boolean shouldWeAcceptApplicationContext(DICOM_PDUItemType applicationContext)
As it turn out we accept all application contexts.- Parameters:
applicationContext- The application context to be check to be . Not used at this time.- Returns:
- Always returns true.
-
parseDICOMintoBuffer
public void parseDICOMintoBuffer(DICOM_Object ddo, DICOM_Comms vrBuffer, DICOM_FileIO ioBuffer)
-
-