Exemple #1
0
 public void Write(RawPDU pdu)
 {
     byte mch = (byte)((_last ? 2 : 0) + (_command ? 1 : 0));
     pdu.MarkLength32("PDV-Length");
     pdu.Write("Presentation Context ID", _pcid);
     pdu.Write("Message Control Header", mch);
     pdu.Write("PDV Value", _value);
     pdu.WriteLength32();
 }
Exemple #2
0
 public RawPDU Write()
 {
     RawPDU pdu = new RawPDU((byte)0x07);
     pdu.Write("Reserved", (byte)0x00);
     pdu.Write("Reserved", (byte)0x00);
     pdu.Write("Source", (byte)_s);
     pdu.Write("Reason", (byte)_r);
     return pdu;
 }
Exemple #3
0
 public RawPDU Write()
 {
     RawPDU pdu = new RawPDU((byte)0x06);
     pdu.Write("Reserved", (uint)0x00000000);
     return pdu;
 }
Exemple #4
0
 public RawPDU Write()
 {
     RawPDU pdu = new RawPDU((byte)0x03);
     pdu.Write("Reserved", (byte)0x00);
     pdu.Write("Result", (byte)_rt);
     pdu.Write("Source", (byte)_so);
     pdu.Write("Reason", (byte)_rn);
     return pdu;
 }
Exemple #5
0
        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", DicomUids.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            foreach (DicomPresContext pc in _assoc.GetPresentationContexts())
            {
                // 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");
                if (pc.AcceptedTransferSyntax!=null) // 
                    pdu.Write("Transfer Syntax UID", pc.AcceptedTransferSyntax.DicomUid.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.LocalMaximumPduLength);

            // 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();

            // 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;
        }
Exemple #6
0
        public RawPDU Write()
        {
            RawPDU pdu = new RawPDU(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", DicomUids.DICOMApplicationContextName.UID);
            pdu.WriteLength16();

            if (_assoc.GetPresentationContexts().Count == 0)
                throw new DicomException("No presentation contexts set for association");

            foreach (DicomPresContext 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();

                if (pc.GetTransfers().Count == 0)
                    throw new DicomException("No transfer syntaxes set for presentation context " + pc.AbstractSyntax.Name );

                // Transfer Syntax
                foreach (TransferSyntax 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.DicomUid.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.LocalMaximumPduLength);

            // Asychronous Window
            if (_assoc.LocalMaxOperationsInvoked != 1 || _assoc.LocalMaxOperationsPerformed != 1)
            {
                pdu.Write("Item-Type", (byte) 0x53);
                pdu.Write("Reserved", (byte) 0x00);
                pdu.Write("Item-Length", (ushort) 0x0004);
                pdu.Write("Max Operations Invoked", (ushort)_assoc.LocalMaxOperationsInvoked);
                pdu.Write("Max Operations Invoked", (ushort)_assoc.LocalMaxOperationsPerformed);
            }

            // SCU / SCP Role Selection

            // 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();

            // 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;
        }