예제 #1
0
        public void OnData(MessageType control, Message message)
        {
            // TODO put a lock on the pdu array
            // TODO interpret the commands

            Logging.Log("CMoveServiceSCU({0}).OnData", Reflection.GetName(typeof(SOPClass), this.SOPClassUId));

            DataSet dicom = message.Dicom;

            if (MessageControl.IsCommand(control))
            {
                ushort status = (ushort)dicom[t.Status].Value;
                bool   last   = !(status == 0xFF00);

                DataSetType present = (DataSetType)dicom[t.CommandDataSetType].Value;

                Logging.Log("<< {0} {1},{2}", Enum.Parse(typeof(CommandType), dicom[t.CommandField].Value.ToString()), (last) ? "LAST FRAGMENT" : "NOT-LAST FRAGMENT", present.ToString());
                //dicom.Dump();

                string text = String.Empty;
                if (dicom.Contains(t.NumberofRemainingSuboperations))
                {
                    text += String.Format("remaining={0} ", dicom[t.NumberofRemainingSuboperations].Value);
                    results.Set(t.NumberofRemainingSuboperations, dicom[t.NumberofRemainingSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofCompletedSuboperations))
                {
                    text += String.Format("completed={0} ", dicom[t.NumberofCompletedSuboperations].Value);
                    results.Set(t.NumberofCompletedSuboperations, dicom[t.NumberofCompletedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofFailedSuboperations))
                {
                    text += String.Format("failed={0} ", dicom[t.NumberofFailedSuboperations].Value);
                    results.Set(t.NumberofFailedSuboperations, dicom[t.NumberofFailedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofWarningSuboperations))
                {
                    text += String.Format("warning={0} ", dicom[t.NumberofWarningSuboperations].Value);
                    results.Set(t.NumberofWarningSuboperations, dicom[t.NumberofWarningSuboperations].Value);
                }

                if (this.ImageMoved != null)
                {
                    ImageMoved(this, new CMoveEventArgs(dicom));
                }

                Logging.Log(text);

                if (last)
                {
                    dicom.Remove(t.NumberofRemainingSuboperations);
                    // TODO do we reset the state to Open here
                    completeEvent.Set();
                }
            }
            else
            {
                Logging.Log("<< P-DATA-TF");
            }
        }
예제 #2
0
        /// <summary>
        /// Perform an N-EVENT-REPORT Storage Commitment report over an established association with the ScpScuRole of Scp.
        /// </summary>
        /// <returns></returns>
        public bool Report(DataSet dicom)
        {
            PresentationDataPdu   pdu = new PresentationDataPdu(Syntaxes[0]);
            PresentationDataValue pdv = new PresentationDataValue(PresentationContextId, Syntaxes[0], MessageType.LastCommand);

            // for storage commit, ScpScuRoleSelectionItem is mandatory and N_EVENT_REPORT_RQ generator is the SCP
            // perhaps move Report to StorageCommitServiceSCU, and move responses in here
            Role = Role.Scp;

            DataSet command = new DataSet();

            command.Add(t.GroupLength(0), (uint)0);
            command.Add(t.AffectedSOPClassUID, SOPClass.StorageCommitmentPushModelSOPClass);
            command.Add(t.CommandField, (ushort)CommandType.N_EVENT_REPORT_RQ);
            command.Add(t.MessageId, (ushort)1);
            command.Add(t.CommandDataSetType, (ushort)DataSetType.DataSetPresent);
            command.Add(t.AffectedSOPInstanceUID, SOPClass.StorageCommitmentPushModelSOPInstance);
            command.Add(t.ActionTypeID, "1");

            pdv.Dicom = command;
            pdu.Values.Add(pdv);

            SendPdu("N_EVENT_REPORT_RQ", pdu);

            if (dicom.Contains(t.SOPClassUID))
            {
                dicom.Remove(t.SOPClassUID);
            }
            if (dicom.Contains(t.SOPInstanceUID))
            {
                dicom.Remove(t.SOPInstanceUID);
            }

            SendDataPdu("N_EVENT_REPORT_RQ DATA", dicom);

            ProcessResponse("N_EVENT_REPORT_RQ (Storage Commit)", 8000, null, null);
            return(true);
        }
예제 #3
0
        private void FlipToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dicom.Contains(t.OverlayData))
            {
                throw new Exception("Cannot flip images with Overlays.");
            }

            attributes = Utilities.GetAttributes(dicom.Elements);

            Utilities.RotateFlip(ref attributes, RotateFlipType.RotateNoneFlipX);

            GetPicture();
            Invalidate();
        }
예제 #4
0
        private void NewTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                TreeNode node = this.TreeView.SelectedNode;
                if (node != null)
                {
                    if (node.Name.Contains(" tag") && node.Text.Contains(" SQ "))
                    {
                        Sequence sequence = dicom[Key(node.Name)] as Sequence;
                        sequence.NewItem();

                        TreeNode child = node.Nodes.Add(sequence.GetPath() + " item" + node.Nodes.Count.ToString(), "Item");
                        TreeView.SelectedNode = child;
                    }
                    else
                    {
                        NewTagForm   dialog = new NewTagForm();
                        DialogResult result = dialog.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            if (node.Name.Contains(" item") || node.Name.Contains("root"))
                            {
                                TreeNode child = null;
                                foreach (string selection in dialog.Selection)
                                {
                                    Tag tag = EK.Capture.Dicom.DicomToolKit.Tag.Parse(selection);
                                    if ((tag.IsPrivate && !tag.IsPrivateCreator) || (tag.IsStandard && !Dictionary.Contains(selection)))
                                    {
                                        VRForm form = new VRForm();
                                        result = form.ShowDialog();
                                        if (result == DialogResult.OK)
                                        {
                                            // automatically add the Private Creator if not found
                                            if (tag.IsPrivate)
                                            {
                                                // e.g., (0029,1000)
                                                string creator = selection.Substring(0, 6) + "00" + selection.Substring(6, 2) + ")";
                                                if (!dicom.Contains(creator))
                                                {
                                                    dicom.Add(creator, null);

                                                    Element temp = dicom[Key(node.Name) + creator];
                                                    int     i    = FindInsertionIndex(creator, node.Nodes);
                                                    if (i <= node.Nodes.Count || node.Nodes.Count == 0)
                                                    {
                                                        child = node.Nodes.Insert(i, temp.GetPath() + " tag", Title(temp));
                                                        child.Nodes.Add(temp.GetPath() + " value", String.Empty);
                                                        child.Expand();
                                                    }
                                                }
                                            }/**/
                                            dicom.Add(selection, form.VR, null);
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    else if (node.Name.Contains("root"))
                                    {
                                        dicom.Add(selection, null);
                                    }
                                    else
                                    {
                                        Sequence sequence = dicom[Key(node.Name)] as Sequence;
                                        int      item     = 0;
                                        sequence.Items[item].Add(selection, null);
                                    }
                                    Element element = dicom[Key(node.Name) + selection];

                                    int n = FindInsertionIndex(selection, node.Nodes);

                                    if (n <= node.Nodes.Count || node.Nodes.Count == 0)
                                    {
                                        child = node.Nodes.Insert(n, element.GetPath() + " tag", Title(element));
                                        if (element.VR != "SQ")
                                        {
                                            child = child.Nodes.Add(element.GetPath() + " value", String.Empty);
                                        }
                                    }
                                }
                                if (child != null)
                                {
                                    TreeView.SelectedNode = child;
                                    TreeView.SelectedNode.BeginEdit();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Logging.Log(ex));
            }
        }