Ejemplo n.º 1
0
 /// <summary>
 /// Write PDU data.
 /// </summary>
 /// <param name="pdu">PDU data to write.</param>
 public void Write(RawPDU pdu)
 {
     if (RelationalRetrieval.HasValue)
     {
         pdu.Write("Relational RelationalRetrieval", RelationalRetrieval.Value);
     }
 }
Ejemplo n.º 2
0
        public void AssociateRJ_Read_ReasonGivenByContext(byte[] buffer, AAssociateRJ _, string expected)
        {
            using var raw = new RawPDU(buffer);
            var reject = new AAssociateRJ();

            reject.Read(raw);
            var actual = reject.Reason.ToString();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        private RawPDU ConvertWriteToReadPdu(RawPDU writePdu)
        {
            using var stream = new MemoryStream();
            writePdu.WritePDU(stream);

            int length = (int)stream.Length;

            byte[] buffer = new byte[length];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(buffer, 0, length);
            return(new RawPDU(buffer));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Factory method for creating a <see cref="RootQueryRetrieveInfoMove"/> instance.
        /// </summary>
        /// <param name="pdu">Raw PDU.</param>
        /// <param name="itemSize">Item size.</param>
        /// <param name="bytesRead">Bytes read.</param>
        /// <returns>The created <see cref="RootQueryRetrieveInfoMove"/> instance.</returns>
        public static RootQueryRetrieveInfoMove Create(RawPDU pdu, int itemSize, out int bytesRead)
        {
            bytesRead = 0;
            byte? relationalRetrieval = null;
            if (itemSize > 0)
            {
                relationalRetrieval = pdu.ReadByte("Relational Retrieval");

                bytesRead = 1;
            }

            return new RootQueryRetrieveInfoMove(relationalRetrieval);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Factory method for creating a <see cref="RootQueryRetrieveInfoMove"/> instance.
        /// </summary>
        /// <param name="pdu">Raw PDU.</param>
        /// <param name="itemSize">Item size.</param>
        /// <param name="bytesRead">Bytes read.</param>
        /// <returns>The created <see cref="RootQueryRetrieveInfoMove"/> instance.</returns>
        public static RootQueryRetrieveInfoMove Create(RawPDU pdu, int itemSize, out int bytesRead)
        {
            bytesRead = 0;
            byte?relationalRetrieval = null;

            if (itemSize > 0)
            {
                relationalRetrieval = pdu.ReadByte("Relational Retrieval");

                bytesRead = 1;
            }

            return(new RootQueryRetrieveInfoMove(relationalRetrieval));
        }
Ejemplo n.º 6
0
        public void Save_ToNonExistingDirectory_Succeeds()
        {
            var path = TestData.Resolve("PDU Test");
            var name = Path.Combine(path, "assoc.pdu");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            var pdu = new RawPDU(0x01);

            pdu.Save(new FileReference(name));

            Assert.True(File.Exists(name));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Factory method for creating a <see cref="RootQueryRetrieveInfoFind"/> instance.
        /// </summary>
        /// <param name="raw">Raw PDU.</param>
        /// <param name="itemSize">Item size.</param>
        /// <param name="bytesRead">Bytes read.</param>
        /// <returns>The created <see cref="RootQueryRetrieveInfoFind"/> instance.</returns>
        public static RootQueryRetrieveInfoFind Create(RawPDU raw, int itemSize, out int bytesRead)
        {
            byte?relationalQueries                 = null;
            byte?dateTimeMatching                  = null;
            byte?fuzzySemanticMatching             = null;
            byte?timezoneQueryAdjustment           = null;
            byte?enhancedMultiFrameImageConversion = null;

            bytesRead = 0;
            if (itemSize > 0)
            {
                relationalQueries = raw.ReadByte("Relational-queries");
                bytesRead++;

                if (itemSize > 1)
                {
                    dateTimeMatching = raw.ReadByte("Date-Time matching");
                    bytesRead++;

                    if (itemSize > 2)
                    {
                        fuzzySemanticMatching = raw.ReadByte("Fuzzy semantic matching");
                        bytesRead++;

                        if (itemSize > 3)
                        {
                            timezoneQueryAdjustment = raw.ReadByte("Timezone query adjustment");
                            bytesRead++;

                            if (itemSize > 4)
                            {
                                enhancedMultiFrameImageConversion = raw.ReadByte(
                                    "Enhanced Multi-Frame Image Conversion");
                                bytesRead++;
                            }
                        }
                    }
                }
            }

            return(new RootQueryRetrieveInfoFind(
                       relationalQueries,
                       dateTimeMatching,
                       fuzzySemanticMatching,
                       timezoneQueryAdjustment,
                       enhancedMultiFrameImageConversion));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Factory method for creating a <see cref="RootQueryRetrieveInfoFind"/> instance.
        /// </summary>
        /// <param name="raw">Raw PDU.</param>
        /// <param name="itemSize">Item size.</param>
        /// <param name="bytesRead">Bytes read.</param>
        /// <returns>The created <see cref="RootQueryRetrieveInfoFind"/> instance.</returns>
        public static RootQueryRetrieveInfoFind Create(RawPDU raw, int itemSize, out int bytesRead)
        {
            byte? relationalQueries = null;
            byte? dateTimeMatching = null;
            byte? fuzzySemanticMatching = null;
            byte? timezoneQueryAdjustment = null;
            byte? enhancedMultiFrameImageConversion = null;

            bytesRead = 0;
            if (itemSize > 0)
            {
                relationalQueries = raw.ReadByte("Relational-queries");
                bytesRead++;

                if (itemSize > 1)
                {
                    dateTimeMatching = raw.ReadByte("Date-Time matching");
                    bytesRead++;

                    if (itemSize > 2)
                    {
                        fuzzySemanticMatching = raw.ReadByte("Fuzzy semantic matching");
                        bytesRead++;

                        if (itemSize > 3)
                        {
                            timezoneQueryAdjustment = raw.ReadByte("Timezone query adjustment");
                            bytesRead++;

                            if (itemSize > 4)
                            {
                                enhancedMultiFrameImageConversion = raw.ReadByte(
                                    "Enhanced Multi-Frame Image Conversion");
                                bytesRead++;
                            }
                        }
                    }
                }
            }

            return new RootQueryRetrieveInfoFind(
                relationalQueries,
                dateTimeMatching,
                fuzzySemanticMatching,
                timezoneQueryAdjustment,
                enhancedMultiFrameImageConversion);
        }
Ejemplo n.º 9
0
        public void AssociateAC_Read_TransferSyntaxIdentifiedIfAccept(byte[] buffer, byte contextId,
                                                                      DicomPresentationContextResult result, DicomTransferSyntax syntax)
        {
            var association = new DicomAssociation();

            association.PresentationContexts.Add(
                new DicomPresentationContext(contextId, DicomUID.Verification));

            using var raw = new RawPDU(buffer);
            var accept = new AAssociateAC(association);

            accept.Read(raw);

            var actual = association.PresentationContexts[contextId];

            Assert.Equal(result, actual.Result);
            Assert.Equal(syntax, actual.AcceptedTransferSyntax);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Write PDU data.
        /// </summary>
        /// <param name="pdu">PDU data to write.</param>
        public void Write(RawPDU pdu)
        {
            if (RelationalQueries.HasValue)
            {
                pdu.Write("Relational-queries", RelationalQueries.Value);

                if (DateTimeMatching.HasValue)
                {
                    pdu.Write("Date-Time matching", DateTimeMatching.Value);
                    if (FuzzySemanticMatching.HasValue)
                    {
                        pdu.Write("Fuzzy semantic matching", FuzzySemanticMatching.Value);
                        if (TimezoneQueryAdjustment.HasValue)
                        {
                            pdu.Write("Timezone query adjustment", TimezoneQueryAdjustment.Value);

                            if (EnhancedMultiFrameImageConversion.HasValue)
                            {
                                pdu.Write(
                                    "Enhanced Multi-Frame Image Conversion",
                                    EnhancedMultiFrameImageConversion.Value);
                            }
                        }
                    }
                }
            }
        }