Beispiel #1
0
 public Dimse(int pcid, String tsUID, Command cmd, Stream ins)
 {
     this.m_pcid = pcid;
     this.cmd = cmd;
     this.ds = null;
     this.src = null;
     this.m_ins = ins;
     this.tsUID = tsUID;
 }
Beispiel #2
0
 public Dimse(int pcid, Command cmd, Dataset ds, DataSourceI src)
 {
     this.m_pcid = pcid;
     this.cmd = cmd;
     this.ds = ds;
     this.src = src;
     this.m_ins = null;
     this.tsUID = null;
     this.cmd.PutUS(Tags.DataSetType, ds == null && src == null?Command.NO_DATASET:0);
 }
 public virtual void WriteTo(Command cmd)
 {
     cmd.PutUS(Tags.Status, status);
     String msg = Message;
     if (msg != null && msg.Length > 0)
     {
         cmd.PutLO(Tags.ErrorComment, msg.Length > 64?msg.Substring(0, (64) - (0)):msg);
     }
     if (errorID >= 0)
     {
         cmd.PutUS(Tags.ErrorID, errorID);
     }
     if (actionTypeID >= 0)
     {
         cmd.PutUS(Tags.ActionTypeID, actionTypeID);
     }
     if (eventTypeID >= 0)
     {
         cmd.PutUS(Tags.EventTypeID, eventTypeID);
     }
 }
 public virtual Dimse NewDimse(int pcid, Command cmd, DataSourceI src)
 {
     return new Dimse(pcid, cmd, null, src);
 }
 public virtual Dimse NewDimse(int pcid, Command cmd, Dataset ds)
 {
     return new Dimse(pcid, cmd, ds, null);
 }
 public virtual Dimse NewDimse(int pcid, Command cmd)
 {
     return new Dimse(pcid, cmd, null, null);
 }
 protected override void DoCEcho(ActiveAssociation assoc, Dimse rq, Command rspCmd)
 {
     rspCmd.PutUS(Tags.Status,DcmServiceBase.SUCCESS);
 }
 // Private -------------------------------------------------------
 private void DoMultiRsp(ActiveAssociation assoc, Dimse rq, Command rspCmd, MultiDimseRsp mdr)
 {
     try
     {
         assoc.AddCancelListener(rspCmd.MessageIDToBeingRespondedTo, mdr.CancelListener);
         do
         {
             Dataset rspData = mdr.next(assoc, rq, rspCmd);
             Dimse rsp = assocFact.NewDimse(rq.pcid(), rspCmd, rspData);
             assoc.Association.Write(rsp);
             DoAfterRsp(assoc, rsp);
         }
         while (rspCmd.IsPending());
     }
     finally
     {
         mdr.release();
     }
 }
 protected virtual Dataset DoNSet(ActiveAssociation assoc, Dimse rq, Command rspCmd)
 {
     org.dicomcs.data.Dataset generatedAux = rq.Dataset; // read out dataset
     throw defEx;
 }
Beispiel #10
0
 protected virtual void DoCEcho(ActiveAssociation assoc, Dimse rq, Command rspCmd)
 {
     //      rq.getDataset(); // read out dataset
     throw defEx;
 }
Beispiel #11
0
 public virtual void n_action(ActiveAssociation assoc, Dimse rq)
 {
     Command rqCmd = rq.Command;
     Command rspCmd = new Command();
     rspCmd.InitNActionRSP(rqCmd.MessageID, rqCmd.RequestedSOPClassUID, rqCmd.RequestedSOPInstanceUID, SUCCESS);
     Dataset rspData = null;
     try
     {
         rspData = DoNAction(assoc, rq, rspCmd);
     }
     catch (DcmServiceException e)
     {
         e.WriteTo(rspCmd);
     }
     Dimse rsp = assocFact.NewDimse(rq.pcid(), rspCmd, rspData);
     assoc.Association.Write(rsp);
     DoAfterRsp(assoc, rsp);
 }
Beispiel #12
0
        /// <summary>
        /// Read DIMSE message from the current association
        /// </summary>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public Dimse Read(int timeout)
        {
            lock(this)
            {
                this.timeout = timeout;
                if (!NextPDV())
                {
                    return null;
                }
                if (!pdv.cmd())
                {
                    Abort("Command PDV expected, but received " + pdv);
                }
                int pcid = pdv.pcid();
                String tsUID = fsm.GetAcceptedTransferSyntaxUID(pcid);
                if (tsUID == null)
                {
                    Abort("No Presentation Context negotiated with pcid:" + pcid);
                }
                Stream ins = new PDataTFInputStream(this, pdv.InputStream);
                cmd = dcmObjFact.NewCommand();
                bool ds = false;
                try
                {
                    cmd.Read(ins);
                    ds = cmd.HasDataset();
                }
                catch (ArgumentException e)
                {
                    Abort(e.Message);
                }
                catch (DcmValueException e)
                {
                    Abort(e.Message);
                }
                finally
                {
                    ins.Close();
                    ins= null;
                }

                if (ds)
                {
                    if (!NextPDV())
                    {
                        throw new EndOfStreamException("Association released during receive of DIMSE");
                    }
                    if (pdv.cmd())
                    {
                        Abort("Data PDV expected, but received " + pdv);
                    }
                    if (pcid != pdv.pcid())
                    {
                        Abort("Mismatch between Command PDV pcid: " + pcid + " and " + pdv);
                    }
                    ins = new PDataTFInputStream(this, pdv.InputStream);
                }
                else
                {
                    // no Dataset
                    // if no Data Fragment
                    ForkNextReadNext();
                }
                Dimse retval = new Dimse(pcid, tsUID, cmd, ins);
                fsm.FireReceived(retval);
                return retval;
            }
        }
Beispiel #13
0
 protected override void DoCStore(ActiveAssociation assoc, Dimse rq, Command rspCmd)
 {
     Command rqCmd = rq.Command;
     Stream ins = rq.DataAsStream;
     try
     {
         String instUID = rqCmd.AffectedSOPInstanceUID;
         String classUID = rqCmd.AffectedSOPClassUID;
         DcmDecodeParam decParam = DcmDecodeParam.ValueOf(rq.TransferSyntaxUID);
         Dataset ds = objFact.NewDataset();
         DcmParser parser = parserFact.NewDcmParser(ins);
         parser.DcmHandler = ds.DcmHandler;
         parser.ParseDataset(decParam, Tags.PixelData);
         ds.SetFileMetaInfo( objFact.NewFileMetaInfo(classUID, instUID, rq.TransferSyntaxUID) );
         FileInfo file = toFile(ds);
         storeToFile(parser, ds, file, (DcmEncodeParam) decParam);
         rspCmd.PutUS(Tags.Status, SUCCESS);
     }
     catch (System.Exception e)
     {
         log.Error(e.Message, e);
         throw new DcmServiceException(PROCESSING_FAILURE, e);
     }
     finally
     {
         ins.Close();
     }
 }