/**
  * Encode the Maximum Length
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return null
  */
 function encodeItem(CDicomStreamWriter $stream_writer)
 {
     $this->calculateLength();
     $stream_writer->writeUInt8($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt16($this->length);
     $stream_writer->writeUInt32($this->maximum_length);
 }
Ejemplo n.º 2
0
 /**
  * Encode the PDU
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return null
  */
 function encodePDU(CDicomStreamWriter $stream_writer)
 {
     $this->calculateLength();
     $stream_writer->writeUInt16($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt32($this->length);
     $stream_writer->skip(4);
 }
 /**
  * Encode the PDU
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return null
  */
 function encodePDU(CDicomStreamWriter $stream_writer)
 {
     $this->calculateLength();
     $stream_writer->writeUInt8($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt32($this->length);
     $stream_writer->skip(1);
     $stream_writer->writeUInt8($this->result);
     $stream_writer->writeUInt8($this->source);
     $stream_writer->writeUInt8($this->diagnostic);
 }
Ejemplo n.º 4
0
 /**
  * Encode the PDU
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return null
  */
 function encodePDU(CDicomStreamWriter $stream_writer)
 {
     $this->calculateLength();
     $stream_writer->writeUInt16($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt32($this->length);
     $stream_writer->skip(2);
     $stream_writer->writeUInt8($this->source);
     if ($this->source == 0) {
         $stream_writer->skip(1);
     } else {
         $stream_writer->writeUInt8($this->diagnostic);
     }
 }
Ejemplo n.º 5
0
 /**
  * Encode the value
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  * 
  * @param string             $endianness    The endianness, must be equal to "BE" (Big Endian) or "LE" (Little Endian)
  * 
  * @return null
  * 
  * @todo traiter les cas FL, FD, OB, OW, OF, SQ
  */
 protected function encodeValue(CDicomStreamWriter $stream_writer, $endianness)
 {
     switch ($this->vr) {
         case 'AE':
         case 'AS':
         case 'CS':
         case 'DA':
         case 'DS':
         case 'DT':
         case 'FL':
         case 'FD':
         case 'IS':
         case 'LO':
         case 'LT':
         case 'OB':
         case 'OF':
         case 'OX':
         case 'OW':
         case 'PN':
         case 'SH':
         case 'ST':
         case 'TM':
         case 'UN':
         case 'UT':
             if ($this->length & 1) {
                 $this->value .= " ";
                 $this->length++;
             }
             $stream_writer->writeString($this->value, $this->length);
             break;
         case 'AT':
             $stream_writer->writeUInt16($this->value[0], $endianness);
             $stream_writer->writeUInt16($this->value[1], $endianness);
             break;
         case 'SL':
             $stream_writer->writeInt32($this->value, $endianness);
             break;
         case 'SS':
             $stream_writer->writeInt16($this->value, $endianness);
             break;
         case 'UI':
             $stream_writer->writeUID($this->value, $this->length);
             if ($this->length & 1) {
                 $stream_writer->writeUInt8(0x0);
                 $this->length++;
             }
             break;
         case 'UL':
             $stream_writer->writeUInt32($this->value, $endianness);
             break;
         case 'US':
             $stream_writer->writeUInt16($this->value, $endianness);
             break;
         case 'SQ':
             $value_stream = new CDicomStreamWriter();
             $value_tmp = array();
             if (is_array($this->value)) {
                 foreach ($this->value as $_sequence) {
                     $sequence = array();
                     $sequence_stream = new CDicomStreamWriter();
                     foreach ($_sequence as $_item) {
                         $dataset = new CDicomDataSet($_item);
                         $dataset->encode($sequence_stream, $this->transfer_syntax);
                         $sequence[] = $dataset;
                     }
                     $sequence_length = strlen($sequence_stream->buf);
                     $value_stream->writeUInt16(0xfffe, $endianness);
                     $value_stream->writeUInt16(0xe000, $endianness);
                     $value_stream->writeUInt32($sequence_length, $endianness);
                     $value_stream->write($sequence_stream->buf, $sequence_length);
                     $this->length += 8 + $sequence_length;
                     $value_tmp[] = $sequence;
                 }
                 $stream_writer->write($value_stream->buf, $this->length);
                 $this->value = $value_tmp;
             } else {
                 $this->length = 8;
                 $stream_writer->writeUInt16(0xfffe, $endianness);
                 $stream_writer->writeUInt16(0xe000, $endianness);
                 $stream_writer->writeUInt32(0, $endianness);
             }
             break;
         default:
             break;
     }
 }
Ejemplo n.º 6
0
 /**
  * Encode the PDU
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return null
  */
 function encodePDU(CDicomStreamWriter $stream_writer)
 {
     $handle = fopen("php://temp", "w+");
     $pdv_stream = new CDicomStreamWriter($handle);
     foreach ($this->pdvs as $_pdv) {
         $_pdv->setPresentationContexts($this->presentation_contexts);
         $_pdv->encode($pdv_stream);
     }
     $this->calculateLength();
     $stream_writer->writeUInt8($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt32($this->length);
     $stream_writer->write($pdv_stream->buf);
 }
 /**
  * Encode the PDU
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  *  
  * @return void
  */
 function encodePDU(CDicomStreamWriter $stream_writer)
 {
     $this->calculateLength();
     $stream_writer->writeUInt8($this->type);
     $stream_writer->skip(1);
     $stream_writer->writeUInt32($this->length);
     $stream_writer->writeUInt16($this->protocol_version);
     $stream_writer->skip(2);
     $stream_writer->writeString($this->called_AE_title, 16);
     $stream_writer->writeString($this->calling_AE_title, 16);
     $stream_writer->skip(32);
     $this->application_context->encodeItem($stream_writer);
     foreach ($this->presentation_contexts as $_item) {
         $_item->encodeItem($stream_writer);
     }
     $this->user_info->encodeItem($stream_writer);
 }
Ejemplo n.º 8
0
 /**
  * Encode the PDV
  * 
  * @param CDicomStreamWriter $stream_writer The stream writer
  * 
  * @return null
  */
 function encode(CDicomStreamWriter $stream_writer)
 {
     $handle = fopen("php://temp", "w+");
     $message_stream = new CDicomStreamwriter($handle);
     if (!($this->transfer_syntax = $this->getTransferSyntax())) {
         /** @todo throw exception **/
         return;
     }
     $this->message->encode($message_stream, $this->transfer_syntax);
     $this->calculateLength(strlen($message_stream->buf));
     $stream_writer->writeUInt32($this->length);
     $stream_writer->writeUInt8($this->pres_context_id);
     $stream_writer->writeUInt8($this->message_control_header);
     $stream_writer->write($message_stream->buf, strlen($message_stream->buf));
     $message_stream->close();
     $this->setBinaryContent($stream_writer->buf);
 }