Ejemplo n.º 1
0
 /**
  *  6.3.1 Variable 'Fixed' Data Header
  *
  *  $data[7 - 18]
  *  |=============================================================================|
  *  | Ident. Nr.   | Manufr. | Version | Medium | Access No. | Status | Signature |
  *  | 4 Byte (BCD) | 2 Byte  | 1 Byte  | 1 Byte | 1 Byte     | 1 Byte | 2 Byte    |
  *  |=============================================================================|
  *
  *  Ident.Nr    [7-10]  \x86\x78\x01\x10
  *  Manufr.     [11-12] \x77\x04
  *  Version     [13]    \x14
  *  Medium      [14]    \x07
  *  Access No.  [15]    \xad
  *  Status      [16]    \x00
  *  Signature   [17-18] \x00\x00
  */
 private function getSlaveInformation()
 {
     /**
      * Identity Number
      * Byte [7-10]
      * Translate 4 Byte BCD.
      * http://en.wikipedia.org/wiki/Binary-coded_decimal
      */
     $this->varheader['Id'] .= (($this->dataarray[10] & 0xf0) >> 4) . ($this->dataarray[10] & 0xf);
     $this->varheader['Id'] .= (($this->dataarray[9] & 0xf0) >> 4) . ($this->dataarray[9] & 0xf);
     $this->varheader['Id'] .= (($this->dataarray[8] & 0xf0) >> 4) . ($this->dataarray[8] & 0xf);
     $this->varheader['Id'] .= (($this->dataarray[7] & 0xf0) >> 4) . ($this->dataarray[7] & 0xf);
     /**
      * Manufacturer
      * Byte [11-12]
      * Ascii encoding using IEC 61107.
      * http://en.wikipedia.org/wiki/Smart_meter
      */
     $manByte1PlusByte2 = $this->dataarray[11] + ($this->dataarray[12] << 8);
     $this->varheader['Manufacturer'] = chr(($manByte1PlusByte2 >> 10 & 0x1f) + 64) . chr(($manByte1PlusByte2 >> 5 & 0x1f) + 64) . chr(($manByte1PlusByte2 & 0x1f) + 64);
     /**
      * Version
      * Byte [13]
      */
     $this->varheader['Version'] = $this->dataarray[13];
     /**
      * Medium
      * Byte [14]
      */
     $this->varheader['Medium'] = mbus_utils::getMedium(dechex($this->dataarray[14]));
     /**
      * Access No.
      * Byte [15]
      */
     $this->varheader['AccessNumber'] = $this->dataarray[15];
     /**
      * Status
      * Byte [16]
      */
     $this->varheader['Status'] = $this->dataarray[16];
     /**
      * Signature - Reserved For Future
      * Byte [17]
      */
     $this->varheader['Signature'] = $this->dataarray[17];
     return true;
 }