#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#  
 | 
##@package AIManager.py  
 | 
# Ä£¿éµÄ¼òҪ˵Ã÷:AI¹ÜÀíÆ÷  
 | 
# @author:ifo  
 | 
# @date 2011-09-06 10:00  
 | 
# @version 1.0  
 | 
#  
 | 
# change log:  
 | 
#     ÐÞ¸ÄÄ£¿é£¬¶Ô´úÂë½øÐÐÓÅ»¯ÒÔ±ãÌá¸ßÐÔÄÜ        2011-9-6        Alee  
 | 
#  
 | 
# Ä£¿éÏêϸ˵Ã÷:AI¹ÜÀíÆ÷  
 | 
#  
 | 
#--------------------------------------------------------------  
 | 
from Utils.timer import Timer  
 | 
import logging  
 | 
  
 | 
  
 | 
class AIBase(Timer):  
 | 
    def __init__(self, robot, sec, bStart, bRep ):  
 | 
          
 | 
        #±£´æµÄRobotµÄÒýÓÃ,ÓÃÓÚÏòrobot´æ´¢Êý¾Ý  
 | 
        #***×¢Ò⣺²»Òª°ÑÖ»ºÍAIÖ´ÐÐÓйصÄÔËÐÐÊý¾Ý·Åµ½robotÄÚ  
 | 
        self.robot = robot    
 | 
        self.bActive = False  
 | 
        self.className = None  
 | 
        Timer.__init__(self, sec, bStart, bRep )  
 | 
          
 | 
    #ÏòAIMgr×¢²áÏûÏ¢»Øµ÷º¯Êý  
 | 
    #×ÓÀà¿ÉÖØÔØ´Ëº¯Êý  
 | 
    def _RegisterPacket(self, aiMgr ):  
 | 
        logging.debug( "Empty _RegisterPacket implementation for class %s" % self.AIName() )  
 | 
          
 | 
    def AIName(self):  
 | 
        if self.className:  
 | 
            return self.className  
 | 
        else:  
 | 
            className = str(self.__class__).split(".")  
 | 
            className = className[len(className)-1]  
 | 
            className = className.split("'")[0]  
 | 
            self.className = className  
 | 
            return className  
 | 
          
 | 
    def Tick( self ):  
 | 
        #δ¼¤»î£¬²»×öÈκβÙ×÷  
 | 
        if not self.bActive:  
 | 
            return  
 | 
        else:  
 | 
            return Timer.Tick( self )  
 | 
        
 | 
    #ÔÚ¼ÆÊ±Æ÷µ½ÁËʱ¼äºó´Ëº¯Êý»á±»µ÷Óà  
 | 
    #×ÓÀà¿ÉÖØÔØ´Ëº¯Êý   
 | 
    def _Process( self ):  
 | 
        logging.debug( "Empty _Process implementation for class %s" % self.AIName() )  
 | 
      
 | 
    #ÉèÖü¤»î״̬  
 | 
    def SetActive(self, bActive ):  
 | 
        self.bActive = bActive  
 | 
          
 | 
    #»ñÈ¡¼¤»î״̬      
 | 
    def Active(self):  
 | 
        return self.bActive  
 | 
      
 | 
      
 | 
     
 |