Class 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/
     
    • Constructor Detail

      • DICOM_PDUService

        public DICOM_PDUService()
        PDU_Service constructor.
    • 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 stream
        dobj - 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 object
        ddo - 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_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 to
        verification - if true only add Verification UID syntax.
        transferSyntax - if this is passed in, only add this transfer syntax to the the available pres contexts
        classUID - 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_Exception
        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

        public void handleConnectionFromServer​(java.net.Socket sock)
                                        throws DICOM_Exception
        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

        public void parseDICOMIntoRawVR​(DICOM_Object dobj,
                                        DICOM_Comms vrBuffer)
        Converts a DICOMObject into an outgoing DICOM data stream.
        Parameters:
        dobj - the DICOMObject to send
        vrBuffer - the I/O Buffer to write to
      • readBinary

        public int readBinary​(byte[] data,
                              int count)
                       throws DICOM_Exception
        Actual binary data from the port.
        Overrides:
        readBinary in class DICOM_Comms
        Parameters:
        data - buffer to store the data
        count - 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_Exception
        Actual binary data to be sent.
        Overrides:
        sendBinary in class DICOM_Comms
        Parameters:
        data - buffer of data send out the port (socket)
        offset - starting offset
        count - 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_Exception
        Accept 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_Exception
        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

        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_Exception
        Writes the image (loaded into ioBuffer from file) out the port.
        Parameters:
        transferSyntax - Transfer syntax
        ddo -
        sopClassUID - SOP class UID
        messageHeader - 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 UID
        messageHeader - 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:
        finalize in class DICOM_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_Exception
        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

        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.