# Path: python/tHome/eagle/messages/Base.py
# class Base:
#    def __init__( self, name, node=None ):
#       self.name = name
# 
#       # Copy the attributes.
#       if node is not None:
#          for child in node:
#             setattr( self, child.tag, child.text )
# 
#       # Convert hex values to int and float.
#       convert.hexKeys( self, self._numHexKeys, float )
#       convert.hexKeys( self, self._intHexKeys, int )
# 
#    #------------------------------------------------------------------------
#    def msgDict( self ):
#       assert( self._jsonKeys )
# 
#       msg = {}
#       for key in self._jsonKeys:
#          if hasattr( self, key ):
#             msg[key] = getattr( self, key )
#             
#       if hasattr( self, "TimeUnix" ):
#          msg["Time"] = self.TimeUnix
# 
#       return msg
#       
#       
#    #------------------------------------------------------------------------
#    def _format( self, indent=3 ):
#       i = " "*indent
#       s = "%s(\n" % self.name
# 
#       for key in dir( self ):
#          if key[0] == "_":
#             continue
#          
#          v = getattr( self, key )
#          if callable( v ):
#             continue
# 
#          if hasattr( v, "_format" ):
#             s += "%s%s : %s,\n" % ( i, key, v._format( indent+3 ) )
#          elif isinstance( v, str ):
#             s += "%s%s : '%s',\n" % ( i, key, v )
#          else:
#             s += "%s%s : %s,\n" % ( i, key, v )
# 
#       s += "%s)" % i
#       return s
#       
#    #------------------------------------------------------------------------
#    def __str__( self ):
#       return self._format()
#       
#    def __repr__( self ):
#       return self.__str__()
# 
#    #------------------------------------------------------------------------


from .Base import Base
      Port              str

   Sample:
   
   <DeviceInfo>
     <DeviceMacId>0xd8d5b9000000103f</DeviceMacId>
     <InstallCode>0x8ba7f1dee6c4f5cc</InstallCode>
     <LinkKey>0x2b26f9124113b1e2b317d402ed789a47</LinkKey>
     <FWVersion>1.4.47 (6798)</FWVersion>
     <HWVersion>1.2.3</HWVersion>
     <ImageType>0x1301</ImageType>
     <Manufacturer>Rainforest Automation, Inc.</Manufacturer>
     <ModelId>Z109-EAGLE</ModelId>
     <DateCode>2013103023220630</DateCode>
     <Port>/dev/ttySP0</Port>
   </DeviceInfo>
   """
   
   # Hex keys turn into floats or ints.  Taken care of automatically
   # in Base.__init__().
   _numHexKeys = []
   _intHexKeys = [ "DeviceMacId", "InstallCode", "LinkKey", "ImageType" ]
   
   _jsonKeys = [ "DeviceMacid", "InstallCode", "LinkKey", "FWVersion",
                 "HWVersion", "ImageType", "Manufacturer", "ModelId",
                 "DateCode", "Port" ]
   
   #------------------------------------------------------------------------
   def __init__( self, node ):
      assert( node.tag == "DeviceInfo" )

# Path: python/tHome/eagle/messages/Base.py
# class Base:
#    def __init__( self, name, node=None ):
#       self.name = name
# 
#       # Copy the attributes.
#       if node is not None:
#          for child in node:
#             setattr( self, child.tag, child.text )
# 
#       # Convert hex values to int and float.
#       convert.hexKeys( self, self._numHexKeys, float )
#       convert.hexKeys( self, self._intHexKeys, int )
# 
#    #------------------------------------------------------------------------
#    def msgDict( self ):
#       assert( self._jsonKeys )
# 
#       msg = {}
#       for key in self._jsonKeys:
#          if hasattr( self, key ):
#             msg[key] = getattr( self, key )
#             
#       if hasattr( self, "TimeUnix" ):
#          msg["Time"] = self.TimeUnix
# 
#       return msg
#       
#       
#    #------------------------------------------------------------------------
#    def _format( self, indent=3 ):
#       i = " "*indent
#       s = "%s(\n" % self.name
# 
#       for key in dir( self ):
#          if key[0] == "_":
#             continue
#          
#          v = getattr( self, key )
#          if callable( v ):
#             continue
# 
#          if hasattr( v, "_format" ):
#             s += "%s%s : %s,\n" % ( i, key, v._format( indent+3 ) )
#          elif isinstance( v, str ):
#             s += "%s%s : '%s',\n" % ( i, key, v )
#          else:
#             s += "%s%s : %s,\n" % ( i, key, v )
# 
#       s += "%s)" % i
#       return s
#       
#    #------------------------------------------------------------------------
#    def __str__( self ):
#       return self._format()
#       
#    def __repr__( self ):
#       return self.__str__()
# 
#    #------------------------------------------------------------------------


# Path: python/tHome/eagle/messages/DeviceInfo.py
from .Base import Base

      Port              str

   Sample:
   
   <DeviceInfo>
     <DeviceMacId>0xd8d5b9000000103f</DeviceMacId>
     <InstallCode>0x8ba7f1dee6c4f5cc</InstallCode>
     <LinkKey>0x2b26f9124113b1e2b317d402ed789a47</LinkKey>
     <FWVersion>1.4.47 (6798)</FWVersion>
     <HWVersion>1.2.3</HWVersion>
     <ImageType>0x1301</ImageType>
     <Manufacturer>Rainforest Automation, Inc.</Manufacturer>
     <ModelId>Z109-EAGLE</ModelId>
     <DateCode>2013103023220630</DateCode>
     <Port>/dev/ttySP0</Port>
   </DeviceInfo>
   """
   
   # Hex keys turn into floats or ints.  Taken care of automatically
   # in Base.__init__().
   _numHexKeys = []
   _intHexKeys = [ "DeviceMacId", "InstallCode", "LinkKey", "ImageType" ]
   
   _jsonKeys = [ "DeviceMacid", "InstallCode", "LinkKey", "FWVersion",
                 "HWVersion", "ImageType", "Manufacturer", "ModelId",
                 "DateCode", "Port" ]
   
   #------------------------------------------------------------------------
   def __init__( self, node ):
      assert( node.tag == "DeviceInfo" )

      Base.__init__( self, "DeviceInfo", node )