/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="assoc"></param>
        /// <param name="services"></param>
        public ActiveAssociation(Association assoc, DcmServiceRegistry services)
        {
            if (assoc.State != Association.ASSOCIATION_ESTABLISHED)
                throw new SystemException("Association not esrablished - " + assoc.State);

            m_threadPool = new LF_ThreadPool( this );

            this.assoc = assoc;
            this.services = services;
            this.assoc.ActiveAssociation = this;
            this.assoc.SetThreadPool( m_threadPool );
        }
Example #2
0
 public void SetThreadPool( LF_ThreadPool pool )
 {
     fsm.ReaderThreadPool = pool;
     reader.ReaderThreadPool = pool;
 }
        /// <summary>
        /// Run this active association
        /// </summary>
        public void Run( LF_ThreadPool pool )
        {
            try
            {
                lock (this)
                {
                    Dimse dimse = assoc.Read(timeout);

                    // if Association was released
                    if (dimse == null)
                    {
                        lock (rspDispatcher)
                        {
                            if (rspDispatcher.Count != 0)
                            {
                                rspDispatcher.Clear();
                                m_released = true;
                            }

                            System.Threading.Monitor.Pulse(rspDispatcher);
                        }

                        pool.Shutdown();
                        return ;
                    }

                    Command cmd = dimse.Command;
                    switch (cmd.CommandField)
                    {
                        case Command.C_STORE_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).c_store(this, dimse);
                            break;

                        case Command.C_GET_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).c_get(this, dimse);
                            break;

                        case Command.C_FIND_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).c_find(this, dimse);
                            break;

                        case Command.C_MOVE_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).c_move(this, dimse);
                            break;

                        case Command.C_ECHO_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).c_echo(this, dimse);
                            break;

                        case Command.N_EVENT_REPORT_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).n_event_report(this, dimse);
                            break;

                        case Command.N_GET_RQ:
                            services.Lookup(cmd.RequestedSOPClassUID).n_get(this, dimse);
                            break;

                        case Command.N_SET_RQ:
                            services.Lookup(cmd.RequestedSOPClassUID).n_set(this, dimse);
                            break;

                        case Command.N_ACTION_RQ:
                            services.Lookup(cmd.RequestedSOPClassUID).n_action(this, dimse);
                            break;

                        case Command.N_CREATE_RQ:
                            services.Lookup(cmd.AffectedSOPClassUID).n_action(this, dimse);
                            break;

                        case Command.N_DELETE_RQ:
                            services.Lookup(cmd.RequestedSOPClassUID).n_delete(this, dimse);
                            break;

                        case Command.C_STORE_RSP: case Command.C_GET_RSP: case Command.C_FIND_RSP: case Command.C_MOVE_RSP: case Command.C_ECHO_RSP: case Command.N_EVENT_REPORT_RSP: case Command.N_GET_RSP: case Command.N_SET_RSP: case Command.N_ACTION_RSP: case Command.N_CREATE_RSP: case Command.N_DELETE_RSP:
                            HandleResponse(dimse);
                            break;

                        case Command.C_CANCEL_RQ:
                            HandleCancel(dimse);
                            break;

                        default:
                            throw new System.SystemException("Illegal Command: " + cmd);

                    }
                }
            }
            catch (Exception ioe)
            {
                log.Error(ioe);
                pool.Shutdown();
            }
        }