Ejemplo n.º 1
0
 /**
  * Decode the messages
  * 
  * @return null
  */
 function loadMessages()
 {
     $this->loadRefDicomExchange();
     if ($this->_ref_dicom_exchange) {
         $this->_ref_dicom_exchange->decodeContent();
     }
     $this->_messages = array();
     $msg_array = explode('|', $this->messages);
     foreach ($msg_array as $msg) {
         $msg = explode('\\', $msg);
         $pdu = CDicomPDUFactory::decodePDU(base64_decode($msg[1]));
         $this->_messages[$msg[0]] = $pdu;
         if ($msg[0] == "A-Associate-AC" && $this->_ref_dicom_exchange) {
             $i = 1;
             foreach ($this->_ref_dicom_exchange->_requests as $_request) {
                 $name = "{$_request->type_str}-RQ{$i}";
                 $this->_messages[$name] = $_request;
                 $i++;
             }
             $i = 1;
             foreach ($this->_ref_dicom_exchange->_responses as $_response) {
                 $name = "{$_response->type_str}-RSP{$i}";
                 $this->_messages[$name] = $_response;
                 $i++;
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Handle a message, and return the response
  * 
  * @param CExchangeDicom $data_format The dicom exchange
  * 
  * @return array
  */
 function event(CExchangeDicom $data_format)
 {
     $dicom_exchange = new CExchangeDicom();
     if ($data_format->_exchange_id) {
         $old_requests = $data_format->_requests;
         $pres_contexts = $data_format->_presentation_contexts;
         $dicom_exchange->load($data_format->_exchange_id);
         $dicom_exchange->decodeContent();
         $dicom_exchange->_presentation_contexts = $pres_contexts;
         $dicom_exchange->_requests = array_merge($dicom_exchange->_requests, $old_requests);
     } else {
         $dicom_exchange = $data_format;
         $dicom_exchange->date_production = CMbDT::dateTime();
         $dicom_exchange->date_echange = CMbDT::dateTime();
     }
     $last_pdvs = $dicom_exchange->_requests[count($dicom_exchange->_requests) - 1]->getPDVs();
     $response = array();
     $time_deb_pdv = microtime(true);
     foreach ($last_pdvs as $last_pdv) {
         if ($last_pdv->getMessageControlHeader() == 0 || $last_pdv->getMessageControlHeader() == 2) {
             $find_rq_pdv = null;
             if (count($last_pdvs) > 1) {
                 $find_rq_pdv = $last_pdvs[0];
             } else {
                 for ($i = count($dicom_exchange->_requests) - 2; $i >= 0; $i--) {
                     $_pdv = $dicom_exchange->_requests[$i]->getPDV(0);
                     if ($_pdv->getMessage()->type == "C-Find-RQ") {
                         $find_rq_pdv = $_pdv;
                         break;
                     }
                 }
             }
             if (!$find_rq_pdv) {
                 return null;
             }
             $response = self::handleCDatas($find_rq_pdv, $last_pdv, $dicom_exchange);
         } else {
             // The PDV contain a header
             $msg = $last_pdv->getMessage();
             switch ($msg->getCommandField()->getValue()) {
                 case 0x30:
                     $response = self::handleCEchoRQ($last_pdv, $dicom_exchange);
                     break;
                 case 0x8030:
                     $response = self::handleCEchoRSP($last_pdv, $dicom_exchange);
                     break;
                 case 0x20:
                     $response = self::handleCFindRQ($last_pdv, $dicom_exchange);
                     break;
                 case 0x8020:
                     $response = self::handleCFindRSP();
                     break;
                 case 0xfff:
                     $response = self::handleCCancelFindRQ();
                     break;
                 default:
             }
         }
     }
     $time_aft_pdv = microtime(true);
     $dicom_exchange->store();
     $response["exchange_id"] = $dicom_exchange->_id;
     return $response;
 }