MarkLength16() публичный Метод

Marks position to write 16-bit length value
public MarkLength16 ( String name ) : void
name String Field name
Результат void
Пример #1
0
        /// <summary>
        /// Write PDU.
        /// </summary>
        /// <param name="pdu">PDU to write.</param>
        public void Write(RawPDU pdu)
        {
            if (null != SubItem)
            {
                pdu.Write("Item-Type", (byte)0x56);
                pdu.Write("Reserved", (byte)0x00);

                pdu.MarkLength16("Item-Length");

                pdu.Write("SOP Class UID Length", (ushort)(SopClassUid.UID.Length));
                pdu.Write("SOP Class UID", SopClassUid.UID);

                SubItem.Write(pdu);

                pdu.WriteLength16();
            }
        }
Пример #2
0
        /// <summary>
        /// Writes A-ASSOCIATE-AC to PDU buffer
        /// </summary>
        /// <returns>PDU buffer</returns>
        public RawPDU Write()
        {
            RawPDU pdu = new RawPDU((byte)0x02);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", (byte)0x10);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (var pc in _assoc.PresentationContexts)
            {
                // Presentation Context
                pdu.Write("Item-Type", (byte)0x21);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", (byte)pc.ID);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Result", (byte)pc.Result);
                pdu.Write("Reserved", (byte)0x00);

                // Transfer Syntax
                pdu.Write("Item-Type", (byte)0x40);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Transfer Syntax UID", pc.AcceptedTransferSyntax.UID.UID);
                pdu.WriteLength16();

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", (byte)0x50);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", (byte)0x51);
            pdu.Write("Reserved", (byte)0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", (uint)_assoc.MaximumPDULength);

            // Implementation Class UID
            pdu.Write("Item-Type", (byte)0x52);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", DicomImplementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.MaxAsyncOpsInvoked != 1 || _assoc.MaxAsyncOpsPerformed != 1)
            {
                pdu.Write("Item-Type", (byte)0x53);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.MaxAsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.MaxAsyncOpsPerformed);
            }

            // Implementation Version
            pdu.Write("Item-Type", (byte)0x55);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", DicomImplementation.Version);
            pdu.WriteLength16();

            pdu.WriteLength16();

            return(pdu);
        }
Пример #3
0
        /// <summary>
        /// Writes A-ASSOCIATE-RQ to PDU buffer
        /// </summary>
        /// <returns>PDU buffer</returns>
        public RawPDU Write()
        {
            RawPDU pdu = new RawPDU((byte)0x01);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", (byte)0x10);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (DcmPresContext pc in _assoc.GetPresentationContexts())
            {
                // Presentation Context
                pdu.Write("Item-Type", (byte)0x20);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", (byte)pc.ID);
                pdu.Write("Reserved", (byte)0x00, 3);

                // Abstract Syntax
                pdu.Write("Item-Type", (byte)0x30);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                pdu.WriteLength16();

                // Transfer Syntax
                foreach (DicomTransferSyntax ts in pc.GetTransfers())
                {
                    pdu.Write("Item-Type", (byte)0x40);
                    pdu.Write("Reserved", (byte)0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.Write("Transfer Syntax UID", ts.UID.UID);
                    pdu.WriteLength16();
                }

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", (byte)0x50);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", (byte)0x51);
            pdu.Write("Reserved", (byte)0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", (uint)_assoc.MaximumPduLength);

            // Implementation Class UID
            pdu.Write("Item-Type", (byte)0x52);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", Implementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.NegotiateAsyncOps)
            {
                pdu.Write("Item-Type", (byte)0x53);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.AsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.AsyncOpsPerformed);
            }

            // Implementation Version
            pdu.Write("Item-Type", (byte)0x55);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", Implementation.Version);
            pdu.WriteLength16();

            pdu.WriteLength16();

            return(pdu);
        }
Пример #4
0
		/// <summary>
		/// Writes A-ASSOCIATE-AC to PDU buffer
		/// </summary>
		/// <returns>PDU buffer</returns>
		public RawPDU Write() {
			RawPDU pdu = new RawPDU((byte)0x02);

			pdu.Write("Version", (ushort)0x0001);
			pdu.Write("Reserved", 0x00, 2);
			pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
			pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
			pdu.Write("Reserved", 0x00, 32);

			// Application Context
			pdu.Write("Item-Type", (byte)0x10);
			pdu.Write("Reserved", (byte)0x00);
			pdu.MarkLength16("Item-Length");
			pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
			pdu.WriteLength16();

			foreach (var pc in _assoc.PresentationContexts) {
				// Presentation Context
				pdu.Write("Item-Type", (byte)0x21);
				pdu.Write("Reserved", (byte)0x00);
				pdu.MarkLength16("Item-Length");
				pdu.Write("Presentation Context ID", (byte)pc.ID);
				pdu.Write("Reserved", (byte)0x00);
				pdu.Write("Result", (byte)pc.Result);
				pdu.Write("Reserved", (byte)0x00);

				// Transfer Syntax
				pdu.Write("Item-Type", (byte)0x40);
				pdu.Write("Reserved", (byte)0x00);
				pdu.MarkLength16("Item-Length");
				pdu.Write("Transfer Syntax UID", pc.AcceptedTransferSyntax.UID.UID);
				pdu.WriteLength16();

				pdu.WriteLength16();
			}

			// User Data Fields
			pdu.Write("Item-Type", (byte)0x50);
			pdu.Write("Reserved", (byte)0x00);
			pdu.MarkLength16("Item-Length");

			// Maximum PDU
			pdu.Write("Item-Type", (byte)0x51);
			pdu.Write("Reserved", (byte)0x00);
			pdu.Write("Item-Length", (ushort)0x0004);
			pdu.Write("Max PDU Length", (uint)_assoc.MaximumPDULength);

			// Implementation Class UID
			pdu.Write("Item-Type", (byte)0x52);
			pdu.Write("Reserved", (byte)0x00);
			pdu.MarkLength16("Item-Length");
			pdu.Write("Implementation Class UID", DicomImplementation.ClassUID.UID);
			pdu.WriteLength16();

			// Asynchronous Operations Negotiation
			if (_assoc.MaxAsyncOpsInvoked != 1 || _assoc.MaxAsyncOpsPerformed != 1) {
				pdu.Write("Item-Type", (byte)0x53);
				pdu.Write("Reserved", (byte)0x00);
				pdu.Write("Item-Length", (ushort)0x0004);
				pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.MaxAsyncOpsInvoked);
				pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.MaxAsyncOpsPerformed);
			}

			// Implementation Version
			pdu.Write("Item-Type", (byte)0x55);
			pdu.Write("Reserved", (byte)0x00);
			pdu.MarkLength16("Item-Length");
			pdu.Write("Implementation Version", DicomImplementation.Version);
			pdu.WriteLength16();

			pdu.WriteLength16();

			return pdu;
		}
Пример #5
0
        /// <summary>
        /// Writes A-ASSOCIATE-RQ to PDU buffer
        /// </summary>
        /// <returns>PDU buffer</returns>
        public RawPDU Write()
        {
            RawPDU pdu = new RawPDU((byte)0x01);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", (byte)0x10);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (var pc in _assoc.PresentationContexts)
            {
                // Presentation Context
                pdu.Write("Item-Type", (byte)0x20);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", (byte)pc.ID);
                pdu.Write("Reserved", (byte)0x00, 3);

                // Abstract Syntax
                pdu.Write("Item-Type", (byte)0x30);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                pdu.WriteLength16();

                // Transfer Syntax
                foreach (DicomTransferSyntax ts in pc.GetTransferSyntaxes())
                {
                    pdu.Write("Item-Type", (byte)0x40);
                    pdu.Write("Reserved", (byte)0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.Write("Transfer Syntax UID", ts.UID.UID);
                    pdu.WriteLength16();
                }

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", (byte)0x50);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", (byte)0x51);
            pdu.Write("Reserved", (byte)0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", (uint)_assoc.MaximumPDULength);

            // Implementation Class UID
            pdu.Write("Item-Type", (byte)0x52);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", DicomImplementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.MaxAsyncOpsInvoked != 1 || _assoc.MaxAsyncOpsPerformed != 1)
            {
                pdu.Write("Item-Type", (byte)0x53);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.MaxAsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.MaxAsyncOpsPerformed);
            }

            foreach (var pc in _assoc.PresentationContexts)
            {
                if (pc.UserRole.HasValue || pc.ProviderRole.HasValue)
                {
                    pdu.Write("Item-Type", (byte)0x54);
                    pdu.Write("Reserved", (byte)0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.MarkLength16("UID-Length");
                    pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                    pdu.WriteLength16();
                    pdu.Write("SCU Role", pc.UserRole.GetValueOrDefault() ? (byte)1 : (byte)0);
                    pdu.Write("SCP Role", pc.ProviderRole.GetValueOrDefault() ? (byte)1 : (byte)0);
                    pdu.WriteLength16();
                }
            }

            // Implementation Version
            pdu.Write("Item-Type", (byte)0x55);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", DicomImplementation.Version);
            pdu.WriteLength16();

            foreach (DicomExtendedNegotiation exNeg in _assoc.ExtendedNegotiations)
            {
                exNeg.Write(pdu);
            }

            pdu.WriteLength16();

            return pdu;
        }
Пример #6
0
        /// <summary>
        /// Writes A-ASSOCIATE-AC to PDU buffer
        /// </summary>
        /// <returns>PDU buffer</returns>
        public RawPDU Write()
        {
            var pdu = new RawPDU(0x02);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", 0x10);
            pdu.Write("Reserved", 0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (var pc in _assoc.PresentationContexts)
            {
                // Presentation Context
                pdu.Write("Item-Type", 0x21);
                pdu.Write("Reserved", 0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", pc.ID);
                pdu.Write("Reserved", 0x00);
                pdu.Write("Result", (byte)pc.Result);
                pdu.Write("Reserved", 0x00);

                // Transfer Syntax (set to Implicit VR Little Endian if no accepted transfer syntax is defined)
                pdu.Write("Item-Type", 0x40);
                pdu.Write("Reserved", 0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Transfer Syntax UID",
                          pc.AcceptedTransferSyntax?.UID.UID ?? DicomUID.ImplicitVRLittleEndian.UID);
                pdu.WriteLength16();

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", 0x50);
            pdu.Write("Reserved", 0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", 0x51);
            pdu.Write("Reserved", 0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", _assoc.MaximumPDULength);

            // Implementation Class UID
            pdu.Write("Item-Type", 0x52);
            pdu.Write("Reserved", 0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", DicomImplementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.MaxAsyncOpsInvoked != 1 || _assoc.MaxAsyncOpsPerformed != 1)
            {
                pdu.Write("Item-Type", 0x53);
                pdu.Write("Reserved", 0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.MaxAsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.MaxAsyncOpsPerformed);
            }

            foreach (var pc in _assoc.PresentationContexts)
            {
                if (pc.UserRole.HasValue || pc.ProviderRole.HasValue)
                {
                    pdu.Write("Item-Type", 0x54);
                    pdu.Write("Reserved", 0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.MarkLength16("UID-Length");
                    pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                    pdu.WriteLength16();
                    pdu.Write("SCU Role", pc.UserRole.GetValueOrDefault() ? (byte)1 : (byte)0);
                    pdu.Write("SCP Role", pc.ProviderRole.GetValueOrDefault() ? (byte)1 : (byte)0);
                    pdu.WriteLength16();
                }
            }

            // Implementation Version
            pdu.Write("Item-Type", 0x55);
            pdu.Write("Reserved", 0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", DicomImplementation.Version);
            pdu.WriteLength16();

            foreach (var exNeg in _assoc.ExtendedNegotiations)
            {
                exNeg.Write(pdu);
            }

            pdu.WriteLength16();

            return(pdu);
        }
Пример #7
0
        /// <summary>
        /// 扩展,向RawPDU中写入UserIdentity身份信息
        /// </summary>
        /// <param name="userIdentity"></param>
        /// <returns></returns>
        public RawPDU WriteAddingUserIdentity(UserIdentity userIdentity)
        {
            RawPDU pdu = new RawPDU((byte)0x01);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", (byte)0x10);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (DcmPresContext pc in _assoc.GetPresentationContexts())
            {
                // Presentation Context
                pdu.Write("Item-Type", (byte)0x20);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", (byte)pc.ID);
                pdu.Write("Reserved", (byte)0x00, 3);

                // Abstract Syntax
                pdu.Write("Item-Type", (byte)0x30);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                pdu.WriteLength16();

                // Transfer Syntax
                foreach (DicomTransferSyntax ts in pc.GetTransfers())
                {
                    pdu.Write("Item-Type", (byte)0x40);
                    pdu.Write("Reserved", (byte)0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.Write("Transfer Syntax UID", ts.UID.UID);
                    pdu.WriteLength16();
                }

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", (byte)0x50);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", (byte)0x51);
            pdu.Write("Reserved", (byte)0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", (uint)_assoc.MaximumPduLength);

            // Implementation Class UID
            pdu.Write("Item-Type", (byte)0x52);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", Implementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.NegotiateAsyncOps)
            {
                pdu.Write("Item-Type", (byte)0x53);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.AsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.AsyncOpsPerformed);
            }

            // Implementation Version
            pdu.Write("Item-Type", (byte)0x55);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", Implementation.Version);
            pdu.WriteLength16();

            //User Indentity
            //http://medical.nema.org/medical/dicom/current/output/html/part07.html#sect_D.3.3.7
            pdu.Write("Item-Type", (byte)0x58);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("User Identity Type", (byte)userIdentity.UserIdentityType);
            pdu.Write("Positive Response Requested", (userIdentity.bPositiveResponseRequested?(byte)0x01:(byte)0x00));
            pdu.Write("Primary Field Length", (ushort)userIdentity.UserName.Length);
            pdu.Write("Primary Field", userIdentity.UserName);
            pdu.Write("Secondary Field Length", (ushort)userIdentity.PassCode.Length);
            pdu.Write("Secondary Field", userIdentity.PassCode);
            pdu.WriteLength16();
            //zssure:end.


            pdu.WriteLength16();

            return(pdu);
        }
Пример #8
0
        /// <summary>
        /// Writes A-ASSOCIATE-RQ to PDU buffer
        /// </summary>
        /// <returns>PDU buffer</returns>
        public RawPDU Write()
        {
            RawPDU pdu = new RawPDU((byte)0x01);

            pdu.Write("Version", (ushort)0x0001);
            pdu.Write("Reserved", 0x00, 2);
            pdu.Write("Called AE", _assoc.CalledAE, 16, ' ');
            pdu.Write("Calling AE", _assoc.CallingAE, 16, ' ');
            pdu.Write("Reserved", 0x00, 32);

            // Application Context
            pdu.Write("Item-Type", (byte)0x10);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Application Context Name", DicomUID.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (DcmPresContext pc in _assoc.GetPresentationContexts()) {
                // Presentation Context
                pdu.Write("Item-Type", (byte)0x20);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Presentation Context ID", (byte)pc.ID);
                pdu.Write("Reserved", (byte)0x00, 3);

                // Abstract Syntax
                pdu.Write("Item-Type", (byte)0x30);
                pdu.Write("Reserved", (byte)0x00);
                pdu.MarkLength16("Item-Length");
                pdu.Write("Abstract Syntax UID", pc.AbstractSyntax.UID);
                pdu.WriteLength16();

                // Transfer Syntax
                foreach (DicomTransferSyntax ts in pc.GetTransfers()) {
                    pdu.Write("Item-Type", (byte)0x40);
                    pdu.Write("Reserved", (byte)0x00);
                    pdu.MarkLength16("Item-Length");
                    pdu.Write("Transfer Syntax UID", ts.UID.UID);
                    pdu.WriteLength16();
                }

                pdu.WriteLength16();
            }

            // User Data Fields
            pdu.Write("Item-Type", (byte)0x50);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");

            // Maximum PDU
            pdu.Write("Item-Type", (byte)0x51);
            pdu.Write("Reserved", (byte)0x00);
            pdu.Write("Item-Length", (ushort)0x0004);
            pdu.Write("Max PDU Length", (uint)_assoc.MaximumPduLength);

            // Implementation Class UID
            pdu.Write("Item-Type", (byte)0x52);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Class UID", Implementation.ClassUID.UID);
            pdu.WriteLength16();

            // Asynchronous Operations Negotiation
            if (_assoc.NegotiateAsyncOps) {
                pdu.Write("Item-Type", (byte)0x53);
                pdu.Write("Reserved", (byte)0x00);
                pdu.Write("Item-Length", (ushort)0x0004);
                pdu.Write("Asynchronous Operations Invoked", (ushort)_assoc.AsyncOpsInvoked);
                pdu.Write("Asynchronous Operations Performed", (ushort)_assoc.AsyncOpsPerformed);
            }

            // Implementation Version
            pdu.Write("Item-Type", (byte)0x55);
            pdu.Write("Reserved", (byte)0x00);
            pdu.MarkLength16("Item-Length");
            pdu.Write("Implementation Version", Implementation.Version);
            pdu.WriteLength16();

            pdu.WriteLength16();

            return pdu;
        }
Пример #9
0
        /// <summary>
        /// Write PDU.
        /// </summary>
        /// <param name="pdu">PDU to write.</param>
        public void Write(RawPDU pdu)
        {
            if (null != SubItem)
            {
                pdu.Write("Item-Type", (byte)0x56);
                pdu.Write("Reserved", (byte)0x00);

                pdu.MarkLength16("Item-Length");

                pdu.Write("SOP Class UID Length", (ushort)(SopClassUid.UID.Length));
                pdu.Write("SOP Class UID", SopClassUid.UID);

                SubItem.Write(pdu);

                pdu.WriteLength16();
            }
        }