Scott Gifford > Ekahau > Ekahau::Response

Download:
Ekahau-0.001.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

Ekahau::Response - Response from an Ekahau server

SYNOPSIS ^

Provides a straightforward encapsulation of the response objects returned by the Ekahau Positioning Engine. This is the base class for the specific responses; in general you will want to use one of them.

DESCRIPTION ^

This class takes care of parsing responses from the Ekahau server into their individual components.

The responses returned by Ekahau are a sort of half-assed XML. They look superficially like XML, but not enough that they can be parsed by an XML parser. Instead, this module takes a simplistic approach to parsing them. The exact rules for parsing aren't clear from the documentation, so this parsing may not be correct in all circumstances, but we have not observed any misparsing with the current code.

The response is parsed into the hash reference that comprises this object. It's parsed like this:

  <#tag cmd args[0] args[1] ...
  params{key1}=value1
  params{key2}=value2
  SEPARATOR1
  params{SEPERATOR1}[0]{key3}=value3
  params{SEPERATOR1}[0]{key4}=value4
  SEPARATOR1
  params{SEPERATOR1}[1]{key3}=value3
  params{SEPERATOR1}[1]{key4}=value4
  >

Here are some examples. First,

  <#LOC LOCATION_ESTIMATE 4
  accurateX=1427.09
  accurateY=2141.73
  accurateTime=1117138297067
  accurateContextId=22940
  latestX=1429.14
  latestY=2140.60
  latestTime=1117138301067
  latestContextId=22940
  speed=0.09101
  heading=5.78188
  >

parses to:

  {
    'tag' => 'LOC',
    'cmd' => 'LOCATION_ESTIMATE',
    'args' => [ '4' ],
    'params' => {
      'latestX' => '1429.14',
      'accurateY' => '2141.73',
      'heading' => '5.78188',
      'accurateTime' => '1117138297067',
      'latestY' => '2140.60',
      'accurateContextId' => '22940',
      'speed' => '0.09101',
      'accurateX' => '1427.09',
      'latestTime' => '1117138301067',
      'latestContextId' => '22940'
    },
  }

Second,

  <#AREA AREA_ESTIMATE 4
  AREA
  name=2425
  probability=1.000
  contextId=22940
  polygon=1396;1396;1554;1554;1394;1396&1964;2200;2200;1964;1964;1964;
  AREA
  name=2431
  probability=0.000
  contextId=22940
  polygon=1560;1559;1682;1680;1804;1804;1559;1560&1968;2197;2196;2153;2154;1966;1966;1968;
  >

parses to:

  {
    'tag' => 'AREA',
    'cmd' => 'AREA_ESTIMATE',
    'args' => [ '4' ],
    'params' => {
      'AREA' => [
        {
          'contextId' => '22940',
          'probability' => '1.000',
          'name' => '2425',
          'polygon' => '1396;1396;1554;1554;1394;1396&1964;2200;2200;1964;1964;1964;'
        }, {
          'contextId' => '22940',
          'probability' => '0.000',
          'name' => '2431',
          'polygon' => '1560;1559;1682;1680;1804;1804;1559;1560&1968;2197;2196;2153;2154;1966;1966;1968;'
        }
      ]
    }
  }

Finally, this response:

  <#2376 DEVICE_LIST
  1
  2
  3
  >

parses to this:

  {
    'tag' => '2376',
    'cmd' => 'DEVICE_LIST',
    'args' => [],
    'params' => {
      '3' => [ {} ],
      '2' => [ {} ],
      '1' => [ {} ],
    }
  }

Constructors

new ( %params )

Creates a new empty object. The only parameter recognized is tag, which sets the tag property for the response.

parsenew ( $response_str )

Parse a response string into an object. The results are undefined if $response_str is not a valid Ekahau response.

Methods

parse ( $response_str )

Populate the fields of an object with the ones in $response_str, overwriting any existing values. The results are undefined if $response_str is not a valid Ekahau response.

get_props ( @prop_names )

Returns a hash containing the values for the list of properties in @prop_names. If @prop_names is empty, all properties will be returned.

get_prop ( $prop_name )

Returns the value for one of this object's properties, specified by $prop_name. If no property named $prop_name exists, undef is returned.

error ( )

Returns true if this response is an Ekahau::Response::Error object, else returns false.

eventname ( )

Returns the name of this event in the same format used by Ekahau::Events.

type ( )

Returns the string Response, to identify the type of this object, and that no more specific information is available.

tostring ( )

Return a string representation of the object. This is reconstructed from the object's properties, and so may not be identical to the string which was parsed to create it.

AUTHOR ^

Scott Gifford <gifford@umich.edu>, <sgifford@suspectclass.com>

Copyright (C) 2005 The Regents of the University of Michigan.

See the file LICENSE included with the distribution for license information.

SEE ALSO ^

Ekahau::Base, Ekahau::Response::DeviceList, Ekahau::Response::DeviceProperties, Ekahau::Response::Error, Ekahau::Response::LocationEstimate, Ekahau::Response::LocationContext, Ekahau::Response::AreaEstimate, Ekahau::Response::AreaList, Ekahau::Response::StopLocationTrackOK, Ekahau::Response::StopAreaTrackOK, Ekahau::Response::MapImage.

syntax highlighting: