Esempio n. 1
0
 def importMsg( self, msgFile ):
     " import device msg format setting"
     _f = XmlParser()
     _f .loadXmlFile( msgFile )
     #获得所有Msg节点
     _msgNdoe = _f.getAllElementByName( self.importFileParser['msg']['id']['path'] )
     for _mn in _msgNdoe:
         #获得msg节点的所有属性
         _ma = _f.getAttrListOneNode( _mn, self.importFileParser['msg']['id']['attr'] )
         #msg type(msg id)做为key
         self.__msg[int( _ma[1] )] = {}
         
         #消息类型
         self.__msg[int( _ma[1] )]['name'] = _ma[0]
         #消息打包格式头
         self.__msg[int( _ma[1] )]['format'] = _ma[2]
         #获得该msg下的所有Item的属性
         _ia = [_f.getAttrListOneNode( _item, self.importFileParser['msg']['item']['attr'] ) \
                 for _item in _f.getNodeListInNode( _mn, self.importFileParser['msg']['item']['path'] )]
         for _ii in _ia:
             #消息格式
             self.__msg[int( _ma[1] )]['format'] += _ii[1]
             #消息子项的偏移
             self.__msg[int( _ma[1] )][_ii[2]] = int( _ii[0] ) 
         #消息的长度
         self.__msg[int( _ma[1] )]['len'] = struct.calcsize( self.__msg[int( _ma[1] )]['format'] )
Esempio n. 2
0
 def importMsg( self, msgFile ):
     " import device msg format setting"
     _f = XmlParser()
     _f .loadXmlFile( msgFile )
     #获得所有Msg节点
     _msgNdoe = _f.getAllElementByName( self.importFileParser['msg']['id']['path'] )
     for _mn in _msgNdoe:
         #获得msg节点的所有属性
         _ma = _f.getAttrListOneNode( _mn, self.importFileParser['msg']['id']['attr'] )
         #msg type(msg id)做为key
         self.__msg[int( _ma[1] )] = {}
         
         #消息类型
         self.__msg[int( _ma[1] )]['name'] = _ma[0]
         #消息打包格式头
         self.__msg[int( _ma[1] )]['format'] = _ma[2]
         #获得该msg下的所有Item的属性
         _ia = [_f.getAttrListOneNode( _item, self.importFileParser['msg']['item']['attr'] ) \
                 for _item in _f.getNodeListInNode( _mn, self.importFileParser['msg']['item']['path'] )]
         for _ii in _ia:
             #消息格式
             self.__msg[int( _ma[1] )]['format'] += _ii[1]
             #消息子项的偏移
             self.__msg[int( _ma[1] )][_ii[2]] = int( _ii[0] )
         #消息的长度
         self.__msg[int( _ma[1] )]['len'] = struct.calcsize( self.__msg[int( _ma[1] )]['format'] )
Esempio n. 3
0
 def importDefSce( self, sceFile ):
     "import default format scenario"
     _f = XmlParser()
     _f .loadXmlFile( sceFile )
     self.defScenario = []
     self.TimeScenario = []
     
     #获得所有Position节点
     _posNode = _f.getAllElementByName( self.defSceParser['pos']['path'] )
     for _pn in _posNode:
         #获Position得属性
         _l = []
         _pna = _f.getAttrListOneNode( _pn, self.defSceParser['pos']['attr'] )
         #_l.append([_pna[0], int(_pna[1]), int(_pna[2])])
         _l.append( _pna[0] )
         _l.append( _pna[1] )
         _l.append( _pna[2] )
         
         #获得所有该Position下Set节点的属性
         _seta = [_f.getAttrListOneNode( _set, self.defSceParser['set']['attr'] ) \
                 for _set in _f.getNodeListInNode( _pn, self.defSceParser['set']['path'] )]           
         _l.append( _seta )
         self.defScenario.append( _l )
     
     #获得所有Time节点
     _timeNode = _f.getAllElementByName( self.defSceParser['time']['path'] )
     for _tn in _timeNode:
         #获Position得属性
         _l = []
         _pna = _f.getAttrListOneNode( _tn, self.defSceParser['time']['attr'] )
         #将loophour以及delay转化为int
         _l.append( int( _pna[0] ) )
          
         #获得所有该Position下Set节点的属性
         _seta = [_f.getAttrListOneNode( _set, self.defSceParser['set']['attr'] ) \
                 for _set in _f.getNodeListInNode( _tn, self.defSceParser['set']['path'] )]           
         _l.append( _seta )
         self.TimeScenario.append( _l )