コード例 #1
0
ファイル: N_CREATE.cs プロジェクト: khaha2210/radio
        public byte[] NCREATERequestCommand(byte PreCtxID, string affectedSOPClass, byte messageID, string affectedSOPInstanceUID)
        {
            var htNCREATERequestCMD = new Hashtable();
            var ngetRequestCmd = new PDataTFPDU(4);
            ngetRequestCmd.PDVContent.Command(true);

            htNCREATERequestCMD.Add(DICOMTag.AffectedSOPClassUIDTag, affectedSOPClass);
            htNCREATERequestCMD.Add(DICOMTag.CommandFieldTag, CommandFieldConst.N_CREATE_RQ);
            htNCREATERequestCMD.Add(DICOMTag.MessageIDTag, messageID);
            htNCREATERequestCMD.Add(DICOMTag.DataSetTypeTag, CommandFieldConst.NoDataSet);
            htNCREATERequestCMD.Add(DICOMTag.AffectedSOPInstanceUIDTag, affectedSOPInstanceUID);
            htNCREATERequestCMD.Add(DICOMTag.CommandGroupLengthTag, Ultility.CalculateGroupLengthValue(htNCREATERequestCMD));
            ArrayList listTag = new ArrayList(htNCREATERequestCMD.Keys);
            listTag.Sort();
            return ngetRequestCmd.CreateByteBuff(PreCtxID, true, true);
        }
コード例 #2
0
ファイル: N_GET.cs プロジェクト: khaha2210/radio
//        Table 10.3-3
//N-GET-RQ MESSAGE FIELDS
//Message Field Tag VR VM Description of Field
//Command Group Length (0000,0000) UL 1 The even number of bytes from the end of the value field to the beginning of the next group.
//Requested SOP Class UID (0000,0003) UI 1 SOP Class UID of the SOP Instance for which Attribute Values are to be retrieved.
//Command Field (0000,0100) US 1 This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0110H for the N-GET-RQ Message.
//Message ID (0000,0110) US 1 Implementation-specific value which distinguishes this Message from other Messages.
//Command Data Set Type (0000,0800) US 1 This field indicates that no Data Set shall be present in the Message. This field shall be set to the value of 0101H).
//Requested SOP Instance UID (0000,1001) UI 1 Contains the UID of the SOP Instance for which Attribute Values are to be retrieved.
//Attribute Identifier List (0000,1005) AT 1-n This field contains an Attribute Tag for each of the n Attributes applicable to the N-GET operation.
        public void CreateNGETRequestCommand(Stream os, byte preCtxID, string requestSOPClassUID, UInt16 messageID,
                                              string requestedSOPInstanceUID)
        {
            var nsetRequestCmd = new PDataTFPDU(4);

            nsetRequestCmd.PDVContent.Command(true);

            nsetRequestCmd.PDVContent.AddDataSet(requestSOPClassUID, DICOMTag.RequestedSOPClassUIDTag);
            nsetRequestCmd.PDVContent.AddDataSet(CommandFieldConst.N_GET_RQ, DICOMTag.CommandFieldTag);
            nsetRequestCmd.PDVContent.AddDataSet(messageID, DICOMTag.MessageIDTag);
            nsetRequestCmd.PDVContent.AddDataSet( CommandFieldConst.NoDataSet, DICOMTag.DataSetTypeTag);
            nsetRequestCmd.PDVContent.AddDataSet(requestedSOPInstanceUID, DICOMTag.RequestedSOPInstanceUIDTag);
            nsetRequestCmd.PDVContent.CreateGroupLengthDataset(DICOMTag.CommandGroupLengthTag);

            var sentmsg = nsetRequestCmd.CreateByteBuff(preCtxID, true, true);
            os.Write(sentmsg, 0, sentmsg.Length);
            
        }
コード例 #3
0
ファイル: DICOMPrint.cs プロジェクト: khaha2210/radio
        Int16 SetImageBox()
        {
            UnparsePDU u;
            var buff = new byte[0];

            try
            {
                var nSet = new N_SET();
                ImageBoxInstanceUID = Ultility.CreateInstanceUID(ImageBoxInstance);
                DataElement dataElement = new DataElement(DICOMTag.ImageBoxPositionTag,BitConverter.GetBytes( 1));
                FileMetaFormat fs = new FileMetaFormat() ;
                string DCMPath=@"C:\x.dcm";
                nSet.NSETRequestCommand(_stream, _presentationContextID, SOP.BasicGrayScaleImageSOPClassUID, bMessageID,
                                        ImageBoxInstanceUID, fs.ReadDCMFile(DCMPath));
                u = new UnparsePDU(_stream, buff);
                if (u.PDUType.Equals(4))
                {
                    var parsedPDU = new PDataTFPDU(u);
                    string nsetRespondstring = nSet.NSETRespondParse(parsedPDU);
                    if (!nsetRespondstring.Contains("FAILURE"))
                    {
                        Int16 retstatus = Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.StatusTag]);
                        _logger.Info("NCREATE RESPOND SUCCESS!");
                        if (!Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.DataSetTypeTag]).Equals(
                            CommandFieldConst.NoDataSet))
                        {
                            u = new UnparsePDU(_stream, buff);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.FatalException("Exception", ex);
            }
        }
コード例 #4
0
ファイル: DICOMPrint.cs プロジェクト: khaha2210/radio
//        (0x20100000,UL,0x000000AA) # 
//(0x20100010,ST,"STANDARD\1,1") # Image Display Format
//(0x20100050,CS,"8INX10IN") # Film Size ID
//(0x20100100,CS,"BLACK ") # Border Density
//(0x20100150,ST,"128 ") # Configuration Information
//(0x20100500,SQ,
//# Item Number 1
//# (0xFFFEE000, UNDEFINED) # ItemIntroducer 
//  >(0x00081150,UI,"1.2.840.10008.5.1.1.1") # Referenced SOP Class UID
//  >(0x00081155,UI,"1.2.826.0.1.3680043.2.1211.9.1") # Referenced SOP Instance UID
//# (0xFFFEE00D, 0) # ItemDelimiter 
//# (0xFFFEE0DD, 0) # SequenceDelimiter
//) # Referenced Film Session Sequence with length of: 0

        private Int16 CreateBasicFilmBox(UInt16 row,UInt16 col)
        {
            UnparsePDU u;
            var buff = new byte[0];
            try
            {
                var ncreate = new N_CREATE();
                var listAttributes = new List<DataElement>();
                DataElement dataElement;
                ImageDisplayFormat = String.Concat(@"STANDARD\",row.ToString( "D"),col.ToString( "D"));
                if ((ImageDisplayFormat.Length%2) != 0) ImageDisplayFormat += ' ';
                dataElement = new DataElement(DICOMTag.ImageDisplayFormatTag,
                                              Encoding.ASCII.GetBytes(ImageDisplayFormat));
                listAttributes.Add(dataElement);
                dataElement = new DataElement(DICOMTag.FilmOrientationTag, Encoding.ASCII.GetBytes(FilmOrientation));
                listAttributes.Add(dataElement);
                dataElement = new DataElement(DICOMTag. FilmSizeIDTag , Encoding.ASCII.GetBytes(FilmSizeID));
                listAttributes.Add(dataElement);
                
                //reference film session
                dataElement = new DataElement(DICOMTag.ReferencedFilmSessionSequenceTag, 0xFFFFFFFFU);
                listAttributes.Add(dataElement);                
                dataElement = new DataElement(DICOMTag.ItemIntroducerTag , 0xFFFFFFFFU);
                listAttributes.Add(dataElement);
                dataElement = new DataElement(DICOMTag.ReferencedSOPClassUIDTag, Encoding.ASCII.GetBytes(SOP.BasicFilmSessionSOPClassUID));
                listAttributes.Add(dataElement);
                dataElement = new DataElement(DICOMTag.ReferencedSOPInstanceUIDTag  , Encoding.ASCII.GetBytes(FilmSessionInstanceUID ));
                listAttributes.Add(dataElement);

                FilmBoxInstanceUID = Ultility.CreateInstanceUID(FilmBoxInstance);
                ncreate.NCREATERequestCommand(_stream, _presentationContextID, SOP.BasicFilmBoxSOPClassUID,
                                              bMessageID, FilmBoxInstanceUID, listAttributes);
                u = new UnparsePDU(_stream, buff);
                if (u.PDUType.Equals(4))
                {
                    var parsedPDU = new PDataTFPDU(u);
                    string ncreateRespondstring = ncreate.NCREATERespondParse(parsedPDU);
                    if (!ncreateRespondstring.Contains("FAILURE"))
                    {
                        Int16 retstatus = Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.StatusTag]);
                        _logger.Info("NCREATE RESPOND SUCCESS!");
                        if (!Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.DataSetTypeTag]).Equals(
                                CommandFieldConst.NoDataSet))
                        {
                            u = new UnparsePDU(_stream, buff);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.FatalException("Exception", ex);
            }
            return 0;
        }
コード例 #5
0
ファイル: DICOMPrint.cs プロジェクト: khaha2210/radio
 private Int16 CreateFilmSession(UInt16 NoOfCopies)
 {
     UnparsePDU u;
     var buff = new byte[0];
     try
     {
         FilmSessionInstance = new object();
         var ncreate = new N_CREATE();
         var listAttributes = new List<DataElement>();
         var dataElement = new DataElement(DICOMTag.NumberOfCopiesTag,
                                           Encoding.ASCII.GetBytes(NoOfCopies.ToString("D2")));
         listAttributes.Add(dataElement);
         FilmSessionInstanceUID = Ultility.CreateInstanceUID(FilmSessionInstance);
         ncreate.NCREATERequestCommand(_stream, _presentationContextID, SOP.BasicFilmSessionSOPClassUID,
                                       bMessageID,FilmSessionInstanceUID , listAttributes);
         u = new UnparsePDU(_stream, buff);
         if (u.PDUType.Equals(4))
         {
             var parsedPDU = new PDataTFPDU(u);
             string ncreateRespondstring = ncreate.NCREATERespondParse(parsedPDU);
             if (!ncreateRespondstring.Contains("FAILURE"))
             {
                 Int16 retstatus = Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.StatusTag]);
                 _logger.Info("NCREATE RESPOND SUCCESS!");
                 if (
                     !Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.DataSetTypeTag]).Equals(
                         CommandFieldConst.NoDataSet))
                 {
                     u = new UnparsePDU(_stream, buff);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.FatalException("Exception", ex);
     }
     return 0;
 }
コード例 #6
0
ファイル: DICOMPrint.cs プロジェクト: khaha2210/radio
        private int GetPrinterJobStatus()
        {
            UnparsePDU u;
            var buff = new byte[0];
            try
            {
                var nget = new N_GET();

                nget.CreateNGETRequestCommand(_stream,_presentationContextID, SOP.PrinterSOPClassUID,
                                                               bMessageID, SOP.PrinterSOPInstanceUID);
               
                u = new UnparsePDU(_stream, buff);
                if (u.PDUType.Equals(4))
                {
                    var parsedPDU = new PDataTFPDU(u);
                    //ParsedPDU.PDUItem[DICOMTag.MessageIDBeingRespondedToTag] == bMessageID;
                    if (Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.StatusTag]).Equals(0))
                    {
                        _logger.Info("NGET RESPOND SUCCESS!");
                        if (
                            !Convert.ToInt16(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.DataSetTypeTag]).Equals(
                                CommandFieldConst.NoDataSet))
                        {
                            u = new UnparsePDU(_stream, buff);
                            parsedPDU = new PDataTFPDU(u);
                            if (
                                Convert.ToString(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.PrintStatusTag]).
                                    Equals("FAILURE"))
                            {
                                _logger.Info("{0}{1}{2}", "Printer failure!", "\r\n",
                                             Convert.ToString(
                                                 parsedPDU.PDVContent.DataElementHashTable[DICOMTag.PrintStatusInforTag]));
                                return 0;
                            }
                            else if (
                                Convert.ToString(parsedPDU.PDVContent.DataElementHashTable[DICOMTag.PrintStatusTag])
                                    .Equals("WARNING"))
                            {
                                _logger.Info("{0}{1}{2}", "Printer warning!", "\r\n",
                                             Convert.ToString(
                                                 parsedPDU.PDVContent.DataElementHashTable[
                                                     DICOMTag.PrintStatusInforTag]));
                                return 1;
                            }
                            else if (
                                Convert.ToString(
                                    parsedPDU.PDVContent.DataElementHashTable[DICOMTag.PrintStatusTag]).Equals(
                                        "NORMAL"))
                            {
                                _logger.Info("{0}{1}{2}", "Printer normal!", "\r\n",
                                             Convert.ToString(
                                                 parsedPDU.PDVContent.DataElementHashTable[
                                                     DICOMTag.PrintStatusInforTag]));
                                return 2;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.FatalException("Exception", ex);
            }
            return 0;
        }