Exemple #1
0
        private void comboBoxConnections_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            HideTabs();

            //Get the selected Association handle
            signature = comboBoxConnections.SelectedItem.ToString();
            comboBoxConnections.Select(0,signature.Length);
            assocHandle = (Association) dicom.ConnectionsList[signature];

            //Fill up the Association overview for selected association
            if (assocHandle != null)
            {
                callingAETitle.Text = assocHandle.CallingAETitle;
                calledAETitle.Text = assocHandle.CalledAETitle;
                richTextBoxReq.Text = assocHandle.RequestedPresentationContexts;
                richTextBoxAccept.Text = assocHandle.AcceptedPresentationContexts;

                reqIPAddress.Text = assocHandle.CalledAETitle;
                accIPAddress.Text = assocHandle.CallingAETitle;

                DisplayIPAddress(signature);
            }

            //Fill up the PDUs overview for selected association
            ClearLists();

            if (assocHandle != null)
            {
                foreach (PDU_DETAIL pdu in assocHandle.PDUList)
                {
                    PreparePDUList(pdu);
                }

                //Display validation result for selected association
                ActionEvaluateSelectedDICOMCommunication();
            }
        }
Exemple #2
0
        /// <summary>
        /// This is the main routine called from TCP layer for handling DICOM data
        /// </summary>
        /// <param name="state"></param>
        /// <param name="direction"></param>
        public void ReceiveTCPData(TCPState state, int direction)
        {
            byte[] p = state.data[direction];
            int length = (int)state.Position[direction];
            uint Position = 0;
            Association Assoc = (Association)state.UserInfo;
            bool TryAnotherPDU = true;

            while(length >= Position + 6 && TryAnotherPDU)
            {
                TryAnotherPDU = false;
                byte PDUType = p[Position];
                uint Index = Position + 2;
                uint PDULength = DICOMUtility.Get4BytesBigEndian( p , ref Index);

                if(Assoc == null && PDUType == 1)
                {
                    Assoc = new Association(state, BaseFileName + state.Signature[0], System.DateTime.Now);
                    Assoc.Output += new Association.OutputEvent(OutputHandler);
                    state.UserInfo = Assoc;
                    string signature = state.Signature[0];
                    list.Add(signature,Assoc);
                    OutputHandler("New : " + signature + "\r\n",true,true);
            //                    snifferObj.Invoke(snifferObj.AddConnectionHandler, new object[] { signature });
                }

                if(Assoc !=null && length >= Index + PDULength)
                {
                    lock(Assoc)
                    {
                        Assoc.HandlePDU(p,Position,PDULength,direction, state);
                        TryAnotherPDU = true;
                    }
                }
                else if(length>64000 && Assoc==null) // non-DICOM
                {
                    OutputHandler("Non-DICOM data : " + state.Signature[0] + "\r\n",true,true);
                    break;  // don't process any more if we have a currently unhandleable PDU
                }
                else
                {
                    break;  // don't prcess any more if we have a currently unhandleable PDU
                }
                Position += PDULength + 6;
            }

            if(Position > 0 )
            {
                if(state.data[direction] != null)
                {
                    state.UsedData(Position, direction);
                }

                // Check if there is anything we have "stacked up" on the other direction
                ReceiveTCPData(state, 1-direction);
            }

            return;
        }