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
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:
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
FieldsModifier and TypeFieldDescriptionAbort connection request.Associate accept object.Associate reject object.Associate request object.protected DICOM_Comms.ByteBufferBuffer used to hold image data.Reference to the DICOM GUI for displaying message information.List of the results of a DICOM query.(package private) DICOM_FileIOBuffer used in sending DICOM image.list of the results of a DICOM move.Data transfer object.(package private) Vector<DICOM_PresentationContextAccept> A list of Presentation contexts.(package private) Hashtable<String, DICOM_PDUItemType> A hash table of proposed abstract syntaxes where: value = AbstractSyntaxes; key = UID.Release request.Release response.socket 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 -
Method Summary
Modifier and TypeMethodDescriptionprivate voidabort()Aborts an association and closes the socket.voidaddAbstractSyntax(String SOP_UID) Adds proposed abstract syntax to hash table.voidAdds all proposed abstract syntaxes to hash table.voidaddFindResultToList(DICOM_Object dco, DICOM_Object ddo) Utility function to collect the results of a DICOM query.voidAdds 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(String remoteAppTitle, boolean verification, String transferSyntax, String classUID) This is a simple interface to establish an association over a socket from the client (i.e.private DICOM_UserInformationFills the with MIPAV information.protected voidfinalize()Used to make sure socket has properly been closed.Returns the association request.Implementation class uid.Implementation version uid.Returns the AETitle we use to identify ourself (our local AppTitle name).protected StringGets the transfer syntax ID of the data.voidEstablishes an association over a socket from the server (SCP) side.private booleanDecompose association ack.private booleanDecompose 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 String[]parseServerInfo(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.readDICOMDataObjectFromFile(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, 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(String applicationUID) Sets the application context UID.voidsetDICOMMessageDisplayer(DICOMDisplayer displayer) Sets the display viewer.private voidsetLocalAddress(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(String AEtitle) Accept all.booleanshouldWeAcceptRemoteAppTitle(String remoteAETitle) Accept only AETitles listed in the server host table (remote) *** We accept all AETitles at this time!voidshowMessage(String str) Shows a message in the GUI message panel.voidwrite(DICOM_Object DICOMObj, String sopClassUID, byte messageHeader) Writes the DICOMObj out through the socket.voidwrite(String transferSyntax, DICOM_Object ddo, 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 Details
-
abortRQ
Abort connection request. -
associateAC
Associate accept object. -
associateRJ
Associate reject object. -
associateRQ
Associate request object. -
dicomMessageDisplayer
Reference to the DICOM GUI for displaying message information. -
findResults
List of the results of a DICOM query. -
moveResults
list of the results of a DICOM move. -
pDataTF
Data transfer object. -
releaseRQ
Release request. -
releaseRSP
Release response. -
socket
socket used to connect to server. -
compData
Buffer used to hold image data. -
PresentationContexts
Vector<DICOM_PresentationContextAccept> PresentationContextsA list of Presentation contexts. -
proposedAbstractSyntaxs
Hashtable<String,DICOM_PDUItemType> proposedAbstractSyntaxsA hash table of proposed abstract syntaxes where: value = AbstractSyntaxes; key = UID. -
ioBuffer
DICOM_FileIO ioBufferBuffer used in sending DICOM image.
-
-
Constructor Details
-
DICOM_PDUService
public DICOM_PDUService()PDU_Service constructor.
-
-
Method Details
-
parseRawVRIntoDICOM
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
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
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
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(String remoteAppTitle, boolean verification, String transferSyntax, String classUID) throws DICOM_Exception This 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
Returns the association request.- Returns:
- the association request
-
getImplementationClassUID
Implementation class uid.- Returns:
- the UID
-
getImplementationVersion
Implementation version uid.- Returns:
- The version.
-
getLocalAppTitle
Returns 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
Establishes 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
Converts a DICOMObject into an outgoing DICOM data stream.- Parameters:
dobj- the DICOMObject to sendvrBuffer- the I/O Buffer to write to
-
readBinary
Actual 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
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
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
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
Actual 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
-
setDICOMMessageDisplayer
Sets the display viewer.- Parameters:
displayer- The GUI used to display
-
shouldWeAcceptLocalAppTitle
Accept all.- Parameters:
AEtitle- the calling (remote AE Title)- Returns:
- always returns true
- Throws:
DICOM_Exception- Not used at this time!
-
shouldWeAcceptRemoteAppTitle
Accept 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
Shows a message in the GUI message panel.- Parameters:
str- the message to be shown.
-
write
public void write(String transferSyntax, DICOM_Object ddo, String sopClassUID, byte messageHeader) throws DICOM_Exception Writes 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, 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
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
Fills the compData buffer from the vrBuffer.incomming buffers.- Parameters:
vrBuffer- DICOM_Comms
-
canWeHandleTransferSyntax
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
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
Decompose 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
Sets the application context UID.- Parameters:
applicationUID- The application context UID.
-
setLocalAddress
Sets the local address of the calling application entity.- Parameters:
localAddress- The IP address of the calling application entity.
-
shouldWeAcceptAbstractSyntax
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
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
-