Example #1
0
        /// <summary>
        /// Query the Information Model using the given query message.
        /// </summary>
        /// <param name="queryMessage">Message used to query the Information Model.</param>
        /// <returns>DicomMessageCollection - containing the query responses. The final query response (without a dataset) is also included.</returns>
        public DicomMessageCollection QueryInformationModel(DicomMessage queryMessage)
        {
            DicomMessageCollection responseMessages = new DicomMessageCollection();

            DvtkHighLevelInterface.Dicom.Other.Values values = queryMessage.CommandSet["0x00000002"].Values;
            System.String sopClassUid = values[0];

            DataSet queryDataset = queryMessage.DataSet;

            Dvtk.Dicom.InformationEntity.DataSetCollection queryResponses = _root.QueryInformationModel(queryDataset.DvtkDataDataSet);

            DvtkData.Dimse.DicomMessage dvtkDicomMessage = null;
            DvtkData.Dimse.CommandSet   dvtkCommand      = null;
            DicomMessage responseMessage = null;

            if (queryResponses != null)
            {
                foreach (DvtkData.Dimse.DataSet dvtkDataset in queryResponses)
                {
                    dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
                    dvtkCommand      = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
                    dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
                    dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0xFF00);

                    dvtkDicomMessage.Apply(dvtkCommand, dvtkDataset, queryMessage.EncodedPresentationContextID);
                    responseMessage = new DicomMessage(dvtkDicomMessage);
                    responseMessages.Add(responseMessage);
                }
            }

            dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
            dvtkCommand      = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
            dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
            dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0x0000);

            dvtkDicomMessage.Apply(dvtkCommand, queryMessage.EncodedPresentationContextID);
            responseMessage = new DicomMessage(dvtkDicomMessage);
            responseMessages.Add(responseMessage);

            return(responseMessages);
        }
Example #2
0
        /// <summary>
        /// Constructor.
        ///
        /// Use this constructor to construct the command set and data set based on the
        /// command set and data set contained in the encapsulated DvtkData DicomMessage.
        /// </summary>
        /// <param name="dvtkDataDicomMessage">The encapsulated DvtkData DicomMessage.</param>
        internal DicomMessage(DvtkData.Dimse.DicomMessage dvtkDataDicomMessage)
        {
            // Sanity check.
            if (dvtkDataDicomMessage == null)
            {
                DvtkHighLevelInterfaceException.Throw("Parameter may not be null.");
            }

            // Create the CommandSet object.
            this.commandSet = new CommandSet(dvtkDataDicomMessage.CommandSet);

            // Create the DataSet object.
            if (dvtkDataDicomMessage.DataSet == null)
            {
                this.dataSet = new DataSet();
            }
            else
            {
                this.dataSet = new DataSet(dvtkDataDicomMessage.DataSet);
            }
        }
Example #3
0
        /// <summary>
        /// Constructor.
        ///
        /// Use this constructor to construct the command set and data set based on the
        /// command set and data set contained in the encapsulated DvtkData DicomMessage.
        /// </summary>
        /// <param name="dvtkDataDicomMessage">The encapsulated DvtkData DicomMessage.</param>
        internal DicomMessage(DvtkData.Dimse.DicomMessage dvtkDataDicomMessage)
        {
            // Sanity check.
            if (dvtkDataDicomMessage == null)
            {
                throw new HliException("Parameter may not be null.");
            }

            // Create the CommandSet object.
            this.commandSet = new CommandSet(dvtkDataDicomMessage.CommandSet);

            // Create the DataSet object.
            if (dvtkDataDicomMessage.DataSet == null)
            {
                this.dataSet = new DataSet();
            }
            else
            {
                this.dataSet = new DataSet(dvtkDataDicomMessage.DataSet);
            }

            this.encodedPCID = dvtkDataDicomMessage.EncodedPresentationContextID;
        }
Example #4
0
        /// <summary>
        /// Query the Information Model using the given query message.
        /// </summary>
        /// <param name="queryMessage">Message used to query the Information Model.</param>
        /// <returns>DicomMessageCollection - containing the query responses. The final query response (without a dataset) is also included.</returns>
        public DicomMessageCollection QueryInformationModel(DicomMessage queryMessage)
        {
            DicomMessageCollection responseMessages = new DicomMessageCollection();

            DvtkHighLevelInterface.Values values = queryMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid            = values.GetString(1);

            DataSet           queryDataset   = queryMessage.DataSet;
            DataSetCollection queryResponses = _root.QueryInformationModel(queryDataset.DvtkDataDataSet);

            DvtkData.Dimse.DicomMessage dvtkDicomMessage = null;
            DvtkData.Dimse.CommandSet   dvtkCommand      = null;
            DicomMessage responseMessage = null;

            foreach (DvtkData.Dimse.DataSet dvtkDataset in queryResponses)
            {
                dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
                dvtkCommand      = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
                dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
                dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0xFF00);

                dvtkDicomMessage.Apply(dvtkCommand, dvtkDataset);
                responseMessage = new DicomMessage(dvtkDicomMessage);
                responseMessages.Add(responseMessage);
            }

            dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
            dvtkCommand      = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
            dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
            dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0x0000);

            dvtkDicomMessage.Apply(dvtkCommand);
            responseMessage = new DicomMessage(dvtkDicomMessage);
            responseMessages.Add(responseMessage);

            return(responseMessages);
        }
Example #5
0
        /// <summary>
        /// Query the Information Model using the given query message.
        /// </summary>
        /// <param name="queryMessage">Message used to query the Information Model.</param>
        /// <returns>DicomMessageCollection - containing the query responses. The final query response (without a dataset) is also included.</returns>
        public DicomMessageCollection QueryInformationModel(DicomMessage queryMessage)
        {
            DicomMessageCollection responseMessages = new DicomMessageCollection();

            DvtkHighLevelInterface.Values values = queryMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid = values.GetString(1);

            DataSet queryDataset = queryMessage.DataSet;
            DataSetCollection queryResponses = _root.QueryInformationModel(queryDataset.DvtkDataDataSet);

            DvtkData.Dimse.DicomMessage dvtkDicomMessage = null;
            DvtkData.Dimse.CommandSet dvtkCommand = null;
            DicomMessage responseMessage = null;

            foreach (DvtkData.Dimse.DataSet dvtkDataset in queryResponses)
            {
                dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
                dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
                dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
                dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0xFF00);

                dvtkDicomMessage.Apply(dvtkCommand, dvtkDataset);
                responseMessage = new DicomMessage(dvtkDicomMessage);
                responseMessages.Add(responseMessage);
            }

            dvtkDicomMessage = new DvtkData.Dimse.DicomMessage();
            dvtkCommand = new DvtkData.Dimse.CommandSet(DvtkData.Dimse.DimseCommand.CFINDRSP);
            dvtkCommand.AddAttribute(0x0000, 0x0002, DvtkData.Dimse.VR.UI, sopClassUid);
            dvtkCommand.AddAttribute(0x0000, 0x0900, DvtkData.Dimse.VR.US, 0x0000);

            dvtkDicomMessage.Apply(dvtkCommand);
            responseMessage = new DicomMessage(dvtkDicomMessage);
            responseMessages.Add(responseMessage);

            return responseMessages;
        }
Example #6
0
        protected override void Execute()
        {
            // loop through all associations
            // Get all kind of DICOM messages from the sniffer file stream.
            DvtkData.Message            message                 = null;
            DvtkData.Dimse.DicomMessage lastMessage             = null;
            DvtkData.Dul.AcceptedPresentationContextList accPCs = null;
            ReceivedMsgReturnCode retcode = ReceivedMsgReturnCode.Failure;

            retcode = dvtkSnifferSession.ReceiveMessage(out message);
            try
            {
                while ((retcode == ReceivedMsgReturnCode.Success) && (message != null))
                {
                    // DicomMessage needs to be validated against a definition file and VR.
                    ValidationControlFlags validationFlags = ValidationControlFlags.None;
                    validationFlags |= ValidationControlFlags.UseDefinitions;
                    validationFlags |= ValidationControlFlags.UseValueRepresentations;

                    if (message is DvtkData.Dul.DulMessage)
                    {
                        //Extract Calling/Called AE Title from received message and save is to
                        // Dvtk Script session
                        if (message is DvtkData.Dul.A_ASSOCIATE_RQ)
                        {
                            DvtkData.Dul.A_ASSOCIATE_RQ assocReq = (DvtkData.Dul.A_ASSOCIATE_RQ)message;
                            Options.DvtkScriptSession.DvtSystemSettings.AeTitle = assocReq.CalledAETitle;
                            Options.DvtkScriptSession.SutSystemSettings.AeTitle = assocReq.CallingAETitle;
                        }

                        if (message is DvtkData.Dul.A_ASSOCIATE_AC)
                        {
                            DvtkData.Dul.A_ASSOCIATE_AC assocAcc = (DvtkData.Dul.A_ASSOCIATE_AC)message;
                            Options.DvtkScriptSession.DvtSystemSettings.AeTitle = assocAcc.CallingAETitle;
                            Options.DvtkScriptSession.SutSystemSettings.AeTitle = assocAcc.CalledAETitle;
                            accPCs = assocAcc.PresentationContexts;
                        }

                        Options.DvtkScriptSession.Validate(message as DvtkData.Dul.DulMessage, null, validationFlags);
                    }
                    else
                    {
                        DvtkData.Dimse.DicomMessage dimseMsg = (DvtkData.Dimse.DicomMessage)message;
                        if (dimseMsg.CommandField == DvtkData.Dimse.DimseCommand.CFINDRQ)
                        {
                            lastMessage = dimseMsg;
                        }

                        foreach (DvtkData.Dul.AcceptedPresentationContext acc in accPCs)
                        {
                            if ((acc.Result == 0) && (acc.ID == dimseMsg.EncodedPresentationContextID))
                            {
                                if (acc.TransferSyntax != DvtkData.Dul.TransferSyntax.Implicit_VR_Little_Endian)
                                {
                                    Options.DvtkScriptSession.IsDataTransferExplicit = true;
                                }
                                else
                                {
                                    Options.DvtkScriptSession.IsDataTransferExplicit = false;
                                }
                                break;
                            }
                        }

                        if ((dimseMsg.CommandField == DvtkData.Dimse.DimseCommand.CFINDRSP) && (lastMessage != null))
                        {
                            Options.DvtkScriptSession.Validate(dimseMsg, null, lastMessage, validationFlags);
                        }
                        else
                        {
                            Options.DvtkScriptSession.Validate(dimseMsg, null, validationFlags);
                        }
                    }

                    message = null;
                    retcode = dvtkSnifferSession.ReceiveMessage(out message);
                    if ((retcode == ReceivedMsgReturnCode.IncompleteByteStream) && (message == null))
                    {
                        string msg = string.Format("Incomplete byte stream, unable to perform further validation, see {0} for detail logging in {1} directory.", (associationName + ".log"), this.Options.ResultsDirectory);
                        WriteHtmlInformation("<b><br />");
                        WriteInformation(msg);
                        WriteHtmlInformation("</b><br />");
                    }
                }
            }
            catch (Exception except)
            {
                string msg = string.Format("Validation error: {0}\n", except.Message);
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //again set the original directory
            dvtkSnifferSession.DataDirectory = orgDataDir;
        }